ReactOS 0.4.16-dev-297-gc569aee
dhcp.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net>
8 * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 * OF SUCH DAMAGE.
32 *
33 * This file is part of the lwIP TCP/IP stack.
34 *
35 * Author: Leon Woestenberg <leon.woestenberg@gmx.net>
36 *
37 */
38#ifndef LWIP_HDR_DHCP_H
39#define LWIP_HDR_DHCP_H
40
41#include "lwip/opt.h"
42
43#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */
44
45#include "lwip/netif.h"
46#include "lwip/udp.h"
47
48#if LWIP_DHCP_DOES_ACD_CHECK
49#include "lwip/acd.h"
50#endif /* LWIP_DHCP_DOES_ACD_CHECK */
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
58#ifdef DHCP_TIMEOUT_SIZE_T
59typedef DHCP_TIMEOUT_SIZE_T dhcp_timeout_t;
60#else /* DHCP_TIMEOUT_SIZE_T */
61typedef u16_t dhcp_timeout_t;
62#endif /* DHCP_TIMEOUT_SIZE_T*/
64#ifndef DHCP_COARSE_TIMER_SECS
65#define DHCP_COARSE_TIMER_SECS 60
66#endif /* DHCP_COARSE_TIMER_SECS */
68#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL)
70#define DHCP_FINE_TIMER_MSECS 500
71
72#define DHCP_BOOT_FILE_LEN 128U
73
74#define DHCP_FLAG_SUBNET_MASK_GIVEN 0x01
75#define DHCP_FLAG_EXTERNAL_MEM 0x02
76
77/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */
78typedef enum {
79 DHCP_AUTOIP_COOP_STATE_OFF = 0,
80 DHCP_AUTOIP_COOP_STATE_ON = 1
81} dhcp_autoip_coop_state_enum_t;
82
83struct dhcp
84{
86 u32_t xid;
88 u8_t pcb_allocated;
90 u8_t state;
92 u8_t tries;
94 u8_t flags;
95
96 dhcp_timeout_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
97 dhcp_timeout_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
98 dhcp_timeout_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
99 dhcp_timeout_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */
100 dhcp_timeout_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */
101 dhcp_timeout_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */
102 dhcp_timeout_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */
103 ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */
104 ip4_addr_t offered_ip_addr;
105 ip4_addr_t offered_sn_mask;
106 ip4_addr_t offered_gw_addr;
107
108 u32_t offered_t0_lease; /* lease period (in seconds) */
109 u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
110 u32_t offered_t2_rebind; /* recommended rebind time (usually 87.5 of lease period) */
111#if LWIP_DHCP_BOOTP_FILE
112 ip4_addr_t offered_si_addr;
113 char boot_file_name[DHCP_BOOT_FILE_LEN];
114#endif /* LWIP_DHCP_BOOTPFILE */
115#if LWIP_DHCP_DOES_ACD_CHECK
117 struct acd acd;
118#endif /* LWIP_DHCP_DOES_ACD_CHECK */
119};
120
121
122void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp);
124#define dhcp_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL)
125void dhcp_cleanup(struct netif *netif);
126err_t dhcp_start(struct netif *netif);
127err_t dhcp_renew(struct netif *netif);
128err_t dhcp_release(struct netif *netif);
129void dhcp_stop(struct netif *netif);
130void dhcp_release_and_stop(struct netif *netif);
131void dhcp_inform(struct netif *netif);
132void dhcp_network_changed_link_up(struct netif *netif);
133
134u8_t dhcp_supplied_address(const struct netif *netif);
135/* to be called every minute */
136void dhcp_coarse_tmr(void);
137/* to be called every half second */
138void dhcp_fine_tmr(void);
139
140#if LWIP_DHCP_GET_NTP_SRV
144extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs);
145#endif /* LWIP_DHCP_GET_NTP_SRV */
146
147#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP))
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif /* LWIP_DHCP */
154
155#endif /*LWIP_HDR_DHCP_H*/
static int state
Definition: maze.c:121
void dhcp(struct packet *packet)
Definition: dhclient.c:674
GLbitfield flags
Definition: glext.h:7161
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
s8_t err_t
Definition: err.h:96
ip6_addr_t ip_addr_t
Definition: ip_addr.h:344
LONGLONG xid
Definition: nfs41_driver.c:106
Definition: netif.h:269