Embedded TCP/IP stack  4.7.0
fnet_dhcp_cln.h
1 /**************************************************************************
2 *
3 * Copyright 2008-2018 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * FNET DHCPv4 Client API.
22 *
23 ***************************************************************************/
24 
25 #ifndef _FNET_DHCP_CLN_H_
26 
27 #define _FNET_DHCP_CLN_H_
28 
29 #if FNET_CFG_DHCP_CLN || defined(__DOXYGEN__)
30 
87 /**************************************************************************/
94 #define FNET_DHCP_CLN_LEASE_INFINITY (0xFFFFFFFFU)
95 
96 /**************************************************************************/
101 #define FNET_DHCP_CLN_LEASE_MIN (180U)
102 
103 /**************************************************************************/
109 typedef struct
110 {
112  struct fnet_in_addr requested_ip_address;
117  fnet_uint32_t requested_lease_time;
126 
127 /**************************************************************************/
135 {
140 #if FNET_CFG_DHCP_CLN_BROADCAST
141  struct fnet_in_addr broadcast;
143 #endif
144 #if FNET_CFG_DNS
145  struct fnet_in_addr dns;
149 #endif
150  /* For debug needs: */
151  fnet_uint32_t t1;
157  fnet_uint32_t t2;
163  fnet_uint32_t lease_time;
168 };
169 
170 #if defined(__cplusplus)
171 extern "C" {
172 #endif
173 
174 /**************************************************************************/
178 typedef void *fnet_dhcp_cln_desc_t;
179 
180 /***************************************************************************/
202 
203 /***************************************************************************/
218 
219 /***************************************************************************/
236 
237 /**************************************************************************/
248 typedef void(*fnet_dhcp_cln_callback_t)(fnet_dhcp_cln_desc_t desc, fnet_netif_desc_t netif, void *cookie);
249 
250 /***************************************************************************/
269 void fnet_dhcp_cln_set_callback_updated (fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_updated, void *cookie);
270 
271 /***************************************************************************/
293 void fnet_dhcp_cln_set_callback_discover (fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_discover, void *cookie);
294 
295 /***************************************************************************/
316 
317 /***************************************************************************/
333 
334 /***************************************************************************/
353 
354 #if defined(__cplusplus)
355 }
356 #endif
357 
360 #endif /* FNET_CFG_DHCP_CLN */
361 
362 #endif /* _FNET_DHCP_CLN_H_ */
void fnet_dhcp_cln_set_response_timeout(fnet_dhcp_cln_desc_t desc, fnet_time_t response_timout_ms)
Change timeout for a DHCP server response.
void fnet_dhcp_cln_release(fnet_dhcp_cln_desc_t desc)
Release the DHCPv4 client service.
fnet_bool_t probe_addr
Probing of the newly received address with ARP:
void fnet_dhcp_cln_set_callback_discover(fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_discover, void *cookie)
Register the "Discover message sent" DHCP event handler callback.
fnet_netif_desc_t netif
Network interface descriptor to be used by the DHCP client.
fnet_dhcp_cln_desc_t fnet_dhcp_cln_init(fnet_dhcp_cln_params_t *params)
Initialize the DHCPv4 client service.
fnet_uint32_t fnet_time_t
Unsigned integer type representing time uinits. It can be seconds or milliseconds.
Definition: fnet_timer.h:64
IPv4 address structure.
Definition: fnet_socket.h:196
fnet_uint32_t t2
Rebinding (T2) Time Value in seconds (in network byte order). This option specifies the time interval...
void fnet_dhcp_cln_set_callback_updated(fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_updated, void *cookie)
Register the "IP parameters updated" DHCP event handler callback.
fnet_uint32_t requested_lease_time
Suggested Lease time in seconds (in network byte order). The client can suggest to the DHCP server th...
struct fnet_in_addr netmask
Subnet Mask (in network byte order).
struct fnet_in_addr ip_address
Client IP address assigned by the DHCP server (in network byte order).
fnet_bool_t fnet_dhcp_cln_is_enabled(fnet_dhcp_cln_desc_t desc)
Detect if the DHCP Client service is enabled or disabled.
fnet_uint32_t t1
Renewal (T1) Time Value in seconds (in network byte order). This option specifies the time interval f...
fnet_dhcp_cln_desc_t fnet_dhcp_cln_get_by_netif(fnet_netif_desc_t netif)
Look for a DHCP Client assigned to the specified network interface.
void * fnet_dhcp_cln_desc_t
DHCPv4 client descriptor.
fnet_uint32_t lease_time
The IP Address Lease Time in seconds (in network byte order). t1 < t2 < lease_time. By default, t1=0.5*lease_time; t2=0.875*lease_time. A user application may ignore this option value. It is used for internal and debug purposes only.
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:80
void fnet_dhcp_cln_get_options(fnet_dhcp_cln_desc_t desc, struct fnet_dhcp_cln_options *options)
Retrieve the current DHCPv4 client options retrieved from a DHCP server.
struct fnet_in_addr dhcp_server
The DHCP server IP address (in network byte order).
void(* fnet_dhcp_cln_callback_t)(fnet_dhcp_cln_desc_t desc, fnet_netif_desc_t netif, void *cookie)
DHCP client event handler callback function prototype, that is called when the DHCP client has update...
struct fnet_in_addr gateway
The IP address of a router on the client&#39;s subnet (in network byte order).
DHCP options are retrieved from a DHCP server.
void * fnet_netif_desc_t
Network interface descriptor.
Definition: fnet_netif.h:68
Initialization parameters for the fnet_dhcp_cln_init() function.

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net