A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
Dynamic Host Configuration Protocol client. More...
Go to the source code of this file.
Functions | |
static void | dhcp_handle_ack (struct netif *netif) |
Handle a DHCP ACK packet. | |
static void | dhcp_handle_nak (struct netif *netif) |
Back-off the DHCP client (because of a received NAK response). | |
static void | dhcp_handle_offer (struct netif *netif) |
Remember the configuration offered by a DHCP server. | |
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_check (struct netif *netif) |
Checks if the offered IP address is already in use. | |
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 void | dhcp_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) |
If an incoming DHCP message is in response to us, then trigger the state machine. | |
static err_t | dhcp_unfold_reply (struct dhcp *dhcp) |
Extract the DHCP message and the DHCP options. | |
static u8_t * | dhcp_get_option_ptr (struct dhcp *dhcp, u8_t option_type) |
Find the offset of a DHCP option inside the DHCP message. | |
static u8_t | dhcp_get_option_byte (u8_t *ptr) |
Return the byte of DHCP option data. | |
static u16_t | dhcp_get_option_short (u8_t *ptr) |
Return the 16-bit value of DHCP option data. | |
static u32_t | dhcp_get_option_long (u8_t *ptr) |
Return the 32-bit value of DHCP option data. | |
static void | dhcp_free_reply (struct dhcp *dhcp) |
Free the incoming DHCP message including contiguous copy of its DHCP options. | |
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_request (struct netif *netif) |
Create a DHCP request, fill in common headers. | |
static void | dhcp_delete_request (struct netif *netif) |
Free previously allocated memory used to send a DHCP request. | |
static void | dhcp_option_trailer (struct dhcp *dhcp) |
Add a DHCP message trailer. | |
void | dhcp_coarse_tmr () |
The DHCP timer that checks for lease renewal/rebind timeouts. | |
void | dhcp_fine_tmr () |
DHCP transaction timeout handling. | |
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_arp_reply (struct netif *netif, struct ip_addr *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. | |
Variables | |
static u32_t | xid = 0xABCD0000 |
global transaction identifier, must be unique for each DHCP request. |
Detailed Description
Dynamic Host Configuration Protocol client.
Definition in file tag/0.2/lwIP/core/dhcp.c.
Function Documentation
void dhcp_arp_reply | ( | struct netif * | netif, |
struct ip_addr * | 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 688 of file tag/0.2/lwIP/core/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 821 of file tag/0.2/lwIP/core/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 179 of file tag/0.2/lwIP/core/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 303 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_create_request | ( | struct netif * | netif ) | [static] |
Create a DHCP request, fill in common headers.
- Parameters:
-
netif the netif under DHCP control
Definition at line 1316 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_decline | ( | struct netif * | netif ) | [static] |
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 715 of file tag/0.2/lwIP/core/dhcp.c.
static void dhcp_delete_request | ( | struct netif * | netif ) | [static] |
Free previously allocated memory used to send a DHCP request.
- Parameters:
-
netif the netif under DHCP control
Definition at line 1377 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_discover | ( | struct netif * | netif ) | [static] |
Start the DHCP process, discover a DHCP server.
- Parameters:
-
netif the netif under DHCP control
Definition at line 762 of file tag/0.2/lwIP/core/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 336 of file tag/0.2/lwIP/core/dhcp.c.
static void dhcp_free_reply | ( | struct dhcp * | dhcp ) | [static] |
Free the incoming DHCP message including contiguous copy of its DHCP options.
Definition at line 1199 of file tag/0.2/lwIP/core/dhcp.c.
static u8_t dhcp_get_option_byte | ( | u8_t * | ptr ) | [static] |
Return the byte of DHCP option data.
- Parameters:
-
client DHCP client. ptr pointer obtained by dhcp_get_option_ptr().
- Returns:
- byte value at the given address.
Definition at line 1503 of file tag/0.2/lwIP/core/dhcp.c.
static u32_t dhcp_get_option_long | ( | u8_t * | ptr ) | [static] |
Return the 32-bit value of DHCP option data.
- Parameters:
-
client DHCP client. ptr pointer obtained by dhcp_get_option_ptr().
- Returns:
- byte value at the given address.
Definition at line 1537 of file tag/0.2/lwIP/core/dhcp.c.
static u8_t * dhcp_get_option_ptr | ( | struct dhcp * | dhcp, |
u8_t | option_type | ||
) | [static] |
Find the offset of a DHCP option inside the DHCP message.
- Parameters:
-
dhcp DHCP client option_type
- Returns:
- a byte offset into the UDP message where the option was found, or zero if the given option was not found.
Definition at line 1425 of file tag/0.2/lwIP/core/dhcp.c.
static u16_t dhcp_get_option_short | ( | u8_t * | ptr ) | [static] |
Return the 16-bit value of DHCP option data.
- Parameters:
-
client DHCP client. ptr pointer obtained by dhcp_get_option_ptr().
- Returns:
- byte value at the given address.
Definition at line 1519 of file tag/0.2/lwIP/core/dhcp.c.
static void dhcp_handle_ack | ( | struct netif * | netif ) | [static] |
Handle a DHCP ACK packet.
- Parameters:
-
netif the netif under DHCP control
Patch #1308 TODO: we must check if the file field is not overloaded by DHCP options!
Definition at line 459 of file tag/0.2/lwIP/core/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 152 of file tag/0.2/lwIP/core/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 205 of file tag/0.2/lwIP/core/dhcp.c.
void dhcp_inform | ( | struct netif * | netif ) |
Inform a DHCP server of our manual configuration.
inform server of our manual IP address
This informs DHCP servers of our fixed IP address configuration by sending an INFORM message. It does not involve DHCP address configuration, it is just here to be nice to the network.
- Parameters:
-
netif The lwIP network interface
Definition at line 626 of file tag/0.2/lwIP/core/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 1401 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_rebind | ( | struct netif * | netif ) | [static] |
Rebind with a DHCP server for an existing DHCP lease.
- Parameters:
-
netif network interface which must rebind with a DHCP server
Definition at line 957 of file tag/0.2/lwIP/core/dhcp.c.
static void dhcp_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
struct ip_addr * | addr, | ||
u16_t | port | ||
) | [static] |
If an incoming DHCP message is in response to us, then trigger the state machine.
Definition at line 1217 of file tag/0.2/lwIP/core/dhcp.c.
err_t dhcp_release | ( | struct netif * | netif ) |
Release a DHCP lease.
release the DHCP lease, usually called before dhcp_stop()
- Parameters:
-
netif network interface which must release its lease
Definition at line 1008 of file tag/0.2/lwIP/core/dhcp.c.
err_t dhcp_renew | ( | struct netif * | netif ) |
Renew an existing DHCP lease at the involved DHCP server.
enforce early lease renewal (not needed normally)
- Parameters:
-
netif network interface which must renew its lease
Definition at line 902 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_select | ( | struct netif * | netif ) | [static] |
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 232 of file tag/0.2/lwIP/core/dhcp.c.
err_t dhcp_start | ( | struct netif * | netif ) |
Start DHCP negotiation for a network interface.
start DHCP configuration
If no DHCP client instance was attached to this interface, a new client is created first. If a DHCP client instance was already present, it restarts negotiation.
- Parameters:
-
netif The lwIP network interface
- Returns:
- lwIP error code
- ERR_OK - No error
- ERR_MEM - Out of memory
Definition at line 563 of file tag/0.2/lwIP/core/dhcp.c.
void dhcp_stop | ( | struct netif * | netif ) |
Remove the DHCP client from the interface.
stop DHCP configuration
- Parameters:
-
netif The network interface to stop DHCP on
Definition at line 1062 of file tag/0.2/lwIP/core/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 424 of file tag/0.2/lwIP/core/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 442 of file tag/0.2/lwIP/core/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 369 of file tag/0.2/lwIP/core/dhcp.c.
static err_t dhcp_unfold_reply | ( | struct dhcp * | dhcp ) | [static] |
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 conitguous piece of memory, and use that further on.
copy the DHCP message without options
copy the DHCP options
Definition at line 1153 of file tag/0.2/lwIP/core/dhcp.c.
Variable Documentation
u32_t xid = 0xABCD0000 [static] |
global transaction identifier, must be unique for each DHCP request.
We simply increment, starting with this value (easy to match with a packet analyzer)
Definition at line 92 of file tag/0.2/lwIP/core/dhcp.c.
Generated on Tue Jul 12 2022 16:06:28 by 1.7.2