NetServices Stack source
Dependents: HelloWorld ServoInterfaceBoardExample1 4180_Lab4
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, 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 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 () |
The DHCP timer that checks for lease renewal/rebind timeouts. | |
void | dhcp_fine_tmr () |
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. | |
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, ip_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. | |
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 dhcp.c.
Function Documentation
void dhcp_arp_reply | ( | struct netif * | netif, |
ip_addr_t * | addr | ||
) |
static void dhcp_bind | ( | struct netif * | netif ) | [static] |
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
void dhcp_coarse_tmr | ( | void | ) |
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
static err_t dhcp_decline | ( | struct netif * | netif ) | [static] |
static void dhcp_delete_msg | ( | struct dhcp * | dhcp ) | [static] |
static err_t dhcp_discover | ( | struct netif * | netif ) | [static] |
void dhcp_fine_tmr | ( | void | ) |
static void dhcp_handle_ack | ( | struct netif * | netif ) | [static] |
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
static void dhcp_handle_offer | ( | struct netif * | netif ) | [static] |
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
void dhcp_network_changed | ( | struct netif * | netif ) |
static void dhcp_option_trailer | ( | struct dhcp * | dhcp ) | [static] |
static err_t dhcp_parse_reply | ( | struct dhcp * | dhcp, |
struct pbuf * | p | ||
) | [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.
static err_t dhcp_rebind | ( | struct netif * | netif ) | [static] |
static err_t dhcp_reboot | ( | struct netif * | netif ) | [static] |
static void dhcp_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
ip_addr_t * | addr, | ||
u16_t | port | ||
) | [static] |
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
err_t dhcp_renew | ( | struct netif * | netif ) |
static err_t dhcp_select | ( | struct netif * | netif ) | [static] |
void dhcp_set_struct | ( | struct netif * | netif, |
struct dhcp * | dhcp | ||
) |
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
void dhcp_stop | ( | struct netif * | netif ) |
static void dhcp_t1_timeout | ( | struct netif * | netif ) | [static] |
static void dhcp_t2_timeout | ( | struct netif * | netif ) | [static] |
static void dhcp_timeout | ( | struct netif * | netif ) | [static] |
Variable Documentation
u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX] |
u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX] |
Generated on Tue Jul 12 2022 11:52:59 by 1.7.2