Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
Dynamic Host Configuration Protocol client. More...
Go to the source code of this file.
Functions | |
static err_t | dhcp_discover (struct netif *netif) |
Start the DHCP process, discover a DHCP server. | |
static err_t | dhcp_select (struct netif *netif) |
Select a DHCP server offer out of all offers. | |
static void | dhcp_bind (struct netif *netif) |
Bind the interface to the offered IP address. | |
static err_t | dhcp_decline (struct netif *netif) |
Decline an offered lease. | |
static err_t | dhcp_rebind (struct netif *netif) |
Rebind with a DHCP server for an existing DHCP lease. | |
static err_t | dhcp_reboot (struct netif *netif) |
Enter REBOOTING state to verify an existing lease. | |
static void | dhcp_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) |
If an incoming DHCP message is in response to us, then trigger the state machine. | |
static void | dhcp_timeout (struct netif *netif) |
A DHCP negotiation transaction, or ARP request, has timed out. | |
static void | dhcp_t1_timeout (struct netif *netif) |
The renewal period has timed out. | |
static void | dhcp_t2_timeout (struct netif *netif) |
The rebind period has timed out. | |
static err_t | dhcp_create_msg (struct netif *netif, struct dhcp *dhcp, u8_t message_type) |
Create a DHCP request, fill in common headers. | |
static void | dhcp_delete_msg (struct dhcp *dhcp) |
Free previously allocated memory used to send a DHCP request. | |
static void | dhcp_option_trailer (struct dhcp *dhcp) |
Add a DHCP message trailer. | |
static err_t | dhcp_inc_pcb_refcount (void) |
Ensure DHCP PCB is allocated and bound. | |
static void | dhcp_dec_pcb_refcount (void) |
Free DHCP PCB if the last netif stops using it. | |
static void | dhcp_handle_nak (struct netif *netif) |
Back-off the DHCP client (because of a received NAK response). | |
static void | dhcp_check (struct netif *netif) |
Checks if the offered IP address is already in use. | |
static void | dhcp_handle_offer (struct netif *netif) |
Remember the configuration offered by a DHCP server. | |
void | dhcp_coarse_tmr (void) |
The DHCP timer that checks for lease renewal/rebind timeouts. | |
void | dhcp_fine_tmr (void) |
DHCP transaction timeout handling. | |
static void | dhcp_handle_ack (struct netif *netif) |
Handle a DHCP ACK packet. | |
void | dhcp_set_struct (struct netif *netif, struct dhcp *dhcp) |
Set a statically allocated struct dhcp to work with. | |
void | dhcp_cleanup (struct netif *netif) |
Removes a struct dhcp from a netif. | |
err_t | dhcp_start (struct netif *netif) |
Start DHCP negotiation for a network interface. | |
void | dhcp_inform (struct netif *netif) |
Inform a DHCP server of our manual configuration. | |
void | dhcp_network_changed (struct netif *netif) |
Handle a possible change in the network configuration. | |
void | dhcp_arp_reply (struct netif *netif, const ip4_addr_t *addr) |
Match an ARP reply with the offered IP address. | |
err_t | dhcp_renew (struct netif *netif) |
Renew an existing DHCP lease at the involved DHCP server. | |
err_t | dhcp_release (struct netif *netif) |
Release a DHCP lease. | |
void | dhcp_stop (struct netif *netif) |
Remove the DHCP client from the interface. | |
static err_t | dhcp_parse_reply (struct dhcp *dhcp, struct pbuf *p) |
Extract the DHCP message and the DHCP options. | |
u8_t | dhcp_supplied_address (const struct netif *netif) |
check if DHCP supplied netif->ip_addr | |
Variables | |
u32_t | dhcp_rx_options_val [DHCP_OPTION_IDX_MAX] |
Holds the decoded option values, only valid while in dhcp_recv. | |
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. |
Detailed Description
Dynamic Host Configuration Protocol client.
Definition in file lwip_dhcp.c.
Function Documentation
void dhcp_arp_reply | ( | struct netif * | netif, |
const ip4_addr_t * | addr | ||
) |
Match an ARP reply with the offered IP address.
if enabled, check whether the offered IP address is not in use, using ARP
- Parameters:
-
netif the network interface on which the reply was received addr The IP address we received a reply from
Definition at line 871 of file lwip_dhcp.c.
static void dhcp_bind | ( | struct netif * | netif ) | [static] |
Bind the interface to the offered IP address.
- Parameters:
-
netif network interface to bind to the offered address
Definition at line 998 of file lwip_dhcp.c.
static void dhcp_check | ( | struct netif * | netif ) | [static] |
Checks if the offered IP address is already in use.
It does so by sending an ARP request for the offered address and entering CHECKING state. If no ARP reply is received within a small interval, the address is assumed to be free for use by us.
- Parameters:
-
netif the netif under DHCP control
Definition at line 285 of file lwip_dhcp.c.
void dhcp_coarse_tmr | ( | void | ) |
The DHCP timer that checks for lease renewal/rebind timeouts.
to be called every minute
Definition at line 401 of file lwip_dhcp.c.
static err_t dhcp_create_msg | ( | struct netif * | netif, |
struct dhcp * | dhcp, | ||
u8_t | message_type | ||
) | [static] |
Create a DHCP request, fill in common headers.
- Parameters:
-
netif the netif under DHCP control dhcp dhcp control struct message_type message type of the request
default global transaction identifier starting value (easy to match with a packet analyser). We simply increment for each new request. Predefine DHCP_GLOBAL_XID to a better value or a function call to generate one at runtime, any supporting function prototypes can be defined in DHCP_GLOBAL_XID_HEADER
Definition at line 1776 of file lwip_dhcp.c.
static void dhcp_dec_pcb_refcount | ( | void | ) | [static] |
Free DHCP PCB if the last netif stops using it.
Definition at line 236 of file lwip_dhcp.c.
Decline an offered lease.
Tell the DHCP server we do not accept the offered address. One reason to decline the lease is when we find out the address is already in use by another host (through ARP).
- Parameters:
-
netif the netif under DHCP control
Definition at line 900 of file lwip_dhcp.c.
static void dhcp_delete_msg | ( | struct dhcp * | dhcp ) | [static] |
Free previously allocated memory used to send a DHCP request.
- Parameters:
-
dhcp the dhcp struct to free the request from
Definition at line 1873 of file lwip_dhcp.c.
Start the DHCP process, discover a DHCP server.
- Parameters:
-
netif the netif under DHCP control
Definition at line 942 of file lwip_dhcp.c.
void dhcp_fine_tmr | ( | void | ) |
DHCP transaction timeout handling.
to be called every half second
A DHCP server is expected to respond within a short period of time. This timer checks whether an outstanding DHCP request is timed out.
Definition at line 440 of file lwip_dhcp.c.
static void dhcp_handle_ack | ( | struct netif * | netif ) | [static] |
Handle a DHCP ACK packet.
- Parameters:
-
netif the netif under DHCP control
Definition at line 572 of file lwip_dhcp.c.
static void dhcp_handle_nak | ( | struct netif * | netif ) | [static] |
Back-off the DHCP client (because of a received NAK response).
Back-off the DHCP client because of a received NAK. Receiving a NAK means the client asked for something non-sensible, for example when it tries to renew a lease obtained on another network.
We clear any existing set IP address and restart DHCP negotiation afresh (as per RFC2131 3.2.3).
- Parameters:
-
netif the netif under DHCP control
Definition at line 260 of file lwip_dhcp.c.
static void dhcp_handle_offer | ( | struct netif * | netif ) | [static] |
Remember the configuration offered by a DHCP server.
- Parameters:
-
netif the netif under DHCP control
Definition at line 314 of file lwip_dhcp.c.
static err_t dhcp_inc_pcb_refcount | ( | void | ) | [static] |
Ensure DHCP PCB is allocated and bound.
Definition at line 209 of file lwip_dhcp.c.
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.
Definition at line 830 of file lwip_dhcp.c.
static void dhcp_option_trailer | ( | struct dhcp * | dhcp ) | [static] |
Add a DHCP message trailer.
Adds the END option to the DHCP message, and if necessary, up to three padding bytes.
- Parameters:
-
dhcp DHCP state structure
Definition at line 1894 of file lwip_dhcp.c.
Extract the DHCP message and the DHCP options.
Extract the DHCP message and the DHCP options, each into a contiguous piece of memory. As a DHCP message is variable sized by its options, and also allows overriding some fields for options, the easy approach is to first unfold the options into a contiguous piece of memory, and use that further on.
Definition at line 1440 of file lwip_dhcp.c.
Rebind with a DHCP server for an existing DHCP lease.
- Parameters:
-
netif network interface which must rebind with a DHCP server
Definition at line 1160 of file lwip_dhcp.c.
Enter REBOOTING state to verify an existing lease.
- Parameters:
-
netif network interface which must reboot
Definition at line 1210 of file lwip_dhcp.c.
static void dhcp_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
const ip_addr_t * | addr, | ||
u16_t | port | ||
) | [static] |
If an incoming DHCP message is in response to us, then trigger the state machine.
Definition at line 1652 of file lwip_dhcp.c.
Select a DHCP server offer out of all offers.
Simply select the first offer received.
- Parameters:
-
netif the netif under DHCP control
- Returns:
- lwIP specific error (see error.h)
Definition at line 345 of file lwip_dhcp.c.
u8_t dhcp_supplied_address | ( | const struct netif * | netif ) |
check if DHCP supplied netif->ip_addr
- Parameters:
-
netif the netif to check
- Returns:
- 1 if DHCP supplied netif->ip_addr (states BOUND or RENEWING), 0 otherwise
Definition at line 1915 of file lwip_dhcp.c.
static void dhcp_t1_timeout | ( | struct netif * | netif ) | [static] |
The renewal period has timed out.
- Parameters:
-
netif the netif under DHCP control
Definition at line 519 of file lwip_dhcp.c.
static void dhcp_t2_timeout | ( | struct netif * | netif ) | [static] |
The rebind period has timed out.
- Parameters:
-
netif the netif under DHCP control
Definition at line 546 of file lwip_dhcp.c.
static void dhcp_timeout | ( | struct netif * | netif ) | [static] |
A DHCP negotiation transaction, or ARP request, has timed out.
The timer that was started with the DHCP or ARP request has timed out, indicating no response was received in time.
- Parameters:
-
netif the netif under DHCP control
Definition at line 473 of file lwip_dhcp.c.
Variable Documentation
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.
Definition at line 144 of file lwip_dhcp.c.
u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX] |
Holds the decoded option values, only valid while in dhcp_recv.
Definition at line 140 of file lwip_dhcp.c.
Generated on Tue Jul 12 2022 11:03:02 by
