Go to the documentation of this file.
31 #ifndef _DHCP_CLIENT_H
32 #define _DHCP_CLIENT_H
41 #ifndef DHCP_CLIENT_SUPPORT
42 #define DHCP_CLIENT_SUPPORT ENABLED
43 #elif (DHCP_CLIENT_SUPPORT != ENABLED && DHCP_CLIENT_SUPPORT != DISABLED)
44 #error DHCP_CLIENT_SUPPORT parameter is not valid
48 #ifndef DHCP_CLIENT_TICK_INTERVAL
49 #define DHCP_CLIENT_TICK_INTERVAL 200
50 #elif (DHCP_CLIENT_TICK_INTERVAL < 10)
51 #error DHCP_CLIENT_TICK_INTERVAL parameter is not valid
55 #ifndef DHCP_CLIENT_INIT_DELAY
56 #define DHCP_CLIENT_INIT_DELAY 2000
57 #elif (DHCP_CLIENT_INIT_DELAY < 0)
58 #error DHCP_CLIENT_INIT_DELAY parameter is not valid
62 #ifndef DHCP_CLIENT_DISCOVER_INIT_RT
63 #define DHCP_CLIENT_DISCOVER_INIT_RT 4000
64 #elif (DHCP_CLIENT_DISCOVER_INIT_RT < 1000)
65 #error DHCP_CLIENT_DISCOVER_INIT_RT parameter is not valid
69 #ifndef DHCP_CLIENT_DISCOVER_MAX_RT
70 #define DHCP_CLIENT_DISCOVER_MAX_RT 16000
71 #elif (DHCP_CLIENT_DISCOVER_MAX_RT < 1000)
72 #error DHCP_CLIENT_DISCOVER_MAX_RT parameter is not valid
76 #ifndef DHCP_CLIENT_REQUEST_MAX_RC
77 #define DHCP_CLIENT_REQUEST_MAX_RC 4
78 #elif (DHCP_CLIENT_REQUEST_MAX_RC < 1)
79 #error DHCP_CLIENT_REQUEST_MAX_RC parameter is not valid
83 #ifndef DHCP_CLIENT_REQUEST_INIT_RT
84 #define DHCP_CLIENT_REQUEST_INIT_RT 4000
85 #elif (DHCP_CLIENT_REQUEST_INIT_RT < 1000)
86 #error DHCP_CLIENT_REQUEST_INIT_RT parameter is not valid
90 #ifndef DHCP_CLIENT_REQUEST_MAX_RT
91 #define DHCP_CLIENT_REQUEST_MAX_RT 64000
92 #elif (DHCP_CLIENT_REQUEST_MAX_RT < 1000)
93 #error DHCP_CLIENT_REQUEST_MAX_RT parameter is not valid
97 #ifndef DHCP_CLIENT_REQUEST_MIN_DELAY
98 #define DHCP_CLIENT_REQUEST_MIN_DELAY 60000
99 #elif (DHCP_CLIENT_REQUEST_MIN_DELAY < 1000)
100 #error DHCP_CLIENT_REQUEST_MIN_DELAY parameter is not valid
104 #ifndef DHCP_CLIENT_PROBE_NUM
105 #define DHCP_CLIENT_PROBE_NUM 1
106 #elif (DHCP_CLIENT_PROBE_NUM < 0)
107 #error DHCP_CLIENT_PROBE_NUM parameter is not valid
111 #ifndef DHCP_CLIENT_PROBE_DELAY
112 #define DHCP_CLIENT_PROBE_DELAY 1000
113 #elif (DHCP_CLIENT_PROBE_DELAY < 100)
114 #error DHCP_CLIENT_PROBE_DELAY parameter is not valid
118 #ifndef DHCP_CLIENT_ANNOUNCE_NUM
119 #define DHCP_CLIENT_ANNOUNCE_NUM 1
120 #elif (DHCP_CLIENT_ANNOUNCE_NUM < 0)
121 #error DHCP_CLIENT_ANNOUNCE_NUM parameter is not valid
125 #ifndef DHCP_CLIENT_ANNOUNCE_INTERVAL
126 #define DHCP_CLIENT_ANNOUNCE_INTERVAL 1000
127 #elif (DHCP_CLIENT_ANNOUNCE_INTERVAL < 100)
128 #error DHCP_CLIENT_ANNOUNCE_INTERVAL parameter is not valid
132 #ifndef DHCP_CLIENT_RAND_FACTOR
133 #define DHCP_CLIENT_RAND_FACTOR 1000
134 #elif (DHCP_CLIENT_RAND_FACTOR < 100)
135 #error DHCP_CLIENT_RAND_FACTOR parameter is not valid
139 #ifndef DHCP_CLIENT_PRIVATE_CONTEXT
140 #define DHCP_CLIENT_PRIVATE_CONTEXT
145 #define DhcpClientContext struct _DhcpClientContext
bool_t running
This flag tells whether the DHCP client is running or not.
void(* DhcpClientAddOptionsCallback)(DhcpClientContext *context, DhcpMessage *message, size_t *length, DhcpMessageType type)
Add DHCP options callback.
DhcpMessageType
DHCP message types.
DhcpClientLinkChangeCallback linkChangeEvent
Link state change event.
uint_t retransmitCount
Retransmission counter.
void(* DhcpClientStateChangeCallback)(DhcpClientContext *context, NetInterface *interface, DhcpState state)
FSM state change callback.
systime_t configStartTime
Address acquisition or renewal process start time.
systime_t retransmitTimeout
Retransmission timeout.
bool_t rapidCommit
Quick configuration using rapid commit.
DhcpClientStateChangeCallback stateChangeEvent
FSM state change event.
uint32_t Ipv4Addr
IPv4 network address.
#define DhcpClientContext
uint32_t t2
Time at which the client enters the REBINDING state.
systime_t timeout
Timeout value.
uint_t ipAddrIndex
Index of the IP address to be configured.
error_t dhcpClientStop(DhcpClientContext *context)
Stop DHCP client.
uint32_t transactionId
Value to match requests with replies.
void(* DhcpClientTimeoutCallback)(DhcpClientContext *context, NetInterface *interface)
DHCP configuration timeout callback.
DhcpClientTimeoutCallback timeoutEvent
DHCP configuration timeout event.
uint32_t leaseTime
Lease time.
error_t dhcpClientStart(DhcpClientContext *context)
Start DHCP client.
Ipv4Addr requestedIpAddr
Requested IPv4 address.
bool_t timeoutEventDone
Timeout callback function has been called.
Definitions common to DHCP client and server.
systime_t leaseStartTime
Lease start time.
DhcpState dhcpClientGetState(DhcpClientContext *context)
Retrieve current state.
Ipv4Addr serverIpAddr
DHCP server IPv4 address.
error_t dhcpClientRelease(DhcpClientContext *context)
Release DHCP lease.
systime_t timeout
DHCP configuration timeout.
uint32_t systime_t
System time.
void dhcpClientGetDefaultSettings(DhcpClientSettings *settings)
Initialize settings with default values.
NetInterface * interface
Network interface to configure.
DhcpState
DHCP FSM states.
uint32_t t1
Time at which the client enters the RENEWING state.
systime_t timestamp
Timestamp to manage retransmissions.
void(* DhcpClientLinkChangeCallback)(DhcpClientContext *context, NetInterface *interface, bool_t linkState)
Link state change callback.
error_t dhcpClientInit(DhcpClientContext *context, const DhcpClientSettings *settings)
DHCP client initialization.
UDP (User Datagram Protocol)
DhcpState state
Current state of the FSM.
bool_t manualDnsConfig
Force manual DNS configuration.
DhcpClientParseOptionsCallback parseOptionsCallback
Parse DHCP options callback.
DhcpClientAddOptionsCallback addOptionsCallback
Add DHCP options callback.
#define DHCP_CLIENT_PRIVATE_CONTEXT
DhcpClientSettings settings
DHCP client settings.
error_t(* DhcpClientParseOptionsCallback)(DhcpClientContext *context, const DhcpMessage *message, size_t length, DhcpMessageType type)
Parse DHCP options callback.