Select one of the symbols to view example projects that use it.
 
Outline
#define __DHCPS_H__
#include "sdkconfig.h"
#include <stdbool.h>
#include "lwip/ip_addr.h"
#include "lwip/err.h"
dhcps_state
dhcps_msg
dhcps_lease_t
dhcps_offer_option
#define DHCPS_COARSE_TIMER_SECS
#define DHCPS_MAX_LEASE
#define DHCPS_LEASE_TIME_DEF
#define DHCPS_LEASE_UNIT
dhcps_pool
dhcps_time_t
dhcps_offer_t
dhcps_options_t
dhcps_cb_t
dhcps_router_enabled(dhcps_offer_t)
dhcps_dns_enabled(dhcps_offer_t)
dhcps_t
dhcps_new();
dhcps_delete(dhcps_t *);
dhcps_start(dhcps_t *, struct netif *, ip4_addr_t);
dhcps_stop(dhcps_t *, struct netif *);
dhcps_option_info(dhcps_t *, u8_t, u32_t);
dhcps_set_option_info(dhcps_t *, u8_t, void *, u32_t);
dhcp_search_ip_on_mac(dhcps_t *, u8_t *, ip4_addr_t *);
dhcps_dns_setserver(dhcps_t *, const ip_addr_t *);
dhcps_dns_getserver(dhcps_t *, ip4_addr_t *);
dhcps_set_new_lease_cb(dhcps_t *, dhcps_cb_t, void *);
Files
loading...
SourceVuESP-IDF Framework and ExampleslwIPinclude/apps/dhcpserver/dhcpserver.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #ifndef __DHCPS_H__ #define __DHCPS_H__ #include "sdkconfig.h" #include <stdbool.h> #include "lwip/ip_addr.h" #include "lwip/err.h" #ifdef __cplusplus extern "C" { #endif typedef struct dhcps_state{ s16_t state; }{ ... } dhcps_state; typedef struct dhcps_msg { u8_t op, htype, hlen, hops; u8_t xid[4]; u16_t secs, flags; u8_t ciaddr[4]; u8_t yiaddr[4]; u8_t siaddr[4]; u8_t giaddr[4]; u8_t chaddr[16]; u8_t sname[64]; u8_t file[128]; u8_t options[312]; }{ ... }dhcps_msg; /* Defined in esp_misc.h */ typedef struct { bool enable; ip4_addr_t start_ip; ip4_addr_t end_ip; }{ ... } dhcps_lease_t; enum dhcps_offer_option{ OFFER_START = 0x00, OFFER_ROUTER = 0x01, OFFER_DNS = 0x02, OFFER_END }{ ... }; /** @brief DHCP server's description of compile time configuration values in dhcpserver.c * * - DHCPS_DEBUG: Prints very detailed debug messages if set to 1, hardcoded to 0 * - USE_CLASS_B_NET: Use class B network mask if enabled, not-defined (could be enabled as CC_FLAGS) * - MAX_STATION_NUM: Maximum number of clients, set to Kconfig value CONFIG_LWIP_DHCPS_MAX_STATION_NUM * - LWIP_HOOK_DHCPS_POST_STATE: Used to inject user code after parsing DHCP message, not defined * - could be enabled in lwipopts.h or via CC_FLAGS * - basic usage of the hook to print hex representation of the entire option field is below: * #define LWIP_HOOK_DHCPS_POST_STATE(msg, len, state) \ * ({ s16_t ret = state; if (state == DHCPS_STATE_ACK) { ESP_LOG_BUFFER_HEXDUMP("DHCPS",msg->options, 312, ESP_LOG_INFO);} ret; }) *//* ... */ /** * @brief Definitions related to lease time, units and limits *//* ... */ #define DHCPS_COARSE_TIMER_SECS 1 #define DHCPS_MAX_LEASE 0x64 #define DHCPS_LEASE_TIME_DEF (120) #define DHCPS_LEASE_UNIT CONFIG_LWIP_DHCPS_LEASE_UNIT struct dhcps_pool{ ip4_addr_t ip; u8_t mac[6]; u32_t lease_timer; }{ ... }; typedef u32_t dhcps_time_t; typedef u8_t dhcps_offer_t; typedef struct { dhcps_offer_t dhcps_offer; dhcps_offer_t dhcps_dns; dhcps_time_t dhcps_time; dhcps_lease_t dhcps_poll; }{ ... } dhcps_options_t; typedef void (*dhcps_cb_t)(void* cb_arg, u8_t client_ip[4], u8_t client_mac[6]); static inline bool dhcps_router_enabled (dhcps_offer_t offer) { return (offer & OFFER_ROUTER) != 0; }{ ... } static inline bool dhcps_dns_enabled (dhcps_offer_t offer) { return (offer & OFFER_DNS) != 0; }{ ... } typedef struct dhcps_t dhcps_t; /** * @brief Creates new DHCP server object * * @return Pointer to the DHCP server handle on success, NULL on error *//* ... */ dhcps_t *dhcps_new(void); /** * @brief Deletes supplied DHPC server object * * @warning This may not delete the handle immediately if the server wasn't * stopped properly, but mark for deleting once the timer callback occurs * * @param dhcps Pointer to the DHCP handle *//* ... */ void dhcps_delete(dhcps_t *dhcps); /** * @brief Starts the DHCP server on the specified network interface * * @param dhcps Pointer to the DHCP handle * @param netif Pointer to the lwIP's network interface struct * @param ip DHCP server's address * @return ERR_ARG if invalid args, ERR_OK on success *//* ... */ err_t dhcps_start(dhcps_t *dhcps, struct netif *netif, ip4_addr_t ip); /** * @brief Stops the DHCP server on the specified netif * @param dhcps Pointer to the DHCP handle * @param netif Pointer to the lwIP's network interface struct * @return ERR_ARG if invalid args, ERR_OK on success *//* ... */ err_t dhcps_stop(dhcps_t *dhcps, struct netif *netif); /** * @brief Gets the DHCP server option info * @param dhcps Pointer to the DHCP handle * @param op_id DHCP message option id * @param opt_len DHCP message option length * @return DHCP message option addr *//* ... */ void *dhcps_option_info(dhcps_t *dhcps, u8_t op_id, u32_t opt_len); /** * @brief Sets the DHCP server option info * @param dhcps Pointer to the DHCP handle * @param op_id DHCP message option id * @param opt_info DHCP message option info * @param opt_len DHCP message option length * @return ERR_ARG if invalid args, ERR_OK on success *//* ... */ err_t dhcps_set_option_info(dhcps_t *dhcps, u8_t op_id, void *opt_info, u32_t opt_len); /** * @brief Tries to find IP address corresponding to the supplied MAC * @param dhcps Pointer to the DHCP handle * @param mac Supplied MAC address * @param ip Pointer to the resultant IP address * @return True if the IP address has been found *//* ... */ bool dhcp_search_ip_on_mac(dhcps_t *dhcps, u8_t *mac, ip4_addr_t *ip); /** * @brief Sets DNS server address for the DHCP server * @param dhcps Pointer to the DHCP handle * @param dnsserver Address of the DNS server * @return ERR_ARG if invalid handle, ERR_OK on success *//* ... */ err_t dhcps_dns_setserver(dhcps_t *dhcps, const ip_addr_t *dnsserver); /** * @brief Gets DNS server associated with this DHCP server * @param dhcps Pointer to the DHCP handle * @param dnsserver Address of the DNS server * @return ERR_ARG if invalid handle, ERR_OK on success *//* ... */ err_t dhcps_dns_getserver(dhcps_t *dhcps, ip4_addr_t *dnsserver); /** * @brief Sets callback on assigning an IP to the connected client * @param dhcps Pointer to the DHCP handle * @param cb Callback for dhcp server * @param cb_arg Context pointer to be added to the callback * @return ERR_ARG if invalid handle, ERR_OK on success *//* ... */ err_t dhcps_set_new_lease_cb(dhcps_t *dhcps, dhcps_cb_t cb, void* cb_arg); #ifdef __cplusplus }{...} #endif /* ... */ #endif /* __DHCPS_H__ */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.