lwIP  2.1.0
Lightweight IP stack
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 "lwip/prot/iana.h"
#include <string.h>
#include "path/to/my/lwip_hooks.h"

Macros

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

Enumerations

enum  dhcp_option_idx
 

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)
 
void dhcp_release_and_stop (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 [DHCP_OPTION_IDX_MAX]
 
u8_t dhcp_rx_options_given [DHCP_OPTION_IDX_MAX]
 

Detailed Description

Dynamic Host Configuration Protocol client

Macro Definition Documentation

◆ DHCP_CREATE_RAND_XID

#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)

◆ DHCP_MAX_MSG_LEN

#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

◆ DHCP_MIN_REPLY_LEN

#define DHCP_MIN_REPLY_LEN   44

Minimum length for reply before packet is parsed

Enumeration Type Documentation

◆ dhcp_option_idx

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

◆ dhcp_arp_reply()

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

◆ dhcp_coarse_tmr()

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).

◆ dhcp_fine_tmr()

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.

◆ dhcp_network_changed()

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.

◆ dhcp_supplied_address()

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

◆ dhcp_rx_options_given

u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX]

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

◆ dhcp_rx_options_val

u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX]

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