]>
Commit | Line | Data |
---|---|---|
d7837182 TL |
1 | /* dhcpd.h |
2 | ||
3 | Definitions for dhcpd... */ | |
4 | ||
5 | /* | |
dc9d7b08 | 6 | * Copyright (c) 2004-2013 by Internet Systems Consortium, Inc. ("ISC") |
98311e4b | 7 | * Copyright (c) 1996-2003 by Internet Software Consortium |
d7837182 | 8 | * |
98311e4b DH |
9 | * Permission to use, copy, modify, and distribute this software for any |
10 | * purpose with or without fee is hereby granted, provided that the above | |
11 | * copyright notice and this permission notice appear in all copies. | |
d7837182 | 12 | * |
98311e4b DH |
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
19 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
d7837182 | 20 | * |
98311e4b DH |
21 | * Internet Systems Consortium, Inc. |
22 | * 950 Charter Street | |
23 | * Redwood City, CA 94063 | |
24 | * <info@isc.org> | |
2c85ac9b | 25 | * https://www.isc.org/ |
49733f31 | 26 | * |
98311e4b | 27 | * This software has been written for Internet Systems Consortium |
49733f31 | 28 | * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. |
98311e4b | 29 | * To learn more about Internet Systems Consortium, see |
2c85ac9b | 30 | * ``https://www.isc.org/''. To learn more about Vixie Enterprises, |
49733f31 TL |
31 | * see ``http://www.vix.com''. To learn more about Nominum, Inc., see |
32 | * ``http://www.nominum.com''. | |
d7837182 TL |
33 | */ |
34 | ||
fe5b0fdd | 35 | #include "config.h" |
98bd7ca0 | 36 | |
0c7802b1 | 37 | #ifndef __CYGWIN32__ |
d7837182 | 38 | #include <sys/types.h> |
d7837182 TL |
39 | #include <netinet/in.h> |
40 | #include <sys/socket.h> | |
5a526cf8 | 41 | #include <sys/un.h> |
d7837182 | 42 | #include <arpa/inet.h> |
59112e84 | 43 | #include <errno.h> |
972ab2aa | 44 | |
d7837182 | 45 | #include <netdb.h> |
0c7802b1 TL |
46 | #else |
47 | #define fd_set cygwin_fd_set | |
48 | #include <sys/types.h> | |
49 | #endif | |
176c2a7d | 50 | #include <stddef.h> |
d7837182 TL |
51 | #include <fcntl.h> |
52 | #include <stdio.h> | |
089fb364 | 53 | #include <unistd.h> |
8fdfeffe | 54 | #include <string.h> |
089fb364 TL |
55 | #include <stdlib.h> |
56 | #include <sys/stat.h> | |
66eaae18 | 57 | #include <sys/mman.h> |
089fb364 | 58 | #include <ctype.h> |
97ca1699 | 59 | #include <time.h> |
089fb364 | 60 | |
fe5b0fdd | 61 | #include <net/if.h> |
b8c0eda0 | 62 | #undef FDDI |
fe5b0fdd DH |
63 | #include <net/route.h> |
64 | #include <net/if_arp.h> | |
627ad6d6 | 65 | #if HAVE_NET_IF_DL_H |
6dd7efa2 DH |
66 | # include <net/if_dl.h> |
67 | #endif | |
fe5b0fdd DH |
68 | |
69 | #include <setjmp.h> | |
70 | ||
2f620dce | 71 | #include "cdefs.h" |
a8b53b42 | 72 | #include "osdep.h" |
e55017af TL |
73 | |
74 | #include "arpa/nameser.h" | |
98bf1607 SR |
75 | |
76 | #include "minires.h" | |
e55017af | 77 | |
98311e4b DH |
78 | struct hash_table; |
79 | typedef struct hash_table group_hash_t; | |
80 | typedef struct hash_table universe_hash_t; | |
f7fdb216 DH |
81 | typedef struct hash_table option_name_hash_t; |
82 | typedef struct hash_table option_code_hash_t; | |
98311e4b | 83 | typedef struct hash_table dns_zone_hash_t; |
6708d944 DH |
84 | typedef struct hash_table lease_ip_hash_t; |
85 | typedef struct hash_table lease_id_hash_t; | |
98311e4b DH |
86 | typedef struct hash_table host_hash_t; |
87 | typedef struct hash_table class_hash_t; | |
88 | ||
fe5b0fdd DH |
89 | typedef time_t TIME; |
90 | ||
91 | #ifndef EOL | |
92 | #define EOL '\n' | |
93 | #endif | |
94 | ||
98bf1607 SR |
95 | #include <omapip/isclib.h> |
96 | #include <omapip/result.h> | |
97 | ||
d7837182 | 98 | #include "dhcp.h" |
98bd7ca0 | 99 | #include "dhcp6.h" |
2b9b6ff7 | 100 | #include "statement.h" |
d7837182 | 101 | #include "tree.h" |
089fb364 | 102 | #include "inet.h" |
fde86d2d | 103 | #include "dhctoken.h" |
d7837182 | 104 | |
400c0b19 | 105 | #include <omapip/omapip_p.h> |
4fe74d72 | 106 | |
33692791 DH |
107 | #if defined(LDAP_CONFIGURATION) |
108 | # include <ldap.h> | |
109 | # include <sys/utsname.h> /* for uname() */ | |
110 | #endif | |
111 | ||
f7fdb216 | 112 | #if !defined (BYTE_NAME_HASH_SIZE) |
20ae1aff | 113 | # define BYTE_NAME_HASH_SIZE 401 /* Default would be ridiculous. */ |
f7fdb216 DH |
114 | #endif |
115 | #if !defined (BYTE_CODE_HASH_SIZE) | |
20ae1aff | 116 | # define BYTE_CODE_HASH_SIZE 254 /* Default would be ridiculous. */ |
f7fdb216 DH |
117 | #endif |
118 | ||
6708d944 DH |
119 | /* Although it is highly improbable that a 16-bit option space might |
120 | * actually use 2^16 actual defined options, it is the worst case | |
121 | * scenario we must prepare for. Having 4 options per bucket in this | |
122 | * case is pretty reasonable. | |
123 | */ | |
f7fdb216 | 124 | #if !defined (WORD_NAME_HASH_SIZE) |
6708d944 | 125 | # define WORD_NAME_HASH_SIZE 20479 |
f7fdb216 DH |
126 | #endif |
127 | #if !defined (WORD_CODE_HASH_SIZE) | |
6708d944 | 128 | # define WORD_CODE_HASH_SIZE 16384 |
f7fdb216 DH |
129 | #endif |
130 | ||
6708d944 | 131 | /* Not only is it improbable that the 32-bit spaces might actually use 2^32 |
20ae1aff | 132 | * defined options, it is infeasible. It would be best for this kind of |
6708d944 DH |
133 | * space to be dynamically sized. Instead we size it at the word hash's |
134 | * level. | |
135 | */ | |
f7fdb216 DH |
136 | #if !defined (QUAD_NAME_HASH_SIZE) |
137 | # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE | |
138 | #endif | |
139 | #if !defined (QUAD_CODE_HASH_SIZE) | |
140 | # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE | |
141 | #endif | |
142 | ||
143 | #if !defined (DNS_HASH_SIZE) | |
144 | # define DNS_HASH_SIZE 0 /* Default. */ | |
145 | #endif | |
146 | ||
147 | /* Default size to use for name/code hashes on user-defined option spaces. */ | |
148 | #if !defined (DEFAULT_SPACE_HASH_SIZE) | |
149 | # define DEFAULT_SPACE_HASH_SIZE 11 | |
150 | #endif | |
151 | ||
152 | #if !defined (NWIP_HASH_SIZE) | |
6708d944 | 153 | # define NWIP_HASH_SIZE 17 /* A really small table. */ |
f7fdb216 DH |
154 | #endif |
155 | ||
156 | #if !defined (FQDN_HASH_SIZE) | |
20ae1aff | 157 | # define FQDN_HASH_SIZE 13 /* A ridiculously small table. */ |
f7fdb216 DH |
158 | #endif |
159 | ||
6708d944 DH |
160 | /* I really doubt a given installation is going to have more than a few |
161 | * hundred vendors involved. | |
162 | */ | |
f7fdb216 | 163 | #if !defined (VIVCO_HASH_SIZE) |
6708d944 | 164 | # define VIVCO_HASH_SIZE 127 |
f7fdb216 DH |
165 | #endif |
166 | ||
167 | #if !defined (VIVSO_HASH_SIZE) | |
168 | # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE | |
169 | #endif | |
170 | ||
98bd7ca0 DH |
171 | #if !defined (VSIO_HASH_SIZE) |
172 | # define VSIO_HASH_SIZE VIVCO_HASH_SIZE | |
173 | #endif | |
174 | ||
f7fdb216 DH |
175 | #if !defined (VIV_ISC_HASH_SIZE) |
176 | # define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */ | |
177 | #endif | |
178 | ||
179 | #if !defined (UNIVERSE_HASH_SIZE) | |
6708d944 | 180 | # define UNIVERSE_HASH_SIZE 13 /* A really small table. */ |
f7fdb216 DH |
181 | #endif |
182 | ||
183 | #if !defined (GROUP_HASH_SIZE) | |
184 | # define GROUP_HASH_SIZE 0 /* Default. */ | |
185 | #endif | |
186 | ||
6708d944 DH |
187 | /* At least one person has indicated they use ~20k host records. |
188 | */ | |
f7fdb216 | 189 | #if !defined (HOST_HASH_SIZE) |
6708d944 | 190 | # define HOST_HASH_SIZE 22501 |
f7fdb216 DH |
191 | #endif |
192 | ||
6708d944 DH |
193 | /* We have user reports of use of ISC DHCP numbering leases in the 200k's. |
194 | * | |
195 | * We also have reports of folks using 10.0/8 as a dynamic range. The | |
196 | * following is something of a compromise between the two. At the ~2-3 | |
197 | * hundred thousand leases, there's ~2-3 leases to search in each bucket. | |
198 | */ | |
f7fdb216 | 199 | #if !defined (LEASE_HASH_SIZE) |
6708d944 | 200 | # define LEASE_HASH_SIZE 100003 |
f7fdb216 DH |
201 | #endif |
202 | ||
6708d944 DH |
203 | /* It is not known what the worst case subclass hash size is. We estimate |
204 | * high, I think. | |
205 | */ | |
f7fdb216 | 206 | #if !defined (SCLASS_HASH_SIZE) |
6708d944 | 207 | # define SCLASS_HASH_SIZE 12007 |
f7fdb216 DH |
208 | #endif |
209 | ||
210 | #if !defined (AGENT_HASH_SIZE) | |
211 | # define AGENT_HASH_SIZE 11 /* A really small table. */ | |
212 | #endif | |
213 | ||
6708d944 DH |
214 | /* The server hash size is used for both names and codes. There aren't |
215 | * many (roughly 50 at the moment), so we use a smaller table. If we | |
216 | * use a 1:1 table size, then we get name collisions due to poor name | |
217 | * hashing. So we use double the space we need, which drastically | |
218 | * reduces collisions. | |
219 | */ | |
f7fdb216 | 220 | #if !defined (SERVER_HASH_SIZE) |
6708d944 | 221 | # define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option))) |
f7fdb216 DH |
222 | #endif |
223 | ||
224 | ||
6708d944 | 225 | /* How many options are likely to appear in a single packet? */ |
27fe61a7 TL |
226 | #if !defined (OPTION_HASH_SIZE) |
227 | # define OPTION_HASH_SIZE 17 | |
0dbb132f TL |
228 | # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */ |
229 | # define OPTION_HASH_EXP 5 /* The exponent for that power of two. */ | |
27fe61a7 TL |
230 | #endif |
231 | ||
0dbb132f TL |
232 | #define compute_option_hash(x) \ |
233 | (((x) & (OPTION_HASH_PTWO - 1)) + \ | |
234 | (((x) >> OPTION_HASH_EXP) & \ | |
235 | (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE; | |
236 | ||
d758ad8c TL |
237 | enum dhcp_shutdown_state { |
238 | shutdown_listeners, | |
239 | shutdown_omapi_connections, | |
240 | shutdown_drop_omapi_connections, | |
241 | shutdown_dhcp, | |
242 | shutdown_done | |
243 | }; | |
244 | ||
35e0fdf8 TL |
245 | /* Client FQDN option, failover FQDN option, etc. */ |
246 | typedef struct { | |
247 | u_int8_t codes [2]; | |
248 | unsigned length; | |
249 | u_int8_t *data; | |
250 | } ddns_fqdn_t; | |
251 | ||
de1863a1 | 252 | #include "failover.h" |
35e0fdf8 | 253 | |
fde86d2d TL |
254 | /* A parsing context. */ |
255 | ||
256 | struct parse { | |
257 | int lexline; | |
258 | int lexchar; | |
259 | char *token_line; | |
260 | char *prev_line; | |
261 | char *cur_line; | |
b1b7b521 | 262 | const char *tlname; |
fde86d2d TL |
263 | int eol_token; |
264 | ||
d19e816e | 265 | /* |
a34feb7d | 266 | * In order to give nice output when we have a parsing error |
d19e816e SK |
267 | * in our file, we keep track of where we are in the line so |
268 | * that we can show the user. | |
269 | * | |
a34feb7d | 270 | * We need to keep track of two lines, because we can look |
d19e816e SK |
271 | * ahead, via the "peek" function, to the next line sometimes. |
272 | * | |
a34feb7d | 273 | * The "line1" and "line2" variables act as buffers for this |
d19e816e SK |
274 | * information. The "lpos" variable tells us where we are in the |
275 | * line. | |
276 | * | |
277 | * When we "put back" a character from the parsing context, we | |
278 | * do not want to have the character appear twice in the error | |
279 | * output. So, we set a flag, the "ugflag", which the | |
280 | * get_char() function uses to check for this condition. | |
281 | */ | |
fde86d2d TL |
282 | char line1 [81]; |
283 | char line2 [81]; | |
284 | int lpos; | |
285 | int line; | |
286 | int tlpos; | |
287 | int tline; | |
288 | enum dhcp_token token; | |
289 | int ugflag; | |
290 | char *tval; | |
b3519f23 | 291 | int tlen; |
fde86d2d TL |
292 | char tokbuf [1500]; |
293 | ||
fde86d2d TL |
294 | int warnings_occurred; |
295 | int file; | |
296 | char *inbuf; | |
66eaae18 SK |
297 | size_t bufix, buflen; |
298 | size_t bufsiz; | |
bda33169 SK |
299 | |
300 | struct parse *saved_state; | |
33692791 DH |
301 | |
302 | #if defined(LDAP_CONFIGURATION) | |
303 | /* | |
304 | * LDAP configuration uses a call-back to iteratively read config | |
305 | * off of the LDAP repository. | |
306 | * XXX: The token stream can not be rewound reliably, so this must | |
307 | * be addressed for DHCPv6 support. | |
308 | */ | |
309 | int (*read_function)(struct parse *); | |
310 | #endif | |
fde86d2d TL |
311 | }; |
312 | ||
74f45f96 | 313 | /* Variable-length array of data. */ |
74f45f96 | 314 | |
6b3b97e1 TL |
315 | struct string_list { |
316 | struct string_list *next; | |
317 | char string [1]; | |
318 | }; | |
319 | ||
0c7802b1 TL |
320 | /* A name server, from /etc/resolv.conf. */ |
321 | struct name_server { | |
322 | struct name_server *next; | |
323 | struct sockaddr_in addr; | |
324 | TIME rcdate; | |
325 | }; | |
326 | ||
327 | /* A domain search list element. */ | |
328 | struct domain_search_list { | |
329 | struct domain_search_list *next; | |
330 | char *domain; | |
331 | TIME rcdate; | |
332 | }; | |
333 | ||
5142937c TL |
334 | /* Option tag structures are used to build chains of option tags, for |
335 | when we're sure we're not going to have enough of them to justify | |
336 | maintaining an array. */ | |
337 | ||
338 | struct option_tag { | |
339 | struct option_tag *next; | |
340 | u_int8_t data [1]; | |
341 | }; | |
342 | ||
343 | /* An agent option structure. We need a special structure for the | |
344 | Relay Agent Information option because if more than one appears in | |
c57db45c | 345 | a message, we have to keep them separate. */ |
5142937c TL |
346 | |
347 | struct agent_options { | |
348 | struct agent_options *next; | |
349 | int length; | |
350 | struct option_tag *first; | |
351 | }; | |
352 | ||
27fe61a7 TL |
353 | struct option_cache { |
354 | int refcnt; | |
355 | struct option_cache *next; | |
356 | struct expression *expression; | |
357 | struct option *option; | |
358 | struct data_string data; | |
88cd8aca DH |
359 | |
360 | #define OPTION_HAD_NULLS 0x00000001 | |
361 | u_int32_t flags; | |
27fe61a7 | 362 | }; |
5142937c | 363 | |
27fe61a7 | 364 | struct option_state { |
a340de95 | 365 | int refcnt; |
4f58da18 | 366 | int universe_count; |
53ac6c6f TL |
367 | int site_universe; |
368 | int site_code_min; | |
fe5b0fdd | 369 | void *universes [1]; |
5142937c TL |
370 | }; |
371 | ||
d7837182 TL |
372 | /* A dhcp packet and the pointers to its option values. */ |
373 | struct packet { | |
374 | struct dhcp_packet *raw; | |
f3e8ea32 | 375 | int refcnt; |
b1b7b521 | 376 | unsigned packet_length; |
d7837182 | 377 | int packet_type; |
98bd7ca0 DH |
378 | |
379 | unsigned char dhcpv6_msg_type; /* DHCPv6 message type */ | |
380 | ||
381 | /* DHCPv6 transaction ID */ | |
382 | unsigned char dhcpv6_transaction_id[3]; | |
383 | ||
384 | /* DHCPv6 relay information */ | |
385 | unsigned char dhcpv6_hop_count; | |
386 | struct in6_addr dhcpv6_link_address; | |
387 | struct in6_addr dhcpv6_peer_address; | |
388 | ||
389 | /* DHCPv6 packet containing this one, or NULL if none */ | |
390 | struct packet *dhcpv6_container_packet; | |
391 | ||
d7837182 | 392 | int options_valid; |
089fb364 TL |
393 | int client_port; |
394 | struct iaddr client_addr; | |
17b95f41 TL |
395 | struct interface_info *interface; /* Interface on which packet |
396 | was received. */ | |
397 | struct hardware *haddr; /* Physical link address | |
398 | of local sender (maybe gateway). */ | |
c4763f5f TL |
399 | |
400 | /* Information for relay agent options (see | |
401 | draft-ietf-dhc-agent-options-xx.txt). */ | |
402 | u_int8_t *circuit_id; /* Circuit ID of client connection. */ | |
403 | int circuit_id_len; | |
404 | u_int8_t *remote_id; /* Remote ID of client. */ | |
405 | int remote_id_len; | |
406 | ||
f67530be TL |
407 | int got_requested_address; /* True if client sent the |
408 | dhcp-requested-address option. */ | |
409 | ||
c626ae69 | 410 | struct shared_network *shared_network; |
4f58da18 | 411 | struct option_state *options; |
102ee7e9 TL |
412 | |
413 | #if !defined (PACKET_MAX_CLASSES) | |
414 | # define PACKET_MAX_CLASSES 5 | |
415 | #endif | |
416 | int class_count; | |
417 | struct class *classes [PACKET_MAX_CLASSES]; | |
734d2258 TL |
418 | |
419 | int known; | |
420 | int authenticated; | |
9aa3f3a5 DH |
421 | |
422 | /* If we stash agent options onto the packet option state, to pretend | |
423 | * options we got in a previous exchange were still there, we need | |
424 | * to signal this in a reliable way. | |
425 | */ | |
426 | isc_boolean_t agent_options_stashed; | |
98bd7ca0 | 427 | |
a34feb7d TM |
428 | /* |
429 | * ISC_TRUE if packet received unicast (as opposed to multicast). | |
98bd7ca0 DH |
430 | * Only used in DHCPv6. |
431 | */ | |
432 | isc_boolean_t unicast; | |
d7837182 TL |
433 | }; |
434 | ||
e563ec2e SR |
435 | /* |
436 | * A network interface's MAC address. | |
437 | * 20 bytes for the hardware address | |
438 | * and 1 byte for the type tag | |
439 | */ | |
440 | ||
441 | #define HARDWARE_ADDR_LEN 20 | |
5142937c | 442 | |
d7837182 | 443 | struct hardware { |
d7837182 | 444 | u_int8_t hlen; |
e563ec2e | 445 | u_int8_t hbuf[HARDWARE_ADDR_LEN + 1]; |
d7837182 TL |
446 | }; |
447 | ||
33692791 DH |
448 | #if defined(LDAP_CONFIGURATION) |
449 | # define LDAP_BUFFER_SIZE 8192 | |
450 | # define LDAP_METHOD_STATIC 0 | |
451 | # define LDAP_METHOD_DYNAMIC 1 | |
452 | #if defined (LDAP_USE_SSL) | |
453 | # define LDAP_SSL_OFF 0 | |
454 | # define LDAP_SSL_ON 1 | |
455 | # define LDAP_SSL_TLS 2 | |
456 | # define LDAP_SSL_LDAPS 3 | |
457 | #endif | |
458 | ||
459 | /* This is a tree of the current configuration we are building from LDAP */ | |
460 | struct ldap_config_stack { | |
461 | LDAPMessage * res; /* Pointer returned from ldap_search */ | |
462 | LDAPMessage * ldent; /* Current item in LDAP that we're processing. | |
463 | in res */ | |
464 | int close_brace; /* Put a closing } after we're through with | |
465 | this item */ | |
466 | int processed; /* We set this flag if this base item has been | |
467 | processed. After this base item is processed, | |
468 | we can start processing the children */ | |
469 | struct ldap_config_stack *children; | |
470 | struct ldap_config_stack *next; | |
471 | }; | |
472 | #endif | |
473 | ||
d758ad8c TL |
474 | typedef enum { |
475 | server_startup = 0, | |
476 | server_running = 1, | |
477 | server_shutdown = 2, | |
478 | server_hibernate = 3, | |
479 | server_awaken = 4 | |
480 | } control_object_state_t; | |
481 | ||
482 | typedef struct { | |
483 | OMAPI_OBJECT_PREAMBLE; | |
484 | control_object_state_t state; | |
485 | } dhcp_control_object_t; | |
486 | ||
7ea8b207 | 487 | /* Lease states: */ |
98311e4b DH |
488 | #define FTS_FREE 1 |
489 | #define FTS_ACTIVE 2 | |
490 | #define FTS_EXPIRED 3 | |
491 | #define FTS_RELEASED 4 | |
492 | #define FTS_ABANDONED 5 | |
493 | #define FTS_RESET 6 | |
494 | #define FTS_BACKUP 7 | |
98311e4b DH |
495 | typedef u_int8_t binding_state_t; |
496 | ||
497 | /* FTS_LAST is the highest value that is valid for a lease binding state. */ | |
a55ccdd0 | 498 | #define FTS_LAST FTS_BACKUP |
7ea8b207 | 499 | |
d7837182 TL |
500 | /* A dhcp lease declaration structure. */ |
501 | struct lease { | |
4fe74d72 | 502 | OMAPI_OBJECT_PREAMBLE; |
d7837182 | 503 | struct lease *next; |
ab370123 | 504 | struct lease *n_uid, *n_hw; |
fc2df23a | 505 | |
089fb364 | 506 | struct iaddr ip_addr; |
6d103865 | 507 | TIME starts, ends, sort_time; |
0c7802b1 | 508 | char *client_hostname; |
6ceb9118 | 509 | struct binding_scope *scope; |
d7837182 | 510 | struct host_decl *host; |
c626ae69 | 511 | struct subnet *subnet; |
734d2258 | 512 | struct pool *pool; |
112a6c2c | 513 | struct class *billing_class; |
625f7cee | 514 | struct option_chain_head *agent_options; |
fc2df23a | 515 | |
79a65726 TL |
516 | struct executable_statement *on_expiry; |
517 | struct executable_statement *on_commit; | |
518 | struct executable_statement *on_release; | |
519 | ||
f3aad410 TL |
520 | unsigned char *uid; |
521 | unsigned short uid_len; | |
522 | unsigned short uid_max; | |
523 | unsigned char uid_buf [7]; | |
524 | struct hardware hardware_addr; | |
525 | ||
526 | u_int8_t flags; | |
c626ae69 | 527 | # define STATIC_LEASE 1 |
98311e4b | 528 | # define BOOTP_LEASE 2 |
a55ccdd0 | 529 | # define RESERVED_LEASE 4 |
fc2df23a | 530 | # define MS_NULL_TERMINATION 8 |
007e3ee4 TL |
531 | # define ON_UPDATE_QUEUE 16 |
532 | # define ON_ACK_QUEUE 32 | |
4c7ffd58 | 533 | # define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE) |
bca94423 | 534 | # define UNICAST_BROADCAST_HACK 64 |
98311e4b | 535 | # define ON_DEFERRED_QUEUE 128 |
a55ccdd0 DH |
536 | |
537 | /* Persistent flags are to be preserved on a given lease structure. */ | |
538 | # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE) | |
539 | /* Ephemeral flags are to be preserved on a given lease (copied etc). */ | |
bca94423 | 540 | # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \ |
a55ccdd0 DH |
541 | UNICAST_BROADCAST_HACK | \ |
542 | RESERVED_LEASE | \ | |
543 | BOOTP_LEASE) | |
2aac4312 | 544 | |
fdfebedf DH |
545 | /* |
546 | * The lease's binding state is its current state. The next binding | |
547 | * state is the next state this lease will move into by expiration, | |
548 | * or timers in general. The desired binding state is used on lease | |
549 | * updates; the caller is attempting to move the lease to the desired | |
550 | * binding state (and this may either succeed or fail, so the binding | |
551 | * state must be preserved). | |
552 | * | |
553 | * The 'rewind' binding state is used in failover processing. It | |
554 | * is used for an optimization when out of communications; it allows | |
555 | * the server to "rewind" a lease to the previous state acknowledged | |
556 | * by the peer, and progress forward from that point. | |
557 | */ | |
98311e4b DH |
558 | binding_state_t binding_state; |
559 | binding_state_t next_binding_state; | |
560 | binding_state_t desired_binding_state; | |
fdfebedf DH |
561 | binding_state_t rewind_binding_state; |
562 | ||
6e5ed8bf | 563 | struct lease_state *state; |
5b7f941d | 564 | |
fdfebedf DH |
565 | /* |
566 | * 'tsfp' is more of an 'effective' tsfp. It may be calculated from | |
88cd8aca DH |
567 | * stos+mclt for example if it's an expired lease and the server is |
568 | * in partner-down state. 'atsfp' is zeroed whenever a lease is | |
569 | * updated - and only set when the peer acknowledges it. This | |
570 | * ensures every state change is transmitted. | |
571 | */ | |
5b7f941d TL |
572 | TIME tstp; /* Time sent to partner. */ |
573 | TIME tsfp; /* Time sent from partner. */ | |
88cd8aca | 574 | TIME atsfp; /* Actual time sent from partner. */ |
5b7f941d | 575 | TIME cltt; /* Client last transaction time. */ |
a55ccdd0 | 576 | u_int32_t last_xid; /* XID we sent in this lease's BNDUPD */ |
aa8579c0 | 577 | struct lease *next_pending; |
98bf1607 SR |
578 | |
579 | /* | |
580 | * A pointer to the state of the ddns update for this lease. | |
581 | * It should be set while the update is in progress and cleared | |
582 | * when the update finishes. It can be used to cancel the | |
583 | * update if we want to do a different update. | |
584 | */ | |
585 | struct dhcp_ddns_cb *ddns_cb; | |
6e5ed8bf TL |
586 | }; |
587 | ||
588 | struct lease_state { | |
589 | struct lease_state *next; | |
590 | ||
591 | struct interface_info *ip; | |
592 | ||
f3e8ea32 TL |
593 | struct packet *packet; /* The incoming packet. */ |
594 | ||
6e5ed8bf TL |
595 | TIME offered_expiry; |
596 | ||
4f58da18 | 597 | struct option_state *options; |
15151db6 | 598 | struct data_string parameter_request_list; |
5142937c | 599 | int max_message_size; |
dcc557db | 600 | unsigned char expiry[4], renewal[4], rebind[4]; |
2b9b6ff7 | 601 | struct data_string filename, server_name; |
f67530be TL |
602 | int got_requested_address; |
603 | int got_server_identifier; | |
604 | struct shared_network *shared_network; /* Shared network of interface | |
605 | on which request arrived. */ | |
fc2df23a TL |
606 | |
607 | u_int32_t xid; | |
608 | u_int16_t secs; | |
609 | u_int16_t bootp_flags; | |
610 | struct in_addr ciaddr; | |
c783f799 | 611 | struct in_addr siaddr; |
fc2df23a TL |
612 | struct in_addr giaddr; |
613 | u_int8_t hops; | |
614 | u_int8_t offer; | |
27fe61a7 | 615 | struct iaddr from; |
c626ae69 TL |
616 | }; |
617 | ||
ab370123 | 618 | #define ROOT_GROUP 0 |
750d0800 TL |
619 | #define HOST_DECL 1 |
620 | #define SHARED_NET_DECL 2 | |
621 | #define SUBNET_DECL 3 | |
622 | #define CLASS_DECL 4 | |
623 | #define GROUP_DECL 5 | |
74f45f96 | 624 | #define POOL_DECL 6 |
ab370123 | 625 | |
cc26de46 TL |
626 | /* Possible modes in which discover_interfaces can run. */ |
627 | ||
628 | #define DISCOVER_RUNNING 0 | |
629 | #define DISCOVER_SERVER 1 | |
630 | #define DISCOVER_UNCONFIGURED 2 | |
f79e49f3 | 631 | #define DISCOVER_RELAY 3 |
5a526cf8 | 632 | #define DISCOVER_REQUESTED 4 |
cc26de46 | 633 | |
98bd7ca0 DH |
634 | /* DDNS_UPDATE_STYLE enumerations. */ |
635 | #define DDNS_UPDATE_STYLE_NONE 0 | |
636 | #define DDNS_UPDATE_STYLE_AD_HOC 1 | |
637 | #define DDNS_UPDATE_STYLE_INTERIM 2 | |
638 | ||
2b9b6ff7 TL |
639 | /* Server option names. */ |
640 | ||
641 | #define SV_DEFAULT_LEASE_TIME 1 | |
642 | #define SV_MAX_LEASE_TIME 2 | |
643 | #define SV_MIN_LEASE_TIME 3 | |
644 | #define SV_BOOTP_LEASE_CUTOFF 4 | |
645 | #define SV_BOOTP_LEASE_LENGTH 5 | |
646 | #define SV_BOOT_UNKNOWN_CLIENTS 6 | |
647 | #define SV_DYNAMIC_BOOTP 7 | |
648 | #define SV_ALLOW_BOOTP 8 | |
649 | #define SV_ALLOW_BOOTING 9 | |
650 | #define SV_ONE_LEASE_PER_CLIENT 10 | |
651 | #define SV_GET_LEASE_HOSTNAMES 11 | |
652 | #define SV_USE_HOST_DECL_NAMES 12 | |
653 | #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13 | |
654 | #define SV_MIN_SECS 14 | |
655 | #define SV_FILENAME 15 | |
656 | #define SV_SERVER_NAME 16 | |
657 | #define SV_NEXT_SERVER 17 | |
d1f2c520 | 658 | #define SV_AUTHORITATIVE 18 |
4f58da18 | 659 | #define SV_VENDOR_OPTION_SPACE 19 |
4b7f8736 | 660 | #define SV_ALWAYS_REPLY_RFC1048 20 |
53ac6c6f | 661 | #define SV_SITE_OPTION_SPACE 21 |
f7b9d823 | 662 | #define SV_ALWAYS_BROADCAST 22 |
972ab2aa TL |
663 | #define SV_DDNS_DOMAIN_NAME 23 |
664 | #define SV_DDNS_HOST_NAME 24 | |
665 | #define SV_DDNS_REV_DOMAIN_NAME 25 | |
94bf482e TL |
666 | #define SV_LEASE_FILE_NAME 26 |
667 | #define SV_PID_FILE_NAME 27 | |
4c026751 TL |
668 | #define SV_DUPLICATES 28 |
669 | #define SV_DECLINES 29 | |
7f6ad5ac | 670 | #define SV_DDNS_UPDATES 30 |
aa8579c0 TL |
671 | #define SV_OMAPI_PORT 31 |
672 | #define SV_LOCAL_PORT 32 | |
673 | #define SV_LIMITED_BROADCAST_ADDRESS 33 | |
674 | #define SV_REMOTE_PORT 34 | |
675 | #define SV_LOCAL_ADDRESS 35 | |
49146f3c | 676 | #define SV_OMAPI_KEY 36 |
159bcce3 | 677 | #define SV_STASH_AGENT_OPTIONS 37 |
b992d7e2 | 678 | #define SV_DDNS_TTL 38 |
dbcc689e | 679 | #define SV_DDNS_UPDATE_STYLE 39 |
afc0ca25 TL |
680 | #define SV_CLIENT_UPDATES 40 |
681 | #define SV_UPDATE_OPTIMIZATION 41 | |
cc4473a0 TL |
682 | #define SV_PING_CHECKS 42 |
683 | #define SV_UPDATE_STATIC_LEASES 43 | |
625f7cee | 684 | #define SV_LOG_FACILITY 44 |
98311e4b | 685 | #define SV_DO_FORWARD_UPDATES 45 |
a55ccdd0 DH |
686 | #define SV_PING_TIMEOUT 46 |
687 | #define SV_RESERVE_INFINITE 47 | |
3004bebf | 688 | #define SV_DDNS_CONFLICT_DETECT 48 |
6d103865 | 689 | #define SV_LEASEQUERY 49 |
b22de500 | 690 | #define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50 |
4d2eaafb | 691 | #define SV_DO_REVERSE_UPDATES 51 |
1ba87b37 | 692 | #define SV_FQDN_REPLY 52 |
98bd7ca0 | 693 | #define SV_PREFER_LIFETIME 53 |
75135a3f EH |
694 | #define SV_DHCPV6_LEASE_FILE_NAME 54 |
695 | #define SV_DHCPV6_PID_FILE_NAME 55 | |
b024480e | 696 | #define SV_LIMIT_ADDRS_PER_IA 56 |
80c9fdb0 FD |
697 | #define SV_LIMIT_PREFS_PER_IA 57 |
698 | #define SV_DELAYED_ACK 58 | |
f8cbf390 | 699 | #define SV_MAX_ACK_DELAY 59 |
929a2364 TM |
700 | #if defined(LDAP_CONFIGURATION) |
701 | # define SV_LDAP_SERVER 60 | |
702 | # define SV_LDAP_PORT 61 | |
703 | # define SV_LDAP_USERNAME 62 | |
704 | # define SV_LDAP_PASSWORD 63 | |
705 | # define SV_LDAP_BASE_DN 64 | |
706 | # define SV_LDAP_METHOD 65 | |
707 | # define SV_LDAP_DEBUG_FILE 66 | |
708 | # define SV_LDAP_DHCP_SERVER_CN 67 | |
709 | # define SV_LDAP_REFERRALS 68 | |
710 | #if defined (LDAP_USE_SSL) | |
711 | # define SV_LDAP_SSL 69 | |
712 | # define SV_LDAP_TLS_REQCERT 70 | |
713 | # define SV_LDAP_TLS_CA_FILE 71 | |
714 | # define SV_LDAP_TLS_CA_DIR 72 | |
715 | # define SV_LDAP_TLS_CERT 73 | |
716 | # define SV_LDAP_TLS_KEY 74 | |
717 | # define SV_LDAP_TLS_CRLCHECK 75 | |
718 | # define SV_LDAP_TLS_CIPHERS 76 | |
719 | # define SV_LDAP_TLS_RANDFILE 77 | |
720 | #endif | |
721 | #endif | |
722 | #define SV_CACHE_THRESHOLD 78 | |
98311e4b DH |
723 | |
724 | #if !defined (DEFAULT_PING_TIMEOUT) | |
725 | # define DEFAULT_PING_TIMEOUT 1 | |
726 | #endif | |
2b9b6ff7 | 727 | |
6368a1bd DH |
728 | #if !defined (DEFAULT_DELAYED_ACK) |
729 | # define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */ | |
730 | #endif | |
731 | ||
f8cbf390 DH |
732 | #if !defined (DEFAULT_ACK_DELAY_SECS) |
733 | # define DEFAULT_ACK_DELAY_SECS 0 | |
734 | #endif | |
735 | ||
736 | #if !defined (DEFAULT_ACK_DELAY_USECS) | |
737 | # define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */ | |
738 | #endif | |
739 | ||
0585235c SR |
740 | #if !defined (DEFAULT_MIN_ACK_DELAY_USECS) |
741 | # define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */ | |
742 | #endif | |
743 | ||
929a2364 TM |
744 | #if !defined (DEFAULT_CACHE_THRESHOLD) |
745 | # define DEFAULT_CACHE_THRESHOLD 25 | |
33692791 DH |
746 | #endif |
747 | ||
2b9b6ff7 TL |
748 | #if !defined (DEFAULT_DEFAULT_LEASE_TIME) |
749 | # define DEFAULT_DEFAULT_LEASE_TIME 43200 | |
750 | #endif | |
751 | ||
752 | #if !defined (DEFAULT_MIN_LEASE_TIME) | |
3a16098f | 753 | # define DEFAULT_MIN_LEASE_TIME 300 |
2b9b6ff7 TL |
754 | #endif |
755 | ||
756 | #if !defined (DEFAULT_MAX_LEASE_TIME) | |
757 | # define DEFAULT_MAX_LEASE_TIME 86400 | |
758 | #endif | |
759 | ||
b992d7e2 DN |
760 | #if !defined (DEFAULT_DDNS_TTL) |
761 | # define DEFAULT_DDNS_TTL 3600 | |
762 | #endif | |
2b58b865 SR |
763 | #if !defined (MAX_DEFAULT_DDNS_TTL) |
764 | # define MAX_DEFAULT_DDNS_TTL 3600 | |
765 | #endif | |
b992d7e2 | 766 | |
5d082abd TM |
767 | #if !defined (MIN_LEASE_WRITE) |
768 | # define MIN_LEASE_WRITE 15 | |
769 | #endif | |
770 | ||
27fe61a7 TL |
771 | /* Client option names */ |
772 | ||
773 | #define CL_TIMEOUT 1 | |
774 | #define CL_SELECT_INTERVAL 2 | |
775 | #define CL_REBOOT_TIMEOUT 3 | |
776 | #define CL_RETRY_INTERVAL 4 | |
777 | #define CL_BACKOFF_CUTOFF 5 | |
778 | #define CL_INITIAL_INTERVAL 6 | |
779 | #define CL_BOOTP_POLICY 7 | |
780 | #define CL_SCRIPT_NAME 8 | |
781 | #define CL_REQUESTED_OPTIONS 9 | |
782 | #define CL_REQUESTED_LEASE_TIME 10 | |
783 | #define CL_SEND_OPTIONS 11 | |
784 | #define CL_MEDIA 12 | |
785 | #define CL_REJECT_LIST 13 | |
786 | ||
787 | #ifndef CL_DEFAULT_TIMEOUT | |
788 | # define CL_DEFAULT_TIMEOUT 60 | |
789 | #endif | |
790 | ||
791 | #ifndef CL_DEFAULT_SELECT_INTERVAL | |
792 | # define CL_DEFAULT_SELECT_INTERVAL 0 | |
793 | #endif | |
794 | ||
795 | #ifndef CL_DEFAULT_REBOOT_TIMEOUT | |
796 | # define CL_DEFAULT_REBOOT_TIMEOUT 10 | |
797 | #endif | |
798 | ||
799 | #ifndef CL_DEFAULT_RETRY_INTERVAL | |
800 | # define CL_DEFAULT_RETRY_INTERVAL 300 | |
801 | #endif | |
802 | ||
803 | #ifndef CL_DEFAULT_BACKOFF_CUTOFF | |
804 | # define CL_DEFAULT_BACKOFF_CUTOFF 120 | |
805 | #endif | |
806 | ||
807 | #ifndef CL_DEFAULT_INITIAL_INTERVAL | |
808 | # define CL_DEFAULT_INITIAL_INTERVAL 10 | |
809 | #endif | |
810 | ||
811 | #ifndef CL_DEFAULT_BOOTP_POLICY | |
c5b0f529 | 812 | # define CL_DEFAULT_BOOTP_POLICY P_ACCEPT |
27fe61a7 TL |
813 | #endif |
814 | ||
27fe61a7 TL |
815 | #ifndef CL_DEFAULT_REQUESTED_OPTIONS |
816 | # define CL_DEFAULT_REQUESTED_OPTIONS \ | |
817 | { DHO_SUBNET_MASK, \ | |
818 | DHO_BROADCAST_ADDRESS, \ | |
819 | DHO_TIME_OFFSET, \ | |
820 | DHO_ROUTERS, \ | |
821 | DHO_DOMAIN_NAME, \ | |
822 | DHO_DOMAIN_NAME_SERVERS, \ | |
823 | DHO_HOST_NAME } | |
824 | #endif | |
825 | ||
940ea8ab TL |
826 | struct group_object { |
827 | OMAPI_OBJECT_PREAMBLE; | |
828 | ||
829 | struct group_object *n_dynamic; | |
830 | struct group *group; | |
831 | char *name; | |
832 | int flags; | |
833 | #define GROUP_OBJECT_DELETED 1 | |
834 | #define GROUP_OBJECT_DYNAMIC 2 | |
835 | #define GROUP_OBJECT_STATIC 4 | |
836 | }; | |
837 | ||
750d0800 | 838 | /* Group of declarations that share common parameters. */ |
ab370123 TL |
839 | struct group { |
840 | struct group *next; | |
841 | ||
20916cae | 842 | int refcnt; |
940ea8ab | 843 | struct group_object *object; |
ab370123 TL |
844 | struct subnet *subnet; |
845 | struct shared_network *shared_network; | |
d1f2c520 | 846 | int authoritative; |
2b9b6ff7 | 847 | struct executable_statement *statements; |
ab370123 TL |
848 | }; |
849 | ||
850 | /* A dhcp host declaration structure. */ | |
851 | struct host_decl { | |
4fe74d72 | 852 | OMAPI_OBJECT_PREAMBLE; |
ab370123 | 853 | struct host_decl *n_ipaddr; |
4fe74d72 | 854 | struct host_decl *n_dynamic; |
ab370123 TL |
855 | char *name; |
856 | struct hardware interface; | |
2b9b6ff7 | 857 | struct data_string client_identifier; |
98bd7ca0 DH |
858 | struct option *host_id_option; |
859 | struct data_string host_id; | |
860 | /* XXXSK: fixed_addr should be an array of iaddr values, | |
861 | not an option_cache, but it's referenced in a lot of | |
862 | places, so we'll leave it for now. */ | |
2b9b6ff7 | 863 | struct option_cache *fixed_addr; |
80c9fdb0 | 864 | struct iaddrcidrnetlist *fixed_prefix; |
ab370123 | 865 | struct group *group; |
940ea8ab | 866 | struct group_object *named_group; |
74f45f96 | 867 | struct data_string auth_key_id; |
4fe74d72 | 868 | int flags; |
3c48d369 TL |
869 | #define HOST_DECL_DELETED 1 |
870 | #define HOST_DECL_DYNAMIC 2 | |
940ea8ab | 871 | #define HOST_DECL_STATIC 4 |
ab370123 TL |
872 | }; |
873 | ||
734d2258 TL |
874 | struct permit { |
875 | struct permit *next; | |
876 | enum { | |
877 | permit_unknown_clients, | |
878 | permit_known_clients, | |
879 | permit_authenticated_clients, | |
880 | permit_unauthenticated_clients, | |
881 | permit_all_clients, | |
882 | permit_dynamic_bootp_clients, | |
b1d3778c DH |
883 | permit_class, |
884 | permit_after | |
734d2258 TL |
885 | } type; |
886 | struct class *class; | |
b1d3778c | 887 | TIME after; /* date after which this clause applies */ |
734d2258 TL |
888 | }; |
889 | ||
890 | struct pool { | |
4fe74d72 | 891 | OMAPI_OBJECT_PREAMBLE; |
734d2258 | 892 | struct pool *next; |
74f45f96 | 893 | struct group *group; |
734d2258 TL |
894 | struct shared_network *shared_network; |
895 | struct permit *permit_list; | |
896 | struct permit *prohibit_list; | |
007e3ee4 TL |
897 | struct lease *active; |
898 | struct lease *expired; | |
899 | struct lease *free; | |
900 | struct lease *backup; | |
901 | struct lease *abandoned; | |
a55ccdd0 | 902 | struct lease *reserved; |
007e3ee4 | 903 | TIME next_event_time; |
5b7f941d | 904 | int lease_count; |
007e3ee4 TL |
905 | int free_leases; |
906 | int backup_leases; | |
d758ad8c | 907 | int index; |
b1d3778c DH |
908 | TIME valid_from; /* deny pool use before this date */ |
909 | TIME valid_until; /* deny pool use after this date */ | |
910 | ||
7ea8b207 | 911 | #if defined (FAILOVER_PROTOCOL) |
5b7f941d TL |
912 | dhcp_failover_state_t *failover_peer; |
913 | #endif | |
d1f2c520 | 914 | }; |
d1f2c520 | 915 | |
c626ae69 | 916 | struct shared_network { |
4fe74d72 | 917 | OMAPI_OBJECT_PREAMBLE; |
c626ae69 | 918 | struct shared_network *next; |
20916cae | 919 | char *name; |
7d6180be DH |
920 | |
921 | #define SHARED_IMPLICIT 1 /* This network was synthesized. */ | |
922 | int flags; | |
923 | ||
c626ae69 TL |
924 | struct subnet *subnets; |
925 | struct interface_info *interface; | |
734d2258 | 926 | struct pool *pools; |
98bd7ca0 DH |
927 | struct ipv6_pool **ipv6_pools; /* NULL-terminated array */ |
928 | int last_ipv6_pool; /* offset of last IPv6 pool | |
929 | used to issue a lease */ | |
5b7f941d | 930 | struct group *group; |
d1f2c520 | 931 | #if defined (FAILOVER_PROTOCOL) |
5b7f941d | 932 | dhcp_failover_state_t *failover_peer; |
d1f2c520 | 933 | #endif |
d7837182 TL |
934 | }; |
935 | ||
936 | struct subnet { | |
4fe74d72 | 937 | OMAPI_OBJECT_PREAMBLE; |
c626ae69 TL |
938 | struct subnet *next_subnet; |
939 | struct subnet *next_sibling; | |
940 | struct shared_network *shared_network; | |
941 | struct interface_info *interface; | |
942 | struct iaddr interface_address; | |
089fb364 TL |
943 | struct iaddr net; |
944 | struct iaddr netmask; | |
98bd7ca0 | 945 | int prefix_len; /* XXX: currently for IPv6 only */ |
ab370123 | 946 | struct group *group; |
d7837182 TL |
947 | }; |
948 | ||
102ee7e9 TL |
949 | struct collection { |
950 | struct collection *next; | |
a34feb7d | 951 | |
b1b7b521 | 952 | const char *name; |
102ee7e9 TL |
953 | struct class *classes; |
954 | }; | |
955 | ||
06e77c34 DH |
956 | /* Used as an argument to parse_clasS_decl() */ |
957 | #define CLASS_TYPE_VENDOR 0 | |
958 | #define CLASS_TYPE_USER 1 | |
959 | #define CLASS_TYPE_CLASS 2 | |
960 | #define CLASS_TYPE_SUBCLASS 3 | |
961 | ||
112a6c2c | 962 | /* XXX classes must be reference-counted. */ |
102ee7e9 | 963 | struct class { |
4fe74d72 | 964 | OMAPI_OBJECT_PREAMBLE; |
a609e69b | 965 | struct class *nic; /* Next in collection. */ |
112a6c2c | 966 | struct class *superclass; /* Set for spawned classes only. */ |
a609e69b | 967 | char *name; /* Not set for spawned classes. */ |
734d2258 TL |
968 | |
969 | /* A class may be configured to permit a limited number of leases. */ | |
970 | int lease_limit; | |
112a6c2c TL |
971 | int leases_consumed; |
972 | struct lease **billed_leases; | |
973 | ||
974 | /* If nonzero, class has not been saved since it was last | |
975 | modified. */ | |
976 | int dirty; | |
ab370123 | 977 | |
112a6c2c | 978 | /* Hash table containing subclasses. */ |
98311e4b | 979 | class_hash_t *hash; |
112a6c2c TL |
980 | struct data_string hash_string; |
981 | ||
982 | /* Expression used to match class. */ | |
2b9b6ff7 | 983 | struct expression *expr; |
112a6c2c TL |
984 | |
985 | /* Expression used to compute subclass identifiers for spawning | |
58bfaaa7 TL |
986 | and to do subclass matching. */ |
987 | struct expression *submatch; | |
988 | int spawning; | |
a34feb7d | 989 | |
ab370123 | 990 | struct group *group; |
2b9b6ff7 TL |
991 | |
992 | /* Statements to execute if class matches. */ | |
993 | struct executable_statement *statements; | |
899d754f JB |
994 | |
995 | #define CLASS_DECL_DELETED 1 | |
996 | #define CLASS_DECL_DYNAMIC 2 | |
997 | #define CLASS_DECL_STATIC 4 | |
998 | #define CLASS_DECL_SUBCLASS 8 | |
a34feb7d | 999 | |
899d754f | 1000 | int flags; |
709f15cc TL |
1001 | }; |
1002 | ||
cc26de46 TL |
1003 | /* DHCP client lease structure... */ |
1004 | struct client_lease { | |
41fb155b TL |
1005 | struct client_lease *next; /* Next lease in list. */ |
1006 | TIME expiry, renewal, rebind; /* Lease timeouts. */ | |
1007 | struct iaddr address; /* Address being leased. */ | |
1008 | char *server_name; /* Name of boot server. */ | |
1009 | char *filename; /* Name of file we're supposed to boot. */ | |
6b3b97e1 | 1010 | struct string_list *medium; /* Network medium. */ |
49146f3c | 1011 | struct auth_key *key; /* Key used in basic DHCP authentication. */ |
cc26de46 | 1012 | |
0c7802b1 | 1013 | unsigned int is_static : 1; /* If set, lease is from config file. */ |
98311e4b | 1014 | unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */ |
41fb155b | 1015 | |
4f58da18 | 1016 | struct option_state *options; /* Options supplied with lease. */ |
cc26de46 TL |
1017 | }; |
1018 | ||
98bd7ca0 DH |
1019 | /* DHCPv6 lease structures */ |
1020 | struct dhc6_addr { | |
1021 | struct dhc6_addr *next; | |
1022 | struct iaddr address; | |
1d9774ab | 1023 | u_int8_t plen; |
98bd7ca0 DH |
1024 | |
1025 | /* Address state flags. */ | |
1026 | #define DHC6_ADDR_DEPREFFED 0x01 | |
1027 | #define DHC6_ADDR_EXPIRED 0x02 | |
1028 | u_int8_t flags; | |
1029 | ||
1030 | TIME starts; | |
1031 | u_int32_t preferred_life; | |
1032 | u_int32_t max_life; | |
1033 | ||
1034 | struct option_state *options; | |
1035 | }; | |
1036 | ||
1037 | struct dhc6_ia { | |
1038 | struct dhc6_ia *next; | |
1039 | unsigned char iaid[4]; | |
1d9774ab | 1040 | u_int16_t ia_type; |
98bd7ca0 DH |
1041 | |
1042 | TIME starts; | |
1043 | u_int32_t renew; | |
1044 | u_int32_t rebind; | |
1045 | struct dhc6_addr *addrs; | |
1046 | ||
1047 | struct option_state *options; | |
1048 | }; | |
1049 | ||
1050 | struct dhc6_lease { | |
1051 | struct dhc6_lease *next; | |
1052 | struct data_string server_id; | |
1053 | ||
cabdb9b1 | 1054 | isc_boolean_t released; |
98bd7ca0 DH |
1055 | int score; |
1056 | u_int8_t pref; | |
1057 | ||
1058 | unsigned char dhcpv6_transaction_id[3]; | |
1059 | struct dhc6_ia *bindings; | |
1060 | ||
1061 | struct option_state *options; | |
1062 | }; | |
1063 | ||
41fb155b | 1064 | /* Possible states in which the client can be. */ |
cc26de46 | 1065 | enum dhcp_state { |
159bcce3 TL |
1066 | S_REBOOTING = 1, |
1067 | S_INIT = 2, | |
1068 | S_SELECTING = 3, | |
a34feb7d | 1069 | S_REQUESTING = 4, |
159bcce3 TL |
1070 | S_BOUND = 5, |
1071 | S_RENEWING = 6, | |
c1f22aef TL |
1072 | S_REBINDING = 7, |
1073 | S_STOPPED = 8 | |
cc26de46 TL |
1074 | }; |
1075 | ||
08512bce TL |
1076 | /* Authentication and BOOTP policy possibilities (not all values work |
1077 | for each). */ | |
1078 | enum policy { P_IGNORE, P_ACCEPT, P_PREFER, P_REQUIRE, P_DONT }; | |
1079 | ||
cc26de46 TL |
1080 | /* Configuration information from the config file... */ |
1081 | struct client_config { | |
27fe61a7 TL |
1082 | /* |
1083 | * When a message has been received, run these statements | |
1084 | * over it. | |
1085 | */ | |
112a6c2c | 1086 | struct group *on_receipt; |
27fe61a7 TL |
1087 | |
1088 | /* | |
1089 | * When a message is sent, run these statements. | |
1090 | */ | |
112a6c2c | 1091 | struct group *on_transmission; |
27fe61a7 | 1092 | |
0c20eab3 DH |
1093 | struct option **required_options; /* Options that MUST be present. */ |
1094 | struct option **requested_options; /* Options to request (ORO/PRL). */ | |
27fe61a7 | 1095 | |
cc26de46 TL |
1096 | TIME timeout; /* Start to panic if we don't get a |
1097 | lease in this time period when | |
1098 | SELECTING. */ | |
a34feb7d TM |
1099 | TIME initial_delay; /* Set initial delay before first |
1100 | transmission. */ | |
83c1b012 TL |
1101 | TIME initial_interval; /* All exponential backoff intervals |
1102 | start here. */ | |
cc26de46 TL |
1103 | TIME retry_interval; /* If the protocol failed to produce |
1104 | an address before the timeout, | |
1105 | try the protocol again after this | |
1106 | many seconds. */ | |
1107 | TIME select_interval; /* Wait this many seconds from the | |
1108 | first DHCPDISCOVER before | |
1109 | picking an offered lease. */ | |
fc2df23a TL |
1110 | TIME reboot_timeout; /* When in INIT-REBOOT, wait this |
1111 | long before giving up and going | |
1112 | to INIT. */ | |
83c1b012 TL |
1113 | TIME backoff_cutoff; /* When doing exponential backoff, |
1114 | never back off to an interval | |
1115 | longer than this amount. */ | |
27fe61a7 TL |
1116 | u_int32_t requested_lease; /* Requested lease time, if user |
1117 | doesn't configure one. */ | |
6b3b97e1 | 1118 | struct string_list *media; /* Possible network media values. */ |
32a47563 | 1119 | char *script_name; /* Name of config script. */ |
432604c3 | 1120 | char *vendor_space_name; /* Name of config script. */ |
08512bce | 1121 | enum policy bootp_policy; |
cc26de46 TL |
1122 | /* Ignore, accept or prefer BOOTP |
1123 | responses. */ | |
08512bce TL |
1124 | enum policy auth_policy; |
1125 | /* Require authentication, prefer | |
1126 | authentication, or don't try to | |
1127 | authenticate. */ | |
6b3b97e1 | 1128 | struct string_list *medium; /* Current network medium. */ |
0c7802b1 | 1129 | |
febbd402 | 1130 | struct iaddrmatchlist *reject_list; /* Servers to reject. */ |
27fe61a7 | 1131 | |
626ca6a2 TL |
1132 | int omapi_port; /* port on which to accept OMAPI |
1133 | connections, or -1 for no | |
1134 | listener. */ | |
98311e4b DH |
1135 | int do_forward_update; /* If nonzero, and if we have the |
1136 | information we need, update the | |
1137 | A record for the address we get. */ | |
cc26de46 TL |
1138 | }; |
1139 | ||
1140 | /* Per-interface state used in the dhcp client... */ | |
98bd7ca0 | 1141 | /* XXX: consider union {}'ing this for v4/v6. */ |
cc26de46 | 1142 | struct client_state { |
734d2258 TL |
1143 | struct client_state *next; |
1144 | struct interface_info *interface; | |
1145 | char *name; | |
1146 | ||
98bd7ca0 DH |
1147 | /* Common values. */ |
1148 | struct client_config *config; /* Client configuration. */ | |
1149 | struct string_list *env; /* Client script environment. */ | |
a34feb7d | 1150 | int envc; /* Number of entries in environment. */ |
98bd7ca0 DH |
1151 | struct option_state *sent_options; /* Options we sent. */ |
1152 | enum dhcp_state state; /* Current state for this interface. */ | |
5d082abd | 1153 | TIME last_write; /* Last time this state was written. */ |
98bd7ca0 DH |
1154 | |
1155 | /* DHCPv4 values. */ | |
cc26de46 TL |
1156 | struct client_lease *active; /* Currently active lease. */ |
1157 | struct client_lease *new; /* New lease. */ | |
1158 | struct client_lease *offered_leases; /* Leases offered to us. */ | |
1159 | struct client_lease *leases; /* Leases we currently hold. */ | |
f79e49f3 | 1160 | struct client_lease *alias; /* Alias lease. */ |
cc26de46 | 1161 | |
cc26de46 TL |
1162 | struct iaddr destination; /* Where to send packet. */ |
1163 | u_int32_t xid; /* Transaction ID. */ | |
64826b61 | 1164 | u_int16_t secs; /* secs value from DHCPDISCOVER. */ |
cc26de46 | 1165 | TIME first_sending; /* When was first copy sent? */ |
6b3b97e1 TL |
1166 | TIME interval; /* What's the current resend interval? */ |
1167 | struct string_list *medium; /* Last media type tried. */ | |
cc26de46 | 1168 | struct dhcp_packet packet; /* Outgoing DHCP packet. */ |
b1b7b521 | 1169 | unsigned packet_length; /* Actual length of generated packet. */ |
cc26de46 | 1170 | |
41fb155b TL |
1171 | struct iaddr requested_address; /* Address we would like to get. */ |
1172 | ||
98bd7ca0 DH |
1173 | /* DHCPv6 values. */ |
1174 | unsigned char dhcpv6_transaction_id[3]; | |
1175 | u_int8_t refresh_type; | |
1176 | ||
1177 | struct dhc6_lease *active_lease; | |
1178 | struct dhc6_lease *old_lease; | |
1179 | struct dhc6_lease *advertised_leases; | |
1180 | struct dhc6_lease *selected_lease; | |
1181 | struct dhc6_lease *held_leases; | |
1182 | ||
be62cf06 | 1183 | struct timeval start_time; |
98bd7ca0 DH |
1184 | u_int16_t elapsed; |
1185 | int txcount; | |
1186 | ||
1187 | /* See RFC3315 section 14. */ | |
be62cf06 FD |
1188 | TIME RT; /* In hundredths of seconds. */ |
1189 | TIME IRT; /* In hundredths of seconds. */ | |
1190 | TIME MRC; /* Count. */ | |
1191 | TIME MRT; /* In hundredths of seconds. */ | |
1192 | TIME MRD; /* In seconds, relative. */ | |
1193 | TIME next_MRD; /* In seconds, absolute. */ | |
98bd7ca0 DH |
1194 | |
1195 | /* Rather than a state, we use a function that shifts around | |
1196 | * depending what stage of life the v6 state machine is in. | |
1197 | * This is where incoming packets are dispatched to (sometimes | |
1198 | * a no-op). | |
1199 | */ | |
1200 | void (*v6_handler)(struct packet *, struct client_state *); | |
98bf1607 SR |
1201 | |
1202 | /* | |
1203 | * A pointer to the state of the ddns update for this lease. | |
1204 | * It should be set while the update is in progress and cleared | |
1205 | * when the update finishes. It can be used to cancel the | |
1206 | * update if we want to do a different update. | |
1207 | */ | |
1208 | struct dhcp_ddns_cb *ddns_cb; | |
98bd7ca0 | 1209 | }; |
d758ad8c | 1210 | |
98bd7ca0 DH |
1211 | struct envadd_state { |
1212 | struct client_state *client; | |
1213 | const char *prefix; | |
1214 | }; | |
1215 | ||
1216 | struct dns_update_state { | |
1217 | struct client_state *client; | |
1218 | struct iaddr address; | |
1219 | int dns_update_timeout; | |
cc26de46 TL |
1220 | }; |
1221 | ||
17b95f41 TL |
1222 | /* Information about each network interface. */ |
1223 | ||
1224 | struct interface_info { | |
4fe74d72 | 1225 | OMAPI_OBJECT_PREAMBLE; |
17b95f41 | 1226 | struct interface_info *next; /* Next interface in list... */ |
c626ae69 TL |
1227 | struct shared_network *shared_network; |
1228 | /* Networks connected to this interface. */ | |
17b95f41 | 1229 | struct hardware hw_address; /* Its physical address. */ |
98bd7ca0 DH |
1230 | struct in_addr *addresses; /* Addresses associated with this |
1231 | * interface. | |
1232 | */ | |
1233 | int address_count; /* Number of addresses stored. */ | |
1234 | int address_max; /* Size of addresses buffer. */ | |
a34feb7d | 1235 | struct in6_addr *v6addresses; /* IPv6 addresses associated with |
98bd7ca0 DH |
1236 | this interface. */ |
1237 | int v6address_count; /* Number of IPv6 addresses associated | |
1238 | with this interface. */ | |
1239 | int v6address_max; /* Maximum number of IPv6 addresses | |
1240 | we can store in current buffer. */ | |
c4763f5f TL |
1241 | |
1242 | u_int8_t *circuit_id; /* Circuit ID associated with this | |
1243 | interface. */ | |
b1b7b521 | 1244 | unsigned circuit_id_len; /* Length of Circuit ID, if there |
c4763f5f TL |
1245 | is one. */ |
1246 | u_int8_t *remote_id; /* Remote ID associated with this | |
1247 | interface (if any). */ | |
b1b7b521 | 1248 | unsigned remote_id_len; /* Length of Remote ID. */ |
c4763f5f | 1249 | |
17b95f41 | 1250 | char name [IFNAMSIZ]; /* Its name... */ |
ecddae64 | 1251 | int index; /* Its if_nametoindex(). */ |
17b95f41 TL |
1252 | int rfdesc; /* Its read file descriptor. */ |
1253 | int wfdesc; /* Its write file descriptor, if | |
1254 | different. */ | |
1255 | unsigned char *rbuf; /* Read buffer, if required. */ | |
98311e4b | 1256 | unsigned int rbuf_max; /* Size of read buffer. */ |
17b95f41 TL |
1257 | size_t rbuf_offset; /* Current offset into buffer. */ |
1258 | size_t rbuf_len; /* Length of data in buffer. */ | |
c626ae69 | 1259 | |
41fb155b | 1260 | struct ifreq *ifp; /* Pointer to ifreq struct. */ |
98bd7ca0 DH |
1261 | int configured; /* If set to 1, interface has at least |
1262 | * one valid IP address. | |
1263 | */ | |
7f91dcfb TL |
1264 | u_int32_t flags; /* Control flags... */ |
1265 | #define INTERFACE_REQUESTED 1 | |
5a526cf8 | 1266 | #define INTERFACE_AUTOMATIC 2 |
347de8bd | 1267 | #define INTERFACE_RUNNING 4 |
7de20a95 EH |
1268 | #define INTERFACE_DOWNSTREAM 8 |
1269 | #define INTERFACE_UPSTREAM 16 | |
1270 | #define INTERFACE_STREAMS (INTERFACE_DOWNSTREAM | INTERFACE_UPSTREAM) | |
cc26de46 TL |
1271 | |
1272 | /* Only used by DHCP client code. */ | |
1273 | struct client_state *client; | |
a57df74a DH |
1274 | # if defined(USE_DLPI_SEND) || defined(USE_DLPI_RECEIVE) || \ |
1275 | defined(USE_DLPI_HWADDR) | |
3d2aa1bf BC |
1276 | int dlpi_sap_length; |
1277 | struct hardware dlpi_broadcast_addr; | |
1278 | # endif /* DLPI_SEND || DLPI_RECEIVE */ | |
0829d595 | 1279 | struct hardware anycast_mac_addr; |
17b95f41 TL |
1280 | }; |
1281 | ||
1282 | struct hardware_link { | |
1283 | struct hardware_link *next; | |
1284 | char name [IFNAMSIZ]; | |
1285 | struct hardware address; | |
1286 | }; | |
1287 | ||
6368a1bd DH |
1288 | struct leasequeue { |
1289 | struct leasequeue *prev; | |
1290 | struct leasequeue *next; | |
1291 | struct lease *lease; | |
1292 | }; | |
1293 | ||
76d5bd36 TL |
1294 | typedef void (*tvref_t)(void *, void *, const char *, int); |
1295 | typedef void (*tvunref_t)(void *, const char *, int); | |
cc26de46 TL |
1296 | struct timeout { |
1297 | struct timeout *next; | |
be62cf06 | 1298 | struct timeval when; |
a34feb7d | 1299 | void (*func) (void *); |
6e5ed8bf | 1300 | void *what; |
76d5bd36 TL |
1301 | tvref_t ref; |
1302 | tvunref_t unref; | |
a34feb7d | 1303 | isc_timer_t *isc_timeout; |
6e5ed8bf TL |
1304 | }; |
1305 | ||
6368a1bd DH |
1306 | struct eventqueue { |
1307 | struct eventqueue *next; | |
1308 | void (*handler)(void *); | |
1309 | }; | |
1310 | ||
6e5ed8bf TL |
1311 | struct protocol { |
1312 | struct protocol *next; | |
1313 | int fd; | |
a34feb7d | 1314 | void (*handler) (struct protocol *); |
6e5ed8bf | 1315 | void *local; |
cc26de46 TL |
1316 | }; |
1317 | ||
94f08824 TL |
1318 | struct dns_query; /* forward */ |
1319 | ||
1320 | struct dns_wakeup { | |
1321 | struct dns_wakeup *next; /* Next wakeup in chain. */ | |
a34feb7d | 1322 | void (*func) (struct dns_query *); |
94f08824 TL |
1323 | }; |
1324 | ||
5142937c TL |
1325 | struct dns_question { |
1326 | u_int16_t type; /* Type of query. */ | |
1327 | u_int16_t class; /* Class of query. */ | |
1328 | unsigned char data [1]; /* Query data. */ | |
1329 | }; | |
1330 | ||
1331 | struct dns_answer { | |
1332 | u_int16_t type; /* Type of answer. */ | |
1333 | u_int16_t class; /* Class of answer. */ | |
1334 | int count; /* Number of answers. */ | |
1335 | unsigned char *answers[1]; /* Pointers to answers. */ | |
1336 | }; | |
1337 | ||
94f08824 TL |
1338 | struct dns_query { |
1339 | struct dns_query *next; /* Next query in hash bucket. */ | |
5142937c | 1340 | u_int32_t hash; /* Hash bucket index. */ |
94f08824 TL |
1341 | TIME expiry; /* Query expiry time (zero if not yet |
1342 | answered. */ | |
1343 | u_int16_t id; /* Query ID (also hash table index) */ | |
1344 | caddr_t waiters; /* Pointer to list of things waiting | |
1345 | on this query. */ | |
5142937c TL |
1346 | |
1347 | struct dns_question *question; /* Question, internal format. */ | |
1348 | struct dns_answer *answer; /* Answer, internal format. */ | |
1349 | ||
1350 | unsigned char *query; /* Query formatted for DNS server. */ | |
b1b7b521 | 1351 | unsigned len; /* Length of entire query. */ |
94f08824 TL |
1352 | int sent; /* The query has been sent. */ |
1353 | struct dns_wakeup *wakeups; /* Wakeups to call if this query is | |
1354 | answered. */ | |
1355 | struct name_server *next_server; /* Next server to try. */ | |
1356 | int backoff; /* Current backoff, in seconds. */ | |
1357 | }; | |
1358 | ||
3f09cb5a TL |
1359 | struct dns_zone { |
1360 | int refcnt; | |
1361 | TIME timeout; | |
1362 | char *name; | |
1363 | struct option_cache *primary; | |
1364 | struct option_cache *secondary; | |
d424157d SR |
1365 | struct option_cache *primary6; |
1366 | struct option_cache *secondary6; | |
49146f3c | 1367 | struct auth_key *key; |
3f09cb5a TL |
1368 | }; |
1369 | ||
d758ad8c TL |
1370 | struct icmp_state { |
1371 | OMAPI_OBJECT_PREAMBLE; | |
1372 | int socket; | |
a34feb7d | 1373 | void (*icmp_handler) (struct iaddr, u_int8_t *, int); |
d758ad8c TL |
1374 | }; |
1375 | ||
f3aad410 TL |
1376 | #include "ctrace.h" |
1377 | ||
d7837182 TL |
1378 | /* Bitmask of dhcp option codes. */ |
1379 | typedef unsigned char option_mask [16]; | |
1380 | ||
1381 | /* DHCP Option mask manipulation macros... */ | |
1382 | #define OPTION_ZERO(mask) (memset (mask, 0, 16)) | |
1383 | #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7))) | |
1384 | #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7))) | |
1385 | #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7))) | |
1386 | #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit)) | |
1387 | ||
1388 | /* An option occupies its length plus two header bytes (code and | |
1389 | length) for every 255 bytes that must be stored. */ | |
1390 | #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1)) | |
1391 | ||
1392 | /* Default path to dhcpd config file. */ | |
d7837182 | 1393 | #ifdef DEBUG |
80ba033e | 1394 | #undef _PATH_DHCPD_CONF |
d7837182 | 1395 | #define _PATH_DHCPD_CONF "dhcpd.conf" |
80ba033e | 1396 | #undef _PATH_DHCPD_DB |
1358b874 | 1397 | #define _PATH_DHCPD_DB "dhcpd.leases" |
75135a3f EH |
1398 | #undef _PATH_DHCPD6_DB |
1399 | #define _PATH_DHCPD6_DB "dhcpd6.leases" | |
98311e4b DH |
1400 | #undef _PATH_DHCPD_PID |
1401 | #define _PATH_DHCPD_PID "dhcpd.pid" | |
75135a3f EH |
1402 | #undef _PATH_DHCPD6_PID |
1403 | #define _PATH_DHCPD6_PID "dhcpd6.pid" | |
fe5b0fdd | 1404 | #else /* !DEBUG */ |
75135a3f | 1405 | |
a8b53b42 | 1406 | #ifndef _PATH_DHCPD_CONF |
d7837182 | 1407 | #define _PATH_DHCPD_CONF "/etc/dhcpd.conf" |
fe5b0fdd | 1408 | #endif /* DEBUG */ |
a8b53b42 TL |
1409 | |
1410 | #ifndef _PATH_DHCPD_DB | |
fe5b0fdd | 1411 | #define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases" |
d7837182 | 1412 | #endif |
a8b53b42 | 1413 | |
75135a3f EH |
1414 | #ifndef _PATH_DHCPD6_DB |
1415 | #define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases" | |
1416 | #endif | |
1417 | ||
a8b53b42 | 1418 | #ifndef _PATH_DHCPD_PID |
fe5b0fdd | 1419 | #define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid" |
a8b53b42 | 1420 | #endif |
75135a3f EH |
1421 | |
1422 | #ifndef _PATH_DHCPD6_PID | |
1423 | #define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid" | |
d7837182 TL |
1424 | #endif |
1425 | ||
75135a3f EH |
1426 | #endif /* DEBUG */ |
1427 | ||
cc26de46 TL |
1428 | #ifndef _PATH_DHCLIENT_CONF |
1429 | #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf" | |
1430 | #endif | |
1431 | ||
e47988bf TL |
1432 | #ifndef _PATH_DHCLIENT_SCRIPT |
1433 | #define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script" | |
1434 | #endif | |
1435 | ||
cc26de46 | 1436 | #ifndef _PATH_DHCLIENT_PID |
fe5b0fdd | 1437 | #define _PATH_DHCLIENT_PID LOCALSTATEDIR"/run/dhclient.pid" |
cc26de46 TL |
1438 | #endif |
1439 | ||
98bd7ca0 | 1440 | #ifndef _PATH_DHCLIENT6_PID |
fe5b0fdd | 1441 | #define _PATH_DHCLIENT6_PID LOCALSTATEDIR"/run/dhclient6.pid" |
98bd7ca0 DH |
1442 | #endif |
1443 | ||
cc26de46 | 1444 | #ifndef _PATH_DHCLIENT_DB |
fe5b0fdd | 1445 | #define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases" |
cc26de46 TL |
1446 | #endif |
1447 | ||
98bd7ca0 | 1448 | #ifndef _PATH_DHCLIENT6_DB |
fe5b0fdd | 1449 | #define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases" |
98bd7ca0 DH |
1450 | #endif |
1451 | ||
0c7802b1 TL |
1452 | #ifndef _PATH_RESOLV_CONF |
1453 | #define _PATH_RESOLV_CONF "/etc/resolv.conf" | |
1454 | #endif | |
cc26de46 | 1455 | |
8afb9ae0 | 1456 | #ifndef _PATH_DHCRELAY_PID |
fe5b0fdd | 1457 | #define _PATH_DHCRELAY_PID LOCALSTATEDIR"/run/dhcrelay.pid" |
8afb9ae0 TL |
1458 | #endif |
1459 | ||
7de20a95 EH |
1460 | #ifndef _PATH_DHCRELAY6_PID |
1461 | #define _PATH_DHCRELAY6_PID LOCALSTATEDIR"/run/dhcrelay6.pid" | |
1462 | #endif | |
1463 | ||
ab370123 TL |
1464 | #ifndef DHCPD_LOG_FACILITY |
1465 | #define DHCPD_LOG_FACILITY LOG_DAEMON | |
1466 | #endif | |
1467 | ||
d7837182 TL |
1468 | #define MAX_TIME 0x7fffffff |
1469 | #define MIN_TIME 0 | |
1470 | ||
d9b43370 | 1471 | /* these are referenced */ |
9322442f | 1472 | typedef struct hash_table ia_hash_t; |
1d17db44 | 1473 | typedef struct hash_table iasubopt_hash_t; |
98bd7ca0 | 1474 | |
1d17db44 | 1475 | /* IAADDR/IAPREFIX lease */ |
9322442f | 1476 | |
1d17db44 | 1477 | struct iasubopt { |
98bd7ca0 | 1478 | int refcnt; /* reference count */ |
9322442f FD |
1479 | struct in6_addr addr; /* IPv6 address/prefix */ |
1480 | u_int8_t plen; /* iaprefix prefix length */ | |
98bd7ca0 DH |
1481 | binding_state_t state; /* state */ |
1482 | struct binding_scope *scope; /* "set var = value;" */ | |
5d89d60f FD |
1483 | time_t hard_lifetime_end_time; /* time address expires */ |
1484 | time_t soft_lifetime_end_time; /* time ephemeral expires */ | |
1acab09f FD |
1485 | u_int32_t prefer; /* cached preferred lifetime */ |
1486 | u_int32_t valid; /* cached valid lifetime */ | |
9322442f FD |
1487 | struct ia_xx *ia; /* IA for this lease */ |
1488 | struct ipv6_pool *ipv6_pool; /* pool for this lease */ | |
d9b43370 | 1489 | /* |
5d89d60f | 1490 | * For now, just pick an arbitrary time to keep old hard leases |
d9b43370 SK |
1491 | * around (value in seconds). |
1492 | */ | |
1493 | #define EXPIRED_IPV6_CLEANUP_TIME (60*60) | |
1494 | ||
a34feb7d | 1495 | int heap_index; /* index into heap, or -1 |
98bd7ca0 | 1496 | (internal use only) */ |
98bf1607 SR |
1497 | |
1498 | /* | |
1499 | * A pointer to the state of the ddns update for this lease. | |
1500 | * It should be set while the update is in progress and cleared | |
1501 | * when the update finishes. It can be used to cancel the | |
1502 | * update if we want to do a different update. | |
1503 | */ | |
1504 | struct dhcp_ddns_cb *ddns_cb; | |
1505 | ||
98bd7ca0 DH |
1506 | }; |
1507 | ||
9322442f | 1508 | struct ia_xx { |
98bd7ca0 DH |
1509 | int refcnt; /* reference count */ |
1510 | struct data_string iaid_duid; /* from the client */ | |
9322442f | 1511 | u_int16_t ia_type; /* IA_XX */ |
1d17db44 FD |
1512 | int num_iasubopt; /* number of IAADDR/PREFIX */ |
1513 | int max_iasubopt; /* space available for IAADDR/PREFIX */ | |
1acab09f | 1514 | time_t cltt; /* client last transaction time */ |
1d17db44 | 1515 | struct iasubopt **iasubopt; /* pointers to the IAADDR/IAPREFIXs */ |
98bd7ca0 DH |
1516 | }; |
1517 | ||
9322442f FD |
1518 | extern ia_hash_t *ia_na_active; |
1519 | extern ia_hash_t *ia_ta_active; | |
1520 | extern ia_hash_t *ia_pd_active; | |
98bd7ca0 DH |
1521 | |
1522 | struct ipv6_pool { | |
1523 | int refcnt; /* reference count */ | |
9322442f | 1524 | u_int16_t pool_type; /* IA_xx */ |
98bd7ca0 DH |
1525 | struct in6_addr start_addr; /* first IPv6 address */ |
1526 | int bits; /* number of bits, CIDR style */ | |
9322442f | 1527 | int units; /* allocation unit in bits */ |
1d17db44 FD |
1528 | iasubopt_hash_t *leases; /* non-free leases */ |
1529 | int num_active; /* count of active leases */ | |
98bd7ca0 | 1530 | isc_heap_t *active_timeouts; /* timeouts for active leases */ |
1d17db44 | 1531 | int num_inactive; /* count of inactive leases */ |
a34feb7d | 1532 | isc_heap_t *inactive_timeouts; /* timeouts for expired or |
98bd7ca0 | 1533 | released leases */ |
a34feb7d | 1534 | struct shared_network *shared_network; /* shared_network for |
98bd7ca0 | 1535 | this pool */ |
7d6180be | 1536 | struct subnet *subnet; /* subnet for this pool */ |
98bd7ca0 DH |
1537 | }; |
1538 | ||
98bf1607 SR |
1539 | /* Flags and state for dhcp_ddns_cb_t */ |
1540 | #define DDNS_UPDATE_ADDR 0x01 | |
1541 | #define DDNS_UPDATE_PTR 0x02 | |
1542 | #define DDNS_INCLUDE_RRSET 0x04 | |
1543 | #define DDNS_CONFLICT_OVERRIDE 0x08 | |
1544 | #define DDNS_CLIENT_DID_UPDATE 0x10 | |
1545 | #define DDNS_EXECUTE_NEXT 0x20 | |
1546 | #define DDNS_ABORT 0x40 | |
3221151b | 1547 | #define DDNS_STATIC_LEASE 0x80 |
0ef9a46e | 1548 | #define DDNS_ACTIVE_LEASE 0x100 |
98bf1607 SR |
1549 | /* |
1550 | * The following two groups are separate and we could reuse | |
1551 | * values but not reusing them may be useful in the future. | |
1552 | */ | |
1553 | #define DDNS_STATE_CLEANUP 0 // The previous step failed, cleanup | |
1554 | ||
1555 | #define DDNS_STATE_ADD_FW_NXDOMAIN 1 | |
1556 | #define DDNS_STATE_ADD_FW_YXDHCID 2 | |
1557 | #define DDNS_STATE_ADD_PTR 3 | |
1558 | ||
1559 | #define DDNS_STATE_REM_FW_YXDHCID 17 | |
1560 | #define DDNS_STATE_REM_FW_NXRR 18 | |
1561 | #define DDNS_STATE_REM_PTR 19 | |
1562 | ||
590298e7 SR |
1563 | /* |
1564 | * Flags for the dns print function | |
1565 | */ | |
1566 | #define DDNS_PRINT_INBOUND 1 | |
1567 | #define DDNS_PRINT_OUTBOUND 0 | |
1568 | ||
98bf1607 SR |
1569 | struct dhcp_ddns_cb; |
1570 | ||
1571 | typedef void (*ddns_action_t)(struct dhcp_ddns_cb *ddns_cb, | |
1572 | isc_result_t result); | |
1573 | ||
1574 | typedef struct dhcp_ddns_cb { | |
1575 | struct data_string fwd_name; | |
1576 | struct data_string rev_name; | |
1577 | struct data_string dhcid; | |
1578 | struct iaddr address; | |
1579 | int address_type; | |
1580 | ||
1581 | unsigned long ttl; | |
1582 | ||
1583 | unsigned char zone_name[DHCP_MAXDNS_WIRE]; | |
1584 | isc_sockaddrlist_t zone_server_list; | |
1585 | isc_sockaddr_t zone_addrs[DHCP_MAXNS]; | |
1586 | int zone_addr_count; | |
1587 | struct dns_zone *zone; | |
1588 | ||
0ef9a46e | 1589 | u_int16_t flags; |
98bf1607 SR |
1590 | TIME timeout; |
1591 | int state; | |
1592 | ddns_action_t cur_func; | |
1593 | ||
1594 | struct dhcp_ddns_cb * next_op; | |
1595 | ||
1596 | /* Lease or client state that triggered the ddns operation */ | |
1597 | void *lease; | |
1598 | struct binding_scope **scope; | |
a34feb7d | 1599 | |
98bf1607 SR |
1600 | void *transaction; |
1601 | void *dataspace; | |
1602 | } dhcp_ddns_cb_t; | |
1603 | ||
98bd7ca0 DH |
1604 | extern struct ipv6_pool **pools; |
1605 | extern int num_pools; | |
1606 | ||
d7837182 TL |
1607 | /* External definitions... */ |
1608 | ||
98311e4b DH |
1609 | HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t) |
1610 | HASH_FUNCTIONS_DECL (universe, const char *, struct universe, universe_hash_t) | |
f7fdb216 DH |
1611 | HASH_FUNCTIONS_DECL (option_name, const char *, struct option, |
1612 | option_name_hash_t) | |
1613 | HASH_FUNCTIONS_DECL (option_code, const unsigned *, struct option, | |
1614 | option_code_hash_t) | |
98311e4b | 1615 | HASH_FUNCTIONS_DECL (dns_zone, const char *, struct dns_zone, dns_zone_hash_t) |
6708d944 DH |
1616 | HASH_FUNCTIONS_DECL(lease_ip, const unsigned char *, struct lease, |
1617 | lease_ip_hash_t) | |
1618 | HASH_FUNCTIONS_DECL(lease_id, const unsigned char *, struct lease, | |
1619 | lease_id_hash_t) | |
98311e4b DH |
1620 | HASH_FUNCTIONS_DECL (host, const unsigned char *, struct host_decl, host_hash_t) |
1621 | HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t) | |
1622 | ||
d7837182 TL |
1623 | /* options.c */ |
1624 | ||
432604c3 | 1625 | extern struct option *vendor_cfg_option; |
a34feb7d TM |
1626 | int parse_options (struct packet *); |
1627 | int parse_option_buffer (struct option_state *, const unsigned char *, | |
1628 | unsigned, struct universe *); | |
6f56b7e2 | 1629 | struct universe *find_option_universe (struct option *, const char *); |
432604c3 | 1630 | int parse_encapsulated_suboptions (struct option_state *, struct option *, |
6f56b7e2 TL |
1631 | const unsigned char *, unsigned, |
1632 | struct universe *, const char *); | |
a34feb7d TM |
1633 | int cons_options (struct packet *, struct dhcp_packet *, struct lease *, |
1634 | struct client_state *, | |
1635 | int, struct option_state *, struct option_state *, | |
1636 | struct binding_scope **, | |
1637 | int, int, int, struct data_string *, const char *); | |
432604c3 | 1638 | int fqdn_universe_decode (struct option_state *, |
6f56b7e2 | 1639 | const unsigned char *, unsigned, struct universe *); |
98bd7ca0 DH |
1640 | struct option_cache * |
1641 | lookup_fqdn6_option(struct universe *universe, struct option_state *options, | |
1642 | unsigned code); | |
1643 | void | |
1644 | save_fqdn6_option(struct universe *universe, struct option_state *options, | |
bead14ea | 1645 | struct option_cache *oc, isc_boolean_t appendp); |
98bd7ca0 DH |
1646 | void |
1647 | delete_fqdn6_option(struct universe *universe, struct option_state *options, | |
1648 | int code); | |
1649 | void | |
1650 | fqdn6_option_space_foreach(struct packet *packet, struct lease *lease, | |
1651 | struct client_state *client_state, | |
1652 | struct option_state *in_options, | |
1653 | struct option_state *cfg_options, | |
1654 | struct binding_scope **scope, | |
1655 | struct universe *u, void *stuff, | |
1656 | void (*func)(struct option_cache *, | |
1657 | struct packet *, | |
1658 | struct lease *, | |
1659 | struct client_state *, | |
1660 | struct option_state *, | |
1661 | struct option_state *, | |
1662 | struct binding_scope **, | |
1663 | struct universe *, void *)); | |
1664 | int | |
1665 | fqdn6_option_space_encapsulate(struct data_string *result, | |
1666 | struct packet *packet, struct lease *lease, | |
1667 | struct client_state *client_state, | |
1668 | struct option_state *in_options, | |
1669 | struct option_state *cfg_options, | |
1670 | struct binding_scope **scope, | |
1671 | struct universe *universe); | |
1672 | int | |
1673 | fqdn6_universe_decode(struct option_state *options, | |
1674 | const unsigned char *buffer, unsigned length, | |
1675 | struct universe *u); | |
1676 | int append_option(struct data_string *dst, struct universe *universe, | |
1677 | struct option *option, struct data_string *src); | |
e2624b82 EH |
1678 | int |
1679 | store_options(int *ocount, | |
1680 | unsigned char *buffer, unsigned buflen, unsigned index, | |
1681 | struct packet *packet, struct lease *lease, | |
1682 | struct client_state *client_state, | |
1683 | struct option_state *in_options, | |
1684 | struct option_state *cfg_options, | |
1685 | struct binding_scope **scope, | |
1686 | unsigned *priority_list, int priority_len, | |
1687 | unsigned first_cutoff, int second_cutoff, int terminate, | |
1688 | const char *vuname); | |
98bd7ca0 DH |
1689 | int store_options6(char *, int, struct option_state *, struct packet *, |
1690 | const int *, struct data_string *); | |
88cd8aca DH |
1691 | int format_has_text(const char *); |
1692 | int format_min_length(const char *, struct option_cache *); | |
a34feb7d TM |
1693 | const char *pretty_print_option (struct option *, const unsigned char *, |
1694 | unsigned, int, int); | |
b543fea9 DH |
1695 | int pretty_escape(char **, char *, const unsigned char **, |
1696 | const unsigned char *); | |
432604c3 | 1697 | int get_option (struct data_string *, struct universe *, |
159bcce3 | 1698 | struct packet *, struct lease *, struct client_state *, |
432604c3 | 1699 | struct option_state *, struct option_state *, |
d758ad8c TL |
1700 | struct option_state *, struct binding_scope **, unsigned, |
1701 | const char *, int); | |
432604c3 TL |
1702 | void set_option (struct universe *, struct option_state *, |
1703 | struct option_cache *, enum statement_op); | |
a34feb7d TM |
1704 | struct option_cache *lookup_option (struct universe *, |
1705 | struct option_state *, unsigned); | |
1706 | struct option_cache *lookup_hashed_option (struct universe *, | |
1707 | struct option_state *, | |
1708 | unsigned); | |
98bd7ca0 | 1709 | struct option_cache *next_hashed_option(struct universe *, |
a34feb7d | 1710 | struct option_state *, |
98bd7ca0 | 1711 | struct option_cache *); |
432604c3 TL |
1712 | int save_option_buffer (struct universe *, struct option_state *, |
1713 | struct buffer *, unsigned char *, unsigned, | |
f7fdb216 | 1714 | unsigned, int); |
bead14ea DH |
1715 | int append_option_buffer(struct universe *, struct option_state *, |
1716 | struct buffer *, unsigned char *, unsigned, | |
1717 | unsigned, int); | |
a34feb7d | 1718 | void build_server_oro(struct data_string *, struct option_state *, |
98bd7ca0 | 1719 | const char *, int); |
bead14ea DH |
1720 | void save_option(struct universe *, struct option_state *, |
1721 | struct option_cache *); | |
1722 | void also_save_option(struct universe *, struct option_state *, | |
1723 | struct option_cache *); | |
1724 | void save_hashed_option(struct universe *, struct option_state *, | |
1725 | struct option_cache *, isc_boolean_t appendp); | |
a34feb7d TM |
1726 | void delete_option (struct universe *, struct option_state *, int); |
1727 | void delete_hashed_option (struct universe *, | |
1728 | struct option_state *, int); | |
1729 | int option_cache_dereference (struct option_cache **, | |
1730 | const char *, int); | |
1731 | int hashed_option_state_dereference (struct universe *, | |
1732 | struct option_state *, | |
1733 | const char *, int); | |
1734 | int store_option (struct data_string *, | |
1735 | struct universe *, struct packet *, struct lease *, | |
1736 | struct client_state *, | |
1737 | struct option_state *, struct option_state *, | |
1738 | struct binding_scope **, struct option_cache *); | |
1739 | int option_space_encapsulate (struct data_string *, | |
1740 | struct packet *, struct lease *, | |
1741 | struct client_state *, | |
1742 | struct option_state *, | |
1743 | struct option_state *, | |
1744 | struct binding_scope **, | |
1745 | struct data_string *); | |
1746 | int hashed_option_space_encapsulate (struct data_string *, | |
f3e8ea32 | 1747 | struct packet *, struct lease *, |
159bcce3 | 1748 | struct client_state *, |
f3e8ea32 | 1749 | struct option_state *, |
4f58da18 | 1750 | struct option_state *, |
6ceb9118 | 1751 | struct binding_scope **, |
a34feb7d TM |
1752 | struct universe *); |
1753 | int nwip_option_space_encapsulate (struct data_string *, | |
1754 | struct packet *, struct lease *, | |
1755 | struct client_state *, | |
1756 | struct option_state *, | |
1757 | struct option_state *, | |
1758 | struct binding_scope **, | |
1759 | struct universe *); | |
432604c3 TL |
1760 | int fqdn_option_space_encapsulate (struct data_string *, |
1761 | struct packet *, struct lease *, | |
159bcce3 | 1762 | struct client_state *, |
432604c3 TL |
1763 | struct option_state *, |
1764 | struct option_state *, | |
1765 | struct binding_scope **, | |
1766 | struct universe *); | |
159bcce3 TL |
1767 | void suboption_foreach (struct packet *, struct lease *, struct client_state *, |
1768 | struct option_state *, struct option_state *, | |
1769 | struct binding_scope **, struct universe *, void *, | |
1770 | void (*) (struct option_cache *, struct packet *, | |
1771 | struct lease *, struct client_state *, | |
1772 | struct option_state *, struct option_state *, | |
6f56b7e2 TL |
1773 | struct binding_scope **, |
1774 | struct universe *, void *), | |
1775 | struct option_cache *, const char *); | |
432604c3 | 1776 | void option_space_foreach (struct packet *, struct lease *, |
159bcce3 | 1777 | struct client_state *, |
432604c3 TL |
1778 | struct option_state *, |
1779 | struct option_state *, | |
1780 | struct binding_scope **, | |
1781 | struct universe *, void *, | |
1782 | void (*) (struct option_cache *, | |
1783 | struct packet *, | |
159bcce3 TL |
1784 | struct lease *, struct client_state *, |
1785 | struct option_state *, | |
432604c3 TL |
1786 | struct option_state *, |
1787 | struct binding_scope **, | |
1788 | struct universe *, void *)); | |
1789 | void hashed_option_space_foreach (struct packet *, struct lease *, | |
159bcce3 | 1790 | struct client_state *, |
432604c3 TL |
1791 | struct option_state *, |
1792 | struct option_state *, | |
1793 | struct binding_scope **, | |
1794 | struct universe *, void *, | |
1795 | void (*) (struct option_cache *, | |
1796 | struct packet *, | |
1797 | struct lease *, | |
159bcce3 | 1798 | struct client_state *, |
432604c3 TL |
1799 | struct option_state *, |
1800 | struct option_state *, | |
1801 | struct binding_scope **, | |
1802 | struct universe *, void *)); | |
a34feb7d TM |
1803 | int linked_option_get (struct data_string *, struct universe *, |
1804 | struct packet *, struct lease *, | |
1805 | struct client_state *, | |
1806 | struct option_state *, struct option_state *, | |
1807 | struct option_state *, struct binding_scope **, | |
1808 | unsigned); | |
1809 | int linked_option_state_dereference (struct universe *, | |
1810 | struct option_state *, | |
1811 | const char *, int); | |
bead14ea DH |
1812 | void save_linked_option(struct universe *, struct option_state *, |
1813 | struct option_cache *, isc_boolean_t appendp); | |
432604c3 | 1814 | void linked_option_space_foreach (struct packet *, struct lease *, |
159bcce3 | 1815 | struct client_state *, |
432604c3 TL |
1816 | struct option_state *, |
1817 | struct option_state *, | |
1818 | struct binding_scope **, | |
1819 | struct universe *, void *, | |
1820 | void (*) (struct option_cache *, | |
1821 | struct packet *, | |
1822 | struct lease *, | |
159bcce3 | 1823 | struct client_state *, |
432604c3 TL |
1824 | struct option_state *, |
1825 | struct option_state *, | |
1826 | struct binding_scope **, | |
1827 | struct universe *, void *)); | |
1828 | int linked_option_space_encapsulate (struct data_string *, struct packet *, | |
159bcce3 TL |
1829 | struct lease *, struct client_state *, |
1830 | struct option_state *, | |
432604c3 TL |
1831 | struct option_state *, |
1832 | struct binding_scope **, | |
1833 | struct universe *); | |
1834 | void delete_linked_option (struct universe *, struct option_state *, int); | |
1835 | struct option_cache *lookup_linked_option (struct universe *, | |
1836 | struct option_state *, unsigned); | |
a34feb7d TM |
1837 | void do_packet (struct interface_info *, |
1838 | struct dhcp_packet *, unsigned, | |
1839 | unsigned int, struct iaddr, struct hardware *); | |
1840 | void do_packet6(struct interface_info *, const char *, | |
98bd7ca0 DH |
1841 | int, int, const struct iaddr *, isc_boolean_t); |
1842 | int packet6_len_okay(const char *, int); | |
1843 | ||
de87ffe3 SR |
1844 | int validate_packet(struct packet *); |
1845 | ||
98bd7ca0 DH |
1846 | int add_option(struct option_state *options, |
1847 | unsigned int option_num, | |
a34feb7d TM |
1848 | void *data, |
1849 | unsigned int data_len); | |
d7837182 | 1850 | |
d7837182 | 1851 | /* dhcpd.c */ |
be62cf06 FD |
1852 | extern struct timeval cur_tv; |
1853 | #define cur_time cur_tv.tv_sec | |
685963dc | 1854 | |
06eb8bab | 1855 | extern int ddns_update_style; |
dbcc689e | 1856 | |
b1b7b521 TL |
1857 | extern const char *path_dhcpd_conf; |
1858 | extern const char *path_dhcpd_db; | |
1859 | extern const char *path_dhcpd_pid; | |
e2ac5814 | 1860 | |
5142937c | 1861 | extern int dhcp_max_agent_option_packet_length; |
6368a1bd | 1862 | extern struct eventqueue *rw_queue_empty; |
5142937c | 1863 | |
98bd7ca0 DH |
1864 | int main(int, char **); |
1865 | void postconf_initialization(int); | |
1866 | void postdb_startup(void); | |
a34feb7d TM |
1867 | void cleanup (void); |
1868 | void lease_pinged (struct iaddr, u_int8_t *, int); | |
1869 | void lease_ping_timeout (void *); | |
20916cae | 1870 | int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia); |
06eb8bab | 1871 | extern enum dhcp_shutdown_state shutdown_state; |
d758ad8c TL |
1872 | isc_result_t dhcp_io_shutdown (omapi_object_t *, void *); |
1873 | isc_result_t dhcp_set_control_state (control_object_state_t oldstate, | |
1874 | control_object_state_t newstate); | |
95fd7038 DH |
1875 | #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) |
1876 | void relinquish_ackqueue(void); | |
1877 | #endif | |
d7837182 TL |
1878 | |
1879 | /* conflex.c */ | |
a34feb7d TM |
1880 | isc_result_t new_parse (struct parse **, int, |
1881 | char *, unsigned, const char *, int); | |
1882 | isc_result_t end_parse (struct parse **); | |
bda33169 SK |
1883 | isc_result_t save_parse_state(struct parse *cfile); |
1884 | isc_result_t restore_parse_state(struct parse *cfile); | |
a34feb7d TM |
1885 | enum dhcp_token next_token (const char **, unsigned *, struct parse *); |
1886 | enum dhcp_token peek_token (const char **, unsigned *, struct parse *); | |
1887 | enum dhcp_token next_raw_token(const char **rval, unsigned *rlen, | |
bda33169 | 1888 | struct parse *cfile); |
a34feb7d | 1889 | enum dhcp_token peek_raw_token(const char **rval, unsigned *rlen, |
bda33169 | 1890 | struct parse *cfile); |
dc9d7b08 MA |
1891 | /* |
1892 | * Use skip_token when we are skipping a token we have previously | |
1893 | * used peek_token on as we know what the result will be in this case. | |
1894 | */ | |
1895 | #define skip_token(a,b,c) ((void) next_token((a),(b),(c))) | |
1896 | ||
d7837182 TL |
1897 | |
1898 | /* confpars.c */ | |
f3aad410 | 1899 | void parse_trace_setup (void); |
a34feb7d | 1900 | isc_result_t readconf (void); |
f3aad410 TL |
1901 | isc_result_t read_conf_file (const char *, struct group *, int, int); |
1902 | #if defined (TRACING) | |
1903 | void trace_conf_input (trace_type_t *, unsigned, char *); | |
1904 | void trace_conf_stop (trace_type_t *ttype); | |
1905 | #endif | |
1906 | isc_result_t conf_file_subparse (struct parse *, struct group *, int); | |
1907 | isc_result_t lease_file_subparse (struct parse *); | |
a34feb7d TM |
1908 | int parse_statement (struct parse *, struct group *, int, |
1909 | struct host_decl *, int); | |
a7982987 | 1910 | #if defined (FAILOVER_PROTOCOL) |
a34feb7d | 1911 | void parse_failover_peer (struct parse *, struct group *, int); |
a7982987 TL |
1912 | void parse_failover_state_declaration (struct parse *, |
1913 | dhcp_failover_state_t *); | |
a34feb7d TM |
1914 | void parse_failover_state (struct parse *, |
1915 | enum failover_state *, TIME *); | |
a7982987 | 1916 | #endif |
98311e4b | 1917 | int permit_list_match (struct permit *, struct permit *); |
a34feb7d | 1918 | void parse_pool_statement (struct parse *, struct group *, int); |
a34feb7d TM |
1919 | int parse_lbrace (struct parse *); |
1920 | void parse_host_declaration (struct parse *, struct group *); | |
1921 | int parse_class_declaration (struct class **, struct parse *, | |
1922 | struct group *, int); | |
1923 | void parse_shared_net_declaration (struct parse *, struct group *); | |
1924 | void parse_subnet_declaration (struct parse *, | |
1925 | struct shared_network *); | |
1926 | void parse_subnet6_declaration (struct parse *, | |
1927 | struct shared_network *); | |
1928 | void parse_group_declaration (struct parse *, struct group *); | |
1929 | int parse_fixed_addr_param (struct option_cache **, | |
1930 | struct parse *, enum dhcp_token); | |
1931 | int parse_lease_declaration (struct lease **, struct parse *); | |
6705543f DH |
1932 | int parse_ip6_addr(struct parse *, struct iaddr *); |
1933 | int parse_ip6_addr_expr(struct expression **, struct parse *); | |
1d9774ab | 1934 | int parse_ip6_prefix(struct parse *, struct iaddr *, u_int8_t *); |
a34feb7d TM |
1935 | void parse_address_range (struct parse *, struct group *, int, |
1936 | struct pool *, struct lease **); | |
98bd7ca0 | 1937 | void parse_address_range6(struct parse *cfile, struct group *group); |
80c9fdb0 FD |
1938 | void parse_prefix6(struct parse *cfile, struct group *group); |
1939 | void parse_fixed_prefix6(struct parse *cfile, struct host_decl *host_decl); | |
98bd7ca0 | 1940 | void parse_ia_na_declaration(struct parse *); |
1d9774ab FD |
1941 | void parse_ia_ta_declaration(struct parse *); |
1942 | void parse_ia_pd_declaration(struct parse *); | |
98bd7ca0 DH |
1943 | void parse_server_duid(struct parse *cfile); |
1944 | void parse_server_duid_conf(struct parse *cfile); | |
8bdd4d02 | 1945 | |
b992d7e2 | 1946 | /* ddns.c */ |
98bd7ca0 | 1947 | int ddns_updates(struct packet *, struct lease *, struct lease *, |
1d17db44 | 1948 | struct iasubopt *, struct iasubopt *, struct option_state *); |
d13db163 SR |
1949 | isc_result_t ddns_removals(struct lease *, struct iasubopt *, |
1950 | struct dhcp_ddns_cb *, isc_boolean_t); | |
7aa153b8 SR |
1951 | #if defined (TRACING) |
1952 | void trace_ddns_init(void); | |
1953 | #endif | |
b992d7e2 | 1954 | |
8bdd4d02 | 1955 | /* parse.c */ |
dbcc689e TL |
1956 | void add_enumeration (struct enumeration *); |
1957 | struct enumeration *find_enumeration (const char *, int); | |
1958 | struct enumeration_value *find_enumeration_value (const char *, int, | |
c54db708 | 1959 | unsigned *, |
dbcc689e | 1960 | const char *); |
a34feb7d TM |
1961 | void skip_to_semi (struct parse *); |
1962 | void skip_to_rbrace (struct parse *, int); | |
1963 | int parse_semi (struct parse *); | |
1964 | int parse_string (struct parse *, char **, unsigned *); | |
1965 | char *parse_host_name (struct parse *); | |
1966 | int parse_ip_addr_or_hostname (struct expression **, | |
1967 | struct parse *, int); | |
1968 | void parse_hardware_param (struct parse *, struct hardware *); | |
1969 | void parse_lease_time (struct parse *, TIME *); | |
1970 | unsigned char *parse_numeric_aggregate (struct parse *, | |
1971 | unsigned char *, unsigned *, | |
1972 | int, int, unsigned); | |
1973 | void convert_num (struct parse *, unsigned char *, const char *, | |
1974 | int, unsigned); | |
1975 | TIME parse_date (struct parse *); | |
b1d3778c | 1976 | TIME parse_date_core(struct parse *); |
a34feb7d TM |
1977 | isc_result_t parse_option_name (struct parse *, int, int *, |
1978 | struct option **); | |
1979 | void parse_option_space_decl (struct parse *); | |
1980 | int parse_option_code_definition (struct parse *, struct option *); | |
a59ea078 | 1981 | int parse_base64 (struct data_string *, struct parse *); |
a34feb7d TM |
1982 | int parse_cshl (struct data_string *, struct parse *); |
1983 | int parse_executable_statement (struct executable_statement **, | |
1984 | struct parse *, int *, | |
1985 | enum expression_context); | |
1986 | int parse_executable_statements (struct executable_statement **, | |
1987 | struct parse *, int *, | |
1988 | enum expression_context); | |
3f09cb5a | 1989 | int parse_zone (struct dns_zone *, struct parse *); |
a59ea078 | 1990 | int parse_key (struct parse *); |
a34feb7d TM |
1991 | int parse_on_statement (struct executable_statement **, |
1992 | struct parse *, int *); | |
1993 | int parse_switch_statement (struct executable_statement **, | |
1994 | struct parse *, int *); | |
1995 | int parse_case_statement (struct executable_statement **, | |
1996 | struct parse *, int *, | |
1997 | enum expression_context); | |
1998 | int parse_if_statement (struct executable_statement **, | |
1999 | struct parse *, int *); | |
2000 | int parse_boolean_expression (struct expression **, | |
2001 | struct parse *, int *); | |
d15aa964 | 2002 | int parse_boolean (struct parse *); |
a34feb7d TM |
2003 | int parse_data_expression (struct expression **, |
2004 | struct parse *, int *); | |
2005 | int parse_numeric_expression (struct expression **, | |
2006 | struct parse *, int *); | |
2007 | int parse_dns_expression (struct expression **, struct parse *, int *); | |
2008 | int parse_non_binary (struct expression **, struct parse *, int *, | |
2009 | enum expression_context); | |
2010 | int parse_expression (struct expression **, struct parse *, int *, | |
2011 | enum expression_context, | |
2012 | struct expression **, enum expr_op); | |
28868515 SK |
2013 | int parse_option_data(struct expression **expr, struct parse *cfile, |
2014 | int lookups, struct option *option); | |
a34feb7d TM |
2015 | int parse_option_statement (struct executable_statement **, |
2016 | struct parse *, int, | |
2017 | struct option *, enum statement_op); | |
2018 | int parse_option_token (struct expression **, struct parse *, | |
2019 | const char **, struct expression *, int, int); | |
2020 | int parse_allow_deny (struct option_cache **, struct parse *, int); | |
2021 | int parse_auth_key (struct data_string *, struct parse *); | |
cfdfb9f1 | 2022 | int parse_warn (struct parse *, const char *, ...) |
4bd8800e | 2023 | __attribute__((__format__(__printf__,2,3))); |
98bd7ca0 | 2024 | struct expression *parse_domain_list(struct parse *cfile, int); |
dba5803b | 2025 | |
d7837182 TL |
2026 | |
2027 | /* tree.c */ | |
de427245 TL |
2028 | #if defined (NSUPDATE) |
2029 | extern struct __res_state resolver_state; | |
2030 | extern int resolver_inited; | |
2031 | #endif | |
2032 | ||
6ceb9118 | 2033 | extern struct binding_scope *global_scope; |
a34feb7d TM |
2034 | pair cons (caddr_t, pair); |
2035 | int make_const_option_cache (struct option_cache **, struct buffer **, | |
2036 | u_int8_t *, unsigned, struct option *, | |
2037 | const char *, int); | |
2038 | int make_host_lookup (struct expression **, const char *); | |
2039 | int enter_dns_host (struct dns_host_entry **, const char *); | |
d758ad8c TL |
2040 | int make_const_data (struct expression **, |
2041 | const unsigned char *, unsigned, int, int, | |
2042 | const char *, int); | |
a34feb7d TM |
2043 | int make_const_int (struct expression **, unsigned long); |
2044 | int make_concat (struct expression **, | |
2045 | struct expression *, struct expression *); | |
2046 | int make_encapsulation (struct expression **, struct data_string *); | |
2047 | int make_substring (struct expression **, struct expression *, | |
2048 | struct expression *, struct expression *); | |
2049 | int make_limit (struct expression **, struct expression *, int); | |
2050 | int make_let (struct executable_statement **, const char *); | |
2051 | int option_cache (struct option_cache **, struct data_string *, | |
2052 | struct expression *, struct option *, | |
2053 | const char *, int); | |
17a10efe | 2054 | int evaluate_expression (struct binding_value **, struct packet *, |
159bcce3 TL |
2055 | struct lease *, struct client_state *, |
2056 | struct option_state *, struct option_state *, | |
d758ad8c TL |
2057 | struct binding_scope **, struct expression *, |
2058 | const char *, int); | |
17a10efe | 2059 | int binding_value_dereference (struct binding_value **, const char *, int); |
98bf1607 | 2060 | #if defined (NSUPDATE_OLD) |
a34feb7d TM |
2061 | int evaluate_dns_expression (ns_updrec **, struct packet *, |
2062 | struct lease *, | |
2063 | struct client_state *, | |
2064 | struct option_state *, | |
2065 | struct option_state *, | |
2066 | struct binding_scope **, | |
2067 | struct expression *); | |
2068 | #endif | |
2069 | int evaluate_boolean_expression (int *, | |
2070 | struct packet *, struct lease *, | |
2071 | struct client_state *, | |
2072 | struct option_state *, | |
2073 | struct option_state *, | |
2074 | struct binding_scope **, | |
2075 | struct expression *); | |
2076 | int evaluate_data_expression (struct data_string *, | |
2077 | struct packet *, struct lease *, | |
2078 | struct client_state *, | |
2079 | struct option_state *, | |
2080 | struct option_state *, | |
2081 | struct binding_scope **, | |
2082 | struct expression *, const char *, int); | |
159bcce3 TL |
2083 | int evaluate_numeric_expression (unsigned long *, struct packet *, |
2084 | struct lease *, struct client_state *, | |
2085 | struct option_state *, struct option_state *, | |
2086 | struct binding_scope **, | |
2087 | struct expression *); | |
a34feb7d TM |
2088 | int evaluate_option_cache (struct data_string *, |
2089 | struct packet *, struct lease *, | |
2090 | struct client_state *, | |
2091 | struct option_state *, struct option_state *, | |
2092 | struct binding_scope **, | |
2093 | struct option_cache *, | |
2094 | const char *, int); | |
2095 | int evaluate_boolean_option_cache (int *, | |
2096 | struct packet *, struct lease *, | |
2097 | struct client_state *, | |
2098 | struct option_state *, | |
2099 | struct option_state *, | |
2100 | struct binding_scope **, | |
2101 | struct option_cache *, | |
2102 | const char *, int); | |
2103 | int evaluate_boolean_expression_result (int *, | |
2104 | struct packet *, struct lease *, | |
2105 | struct client_state *, | |
2106 | struct option_state *, | |
2107 | struct option_state *, | |
2108 | struct binding_scope **, | |
2109 | struct expression *); | |
2110 | void expression_dereference (struct expression **, const char *, int); | |
2111 | int is_dns_expression (struct expression *); | |
2112 | int is_boolean_expression (struct expression *); | |
2113 | int is_data_expression (struct expression *); | |
2114 | int is_numeric_expression (struct expression *); | |
2115 | int is_compound_expression (struct expression *); | |
2116 | int op_precedence (enum expr_op, enum expr_op); | |
cc4473a0 | 2117 | enum expression_context expression_context (struct expression *); |
a34feb7d TM |
2118 | enum expression_context op_context (enum expr_op); |
2119 | int write_expression (FILE *, struct expression *, int, int, int); | |
2120 | struct binding *find_binding (struct binding_scope *, const char *); | |
2121 | int free_bindings (struct binding_scope *, const char *, int); | |
2122 | int binding_scope_dereference (struct binding_scope **, | |
2123 | const char *, int); | |
432604c3 TL |
2124 | int fundef_dereference (struct fundef **, const char *, int); |
2125 | int data_subexpression_length (int *, struct expression *); | |
2126 | int expr_valid_for_context (struct expression *, enum expression_context); | |
2f7ca092 TL |
2127 | struct binding *create_binding (struct binding_scope **, const char *); |
2128 | int bind_ds_value (struct binding_scope **, | |
2129 | const char *, struct data_string *); | |
2130 | int find_bound_string (struct data_string *, | |
2131 | struct binding_scope *, const char *); | |
2132 | int unset (struct binding_scope *, const char *); | |
98bd7ca0 | 2133 | int data_string_sprintfa(struct data_string *ds, const char *fmt, ...); |
d7837182 TL |
2134 | |
2135 | /* dhcp.c */ | |
e5078937 | 2136 | extern int outstanding_pings; |
6368a1bd | 2137 | extern int max_outstanding_acks; |
f8cbf390 DH |
2138 | extern int max_ack_delay_secs; |
2139 | extern int max_ack_delay_usecs; | |
e5078937 | 2140 | |
a34feb7d TM |
2141 | void dhcp (struct packet *); |
2142 | void dhcpdiscover (struct packet *, int); | |
2143 | void dhcprequest (struct packet *, int, struct lease *); | |
2144 | void dhcprelease (struct packet *, int); | |
2145 | void dhcpdecline (struct packet *, int); | |
2146 | void dhcpinform (struct packet *, int); | |
2147 | void nak_lease (struct packet *, struct iaddr *cip); | |
2148 | void ack_lease (struct packet *, struct lease *, | |
2149 | unsigned int, TIME, char *, int, struct host_decl *); | |
6368a1bd DH |
2150 | void delayed_ack_enqueue(struct lease *); |
2151 | void commit_leases_readerdry(void *); | |
2152 | void flush_ackqueue(void *); | |
a34feb7d TM |
2153 | void dhcp_reply (struct lease *); |
2154 | int find_lease (struct lease **, struct packet *, | |
2155 | struct shared_network *, int *, int *, struct lease *, | |
2156 | const char *, int); | |
2157 | int mockup_lease (struct lease **, struct packet *, | |
2158 | struct shared_network *, | |
2159 | struct host_decl *); | |
2160 | void static_lease_dereference (struct lease *, const char *, int); | |
2161 | ||
2162 | int allocate_lease (struct lease **, struct packet *, | |
2163 | struct pool *, int *); | |
2164 | int permitted (struct packet *, struct permit *); | |
2165 | int locate_network (struct packet *); | |
2166 | int parse_agent_information_option (struct packet *, int, u_int8_t *); | |
2167 | unsigned cons_agent_information_options (struct option_state *, | |
2168 | struct dhcp_packet *, | |
2169 | unsigned, unsigned); | |
6d103865 SK |
2170 | void get_server_source_address(struct in_addr *from, |
2171 | struct option_state *options, | |
f8380d3f | 2172 | struct option_state *out_options, |
6d103865 | 2173 | struct packet *packet); |
f8380d3f SR |
2174 | void setup_server_source_address(struct in_addr *from, |
2175 | struct option_state *options, | |
2176 | struct packet *packet); | |
734d2258 | 2177 | |
37ec5845 | 2178 | /* dhcpleasequery.c */ |
a34feb7d TM |
2179 | void dhcpleasequery (struct packet *, int); |
2180 | void dhcpv6_leasequery (struct data_string *, struct packet *); | |
37ec5845 | 2181 | |
98bd7ca0 DH |
2182 | /* dhcpv6.c */ |
2183 | isc_boolean_t server_duid_isset(void); | |
2184 | void copy_server_duid(struct data_string *ds, const char *file, int line); | |
2185 | void set_server_duid(struct data_string *new_duid); | |
2186 | isc_result_t set_server_duid_from_option(void); | |
6705543f | 2187 | void set_server_duid_type(int type); |
98bd7ca0 | 2188 | isc_result_t generate_new_server_duid(void); |
37ec5845 | 2189 | isc_result_t get_client_id(struct packet *, struct data_string *); |
98bd7ca0 DH |
2190 | void dhcpv6(struct packet *); |
2191 | ||
d7837182 | 2192 | /* bootp.c */ |
a34feb7d | 2193 | void bootp (struct packet *); |
d7837182 TL |
2194 | |
2195 | /* memory.c */ | |
06eb8bab | 2196 | extern int (*group_write_hook) (struct group_object *); |
20916cae | 2197 | extern struct group *root_group; |
98311e4b | 2198 | extern group_hash_t *group_name_hash; |
20916cae TL |
2199 | isc_result_t delete_group (struct group_object *, int); |
2200 | isc_result_t supersede_group (struct group_object *, int); | |
2201 | int clone_group (struct group **, struct group *, const char *, int); | |
a34feb7d | 2202 | int write_group (struct group_object *); |
20916cae TL |
2203 | |
2204 | /* salloc.c */ | |
d758ad8c | 2205 | void relinquish_lease_hunks (void); |
a34feb7d | 2206 | struct lease *new_leases (unsigned, const char *, int); |
d758ad8c TL |
2207 | #if defined (DEBUG_MEMORY_LEAKAGE) || \ |
2208 | defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) | |
2209 | void relinquish_free_lease_states (void); | |
2210 | #endif | |
20916cae TL |
2211 | OMAPI_OBJECT_ALLOC_DECL (lease, struct lease, dhcp_type_lease) |
2212 | OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class) | |
899d754f | 2213 | OMAPI_OBJECT_ALLOC_DECL (subclass, struct class, dhcp_type_subclass) |
20916cae | 2214 | OMAPI_OBJECT_ALLOC_DECL (pool, struct pool, dhcp_type_pool) |
165bce70 | 2215 | OMAPI_OBJECT_ALLOC_DECL (host, struct host_decl, dhcp_type_host) |
d7837182 TL |
2216 | |
2217 | /* alloc.c */ | |
20916cae TL |
2218 | OMAPI_OBJECT_ALLOC_DECL (subnet, struct subnet, dhcp_type_subnet) |
2219 | OMAPI_OBJECT_ALLOC_DECL (shared_network, struct shared_network, | |
2220 | dhcp_type_shared_network) | |
2221 | OMAPI_OBJECT_ALLOC_DECL (group_object, struct group_object, dhcp_type_group) | |
d758ad8c TL |
2222 | OMAPI_OBJECT_ALLOC_DECL (dhcp_control, |
2223 | dhcp_control_object_t, dhcp_type_control) | |
2224 | ||
2225 | #if defined (DEBUG_MEMORY_LEAKAGE) || \ | |
2226 | defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) | |
2227 | void relinquish_free_pairs (void); | |
2228 | void relinquish_free_expressions (void); | |
2229 | void relinquish_free_binding_values (void); | |
2230 | void relinquish_free_option_caches (void); | |
2231 | void relinquish_free_packets (void); | |
2232 | #endif | |
20916cae | 2233 | |
625f7cee TL |
2234 | int option_chain_head_allocate (struct option_chain_head **, |
2235 | const char *, int); | |
2236 | int option_chain_head_reference (struct option_chain_head **, | |
2237 | struct option_chain_head *, | |
2238 | const char *, int); | |
2239 | int option_chain_head_dereference (struct option_chain_head **, | |
2240 | const char *, int); | |
20916cae TL |
2241 | int group_allocate (struct group **, const char *, int); |
2242 | int group_reference (struct group **, struct group *, const char *, int); | |
2243 | int group_dereference (struct group **, const char *, int); | |
a34feb7d TM |
2244 | struct dhcp_packet *new_dhcp_packet (const char *, int); |
2245 | struct protocol *new_protocol (const char *, int); | |
2246 | struct lease_state *new_lease_state (const char *, int); | |
2247 | struct domain_search_list *new_domain_search_list (const char *, int); | |
2248 | struct name_server *new_name_server (const char *, int); | |
2249 | void free_name_server (struct name_server *, const char *, int); | |
2250 | struct option *new_option (const char *, const char *, int); | |
f7fdb216 DH |
2251 | int option_reference(struct option **dest, struct option *src, |
2252 | const char * file, int line); | |
2253 | int option_dereference(struct option **dest, const char *file, int line); | |
a34feb7d TM |
2254 | struct universe *new_universe (const char *, int); |
2255 | void free_universe (struct universe *, const char *, int); | |
2256 | void free_domain_search_list (struct domain_search_list *, | |
2257 | const char *, int); | |
2258 | void free_lease_state (struct lease_state *, const char *, int); | |
2259 | void free_protocol (struct protocol *, const char *, int); | |
2260 | void free_dhcp_packet (struct dhcp_packet *, const char *, int); | |
2261 | struct client_lease *new_client_lease (const char *, int); | |
2262 | void free_client_lease (struct client_lease *, const char *, int); | |
2263 | struct permit *new_permit (const char *, int); | |
2264 | void free_permit (struct permit *, const char *, int); | |
2265 | pair new_pair (const char *, int); | |
2266 | void free_pair (pair, const char *, int); | |
2267 | int expression_allocate (struct expression **, const char *, int); | |
2268 | int expression_reference (struct expression **, | |
2269 | struct expression *, const char *, int); | |
2270 | void free_expression (struct expression *, const char *, int); | |
2271 | int binding_value_allocate (struct binding_value **, | |
2272 | const char *, int); | |
2273 | int binding_value_reference (struct binding_value **, | |
2274 | struct binding_value *, | |
2275 | const char *, int); | |
2276 | void free_binding_value (struct binding_value *, const char *, int); | |
2277 | int fundef_allocate (struct fundef **, const char *, int); | |
2278 | int fundef_reference (struct fundef **, | |
2279 | struct fundef *, const char *, int); | |
2280 | int option_cache_allocate (struct option_cache **, const char *, int); | |
2281 | int option_cache_reference (struct option_cache **, | |
2282 | struct option_cache *, const char *, int); | |
2283 | int buffer_allocate (struct buffer **, unsigned, const char *, int); | |
2284 | int buffer_reference (struct buffer **, struct buffer *, | |
2285 | const char *, int); | |
2286 | int buffer_dereference (struct buffer **, const char *, int); | |
2287 | int dns_host_entry_allocate (struct dns_host_entry **, | |
2288 | const char *, const char *, int); | |
2289 | int dns_host_entry_reference (struct dns_host_entry **, | |
2290 | struct dns_host_entry *, | |
2291 | const char *, int); | |
2292 | int dns_host_entry_dereference (struct dns_host_entry **, | |
2293 | const char *, int); | |
2294 | int option_state_allocate (struct option_state **, const char *, int); | |
2295 | int option_state_reference (struct option_state **, | |
2296 | struct option_state *, const char *, int); | |
2297 | int option_state_dereference (struct option_state **, | |
2298 | const char *, int); | |
5279b8f3 DH |
2299 | void data_string_copy(struct data_string *, const struct data_string *, |
2300 | const char *, int); | |
a34feb7d TM |
2301 | void data_string_forget (struct data_string *, const char *, int); |
2302 | void data_string_truncate (struct data_string *, int); | |
2303 | int executable_statement_allocate (struct executable_statement **, | |
2304 | const char *, int); | |
2305 | int executable_statement_reference (struct executable_statement **, | |
2306 | struct executable_statement *, | |
2307 | const char *, int); | |
2308 | int packet_allocate (struct packet **, const char *, int); | |
2309 | int packet_reference (struct packet **, | |
2310 | struct packet *, const char *, int); | |
2311 | int packet_dereference (struct packet **, const char *, int); | |
2312 | int binding_scope_allocate (struct binding_scope **, | |
2313 | const char *, int); | |
2314 | int binding_scope_reference (struct binding_scope **, | |
2315 | struct binding_scope *, | |
2316 | const char *, int); | |
2317 | int dns_zone_allocate (struct dns_zone **, const char *, int); | |
2318 | int dns_zone_reference (struct dns_zone **, | |
2319 | struct dns_zone *, const char *, int); | |
d7837182 TL |
2320 | |
2321 | /* print.c */ | |
5e864416 DH |
2322 | #define DEFAULT_TIME_FORMAT 0 |
2323 | #define LOCAL_TIME_FORMAT 1 | |
2324 | extern int db_time_format; | |
d73c2404 TL |
2325 | char *quotify_string (const char *, const char *, int); |
2326 | char *quotify_buf (const unsigned char *, unsigned, const char *, int); | |
d758ad8c | 2327 | char *print_base64 (const unsigned char *, unsigned, const char *, int); |
a34feb7d TM |
2328 | char *print_hw_addr (const int, const int, const unsigned char *); |
2329 | void print_lease (struct lease *); | |
2330 | void dump_raw (const unsigned char *, unsigned); | |
b2398d97 | 2331 | void dump_packet_option (struct option_cache *, struct packet *, |
159bcce3 TL |
2332 | struct lease *, struct client_state *, |
2333 | struct option_state *, struct option_state *, | |
2334 | struct binding_scope **, struct universe *, void *); | |
a34feb7d TM |
2335 | void dump_packet (struct packet *); |
2336 | void hash_dump (struct hash_table *); | |
2337 | char *print_hex (unsigned, const u_int8_t *, unsigned, unsigned); | |
2338 | void print_hex_only (unsigned, const u_int8_t *, unsigned, char *); | |
2339 | void print_hex_or_string (unsigned, const u_int8_t *, unsigned, char *); | |
6aaaf6a4 SR |
2340 | #define print_hex_1(len, data, limit) print_hex(len, data, limit, 0) |
2341 | #define print_hex_2(len, data, limit) print_hex(len, data, limit, 1) | |
2342 | #define print_hex_3(len, data, limit) print_hex(len, data, limit, 2) | |
a34feb7d TM |
2343 | char *print_dotted_quads (unsigned, const u_int8_t *); |
2344 | char *print_dec_1 (unsigned long); | |
2345 | char *print_dec_2 (unsigned long); | |
2346 | void print_expression (const char *, struct expression *); | |
b1b7b521 TL |
2347 | int token_print_indent_concat (FILE *, int, int, |
2348 | const char *, const char *, ...); | |
2349 | int token_indent_data_string (FILE *, int, int, const char *, const char *, | |
fa098be8 | 2350 | struct data_string *); |
b1b7b521 TL |
2351 | int token_print_indent (FILE *, int, int, |
2352 | const char *, const char *, const char *); | |
fa098be8 | 2353 | void indent_spaces (FILE *, int); |
69bb758c | 2354 | #if defined (NSUPDATE) |
590298e7 | 2355 | void print_dns_status (int, struct dhcp_ddns_cb *, isc_result_t); |
98bf1607 | 2356 | #endif |
5e864416 | 2357 | const char *print_time(TIME); |
d7837182 | 2358 | |
98bd7ca0 DH |
2359 | void get_hw_addr(const char *name, struct hardware *hw); |
2360 | ||
d7837182 | 2361 | /* socket.c */ |
c626ae69 TL |
2362 | #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \ |
2363 | || defined (USE_SOCKET_FALLBACK) | |
ecddae64 | 2364 | int if_register_socket(struct interface_info *, int, int *); |
17b95f41 TL |
2365 | #endif |
2366 | ||
5d4afdbc | 2367 | #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND) |
a34feb7d TM |
2368 | void if_reinitialize_fallback (struct interface_info *); |
2369 | void if_register_fallback (struct interface_info *); | |
2370 | ssize_t send_fallback (struct interface_info *, | |
2371 | struct packet *, struct dhcp_packet *, size_t, | |
2372 | struct in_addr, | |
2373 | struct sockaddr_in *, struct hardware *); | |
2374 | ssize_t send_fallback6(struct interface_info *, struct packet *, | |
98bd7ca0 DH |
2375 | struct dhcp_packet *, size_t, struct in6_addr, |
2376 | struct sockaddr_in6 *, struct hardware *); | |
c626ae69 TL |
2377 | #endif |
2378 | ||
6f10b1a4 | 2379 | #ifdef USE_SOCKET_SEND |
a34feb7d TM |
2380 | void if_reinitialize_send (struct interface_info *); |
2381 | void if_register_send (struct interface_info *); | |
2382 | void if_deregister_send (struct interface_info *); | |
2383 | ssize_t send_packet (struct interface_info *, | |
2384 | struct packet *, struct dhcp_packet *, size_t, | |
2385 | struct in_addr, | |
2386 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 | 2387 | #endif |
6705543f DH |
2388 | ssize_t send_packet6(struct interface_info *, const unsigned char *, size_t, |
2389 | struct sockaddr_in6 *); | |
6f10b1a4 | 2390 | #ifdef USE_SOCKET_RECEIVE |
a34feb7d TM |
2391 | void if_reinitialize_receive (struct interface_info *); |
2392 | void if_register_receive (struct interface_info *); | |
2393 | void if_deregister_receive (struct interface_info *); | |
2394 | ssize_t receive_packet (struct interface_info *, | |
2395 | unsigned char *, size_t, | |
2396 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 | 2397 | #endif |
b5c11cbe | 2398 | |
5d4afdbc | 2399 | #if defined (USE_SOCKET_FALLBACK) |
a34feb7d | 2400 | isc_result_t fallback_discard (omapi_object_t *); |
b5c11cbe TL |
2401 | #endif |
2402 | ||
5d4afdbc | 2403 | #if defined (USE_SOCKET_SEND) |
a34feb7d TM |
2404 | int can_unicast_without_arp (struct interface_info *); |
2405 | int can_receive_unicast_unconfigured (struct interface_info *); | |
af380050 | 2406 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2407 | void maybe_setup_fallback (void); |
469cf3a4 | 2408 | #endif |
6f10b1a4 | 2409 | |
99fe695e SK |
2410 | void if_register6(struct interface_info *info, int do_multicast); |
2411 | ssize_t receive_packet6(struct interface_info *interface, | |
2412 | unsigned char *buf, size_t len, | |
ecddae64 DH |
2413 | struct sockaddr_in6 *from, struct in6_addr *to_addr, |
2414 | unsigned int *if_index); | |
99fe695e SK |
2415 | void if_deregister6(struct interface_info *info); |
2416 | ||
2417 | ||
6f10b1a4 | 2418 | /* bpf.c */ |
17b95f41 | 2419 | #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) |
a34feb7d | 2420 | int if_register_bpf (struct interface_info *); |
17b95f41 | 2421 | #endif |
6f10b1a4 | 2422 | #ifdef USE_BPF_SEND |
a34feb7d TM |
2423 | void if_reinitialize_send (struct interface_info *); |
2424 | void if_register_send (struct interface_info *); | |
2425 | void if_deregister_send (struct interface_info *); | |
2426 | ssize_t send_packet (struct interface_info *, | |
2427 | struct packet *, struct dhcp_packet *, size_t, | |
2428 | struct in_addr, | |
2429 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 TL |
2430 | #endif |
2431 | #ifdef USE_BPF_RECEIVE | |
a34feb7d TM |
2432 | void if_reinitialize_receive (struct interface_info *); |
2433 | void if_register_receive (struct interface_info *); | |
2434 | void if_deregister_receive (struct interface_info *); | |
2435 | ssize_t receive_packet (struct interface_info *, | |
2436 | unsigned char *, size_t, | |
2437 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 | 2438 | #endif |
469cf3a4 | 2439 | #if defined (USE_BPF_SEND) |
a34feb7d TM |
2440 | int can_unicast_without_arp (struct interface_info *); |
2441 | int can_receive_unicast_unconfigured (struct interface_info *); | |
af380050 | 2442 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2443 | void maybe_setup_fallback (void); |
d1f2c520 TL |
2444 | #endif |
2445 | ||
2446 | /* lpf.c */ | |
2447 | #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) | |
a34feb7d | 2448 | int if_register_lpf (struct interface_info *); |
d1f2c520 TL |
2449 | #endif |
2450 | #ifdef USE_LPF_SEND | |
a34feb7d TM |
2451 | void if_reinitialize_send (struct interface_info *); |
2452 | void if_register_send (struct interface_info *); | |
2453 | void if_deregister_send (struct interface_info *); | |
2454 | ssize_t send_packet (struct interface_info *, | |
2455 | struct packet *, struct dhcp_packet *, size_t, | |
2456 | struct in_addr, | |
2457 | struct sockaddr_in *, struct hardware *); | |
d1f2c520 TL |
2458 | #endif |
2459 | #ifdef USE_LPF_RECEIVE | |
a34feb7d TM |
2460 | void if_reinitialize_receive (struct interface_info *); |
2461 | void if_register_receive (struct interface_info *); | |
2462 | void if_deregister_receive (struct interface_info *); | |
2463 | ssize_t receive_packet (struct interface_info *, | |
2464 | unsigned char *, size_t, | |
2465 | struct sockaddr_in *, struct hardware *); | |
d1f2c520 TL |
2466 | #endif |
2467 | #if defined (USE_LPF_SEND) | |
a34feb7d TM |
2468 | int can_unicast_without_arp (struct interface_info *); |
2469 | int can_receive_unicast_unconfigured (struct interface_info *); | |
af380050 | 2470 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2471 | void maybe_setup_fallback (void); |
469cf3a4 | 2472 | #endif |
6f10b1a4 TL |
2473 | |
2474 | /* nit.c */ | |
41fb155b | 2475 | #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE) |
a34feb7d | 2476 | int if_register_nit (struct interface_info *); |
41fb155b TL |
2477 | #endif |
2478 | ||
6f10b1a4 | 2479 | #ifdef USE_NIT_SEND |
a34feb7d TM |
2480 | void if_reinitialize_send (struct interface_info *); |
2481 | void if_register_send (struct interface_info *); | |
2482 | void if_deregister_send (struct interface_info *); | |
2483 | ssize_t send_packet (struct interface_info *, | |
2484 | struct packet *, struct dhcp_packet *, size_t, | |
2485 | struct in_addr, | |
2486 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 TL |
2487 | #endif |
2488 | #ifdef USE_NIT_RECEIVE | |
a34feb7d TM |
2489 | void if_reinitialize_receive (struct interface_info *); |
2490 | void if_register_receive (struct interface_info *); | |
2491 | void if_deregister_receive (struct interface_info *); | |
2492 | ssize_t receive_packet (struct interface_info *, | |
2493 | unsigned char *, size_t, | |
2494 | struct sockaddr_in *, struct hardware *); | |
6f10b1a4 | 2495 | #endif |
94f08824 | 2496 | #if defined (USE_NIT_SEND) |
a34feb7d TM |
2497 | int can_unicast_without_arp (struct interface_info *); |
2498 | int can_receive_unicast_unconfigured (struct interface_info *); | |
af380050 | 2499 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2500 | void maybe_setup_fallback (void); |
469cf3a4 | 2501 | #endif |
6f10b1a4 | 2502 | |
94f08824 | 2503 | /* dlpi.c */ |
5142937c | 2504 | #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE) |
a34feb7d | 2505 | int if_register_dlpi (struct interface_info *); |
5142937c TL |
2506 | #endif |
2507 | ||
94f08824 | 2508 | #ifdef USE_DLPI_SEND |
a34feb7d TM |
2509 | int can_unicast_without_arp (struct interface_info *); |
2510 | int can_receive_unicast_unconfigured (struct interface_info *); | |
2511 | void if_reinitialize_send (struct interface_info *); | |
2512 | void if_register_send (struct interface_info *); | |
2513 | void if_deregister_send (struct interface_info *); | |
2514 | ssize_t send_packet (struct interface_info *, | |
2515 | struct packet *, struct dhcp_packet *, size_t, | |
2516 | struct in_addr, | |
2517 | struct sockaddr_in *, struct hardware *); | |
109e00db | 2518 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2519 | void maybe_setup_fallback (void); |
94f08824 TL |
2520 | #endif |
2521 | #ifdef USE_DLPI_RECEIVE | |
a34feb7d TM |
2522 | void if_reinitialize_receive (struct interface_info *); |
2523 | void if_register_receive (struct interface_info *); | |
2524 | void if_deregister_receive (struct interface_info *); | |
2525 | ssize_t receive_packet (struct interface_info *, | |
2526 | unsigned char *, size_t, | |
2527 | struct sockaddr_in *, struct hardware *); | |
94f08824 TL |
2528 | #endif |
2529 | ||
2530 | ||
6f10b1a4 TL |
2531 | /* raw.c */ |
2532 | #ifdef USE_RAW_SEND | |
a34feb7d TM |
2533 | void if_reinitialize_send (struct interface_info *); |
2534 | void if_register_send (struct interface_info *); | |
2535 | void if_deregister_send (struct interface_info *); | |
2536 | ssize_t send_packet (struct interface_info *, struct packet *, | |
2537 | struct dhcp_packet *, size_t, struct in_addr, | |
2538 | struct sockaddr_in *, struct hardware *); | |
2539 | int can_unicast_without_arp (struct interface_info *); | |
2540 | int can_receive_unicast_unconfigured (struct interface_info *); | |
af380050 | 2541 | int supports_multiple_interfaces (struct interface_info *); |
a34feb7d | 2542 | void maybe_setup_fallback (void); |
6f10b1a4 TL |
2543 | #endif |
2544 | ||
f3aad410 | 2545 | /* discover.c */ |
d1f2c520 | 2546 | extern struct interface_info *interfaces, |
339b0231 | 2547 | *dummy_interfaces, *fallback_interface; |
6e5ed8bf | 2548 | extern struct protocol *protocols; |
d032a71e | 2549 | extern int quiet_interface_discovery; |
8bed305d | 2550 | isc_result_t interface_setup (void); |
f3aad410 | 2551 | void interface_trace_setup (void); |
aa8579c0 TL |
2552 | |
2553 | extern struct in_addr limited_broadcast; | |
98bd7ca0 | 2554 | extern int local_family; |
aa8579c0 | 2555 | extern struct in_addr local_address; |
98bd7ca0 | 2556 | extern struct in6_addr local_address6; |
aa8579c0 TL |
2557 | |
2558 | extern u_int16_t local_port; | |
2559 | extern u_int16_t remote_port; | |
20916cae TL |
2560 | extern int (*dhcp_interface_setup_hook) (struct interface_info *, |
2561 | struct iaddr *); | |
2562 | extern int (*dhcp_interface_discovery_hook) (struct interface_info *); | |
06eb8bab | 2563 | extern isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *); |
aa8579c0 | 2564 | |
a34feb7d TM |
2565 | extern void (*bootp_packet_handler) (struct interface_info *, |
2566 | struct dhcp_packet *, unsigned, | |
2567 | unsigned int, | |
2568 | struct iaddr, struct hardware *); | |
98bd7ca0 DH |
2569 | extern void (*dhcpv6_packet_handler)(struct interface_info *, |
2570 | const char *, int, | |
2571 | int, const struct iaddr *, isc_boolean_t); | |
cc26de46 | 2572 | extern struct timeout *timeouts; |
4fe74d72 | 2573 | extern omapi_object_type_t *dhcp_type_interface; |
f3aad410 | 2574 | #if defined (TRACING) |
06eb8bab SK |
2575 | extern trace_type_t *interface_trace; |
2576 | extern trace_type_t *inpacket_trace; | |
2577 | extern trace_type_t *outpacket_trace; | |
f3aad410 TL |
2578 | #endif |
2579 | extern struct interface_info **interface_vector; | |
2580 | extern int interface_count; | |
2581 | extern int interface_max; | |
98bd7ca0 DH |
2582 | isc_result_t interface_initialize(omapi_object_t *, const char *, int); |
2583 | void discover_interfaces(int); | |
20916cae | 2584 | int setup_fallback (struct interface_info **, const char *, int); |
a34feb7d TM |
2585 | int if_readsocket (omapi_object_t *); |
2586 | void reinitialize_interfaces (void); | |
f3aad410 TL |
2587 | |
2588 | /* dispatch.c */ | |
88cd8aca | 2589 | void set_time(TIME); |
f3aad410 | 2590 | struct timeval *process_outstanding_timeouts (struct timeval *); |
a34feb7d | 2591 | void dispatch (void); |
98bd7ca0 DH |
2592 | isc_result_t got_one(omapi_object_t *); |
2593 | isc_result_t got_one_v6(omapi_object_t *); | |
4fe74d72 TL |
2594 | isc_result_t interface_set_value (omapi_object_t *, omapi_object_t *, |
2595 | omapi_data_string_t *, omapi_typed_data_t *); | |
2596 | isc_result_t interface_get_value (omapi_object_t *, omapi_object_t *, | |
a34feb7d | 2597 | omapi_data_string_t *, omapi_value_t **); |
4bd8800e | 2598 | isc_result_t interface_destroy (omapi_object_t *, const char *, int); |
b1b7b521 TL |
2599 | isc_result_t interface_signal_handler (omapi_object_t *, |
2600 | const char *, va_list); | |
4fe74d72 TL |
2601 | isc_result_t interface_stuff_values (omapi_object_t *, |
2602 | omapi_object_t *, | |
2603 | omapi_object_t *); | |
2604 | ||
a34feb7d TM |
2605 | void add_timeout (struct timeval *, void (*) (void *), void *, |
2606 | tvref_t, tvunref_t); | |
2607 | void cancel_timeout (void (*) (void *), void *); | |
d758ad8c TL |
2608 | void cancel_all_timeouts (void); |
2609 | void relinquish_timeouts (void); | |
d7837182 | 2610 | |
20916cae | 2611 | OMAPI_OBJECT_ALLOC_DECL (interface, |
165bce70 | 2612 | struct interface_info, dhcp_type_interface) |
5a526cf8 | 2613 | |
d7837182 | 2614 | /* tables.c */ |
f7fdb216 | 2615 | extern char *default_option_format; |
102ee7e9 | 2616 | extern struct universe dhcp_universe; |
98bd7ca0 | 2617 | extern struct universe dhcpv6_universe; |
432604c3 | 2618 | extern struct universe nwip_universe; |
432604c3 | 2619 | extern struct universe fqdn_universe; |
98bd7ca0 | 2620 | extern struct universe vsio_universe; |
27fe61a7 TL |
2621 | extern int dhcp_option_default_priority_list []; |
2622 | extern int dhcp_option_default_priority_list_count; | |
b1b7b521 | 2623 | extern const char *hardware_types [256]; |
06eb8bab SK |
2624 | extern int universe_count, universe_max; |
2625 | extern struct universe **universes; | |
98311e4b | 2626 | extern universe_hash_t *universe_hash; |
a34feb7d | 2627 | void initialize_common_option_spaces (void); |
06eb8bab | 2628 | extern struct universe *config_universe; |
516cf43a TL |
2629 | |
2630 | /* stables.c */ | |
d9eefc5d | 2631 | #if defined (FAILOVER_PROTOCOL) |
76d5bd36 TL |
2632 | extern failover_option_t null_failover_option; |
2633 | extern failover_option_t skip_failover_option; | |
2634 | extern struct failover_option_info ft_options []; | |
2635 | extern u_int32_t fto_allowed []; | |
2636 | extern int ft_sizes []; | |
2637 | extern const char *dhcp_flink_state_names []; | |
d9eefc5d | 2638 | #endif |
007e3ee4 TL |
2639 | extern const char *binding_state_names []; |
2640 | ||
516cf43a | 2641 | extern struct universe agent_universe; |
516cf43a | 2642 | extern struct universe server_universe; |
dbcc689e TL |
2643 | |
2644 | extern struct enumeration ddns_styles; | |
625f7cee | 2645 | extern struct enumeration syslog_enum; |
a34feb7d | 2646 | void initialize_server_option_spaces (void); |
d7837182 | 2647 | |
089fb364 | 2648 | /* inet.c */ |
a34feb7d TM |
2649 | struct iaddr subnet_number (struct iaddr, struct iaddr); |
2650 | struct iaddr ip_addr (struct iaddr, struct iaddr, u_int32_t); | |
2651 | struct iaddr broadcast_addr (struct iaddr, struct iaddr); | |
2652 | u_int32_t host_addr (struct iaddr, struct iaddr); | |
2653 | int addr_eq (struct iaddr, struct iaddr); | |
febbd402 | 2654 | int addr_match(struct iaddr *, struct iaddrmatch *); |
98bd7ca0 | 2655 | int addr_cmp(const struct iaddr *a1, const struct iaddr *a2); |
a34feb7d | 2656 | int addr_or(struct iaddr *result, |
98bd7ca0 | 2657 | const struct iaddr *a1, const struct iaddr *a2); |
a34feb7d | 2658 | int addr_and(struct iaddr *result, |
98bd7ca0 | 2659 | const struct iaddr *a1, const struct iaddr *a2); |
9b21e73e | 2660 | isc_boolean_t is_cidr_mask_valid(const struct iaddr *addr, int bits); |
98bd7ca0 DH |
2661 | isc_result_t range2cidr(struct iaddrcidrnetlist **result, |
2662 | const struct iaddr *lo, const struct iaddr *hi); | |
2663 | isc_result_t free_iaddrcidrnetlist(struct iaddrcidrnetlist **result); | |
a34feb7d | 2664 | const char *piaddr (struct iaddr); |
98bd7ca0 DH |
2665 | char *piaddrmask(struct iaddr *, struct iaddr *); |
2666 | char *piaddrcidr(const struct iaddr *, unsigned int); | |
59112e84 | 2667 | u_int16_t validate_port(char *); |
95821729 TL |
2668 | |
2669 | /* dhclient.c */ | |
8ea19a71 DH |
2670 | extern int nowait; |
2671 | ||
420d8b3f FD |
2672 | extern int wanted_ia_na; |
2673 | extern int wanted_ia_ta; | |
2674 | extern int wanted_ia_pd; | |
2675 | ||
b1b7b521 TL |
2676 | extern const char *path_dhclient_conf; |
2677 | extern const char *path_dhclient_db; | |
2678 | extern const char *path_dhclient_pid; | |
e47988bf | 2679 | extern char *path_dhclient_script; |
5a526cf8 | 2680 | extern int interfaces_requested; |
98bd7ca0 | 2681 | extern struct data_string default_duid; |
a41d7a25 | 2682 | extern int duid_type; |
cc26de46 TL |
2683 | |
2684 | extern struct client_config top_level_config; | |
2685 | ||
a34feb7d TM |
2686 | void dhcpoffer (struct packet *); |
2687 | void dhcpack (struct packet *); | |
2688 | void dhcpnak (struct packet *); | |
2689 | ||
2690 | void send_discover (void *); | |
2691 | void send_request (void *); | |
2692 | void send_release (void *); | |
2693 | void send_decline (void *); | |
2694 | ||
2695 | void state_reboot (void *); | |
2696 | void state_init (void *); | |
2697 | void state_selecting (void *); | |
2698 | void state_requesting (void *); | |
2699 | void state_bound (void *); | |
2700 | void state_stop (void *); | |
2701 | void state_panic (void *); | |
2702 | ||
2703 | void bind_lease (struct client_state *); | |
2704 | ||
2705 | void make_client_options (struct client_state *, | |
2706 | struct client_lease *, u_int8_t *, | |
2707 | struct option_cache *, struct iaddr *, | |
2708 | struct option **, struct option_state **); | |
2709 | void make_discover (struct client_state *, struct client_lease *); | |
2710 | void make_request (struct client_state *, struct client_lease *); | |
2711 | void make_decline (struct client_state *, struct client_lease *); | |
2712 | void make_release (struct client_state *, struct client_lease *); | |
2713 | ||
2714 | void destroy_client_lease (struct client_lease *); | |
2715 | void rewrite_client_leases (void); | |
432604c3 | 2716 | void write_lease_option (struct option_cache *, struct packet *, |
159bcce3 TL |
2717 | struct lease *, struct client_state *, |
2718 | struct option_state *, struct option_state *, | |
2719 | struct binding_scope **, struct universe *, void *); | |
a34feb7d | 2720 | int write_client_lease (struct client_state *, struct client_lease *, int, int); |
98bd7ca0 DH |
2721 | isc_result_t write_client6_lease(struct client_state *client, |
2722 | struct dhc6_lease *lease, | |
2723 | int rewrite, int sync); | |
32a47563 | 2724 | int dhcp_option_ev_name (char *, size_t, struct option *); |
cc26de46 | 2725 | |
a34feb7d TM |
2726 | void script_init (struct client_state *, const char *, |
2727 | struct string_list *); | |
432604c3 | 2728 | void client_option_envadd (struct option_cache *, struct packet *, |
159bcce3 TL |
2729 | struct lease *, struct client_state *, |
2730 | struct option_state *, struct option_state *, | |
2731 | struct binding_scope **, struct universe *, void *); | |
a34feb7d TM |
2732 | void script_write_params (struct client_state *, const char *, |
2733 | struct client_lease *); | |
10613724 | 2734 | void script_write_requested (struct client_state *); |
a34feb7d | 2735 | int script_go (struct client_state *); |
32a47563 TL |
2736 | void client_envadd (struct client_state *, |
2737 | const char *, const char *, const char *, ...) | |
2738 | __attribute__((__format__(__printf__,4,5))); | |
cc26de46 | 2739 | |
6ceb9118 | 2740 | struct client_lease *packet_to_lease (struct packet *, struct client_state *); |
a34feb7d TM |
2741 | void go_daemon (void); |
2742 | void write_client_pid_file (void); | |
2743 | void client_location_changed (void); | |
2744 | void do_release (struct client_state *); | |
20916cae TL |
2745 | int dhclient_interface_shutdown_hook (struct interface_info *); |
2746 | int dhclient_interface_discovery_hook (struct interface_info *); | |
c1f22aef | 2747 | isc_result_t dhclient_interface_startup_hook (struct interface_info *); |
98bd7ca0 DH |
2748 | void dhclient_schedule_updates(struct client_state *client, |
2749 | struct iaddr *addr, int offset); | |
98311e4b | 2750 | void client_dns_update_timeout (void *cp); |
98bf1607 SR |
2751 | isc_result_t client_dns_update(struct client_state *client, |
2752 | dhcp_ddns_cb_t *ddns_cb); | |
2753 | void client_dns_remove(struct client_state *client, struct iaddr *addr); | |
98bd7ca0 DH |
2754 | |
2755 | void dhcpv4_client_assignments(void); | |
2756 | void dhcpv6_client_assignments(void); | |
2757 | ||
2758 | /* dhc6.c */ | |
06eb8bab | 2759 | void form_duid(struct data_string *duid, const char *file, int line); |
e32529a5 | 2760 | void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line); |
98bd7ca0 | 2761 | void start_init6(struct client_state *client); |
3dbe2246 | 2762 | void start_info_request6(struct client_state *client); |
98bd7ca0 | 2763 | void start_confirm6(struct client_state *client); |
af5fa176 | 2764 | void start_release6(struct client_state *client); |
98bd7ca0 | 2765 | void start_selecting6(struct client_state *client); |
af5fa176 | 2766 | void unconfigure6(struct client_state *client, const char *reason); |
95821729 | 2767 | |
1358b874 | 2768 | /* db.c */ |
a34feb7d TM |
2769 | int write_lease (struct lease *); |
2770 | int write_host (struct host_decl *); | |
6705543f | 2771 | int write_server_duid(void); |
a7982987 TL |
2772 | #if defined (FAILOVER_PROTOCOL) |
2773 | int write_failover_state (dhcp_failover_state_t *); | |
2774 | #endif | |
a34feb7d TM |
2775 | int db_printable (const unsigned char *); |
2776 | int db_printable_len (const unsigned char *, unsigned); | |
f7fdb216 | 2777 | isc_result_t write_named_billing_class(const void *, unsigned, void *); |
875d2b66 | 2778 | void write_billing_classes (void); |
a34feb7d TM |
2779 | int write_billing_class (struct class *); |
2780 | void commit_leases_timeout (void *); | |
6368a1bd | 2781 | void commit_leases_readerdry(void *); |
a34feb7d | 2782 | int commit_leases (void); |
cbbd2714 | 2783 | int commit_leases_timed (void); |
a34feb7d TM |
2784 | void db_startup (int); |
2785 | int new_lease_file (void); | |
20916cae | 2786 | int group_writer (struct group_object *); |
9322442f | 2787 | int write_ia(const struct ia_xx *); |
17b95f41 TL |
2788 | |
2789 | /* packet.c */ | |
a34feb7d TM |
2790 | u_int32_t checksum (unsigned char *, unsigned, u_int32_t); |
2791 | u_int32_t wrapsum (u_int32_t); | |
2792 | void assemble_hw_header (struct interface_info *, unsigned char *, | |
2793 | unsigned *, struct hardware *); | |
2794 | void assemble_udp_ip_header (struct interface_info *, unsigned char *, | |
2795 | unsigned *, u_int32_t, u_int32_t, | |
2796 | u_int32_t, unsigned char *, unsigned); | |
2797 | ssize_t decode_hw_header (struct interface_info *, unsigned char *, | |
2798 | unsigned, struct hardware *); | |
2799 | ssize_t decode_udp_ip_header (struct interface_info *, unsigned char *, | |
2800 | unsigned, struct sockaddr_in *, | |
2801 | unsigned, unsigned *); | |
ab370123 | 2802 | |
7d29d66d | 2803 | /* ethernet.c */ |
a34feb7d TM |
2804 | void assemble_ethernet_header (struct interface_info *, unsigned char *, |
2805 | unsigned *, struct hardware *); | |
2806 | ssize_t decode_ethernet_header (struct interface_info *, | |
2807 | unsigned char *, | |
2808 | unsigned, struct hardware *); | |
7d29d66d TL |
2809 | |
2810 | /* tr.c */ | |
a34feb7d TM |
2811 | void assemble_tr_header (struct interface_info *, unsigned char *, |
2812 | unsigned *, struct hardware *); | |
2813 | ssize_t decode_tr_header (struct interface_info *, | |
2814 | unsigned char *, | |
2815 | unsigned, struct hardware *); | |
7d29d66d | 2816 | |
ab370123 | 2817 | /* dhxpxlt.c */ |
a34feb7d TM |
2818 | void convert_statement (struct parse *); |
2819 | void convert_host_statement (struct parse *, jrefproto); | |
2820 | void convert_host_name (struct parse *, jrefproto); | |
2821 | void convert_class_statement (struct parse *, jrefproto, int); | |
2822 | void convert_class_decl (struct parse *, jrefproto); | |
2823 | void convert_lease_time (struct parse *, jrefproto, char *); | |
2824 | void convert_shared_net_statement (struct parse *, jrefproto); | |
2825 | void convert_subnet_statement (struct parse *, jrefproto); | |
2826 | void convert_subnet_decl (struct parse *, jrefproto); | |
2827 | void convert_host_decl (struct parse *, jrefproto); | |
2828 | void convert_hardware_decl (struct parse *, jrefproto); | |
2829 | void convert_hardware_addr (struct parse *, jrefproto); | |
2830 | void convert_filename_decl (struct parse *, jrefproto); | |
2831 | void convert_servername_decl (struct parse *, jrefproto); | |
2832 | void convert_ip_addr_or_hostname (struct parse *, jrefproto, int); | |
2833 | void convert_fixed_addr_decl (struct parse *, jrefproto); | |
2834 | void convert_option_decl (struct parse *, jrefproto); | |
2835 | void convert_lease_statement (struct parse *, jrefproto); | |
2836 | void convert_address_range (struct parse *, jrefproto); | |
2837 | void convert_date (struct parse *, jrefproto, char *); | |
2838 | void convert_numeric_aggregate (struct parse *, jrefproto, int, int, int, int); | |
2839 | void indent (int); | |
469cf3a4 TL |
2840 | |
2841 | /* route.c */ | |
a34feb7d TM |
2842 | void add_route_direct (struct interface_info *, struct in_addr); |
2843 | void add_route_net (struct interface_info *, struct in_addr, struct in_addr); | |
2844 | void add_route_default_gateway (struct interface_info *, struct in_addr); | |
2845 | void remove_routes (struct in_addr); | |
2846 | void remove_if_route (struct interface_info *, struct in_addr); | |
2847 | void remove_all_if_routes (struct interface_info *); | |
2848 | void set_netmask (struct interface_info *, struct in_addr); | |
2849 | void set_broadcast_addr (struct interface_info *, struct in_addr); | |
2850 | void set_ip_address (struct interface_info *, struct in_addr); | |
cc26de46 TL |
2851 | |
2852 | /* clparse.c */ | |
a34feb7d | 2853 | isc_result_t read_client_conf (void); |
d758ad8c TL |
2854 | int read_client_conf_file (const char *, |
2855 | struct interface_info *, struct client_config *); | |
a34feb7d TM |
2856 | void read_client_leases (void); |
2857 | void parse_client_statement (struct parse *, struct interface_info *, | |
2858 | struct client_config *); | |
2859 | int parse_X (struct parse *, u_int8_t *, unsigned); | |
2860 | int parse_option_list (struct parse *, struct option ***); | |
2861 | void parse_interface_declaration (struct parse *, | |
2862 | struct client_config *, char *); | |
2863 | int interface_or_dummy (struct interface_info **, const char *); | |
2864 | void make_client_state (struct client_state **); | |
2865 | void make_client_config (struct client_state *, struct client_config *); | |
2866 | void parse_client_lease_statement (struct parse *, int); | |
2867 | void parse_client_lease_declaration (struct parse *, | |
2868 | struct client_lease *, | |
2869 | struct interface_info **, | |
2870 | struct client_state **); | |
2871 | int parse_option_decl (struct option_cache **, struct parse *); | |
2872 | void parse_string_list (struct parse *, struct string_list **, int); | |
2873 | int parse_ip_addr (struct parse *, struct iaddr *); | |
d19e2cf7 | 2874 | int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *); |
a34feb7d | 2875 | void parse_reject_statement (struct parse *, struct client_config *); |
6b3b97e1 | 2876 | |
6e5ed8bf | 2877 | /* icmp.c */ |
d758ad8c TL |
2878 | OMAPI_OBJECT_ALLOC_DECL (icmp_state, struct icmp_state, dhcp_type_icmp) |
2879 | extern struct icmp_state *icmp_state; | |
a34feb7d TM |
2880 | void icmp_startup (int, void (*) (struct iaddr, u_int8_t *, int)); |
2881 | int icmp_readsocket (omapi_object_t *); | |
2882 | int icmp_echorequest (struct iaddr *); | |
2883 | isc_result_t icmp_echoreply (omapi_object_t *); | |
83c1b012 TL |
2884 | |
2885 | /* dns.c */ | |
7d9784f6 | 2886 | #if defined (NSUPDATE) |
aa8579c0 | 2887 | isc_result_t find_tsig_key (ns_tsig_key **, const char *, struct dns_zone *); |
7d9784f6 TL |
2888 | void tkey_free (ns_tsig_key **); |
2889 | #endif | |
3f09cb5a TL |
2890 | isc_result_t enter_dns_zone (struct dns_zone *); |
2891 | isc_result_t dns_zone_lookup (struct dns_zone **, const char *); | |
a34feb7d | 2892 | int dns_zone_dereference (struct dns_zone **, const char *, int); |
29a026db | 2893 | #if defined (NSUPDATE) |
98bf1607 SR |
2894 | #define FIND_FORWARD 0 |
2895 | #define FIND_REVERSE 1 | |
2896 | isc_result_t find_cached_zone (dhcp_ddns_cb_t *, int); | |
aa8579c0 TL |
2897 | void forget_zone (struct dns_zone **); |
2898 | void repudiate_zone (struct dns_zone **); | |
98bf1607 | 2899 | //void cache_found_zone (ns_class, char *, struct in_addr *, int); |
d758ad8c | 2900 | int get_dhcid (struct data_string *, int, const u_int8_t *, unsigned); |
98bf1607 SR |
2901 | void dhcid_tolease (struct data_string *, struct data_string *); |
2902 | isc_result_t dhcid_fromlease (struct data_string *, struct data_string *); | |
98bd7ca0 DH |
2903 | isc_result_t ddns_update_fwd(struct data_string *, struct iaddr, |
2904 | struct data_string *, unsigned long, unsigned, | |
2905 | unsigned); | |
a34feb7d | 2906 | isc_result_t ddns_remove_fwd(struct data_string *, |
98bd7ca0 | 2907 | struct iaddr, struct data_string *); |
29a026db | 2908 | #endif /* NSUPDATE */ |
0c7802b1 TL |
2909 | |
2910 | /* resolv.c */ | |
2911 | extern char path_resolv_conf []; | |
06eb8bab SK |
2912 | extern struct name_server *name_servers; |
2913 | extern struct domain_search_list *domains; | |
0c7802b1 | 2914 | |
a34feb7d TM |
2915 | void read_resolv_conf (TIME); |
2916 | struct name_server *first_name_server (void); | |
2b60cc68 TL |
2917 | |
2918 | /* inet_addr.c */ | |
2919 | #ifdef NEED_INET_ATON | |
a34feb7d | 2920 | int inet_aton (const char *, struct in_addr *); |
2b60cc68 | 2921 | #endif |
5a526cf8 | 2922 | |
102ee7e9 | 2923 | /* class.c */ |
112a6c2c | 2924 | extern int have_billing_classes; |
102ee7e9 TL |
2925 | struct class unknown_class; |
2926 | struct class known_class; | |
2927 | struct collection default_collection; | |
8bdd4d02 | 2928 | struct collection *collections; |
06eb8bab | 2929 | extern struct executable_statement *default_classification_rules; |
102ee7e9 | 2930 | |
a34feb7d TM |
2931 | void classification_setup (void); |
2932 | void classify_client (struct packet *); | |
2933 | int check_collection (struct packet *, struct lease *, struct collection *); | |
2934 | void classify (struct packet *, struct class *); | |
2935 | isc_result_t unlink_class (struct class **class); | |
2936 | isc_result_t find_class (struct class **, const char *, | |
2937 | const char *, int); | |
2938 | int unbill_class (struct lease *, struct class *); | |
2939 | int bill_class (struct lease *, struct class *); | |
2b9b6ff7 TL |
2940 | |
2941 | /* execute.c */ | |
a34feb7d TM |
2942 | int execute_statements (struct binding_value **result, |
2943 | struct packet *, struct lease *, | |
2944 | struct client_state *, | |
2945 | struct option_state *, struct option_state *, | |
2946 | struct binding_scope **, | |
2947 | struct executable_statement *); | |
2948 | void execute_statements_in_scope (struct binding_value **result, | |
2949 | struct packet *, struct lease *, | |
2950 | struct client_state *, | |
2951 | struct option_state *, | |
2952 | struct option_state *, | |
2953 | struct binding_scope **, | |
2954 | struct group *, struct group *); | |
2955 | int executable_statement_dereference (struct executable_statement **, | |
2956 | const char *, int); | |
7f6ad5ac | 2957 | void write_statements (FILE *, struct executable_statement *, int); |
932d739c | 2958 | int find_matching_case (struct executable_statement **, |
159bcce3 | 2959 | struct packet *, struct lease *, struct client_state *, |
932d739c | 2960 | struct option_state *, struct option_state *, |
6ceb9118 | 2961 | struct binding_scope **, |
932d739c | 2962 | struct expression *, struct executable_statement *); |
d758ad8c TL |
2963 | int executable_statement_foreach (struct executable_statement *, |
2964 | int (*) (struct executable_statement *, | |
2965 | void *, int), void *, int); | |
74f45f96 | 2966 | |
20916cae | 2967 | /* comapi.c */ |
4fe74d72 | 2968 | extern omapi_object_type_t *dhcp_type_group; |
4fe74d72 TL |
2969 | extern omapi_object_type_t *dhcp_type_shared_network; |
2970 | extern omapi_object_type_t *dhcp_type_subnet; | |
d758ad8c TL |
2971 | extern omapi_object_type_t *dhcp_type_control; |
2972 | extern dhcp_control_object_t *dhcp_control_object; | |
20916cae TL |
2973 | |
2974 | void dhcp_common_objects_setup (void); | |
2975 | ||
2976 | isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *, | |
2977 | omapi_data_string_t *, | |
2978 | omapi_typed_data_t *); | |
2979 | isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *, | |
2980 | omapi_data_string_t *, | |
a34feb7d | 2981 | omapi_value_t **); |
20916cae TL |
2982 | isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int); |
2983 | isc_result_t dhcp_group_signal_handler (omapi_object_t *, | |
2984 | const char *, va_list); | |
2985 | isc_result_t dhcp_group_stuff_values (omapi_object_t *, | |
2986 | omapi_object_t *, | |
2987 | omapi_object_t *); | |
2988 | isc_result_t dhcp_group_lookup (omapi_object_t **, | |
2989 | omapi_object_t *, omapi_object_t *); | |
2990 | isc_result_t dhcp_group_create (omapi_object_t **, | |
2991 | omapi_object_t *); | |
2992 | isc_result_t dhcp_group_remove (omapi_object_t *, | |
2993 | omapi_object_t *); | |
2994 | ||
d758ad8c TL |
2995 | isc_result_t dhcp_control_set_value (omapi_object_t *, omapi_object_t *, |
2996 | omapi_data_string_t *, | |
2997 | omapi_typed_data_t *); | |
2998 | isc_result_t dhcp_control_get_value (omapi_object_t *, omapi_object_t *, | |
2999 | omapi_data_string_t *, | |
a34feb7d | 3000 | omapi_value_t **); |
d758ad8c TL |
3001 | isc_result_t dhcp_control_destroy (omapi_object_t *, const char *, int); |
3002 | isc_result_t dhcp_control_signal_handler (omapi_object_t *, | |
3003 | const char *, va_list); | |
3004 | isc_result_t dhcp_control_stuff_values (omapi_object_t *, | |
3005 | omapi_object_t *, | |
3006 | omapi_object_t *); | |
3007 | isc_result_t dhcp_control_lookup (omapi_object_t **, | |
3008 | omapi_object_t *, omapi_object_t *); | |
3009 | isc_result_t dhcp_control_create (omapi_object_t **, | |
3010 | omapi_object_t *); | |
3011 | isc_result_t dhcp_control_remove (omapi_object_t *, | |
3012 | omapi_object_t *); | |
3013 | ||
20916cae TL |
3014 | isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *, |
3015 | omapi_data_string_t *, | |
3016 | omapi_typed_data_t *); | |
3017 | isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *, | |
3018 | omapi_data_string_t *, | |
a34feb7d | 3019 | omapi_value_t **); |
20916cae TL |
3020 | isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int); |
3021 | isc_result_t dhcp_subnet_signal_handler (omapi_object_t *, | |
3022 | const char *, va_list); | |
3023 | isc_result_t dhcp_subnet_stuff_values (omapi_object_t *, | |
3024 | omapi_object_t *, | |
3025 | omapi_object_t *); | |
3026 | isc_result_t dhcp_subnet_lookup (omapi_object_t **, | |
3027 | omapi_object_t *, omapi_object_t *); | |
3028 | isc_result_t dhcp_subnet_create (omapi_object_t **, | |
3029 | omapi_object_t *); | |
3030 | isc_result_t dhcp_subnet_remove (omapi_object_t *, | |
3031 | omapi_object_t *); | |
3032 | ||
3033 | isc_result_t dhcp_shared_network_set_value (omapi_object_t *, | |
3034 | omapi_object_t *, | |
3035 | omapi_data_string_t *, | |
3036 | omapi_typed_data_t *); | |
3037 | isc_result_t dhcp_shared_network_get_value (omapi_object_t *, | |
3038 | omapi_object_t *, | |
3039 | omapi_data_string_t *, | |
a34feb7d | 3040 | omapi_value_t **); |
20916cae TL |
3041 | isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int); |
3042 | isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *, | |
3043 | const char *, va_list); | |
3044 | isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *, | |
3045 | omapi_object_t *, | |
3046 | omapi_object_t *); | |
3047 | isc_result_t dhcp_shared_network_lookup (omapi_object_t **, | |
3048 | omapi_object_t *, omapi_object_t *); | |
3049 | isc_result_t dhcp_shared_network_create (omapi_object_t **, | |
3050 | omapi_object_t *); | |
3051 | isc_result_t dhcp_shared_network_remove (omapi_object_t *, | |
3052 | omapi_object_t *); | |
3053 | ||
3054 | /* omapi.c */ | |
3055 | extern int (*dhcp_interface_shutdown_hook) (struct interface_info *); | |
3056 | ||
3057 | extern omapi_object_type_t *dhcp_type_lease; | |
3058 | extern omapi_object_type_t *dhcp_type_pool; | |
4fe74d72 | 3059 | extern omapi_object_type_t *dhcp_type_class; |
899d754f | 3060 | extern omapi_object_type_t *dhcp_type_subclass; |
bdcaf7b9 | 3061 | |
d9eefc5d TL |
3062 | #if defined (FAILOVER_PROTOCOL) |
3063 | extern omapi_object_type_t *dhcp_type_failover_state; | |
3064 | extern omapi_object_type_t *dhcp_type_failover_link; | |
3065 | extern omapi_object_type_t *dhcp_type_failover_listener; | |
3066 | #endif | |
4fe74d72 TL |
3067 | |
3068 | void dhcp_db_objects_setup (void); | |
3069 | ||
3070 | isc_result_t dhcp_lease_set_value (omapi_object_t *, omapi_object_t *, | |
3071 | omapi_data_string_t *, | |
3072 | omapi_typed_data_t *); | |
3073 | isc_result_t dhcp_lease_get_value (omapi_object_t *, omapi_object_t *, | |
3074 | omapi_data_string_t *, | |
a34feb7d | 3075 | omapi_value_t **); |
4bd8800e | 3076 | isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *, int); |
b1b7b521 TL |
3077 | isc_result_t dhcp_lease_signal_handler (omapi_object_t *, |
3078 | const char *, va_list); | |
4fe74d72 TL |
3079 | isc_result_t dhcp_lease_stuff_values (omapi_object_t *, |
3080 | omapi_object_t *, | |
3081 | omapi_object_t *); | |
3082 | isc_result_t dhcp_lease_lookup (omapi_object_t **, | |
3083 | omapi_object_t *, omapi_object_t *); | |
3084 | isc_result_t dhcp_lease_create (omapi_object_t **, | |
3085 | omapi_object_t *); | |
ccce1cc6 | 3086 | isc_result_t dhcp_lease_remove (omapi_object_t *, |
3c48d369 | 3087 | omapi_object_t *); |
4fe74d72 TL |
3088 | isc_result_t dhcp_host_set_value (omapi_object_t *, omapi_object_t *, |
3089 | omapi_data_string_t *, | |
3090 | omapi_typed_data_t *); | |
3091 | isc_result_t dhcp_host_get_value (omapi_object_t *, omapi_object_t *, | |
3092 | omapi_data_string_t *, | |
a34feb7d | 3093 | omapi_value_t **); |
4bd8800e | 3094 | isc_result_t dhcp_host_destroy (omapi_object_t *, const char *, int); |
b1b7b521 TL |
3095 | isc_result_t dhcp_host_signal_handler (omapi_object_t *, |
3096 | const char *, va_list); | |
4fe74d72 TL |
3097 | isc_result_t dhcp_host_stuff_values (omapi_object_t *, |
3098 | omapi_object_t *, | |
3099 | omapi_object_t *); | |
3100 | isc_result_t dhcp_host_lookup (omapi_object_t **, | |
3101 | omapi_object_t *, omapi_object_t *); | |
3102 | isc_result_t dhcp_host_create (omapi_object_t **, | |
3103 | omapi_object_t *); | |
ccce1cc6 | 3104 | isc_result_t dhcp_host_remove (omapi_object_t *, |
3c48d369 | 3105 | omapi_object_t *); |
4fe74d72 TL |
3106 | isc_result_t dhcp_pool_set_value (omapi_object_t *, omapi_object_t *, |
3107 | omapi_data_string_t *, | |
3108 | omapi_typed_data_t *); | |
3109 | isc_result_t dhcp_pool_get_value (omapi_object_t *, omapi_object_t *, | |
3110 | omapi_data_string_t *, | |
a34feb7d | 3111 | omapi_value_t **); |
4bd8800e | 3112 | isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *, int); |
b1b7b521 TL |
3113 | isc_result_t dhcp_pool_signal_handler (omapi_object_t *, |
3114 | const char *, va_list); | |
4fe74d72 TL |
3115 | isc_result_t dhcp_pool_stuff_values (omapi_object_t *, |
3116 | omapi_object_t *, | |
3117 | omapi_object_t *); | |
3118 | isc_result_t dhcp_pool_lookup (omapi_object_t **, | |
3119 | omapi_object_t *, omapi_object_t *); | |
3120 | isc_result_t dhcp_pool_create (omapi_object_t **, | |
3121 | omapi_object_t *); | |
ccce1cc6 | 3122 | isc_result_t dhcp_pool_remove (omapi_object_t *, |
3c48d369 | 3123 | omapi_object_t *); |
20916cae TL |
3124 | isc_result_t dhcp_class_set_value (omapi_object_t *, omapi_object_t *, |
3125 | omapi_data_string_t *, | |
3126 | omapi_typed_data_t *); | |
3127 | isc_result_t dhcp_class_get_value (omapi_object_t *, omapi_object_t *, | |
3128 | omapi_data_string_t *, | |
a34feb7d | 3129 | omapi_value_t **); |
20916cae TL |
3130 | isc_result_t dhcp_class_destroy (omapi_object_t *, const char *, int); |
3131 | isc_result_t dhcp_class_signal_handler (omapi_object_t *, | |
3132 | const char *, va_list); | |
3133 | isc_result_t dhcp_class_stuff_values (omapi_object_t *, | |
3134 | omapi_object_t *, | |
3135 | omapi_object_t *); | |
3136 | isc_result_t dhcp_class_lookup (omapi_object_t **, | |
3137 | omapi_object_t *, omapi_object_t *); | |
3138 | isc_result_t dhcp_class_create (omapi_object_t **, | |
3139 | omapi_object_t *); | |
3140 | isc_result_t dhcp_class_remove (omapi_object_t *, | |
3141 | omapi_object_t *); | |
c1f22aef TL |
3142 | isc_result_t dhcp_subclass_set_value (omapi_object_t *, omapi_object_t *, |
3143 | omapi_data_string_t *, | |
3144 | omapi_typed_data_t *); | |
3145 | isc_result_t dhcp_subclass_get_value (omapi_object_t *, omapi_object_t *, | |
3146 | omapi_data_string_t *, | |
a34feb7d | 3147 | omapi_value_t **); |
c1f22aef TL |
3148 | isc_result_t dhcp_subclass_destroy (omapi_object_t *, const char *, int); |
3149 | isc_result_t dhcp_subclass_signal_handler (omapi_object_t *, | |
3150 | const char *, va_list); | |
3151 | isc_result_t dhcp_subclass_stuff_values (omapi_object_t *, | |
3152 | omapi_object_t *, | |
3153 | omapi_object_t *); | |
3154 | isc_result_t dhcp_subclass_lookup (omapi_object_t **, | |
3155 | omapi_object_t *, omapi_object_t *); | |
3156 | isc_result_t dhcp_subclass_create (omapi_object_t **, | |
3157 | omapi_object_t *); | |
3158 | isc_result_t dhcp_subclass_remove (omapi_object_t *, | |
3159 | omapi_object_t *); | |
20916cae TL |
3160 | isc_result_t dhcp_interface_set_value (omapi_object_t *, |
3161 | omapi_object_t *, | |
3162 | omapi_data_string_t *, | |
3163 | omapi_typed_data_t *); | |
3164 | isc_result_t dhcp_interface_get_value (omapi_object_t *, | |
3165 | omapi_object_t *, | |
3166 | omapi_data_string_t *, | |
3167 | omapi_value_t **); | |
3168 | isc_result_t dhcp_interface_destroy (omapi_object_t *, | |
3169 | const char *, int); | |
3170 | isc_result_t dhcp_interface_signal_handler (omapi_object_t *, | |
3171 | const char *, | |
3172 | va_list ap); | |
3173 | isc_result_t dhcp_interface_stuff_values (omapi_object_t *, | |
3174 | omapi_object_t *, | |
3175 | omapi_object_t *); | |
3176 | isc_result_t dhcp_interface_lookup (omapi_object_t **, | |
3177 | omapi_object_t *, | |
3178 | omapi_object_t *); | |
3179 | isc_result_t dhcp_interface_create (omapi_object_t **, | |
3180 | omapi_object_t *); | |
3181 | isc_result_t dhcp_interface_remove (omapi_object_t *, | |
3182 | omapi_object_t *); | |
f3aad410 TL |
3183 | void interface_stash (struct interface_info *); |
3184 | void interface_snorf (struct interface_info *, int); | |
4fe74d72 | 3185 | |
d758ad8c TL |
3186 | isc_result_t binding_scope_set_value (struct binding_scope *, int, |
3187 | omapi_data_string_t *, | |
3188 | omapi_typed_data_t *); | |
3189 | isc_result_t binding_scope_get_value (omapi_value_t **, | |
3190 | struct binding_scope *, | |
3191 | omapi_data_string_t *); | |
3192 | isc_result_t binding_scope_stuff_values (omapi_object_t *, | |
3193 | struct binding_scope *); | |
3194 | ||
6368a1bd DH |
3195 | void register_eventhandler(struct eventqueue **, void (*handler)(void *)); |
3196 | void unregister_eventhandler(struct eventqueue **, void (*handler)(void *)); | |
a34feb7d | 3197 | void trigger_event(struct eventqueue **); |
6368a1bd | 3198 | |
940ea8ab TL |
3199 | /* mdb.c */ |
3200 | ||
8c8e27c5 TL |
3201 | extern struct subnet *subnets; |
3202 | extern struct shared_network *shared_networks; | |
98311e4b DH |
3203 | extern host_hash_t *host_hw_addr_hash; |
3204 | extern host_hash_t *host_uid_hash; | |
3205 | extern host_hash_t *host_name_hash; | |
6708d944 DH |
3206 | extern lease_id_hash_t *lease_uid_hash; |
3207 | extern lease_ip_hash_t *lease_ip_addr_hash; | |
3208 | extern lease_id_hash_t *lease_hw_addr_hash; | |
940ea8ab TL |
3209 | |
3210 | extern omapi_object_type_t *dhcp_type_host; | |
3211 | ||
f3fe382d JB |
3212 | extern int numclasseswritten; |
3213 | ||
3214 | ||
a34feb7d TM |
3215 | isc_result_t enter_class (struct class *, int, int); |
3216 | isc_result_t delete_class (struct class *, int); | |
3217 | isc_result_t enter_host (struct host_decl *, int, int); | |
3218 | isc_result_t delete_host (struct host_decl *, int); | |
98bd7ca0 | 3219 | void change_host_uid(struct host_decl *host, const char *data, int len); |
a34feb7d TM |
3220 | int find_hosts_by_haddr (struct host_decl **, int, |
3221 | const unsigned char *, unsigned, | |
3222 | const char *, int); | |
3223 | int find_hosts_by_uid (struct host_decl **, const unsigned char *, | |
3224 | unsigned, const char *, int); | |
3225 | int find_hosts_by_option(struct host_decl **, struct packet *, | |
98bd7ca0 | 3226 | struct option_state *, const char *, int); |
a34feb7d TM |
3227 | int find_host_for_network (struct subnet **, struct host_decl **, |
3228 | struct iaddr *, struct shared_network *); | |
3229 | void new_address_range (struct parse *, struct iaddr, struct iaddr, | |
3230 | struct subnet *, struct pool *, | |
3231 | struct lease **); | |
20916cae | 3232 | isc_result_t dhcp_lease_free (omapi_object_t *, const char *, int); |
932d739c | 3233 | isc_result_t dhcp_lease_get (omapi_object_t **, const char *, int); |
a34feb7d TM |
3234 | int find_grouped_subnet (struct subnet **, struct shared_network *, |
3235 | struct iaddr, const char *, int); | |
98bd7ca0 | 3236 | int find_subnet(struct subnet **, struct iaddr, const char *, int); |
a34feb7d TM |
3237 | void enter_shared_network (struct shared_network *); |
3238 | void new_shared_network_interface (struct parse *, | |
3239 | struct shared_network *, | |
3240 | const char *); | |
98bd7ca0 | 3241 | int subnet_inner_than(const struct subnet *, const struct subnet *, int); |
a34feb7d TM |
3242 | void enter_subnet (struct subnet *); |
3243 | void enter_lease (struct lease *); | |
3244 | int supersede_lease (struct lease *, struct lease *, int, int, int); | |
e540864e | 3245 | void make_binding_state_transition (struct lease *); |
a34feb7d TM |
3246 | int lease_copy (struct lease **, struct lease *, const char *, int); |
3247 | void release_lease (struct lease *, struct packet *); | |
3248 | void abandon_lease (struct lease *, const char *); | |
d13db163 SR |
3249 | #if 0 |
3250 | /* this appears to be unused and I plan to remove it SAR */ | |
a34feb7d | 3251 | void dissociate_lease (struct lease *); |
d13db163 | 3252 | #endif |
a34feb7d TM |
3253 | void pool_timer (void *); |
3254 | int find_lease_by_uid (struct lease **, const unsigned char *, | |
3255 | unsigned, const char *, int); | |
3256 | int find_lease_by_hw_addr (struct lease **, const unsigned char *, | |
3257 | unsigned, const char *, int); | |
3258 | int find_lease_by_ip_addr (struct lease **, struct iaddr, | |
3259 | const char *, int); | |
3260 | void uid_hash_add (struct lease *); | |
3261 | void uid_hash_delete (struct lease *); | |
3262 | void hw_hash_add (struct lease *); | |
3263 | void hw_hash_delete (struct lease *); | |
3264 | int write_leases (void); | |
98bd7ca0 | 3265 | int write_leases6(void); |
d0411fbd | 3266 | int lease_enqueue (struct lease *); |
f7fdb216 | 3267 | isc_result_t lease_instantiate(const void *, unsigned, void *); |
a34feb7d TM |
3268 | void expire_all_pools (void); |
3269 | void dump_subnets (void); | |
d758ad8c TL |
3270 | #if defined (DEBUG_MEMORY_LEAKAGE) || \ |
3271 | defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT) | |
3272 | void free_everything (void); | |
3273 | #endif | |
9ba7cdec TL |
3274 | |
3275 | /* nsupdate.c */ | |
3276 | char *ddns_rev_name (struct lease *, struct lease_state *, struct packet *); | |
3277 | char *ddns_fwd_name (struct lease *, struct lease_state *, struct packet *); | |
3278 | int nsupdateA (const char *, const unsigned char *, u_int32_t, int); | |
3279 | int nsupdatePTR (const char *, const unsigned char *, u_int32_t, int); | |
3280 | void nsupdate (struct lease *, struct lease_state *, struct packet *, int); | |
3281 | int updateA (const struct data_string *, const struct data_string *, | |
3282 | unsigned int, struct lease *); | |
3283 | int updatePTR (const struct data_string *, const struct data_string *, | |
3284 | unsigned int, struct lease *); | |
91dc2849 TL |
3285 | int deleteA (const struct data_string *, const struct data_string *, |
3286 | struct lease *); | |
3287 | int deletePTR (const struct data_string *, const struct data_string *, | |
3288 | struct lease *); | |
d9eefc5d TL |
3289 | |
3290 | /* failover.c */ | |
3291 | #if defined (FAILOVER_PROTOCOL) | |
d758ad8c | 3292 | extern dhcp_failover_state_t *failover_states; |
a34feb7d | 3293 | void dhcp_failover_startup (void); |
d758ad8c | 3294 | int dhcp_failover_write_all_states (void); |
a34feb7d TM |
3295 | isc_result_t enter_failover_peer (dhcp_failover_state_t *); |
3296 | isc_result_t find_failover_peer (dhcp_failover_state_t **, | |
3297 | const char *, const char *, int); | |
3298 | isc_result_t dhcp_failover_link_initiate (omapi_object_t *); | |
3299 | isc_result_t dhcp_failover_link_signal (omapi_object_t *, | |
3300 | const char *, va_list); | |
3301 | isc_result_t dhcp_failover_link_set_value (omapi_object_t *, | |
3302 | omapi_object_t *, | |
3303 | omapi_data_string_t *, | |
3304 | omapi_typed_data_t *); | |
3305 | isc_result_t dhcp_failover_link_get_value (omapi_object_t *, | |
3306 | omapi_object_t *, | |
3307 | omapi_data_string_t *, | |
3308 | omapi_value_t **); | |
3309 | isc_result_t dhcp_failover_link_destroy (omapi_object_t *, | |
3310 | const char *, int); | |
3311 | isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *, | |
3312 | omapi_object_t *, | |
3313 | omapi_object_t *); | |
3314 | isc_result_t dhcp_failover_listen (omapi_object_t *); | |
3315 | ||
3316 | isc_result_t dhcp_failover_listener_signal (omapi_object_t *, | |
3317 | const char *, | |
3318 | va_list); | |
3319 | isc_result_t dhcp_failover_listener_set_value (omapi_object_t *, | |
3320 | omapi_object_t *, | |
3321 | omapi_data_string_t *, | |
3322 | omapi_typed_data_t *); | |
3323 | isc_result_t dhcp_failover_listener_get_value (omapi_object_t *, | |
3324 | omapi_object_t *, | |
3325 | omapi_data_string_t *, | |
3326 | omapi_value_t **); | |
3327 | isc_result_t dhcp_failover_listener_destroy (omapi_object_t *, | |
3328 | const char *, int); | |
3329 | isc_result_t dhcp_failover_listener_stuff (omapi_object_t *, | |
3330 | omapi_object_t *, | |
3331 | omapi_object_t *); | |
3332 | isc_result_t dhcp_failover_register (omapi_object_t *); | |
3333 | isc_result_t dhcp_failover_state_signal (omapi_object_t *, | |
3334 | const char *, va_list); | |
aa8579c0 TL |
3335 | isc_result_t dhcp_failover_state_transition (dhcp_failover_state_t *, |
3336 | const char *); | |
c489f075 | 3337 | isc_result_t dhcp_failover_set_service_state (dhcp_failover_state_t *state); |
aa8579c0 TL |
3338 | isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *, |
3339 | enum failover_state); | |
c489f075 TL |
3340 | isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *, |
3341 | failover_message_t *); | |
2426234f DH |
3342 | void dhcp_failover_pool_rebalance (void *); |
3343 | void dhcp_failover_pool_check (struct pool *); | |
8c8e27c5 | 3344 | int dhcp_failover_state_pool_check (dhcp_failover_state_t *); |
d0411fbd TL |
3345 | void dhcp_failover_timeout (void *); |
3346 | void dhcp_failover_send_contact (void *); | |
8d3aec71 | 3347 | isc_result_t dhcp_failover_send_state (dhcp_failover_state_t *); |
a7982987 | 3348 | isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *); |
007e3ee4 | 3349 | int dhcp_failover_queue_update (struct lease *, int); |
988c1ca7 | 3350 | int dhcp_failover_send_acks (dhcp_failover_state_t *); |
af5ad6df | 3351 | void dhcp_failover_toack_queue_timeout (void *); |
988c1ca7 | 3352 | int dhcp_failover_queue_ack (dhcp_failover_state_t *, failover_message_t *msg); |
f9d43a9a | 3353 | void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *); |
a34feb7d TM |
3354 | isc_result_t dhcp_failover_state_set_value (omapi_object_t *, |
3355 | omapi_object_t *, | |
3356 | omapi_data_string_t *, | |
3357 | omapi_typed_data_t *); | |
aa8579c0 | 3358 | void dhcp_failover_keepalive (void *); |
a7982987 | 3359 | void dhcp_failover_reconnect (void *); |
c489f075 | 3360 | void dhcp_failover_startup_timeout (void *); |
8d3aec71 | 3361 | void dhcp_failover_link_startup_timeout (void *); |
a7982987 | 3362 | void dhcp_failover_listener_restart (void *); |
9e3eb22a | 3363 | void dhcp_failover_auto_partner_down(void *vs); |
a34feb7d TM |
3364 | isc_result_t dhcp_failover_state_get_value (omapi_object_t *, |
3365 | omapi_object_t *, | |
3366 | omapi_data_string_t *, | |
3367 | omapi_value_t **); | |
3368 | isc_result_t dhcp_failover_state_destroy (omapi_object_t *, | |
3369 | const char *, int); | |
3370 | isc_result_t dhcp_failover_state_stuff (omapi_object_t *, | |
3371 | omapi_object_t *, | |
3372 | omapi_object_t *); | |
3373 | isc_result_t dhcp_failover_state_lookup (omapi_object_t **, | |
3374 | omapi_object_t *, | |
3375 | omapi_object_t *); | |
3376 | isc_result_t dhcp_failover_state_create (omapi_object_t **, | |
3377 | omapi_object_t *); | |
3378 | isc_result_t dhcp_failover_state_remove (omapi_object_t *, | |
3379 | omapi_object_t *); | |
a7982987 | 3380 | int dhcp_failover_state_match (dhcp_failover_state_t *, u_int8_t *, unsigned); |
a55ccdd0 | 3381 | int dhcp_failover_state_match_by_name(dhcp_failover_state_t *, |
a34feb7d | 3382 | failover_option_t *); |
a7982987 TL |
3383 | const char *dhcp_failover_reject_reason_print (int); |
3384 | const char *dhcp_failover_state_name_print (enum failover_state); | |
af380050 TL |
3385 | const char *dhcp_failover_message_name (unsigned); |
3386 | const char *dhcp_failover_option_name (unsigned); | |
165bce70 TL |
3387 | failover_option_t *dhcp_failover_option_printf (unsigned, char *, |
3388 | unsigned *, | |
a34feb7d | 3389 | unsigned, |
72896e9f TL |
3390 | const char *, ...) |
3391 | __attribute__((__format__(__printf__,5,6))); | |
3392 | failover_option_t *dhcp_failover_make_option (unsigned, char *, | |
3393 | unsigned *, unsigned, ...); | |
165bce70 | 3394 | isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *, |
a55ccdd0 | 3395 | omapi_object_t *, int, u_int32_t, ...); |
a34feb7d TM |
3396 | isc_result_t dhcp_failover_send_connect (omapi_object_t *); |
3397 | isc_result_t dhcp_failover_send_connectack (omapi_object_t *, | |
3398 | dhcp_failover_state_t *, | |
3399 | int, const char *); | |
3400 | isc_result_t dhcp_failover_send_disconnect (omapi_object_t *, | |
3401 | int, const char *); | |
a7982987 TL |
3402 | isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *, |
3403 | struct lease *); | |
8c8e27c5 | 3404 | isc_result_t dhcp_failover_send_bind_ack (dhcp_failover_state_t *, |
988c1ca7 | 3405 | failover_message_t *, |
8c8e27c5 TL |
3406 | int, const char *); |
3407 | isc_result_t dhcp_failover_send_poolreq (dhcp_failover_state_t *); | |
3408 | isc_result_t dhcp_failover_send_poolresp (dhcp_failover_state_t *, int); | |
c489f075 TL |
3409 | isc_result_t dhcp_failover_send_update_request (dhcp_failover_state_t *); |
3410 | isc_result_t dhcp_failover_send_update_request_all (dhcp_failover_state_t *); | |
3411 | isc_result_t dhcp_failover_send_update_done (dhcp_failover_state_t *); | |
8c8e27c5 TL |
3412 | isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *, |
3413 | failover_message_t *); | |
3414 | isc_result_t dhcp_failover_process_bind_ack (dhcp_failover_state_t *, | |
3415 | failover_message_t *); | |
c489f075 TL |
3416 | isc_result_t dhcp_failover_generate_update_queue (dhcp_failover_state_t *, |
3417 | int); | |
3418 | isc_result_t dhcp_failover_process_update_request (dhcp_failover_state_t *, | |
3419 | failover_message_t *); | |
3420 | isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *, | |
3421 | failover_message_t *); | |
3422 | isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *, | |
3423 | failover_message_t *); | |
1d17db44 | 3424 | void ia_remove_all_lease(struct ia_xx *ia, const char *file, int line); |
c489f075 | 3425 | void dhcp_failover_recover_done (void *); |
a34feb7d TM |
3426 | void failover_print (char *, unsigned *, unsigned, const char *); |
3427 | void update_partner (struct lease *); | |
aa8579c0 | 3428 | int load_balance_mine (struct packet *, dhcp_failover_state_t *); |
2426234f | 3429 | int peer_wants_lease (struct lease *); |
e540864e TL |
3430 | binding_state_t normal_binding_state_transition_check (struct lease *, |
3431 | dhcp_failover_state_t *, | |
31bbee78 TL |
3432 | binding_state_t, |
3433 | u_int32_t); | |
e540864e TL |
3434 | binding_state_t |
3435 | conflict_binding_state_transition_check (struct lease *, | |
3436 | dhcp_failover_state_t *, | |
31bbee78 | 3437 | binding_state_t, u_int32_t); |
c489f075 | 3438 | int lease_mine_to_reallocate (struct lease *); |
007e3ee4 | 3439 | |
20916cae TL |
3440 | OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t, |
3441 | dhcp_type_failover_state) | |
3442 | OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener, dhcp_failover_listener_t, | |
3443 | dhcp_type_failover_listener) | |
3444 | OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link, dhcp_failover_link_t, | |
57c8fdd7 | 3445 | dhcp_type_failover_link) |
d9eefc5d | 3446 | #endif /* FAILOVER_PROTOCOL */ |
e540864e TL |
3447 | |
3448 | const char *binding_state_print (enum failover_state); | |
98bd7ca0 | 3449 | |
33692791 DH |
3450 | /* ldap.c */ |
3451 | #if defined(LDAP_CONFIGURATION) | |
3452 | extern struct enumeration ldap_methods; | |
3453 | #if defined (LDAP_USE_SSL) | |
3454 | extern struct enumeration ldap_ssl_usage_enum; | |
3455 | extern struct enumeration ldap_tls_reqcert_enum; | |
3456 | extern struct enumeration ldap_tls_crlcheck_enum; | |
3457 | #endif | |
3458 | isc_result_t ldap_read_config (void); | |
3459 | int find_haddr_in_ldap (struct host_decl **, int, unsigned, | |
a34feb7d | 3460 | const unsigned char *, const char *, int); |
33692791 | 3461 | int find_subclass_in_ldap (struct class *, struct class **, |
a34feb7d | 3462 | struct data_string *); |
33692791 | 3463 | #endif |
98bd7ca0 DH |
3464 | |
3465 | /* mdb6.c */ | |
e91b6f3c | 3466 | HASH_FUNCTIONS_DECL(ia, unsigned char *, struct ia_xx, ia_hash_t) |
1d17db44 | 3467 | HASH_FUNCTIONS_DECL(iasubopt, struct in6_addr *, struct iasubopt, |
e91b6f3c | 3468 | iasubopt_hash_t) |
98bd7ca0 | 3469 | |
1d17db44 FD |
3470 | isc_result_t iasubopt_allocate(struct iasubopt **iasubopt, |
3471 | const char *file, int line); | |
3472 | isc_result_t iasubopt_reference(struct iasubopt **iasubopt, | |
3473 | struct iasubopt *src, | |
98bd7ca0 | 3474 | const char *file, int line); |
1d17db44 FD |
3475 | isc_result_t iasubopt_dereference(struct iasubopt **iasubopt, |
3476 | const char *file, int line); | |
98bd7ca0 | 3477 | |
1d9774ab FD |
3478 | isc_result_t ia_make_key(struct data_string *key, u_int32_t iaid, |
3479 | const char *duid, unsigned int duid_len, | |
3480 | const char *file, int line); | |
9322442f FD |
3481 | isc_result_t ia_allocate(struct ia_xx **ia, u_int32_t iaid, |
3482 | const char *duid, unsigned int duid_len, | |
98bd7ca0 | 3483 | const char *file, int line); |
9322442f FD |
3484 | isc_result_t ia_reference(struct ia_xx **ia, struct ia_xx *src, |
3485 | const char *file, int line); | |
3486 | isc_result_t ia_dereference(struct ia_xx **ia, | |
1d9774ab | 3487 | const char *file, int line); |
1d17db44 FD |
3488 | isc_result_t ia_add_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, |
3489 | const char *file, int line); | |
3490 | void ia_remove_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, | |
3491 | const char *file, int line); | |
9322442f | 3492 | isc_boolean_t ia_equal(const struct ia_xx *a, const struct ia_xx *b); |
1d9774ab | 3493 | |
9322442f FD |
3494 | isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type, |
3495 | const struct in6_addr *start_addr, | |
3496 | int bits, int units, | |
98bd7ca0 DH |
3497 | const char *file, int line); |
3498 | isc_result_t ipv6_pool_reference(struct ipv6_pool **pool, | |
3499 | struct ipv6_pool *src, | |
3500 | const char *file, int line); | |
3501 | isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool, | |
3502 | const char *file, int line); | |
5d89d60f | 3503 | isc_result_t create_lease6(struct ipv6_pool *pool, |
1d17db44 | 3504 | struct iasubopt **addr, |
5d89d60f FD |
3505 | unsigned int *attempts, |
3506 | const struct data_string *uid, | |
3507 | time_t soft_lifetime_end_time); | |
98bd7ca0 | 3508 | isc_result_t add_lease6(struct ipv6_pool *pool, |
1d17db44 | 3509 | struct iasubopt *lease, |
98bd7ca0 | 3510 | time_t valid_lifetime_end_time); |
1d17db44 FD |
3511 | isc_result_t renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease); |
3512 | isc_result_t expire_lease6(struct iasubopt **leasep, | |
98bd7ca0 | 3513 | struct ipv6_pool *pool, time_t now); |
1d17db44 FD |
3514 | isc_result_t release_lease6(struct ipv6_pool *pool, struct iasubopt *lease); |
3515 | isc_result_t decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease); | |
a34feb7d | 3516 | isc_boolean_t lease6_exists(const struct ipv6_pool *pool, |
98bd7ca0 | 3517 | const struct in6_addr *addr); |
bc7f8b8e SR |
3518 | isc_boolean_t lease6_usable(struct iasubopt *lease); |
3519 | isc_result_t cleanup_lease6(ia_hash_t *ia_table, | |
3520 | struct ipv6_pool *pool, | |
3521 | struct iasubopt *lease, | |
3522 | struct ia_xx *ia); | |
9322442f FD |
3523 | isc_result_t mark_lease_unavailble(struct ipv6_pool *pool, |
3524 | const struct in6_addr *addr); | |
9322442f | 3525 | isc_result_t create_prefix6(struct ipv6_pool *pool, |
1d17db44 | 3526 | struct iasubopt **pref, |
5d89d60f FD |
3527 | unsigned int *attempts, |
3528 | const struct data_string *uid, | |
3529 | time_t soft_lifetime_end_time); | |
a34feb7d | 3530 | isc_boolean_t prefix6_exists(const struct ipv6_pool *pool, |
1d9774ab FD |
3531 | const struct in6_addr *pref, u_int8_t plen); |
3532 | ||
98bd7ca0 | 3533 | isc_result_t add_ipv6_pool(struct ipv6_pool *pool); |
9322442f | 3534 | isc_result_t find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type, |
98bd7ca0 | 3535 | const struct in6_addr *addr); |
a34feb7d | 3536 | isc_boolean_t ipv6_in_pool(const struct in6_addr *addr, |
9322442f FD |
3537 | const struct ipv6_pool *pool); |
3538 | ||
3539 | isc_result_t renew_leases(struct ia_xx *ia); | |
3540 | isc_result_t release_leases(struct ia_xx *ia); | |
3541 | isc_result_t decline_leases(struct ia_xx *ia); | |
d9b43370 SK |
3542 | void schedule_lease_timeout(struct ipv6_pool *pool); |
3543 | void schedule_all_ipv6_lease_timeouts(); | |
98bd7ca0 DH |
3544 | |
3545 | void mark_hosts_unavailable(void); | |
80c9fdb0 | 3546 | void mark_phosts_unavailable(void); |
98bd7ca0 DH |
3547 | void mark_interfaces_unavailable(void); |
3548 | ||
98bf1607 SR |
3549 | dhcp_ddns_cb_t *ddns_cb_alloc(const char *file, int line); |
3550 | void ddns_cb_free (dhcp_ddns_cb_t *ddns_cb, const char *file, int line); | |
3551 | void ddns_cb_forget_zone (dhcp_ddns_cb_t *ddns_cb); | |
3552 | ||
3553 | //void *key_from_zone(struct dns_zone *zone); | |
3554 | ||
3555 | isc_result_t | |
87132514 | 3556 | ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line); |
98bf1607 SR |
3557 | |
3558 | isc_result_t | |
87132514 | 3559 | ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb, const char *file, int line); |
98bf1607 SR |
3560 | |
3561 | void | |
87132514 | 3562 | ddns_cancel(dhcp_ddns_cb_t *ddns_cb, const char *file, int line); |
beaed73f SR |
3563 | |
3564 | #define MAX_ADDRESS_STRING_LEN \ | |
3565 | (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")) |