Embedded TCP/IP stack: fnet_dhcp_cln.h Source File

FNET

fnet_dhcp_cln.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2017 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * FNET DHCPv4 Client API.
23 *
24 ***************************************************************************/
25 
26 #ifndef _FNET_DHCP_CLN_H_
27 
28 #define _FNET_DHCP_CLN_H_
29 
30 #if FNET_CFG_DHCP_CLN || defined(__DOXYGEN__)
31 
88 /**************************************************************************/
95 #define FNET_DHCP_CLN_LEASE_INFINITY (0xFFFFFFFFU)
96 
97 /**************************************************************************/
102 #define FNET_DHCP_CLN_LEASE_MIN (180U)
103 
104 /**************************************************************************/
111 {
118  fnet_uint32_t requested_lease_time;
126 };
127 
128 /**************************************************************************/
136 {
137  struct fnet_in_addr ip_address;
138  struct fnet_in_addr netmask;
139  struct fnet_in_addr gateway;
140  struct fnet_in_addr dhcp_server;
141 #if FNET_CFG_DHCP_CLN_BROADCAST
142  struct fnet_in_addr broadcast;
144 #endif
145 #if FNET_CFG_DNS
146  struct fnet_in_addr dns;
150 #endif
151  /* For debug needs: */
152  fnet_uint32_t t1;
158  fnet_uint32_t t2;
164  fnet_uint32_t lease_time;
169 };
170 
171 #if defined(__cplusplus)
172 extern "C" {
173 #endif
174 
175 /**************************************************************************/
179 typedef void* fnet_dhcp_cln_desc_t;
180 
181 /***************************************************************************/
202 fnet_dhcp_cln_desc_t fnet_dhcp_cln_init( struct fnet_dhcp_cln_params *params );
203 
204 /***************************************************************************/
218 void fnet_dhcp_cln_release(fnet_dhcp_cln_desc_t desc);
219 
220 /***************************************************************************/
236 void fnet_dhcp_cln_get_options(fnet_dhcp_cln_desc_t desc, struct fnet_dhcp_cln_options *options );
237 
238 /**************************************************************************/
249 typedef void(*fnet_dhcp_cln_callback_t)(fnet_dhcp_cln_desc_t desc, fnet_netif_desc_t netif, void *cookie);
250 
251 /***************************************************************************/
270 void fnet_dhcp_cln_set_callback_updated (fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_updated, void *cookie);
271 
272 /***************************************************************************/
294 void fnet_dhcp_cln_set_callback_discover (fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_discover, void *cookie);
295 
296 /***************************************************************************/
311 fnet_bool_t fnet_dhcp_cln_is_enabled(fnet_dhcp_cln_desc_t desc);
312 
313 /***************************************************************************/
331 fnet_dhcp_cln_desc_t fnet_dhcp_cln_get_by_netif(fnet_netif_desc_t netif);
332 
333 #if defined(__cplusplus)
334 }
335 #endif
336 
339 #endif /* FNET_CFG_DHCP_CLN */
340 
341 #endif /* _FNET_DHCP_CLN_H_ */
void fnet_dhcp_cln_release(fnet_dhcp_cln_desc_t desc)
Releases the DHCPv4 client service.
Initialization parameters for the fnet_dhcp_cln_init() function.
void fnet_dhcp_cln_set_callback_discover(fnet_dhcp_cln_desc_t desc, fnet_dhcp_cln_callback_t callback_discover, void *cookie)
Registers the "Discover message sent" 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...
IPv4 address structure.
Definition: fnet_socket.h:198
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)
Registers the "IP parameters updated" DHCP event handler callback.
fnet_bool_t fnet_dhcp_cln_is_enabled(fnet_dhcp_cln_desc_t desc)
Detects 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)
Looks 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:81
void fnet_dhcp_cln_get_options(fnet_dhcp_cln_desc_t desc, struct fnet_dhcp_cln_options *options)
Retrieves the current DHCPv4 client options retrieved from a DHCP server.
fnet_netif_desc_t netif
Network interface descriptor to be used by the DHCP client.
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...
fnet_bool_t probe_addr
Probing of the newly received address with ARP:
DHCP options are retrieved from a DHCP server.
fnet_dhcp_cln_desc_t fnet_dhcp_cln_init(struct fnet_dhcp_cln_params *params)
Initializes the DHCPv4 client service.
void * fnet_netif_desc_t
Network interface descriptor.
Definition: fnet_netif.h:71
struct fnet_in_addr requested_ip_address
Suggested IPv4 address (in network byte order). The client can suggest to the DHCP server that a par...

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net