lwIP 2.0.0  lwIP 2.0.0
LightweightIPstack
dhcp.c File Reference
#include "lwip/opt.h"
#include "lwip/stats.h"
#include "lwip/mem.h"
#include "lwip/udp.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/def.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#include "lwip/dns.h"
#include "lwip/etharp.h"
#include "lwip/prot/dhcp.h"
#include <string.h>

Macros

#define DHCP_CREATE_RAND_XID   1
 
#define DHCP_MAX_MSG_LEN(netif)    (netif->mtu)
 
#define DHCP_MIN_REPLY_LEN   44
 
#define DHCP_OPTION_IDX_OVERLOAD   0
 

Functions

void dhcp_coarse_tmr (void)
 
void dhcp_fine_tmr (void)
 
void dhcp_set_struct (struct netif *netif, struct dhcp *dhcp)
 
void dhcp_cleanup (struct netif *netif)
 
err_t dhcp_start (struct netif *netif)
 
void dhcp_inform (struct netif *netif)
 
void dhcp_network_changed (struct netif *netif)
 
void dhcp_arp_reply (struct netif *netif, const ip4_addr_t *addr)
 
err_t dhcp_renew (struct netif *netif)
 
err_t dhcp_release (struct netif *netif)
 
void dhcp_stop (struct netif *netif)
 
u8_t dhcp_supplied_address (const struct netif *netif)
 

Variables

u32_t dhcp_rx_options_val [(8+2)]
 
u8_t dhcp_rx_options_given [(8+2)]
 

Detailed Description

Dynamic Host Configuration Protocol client

Macro Definition Documentation

#define DHCP_CREATE_RAND_XID   1

DHCP_CREATE_RAND_XID: if this is set to 1, the xid is created using LWIP_RAND() (this overrides DHCP_GLOBAL_XID)

#define DHCP_MAX_MSG_LEN (   netif)    (netif->mtu)

Default for DHCP_GLOBAL_XID is 0xABCD0000 This can be changed by defining DHCP_GLOBAL_XID and DHCP_GLOBAL_XID_HEADER, e.g. #define DHCP_GLOBAL_XID_HEADER "stdlib.h" #define DHCP_GLOBAL_XID rand() DHCP_OPTION_MAX_MSG_SIZE is set to the MTU MTU is checked to be big enough in dhcp_start

#define DHCP_MIN_REPLY_LEN   44

Minimum length for reply before packet is parsed

#define DHCP_OPTION_IDX_OVERLOAD   0

Option handling: options are parsed in dhcp_parse_reply and saved in an array where other functions can load them from. This might be moved into the struct dhcp (not necessarily since lwIP is single-threaded and the array is only used while in recv callback).

Function Documentation

void dhcp_arp_reply ( struct netif netif,
const ip4_addr_t addr 
)

Match an ARP reply with the offered IP address: check whether the offered IP address is not in use using ARP

Parameters
netifthe network interface on which the reply was received
addrThe IP address we received a reply from
void dhcp_coarse_tmr ( void  )

The DHCP timer that checks for lease renewal/rebind timeouts. Must be called once a minute (see DHCP_COARSE_TIMER_SECS).

void dhcp_fine_tmr ( void  )

DHCP transaction timeout handling (this function must be called every 500ms, see DHCP_FINE_TIMER_MSECS).

A DHCP server is expected to respond within a short period of time. This timer checks whether an outstanding DHCP request is timed out.

void dhcp_network_changed ( struct netif netif)

Handle a possible change in the network configuration.

This enters the REBOOTING state to verify that the currently bound address is still valid.

u8_t dhcp_supplied_address ( const struct netif netif)

check if DHCP supplied netif->ip_addr

Parameters
netifthe netif to check
Returns
1 if DHCP supplied netif->ip_addr (states BOUND or RENEWING), 0 otherwise

Variable Documentation

u8_t dhcp_rx_options_given[(8 + 2)]

Holds a flag which option was received and is contained in dhcp_rx_options_val, only valid while in dhcp_recv.

u32_t dhcp_rx_options_val[(8 + 2)]

Holds the decoded option values, only valid while in dhcp_recv.