-
Notifications
You must be signed in to change notification settings - Fork 2
/
dhcpd.h
executable file
·3582 lines (3208 loc) · 122 KB
/
dhcpd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* dhcpd.h
Definitions for dhcpd... */
/*
* Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
* This software has been written for Internet Systems Consortium
* by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
* To learn more about Internet Systems Consortium, see
* ``https://www.isc.org/''. To learn more about Vixie Enterprises,
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
* ``http://www.nominum.com''.
*/
#include "config.h"
#ifndef __CYGWIN32__
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
#else
#define fd_set cygwin_fd_set
#include <sys/types.h>
#endif
#include <stddef.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <ctype.h>
#include <time.h>
#include <net/if.h>
#undef FDDI
#include <net/route.h>
#include <net/if_arp.h>
#if HAVE_NET_IF_DL_H
# include <net/if_dl.h>
#endif
#include <setjmp.h>
#include "cdefs.h"
#include "osdep.h"
#include "arpa/nameser.h"
#include "minires.h"
struct hash_table;
typedef struct hash_table group_hash_t;
typedef struct hash_table universe_hash_t;
typedef struct hash_table option_name_hash_t;
typedef struct hash_table option_code_hash_t;
typedef struct hash_table dns_zone_hash_t;
typedef struct hash_table lease_ip_hash_t;
typedef struct hash_table lease_id_hash_t;
typedef struct hash_table host_hash_t;
typedef struct hash_table class_hash_t;
typedef time_t TIME;
#ifndef EOL
#define EOL '\n'
#endif
#include <omapip/isclib.h>
#include <omapip/result.h>
#include "dhcp.h"
#include "dhcp6.h"
#include "statement.h"
#include "tree.h"
#include "inet.h"
#include "dhctoken.h"
#include <omapip/omapip_p.h>
#if defined(LDAP_CONFIGURATION)
# include <ldap.h>
# include <sys/utsname.h> /* for uname() */
#endif
#if !defined (BYTE_NAME_HASH_SIZE)
# define BYTE_NAME_HASH_SIZE 401 /* Default would be ridiculous. */
#endif
#if !defined (BYTE_CODE_HASH_SIZE)
# define BYTE_CODE_HASH_SIZE 254 /* Default would be ridiculous. */
#endif
/* Although it is highly improbable that a 16-bit option space might
* actually use 2^16 actual defined options, it is the worst case
* scenario we must prepare for. Having 4 options per bucket in this
* case is pretty reasonable.
*/
#if !defined (WORD_NAME_HASH_SIZE)
# define WORD_NAME_HASH_SIZE 20479
#endif
#if !defined (WORD_CODE_HASH_SIZE)
# define WORD_CODE_HASH_SIZE 16384
#endif
/* Not only is it improbable that the 32-bit spaces might actually use 2^32
* defined options, it is infeasible. It would be best for this kind of
* space to be dynamically sized. Instead we size it at the word hash's
* level.
*/
#if !defined (QUAD_NAME_HASH_SIZE)
# define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
#endif
#if !defined (QUAD_CODE_HASH_SIZE)
# define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
#endif
#if !defined (DNS_HASH_SIZE)
# define DNS_HASH_SIZE 0 /* Default. */
#endif
/* Default size to use for name/code hashes on user-defined option spaces. */
#if !defined (DEFAULT_SPACE_HASH_SIZE)
# define DEFAULT_SPACE_HASH_SIZE 11
#endif
#if !defined (NWIP_HASH_SIZE)
# define NWIP_HASH_SIZE 17 /* A really small table. */
#endif
#if !defined (FQDN_HASH_SIZE)
# define FQDN_HASH_SIZE 13 /* A ridiculously small table. */
#endif
/* I really doubt a given installation is going to have more than a few
* hundred vendors involved.
*/
#if !defined (VIVCO_HASH_SIZE)
# define VIVCO_HASH_SIZE 127
#endif
#if !defined (VIVSO_HASH_SIZE)
# define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
#endif
#if !defined (VSIO_HASH_SIZE)
# define VSIO_HASH_SIZE VIVCO_HASH_SIZE
#endif
#if !defined (VIV_ISC_HASH_SIZE)
# define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */
#endif
#if !defined (UNIVERSE_HASH_SIZE)
# define UNIVERSE_HASH_SIZE 13 /* A really small table. */
#endif
#if !defined (GROUP_HASH_SIZE)
# define GROUP_HASH_SIZE 0 /* Default. */
#endif
/* At least one person has indicated they use ~20k host records.
*/
#if !defined (HOST_HASH_SIZE)
# define HOST_HASH_SIZE 22501
#endif
/* We have user reports of use of ISC DHCP numbering leases in the 200k's.
*
* We also have reports of folks using 10.0/8 as a dynamic range. The
* following is something of a compromise between the two. At the ~2-3
* hundred thousand leases, there's ~2-3 leases to search in each bucket.
*/
#if !defined (LEASE_HASH_SIZE)
# define LEASE_HASH_SIZE 100003
#endif
/* It is not known what the worst case subclass hash size is. We estimate
* high, I think.
*/
#if !defined (SCLASS_HASH_SIZE)
# define SCLASS_HASH_SIZE 12007
#endif
#if !defined (AGENT_HASH_SIZE)
# define AGENT_HASH_SIZE 11 /* A really small table. */
#endif
/* The server hash size is used for both names and codes. There aren't
* many (roughly 50 at the moment), so we use a smaller table. If we
* use a 1:1 table size, then we get name collisions due to poor name
* hashing. So we use double the space we need, which drastically
* reduces collisions.
*/
#if !defined (SERVER_HASH_SIZE)
# define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option)))
#endif
/* How many options are likely to appear in a single packet? */
#if !defined (OPTION_HASH_SIZE)
# define OPTION_HASH_SIZE 17
# define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */
# define OPTION_HASH_EXP 5 /* The exponent for that power of two. */
#endif
#define compute_option_hash(x) \
(((x) & (OPTION_HASH_PTWO - 1)) + \
(((x) >> OPTION_HASH_EXP) & \
(OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
enum dhcp_shutdown_state {
shutdown_listeners,
shutdown_omapi_connections,
shutdown_drop_omapi_connections,
shutdown_dhcp,
shutdown_done
};
/* Client FQDN option, failover FQDN option, etc. */
typedef struct {
u_int8_t codes [2];
unsigned length;
u_int8_t *data;
} ddns_fqdn_t;
#include "failover.h"
/* A parsing context. */
struct parse {
int lexline;
int lexchar;
char *token_line;
char *prev_line;
char *cur_line;
const char *tlname;
int eol_token;
/*
* In order to give nice output when we have a parsing error
* in our file, we keep track of where we are in the line so
* that we can show the user.
*
* We need to keep track of two lines, because we can look
* ahead, via the "peek" function, to the next line sometimes.
*
* The "line1" and "line2" variables act as buffers for this
* information. The "lpos" variable tells us where we are in the
* line.
*
* When we "put back" a character from the parsing context, we
* do not want to have the character appear twice in the error
* output. So, we set a flag, the "ugflag", which the
* get_char() function uses to check for this condition.
*/
char line1 [81];
char line2 [81];
int lpos;
int line;
int tlpos;
int tline;
enum dhcp_token token;
int ugflag;
char *tval;
int tlen;
char tokbuf [1500];
int warnings_occurred;
int file;
char *inbuf;
size_t bufix, buflen;
size_t bufsiz;
struct parse *saved_state;
#if defined(LDAP_CONFIGURATION)
/*
* LDAP configuration uses a call-back to iteratively read config
* off of the LDAP repository.
* XXX: The token stream can not be rewound reliably, so this must
* be addressed for DHCPv6 support.
*/
int (*read_function)(struct parse *);
#endif
};
/* Variable-length array of data. */
struct string_list {
struct string_list *next;
char string [1];
};
/* A name server, from /etc/resolv.conf. */
struct name_server {
struct name_server *next;
struct sockaddr_in addr;
TIME rcdate;
};
/* A domain search list element. */
struct domain_search_list {
struct domain_search_list *next;
char *domain;
TIME rcdate;
};
/* Option tag structures are used to build chains of option tags, for
when we're sure we're not going to have enough of them to justify
maintaining an array. */
struct option_tag {
struct option_tag *next;
u_int8_t data [1];
};
/* An agent option structure. We need a special structure for the
Relay Agent Information option because if more than one appears in
a message, we have to keep them separate. */
struct agent_options {
struct agent_options *next;
int length;
struct option_tag *first;
};
struct option_cache {
int refcnt;
struct option_cache *next;
struct expression *expression;
struct option *option;
struct data_string data;
#define OPTION_HAD_NULLS 0x00000001
u_int32_t flags;
};
struct option_state {
int refcnt;
int universe_count;
int site_universe;
int site_code_min;
void *universes [1];
};
/* A dhcp packet and the pointers to its option values. */
struct packet {
struct dhcp_packet *raw;
int refcnt;
unsigned packet_length;
int packet_type;
unsigned char dhcpv6_msg_type; /* DHCPv6 message type */
/* DHCPv6 transaction ID */
unsigned char dhcpv6_transaction_id[3];
/* DHCPv6 relay information */
unsigned char dhcpv6_hop_count;
struct in6_addr dhcpv6_link_address;
struct in6_addr dhcpv6_peer_address;
/* DHCPv6 packet containing this one, or NULL if none */
struct packet *dhcpv6_container_packet;
int options_valid;
int client_port;
struct iaddr client_addr;
struct interface_info *interface; /* Interface on which packet
was received. */
struct hardware *haddr; /* Physical link address
of local sender (maybe gateway). */
/* Information for relay agent options (see
draft-ietf-dhc-agent-options-xx.txt). */
u_int8_t *circuit_id; /* Circuit ID of client connection. */
int circuit_id_len;
u_int8_t *remote_id; /* Remote ID of client. */
int remote_id_len;
int got_requested_address; /* True if client sent the
dhcp-requested-address option. */
struct shared_network *shared_network;
struct option_state *options;
#if !defined (PACKET_MAX_CLASSES)
# define PACKET_MAX_CLASSES 5
#endif
int class_count;
struct class *classes [PACKET_MAX_CLASSES];
int known;
int authenticated;
/* If we stash agent options onto the packet option state, to pretend
* options we got in a previous exchange were still there, we need
* to signal this in a reliable way.
*/
isc_boolean_t agent_options_stashed;
/*
* ISC_TRUE if packet received unicast (as opposed to multicast).
* Only used in DHCPv6.
*/
isc_boolean_t unicast;
};
/* A network interface's MAC address. */
struct hardware {
u_int8_t hlen;
u_int8_t hbuf [17];
};
#if defined(LDAP_CONFIGURATION)
# define LDAP_BUFFER_SIZE 8192
# define LDAP_METHOD_STATIC 0
# define LDAP_METHOD_DYNAMIC 1
#if defined (LDAP_USE_SSL)
# define LDAP_SSL_OFF 0
# define LDAP_SSL_ON 1
# define LDAP_SSL_TLS 2
# define LDAP_SSL_LDAPS 3
#endif
/* This is a tree of the current configuration we are building from LDAP */
struct ldap_config_stack {
LDAPMessage * res; /* Pointer returned from ldap_search */
LDAPMessage * ldent; /* Current item in LDAP that we're processing.
in res */
int close_brace; /* Put a closing } after we're through with
this item */
int processed; /* We set this flag if this base item has been
processed. After this base item is processed,
we can start processing the children */
struct ldap_config_stack *children;
struct ldap_config_stack *next;
};
#endif
typedef enum {
server_startup = 0,
server_running = 1,
server_shutdown = 2,
server_hibernate = 3,
server_awaken = 4
} control_object_state_t;
typedef struct {
OMAPI_OBJECT_PREAMBLE;
control_object_state_t state;
} dhcp_control_object_t;
/* Lease states: */
#define FTS_FREE 1
#define FTS_ACTIVE 2
#define FTS_EXPIRED 3
#define FTS_RELEASED 4
#define FTS_ABANDONED 5
#define FTS_RESET 6
#define FTS_BACKUP 7
typedef u_int8_t binding_state_t;
/* FTS_LAST is the highest value that is valid for a lease binding state. */
#define FTS_LAST FTS_BACKUP
/* An A+P structure, [pset]*/
struct iaddr_pset{
struct iaddr ip_addr;//original ipv4 address
u_int16_t pset_index; //port-set index
u_int16_t pset_mask; //pset
};
/* A dhcp lease declaration structure. */
struct lease {
OMAPI_OBJECT_PREAMBLE;
struct lease *next;
struct lease *n_uid, *n_hw;
struct packet *decoded_packet;
struct iaddr ip_addr;
struct iaddr_pset ip_pset;//[pset]
TIME starts, ends, sort_time;
char *client_hostname;
struct binding_scope *scope;
struct host_decl *host;
struct subnet *subnet;
struct pool *pool;
struct class *billing_class;
struct option_chain_head *agent_options;
struct executable_statement *on_expiry;
struct executable_statement *on_commit;
struct executable_statement *on_release;
unsigned char *uid;
unsigned short uid_len;
unsigned short uid_max;
unsigned char uid_buf [7];
struct hardware hardware_addr;
u_int8_t flags;
# define STATIC_LEASE 1
# define BOOTP_LEASE 2
# define RESERVED_LEASE 4
# define MS_NULL_TERMINATION 8
# define ON_UPDATE_QUEUE 16
# define ON_ACK_QUEUE 32
# define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE)
# define UNICAST_BROADCAST_HACK 64
# define ON_DEFERRED_QUEUE 128
/* Persistent flags are to be preserved on a given lease structure. */
# define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
/* Ephemeral flags are to be preserved on a given lease (copied etc). */
# define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
UNICAST_BROADCAST_HACK | \
RESERVED_LEASE | \
BOOTP_LEASE)
/*
* The lease's binding state is its current state. The next binding
* state is the next state this lease will move into by expiration,
* or timers in general. The desired binding state is used on lease
* updates; the caller is attempting to move the lease to the desired
* binding state (and this may either succeed or fail, so the binding
* state must be preserved).
*
* The 'rewind' binding state is used in failover processing. It
* is used for an optimization when out of communications; it allows
* the server to "rewind" a lease to the previous state acknowledged
* by the peer, and progress forward from that point.
*/
binding_state_t binding_state;
binding_state_t next_binding_state;
binding_state_t desired_binding_state;
binding_state_t rewind_binding_state;
struct lease_state *state;
/*
* 'tsfp' is more of an 'effective' tsfp. It may be calculated from
* stos+mclt for example if it's an expired lease and the server is
* in partner-down state. 'atsfp' is zeroed whenever a lease is
* updated - and only set when the peer acknowledges it. This
* ensures every state change is transmitted.
*/
TIME tstp; /* Time sent to partner. */
TIME tsfp; /* Time sent from partner. */
TIME atsfp; /* Actual time sent from partner. */
TIME cltt; /* Client last transaction time. */
u_int32_t last_xid; /* XID we sent in this lease's BNDUPD */
struct lease *next_pending;
/*
* A pointer to the state of the ddns update for this lease.
* It should be set while the update is in progress and cleared
* when the update finishes. It can be used to cancel the
* update if we want to do a different update.
*/
struct dhcp_ddns_cb *ddns_cb;
};
struct lease_state {
struct lease_state *next;
struct interface_info *ip;
struct packet *packet; /* The incoming packet. */
TIME offered_expiry;
struct option_state *options;
struct data_string parameter_request_list;
int max_message_size;
unsigned char expiry[4], renewal[4], rebind[4];
struct data_string filename, server_name;
int got_requested_address;
int got_server_identifier;
struct shared_network *shared_network; /* Shared network of interface
on which request arrived. */
u_int32_t xid;
u_int16_t secs;
u_int16_t bootp_flags;
struct in_addr ciaddr;
struct in_addr siaddr;
struct in_addr giaddr;
u_int8_t hops;
u_int8_t offer;
struct iaddr from;
};
#define ROOT_GROUP 0
#define HOST_DECL 1
#define SHARED_NET_DECL 2
#define SUBNET_DECL 3
#define CLASS_DECL 4
#define GROUP_DECL 5
#define POOL_DECL 6
/* Possible modes in which discover_interfaces can run. */
#define DISCOVER_RUNNING 0
#define DISCOVER_SERVER 1
#define DISCOVER_UNCONFIGURED 2
#define DISCOVER_RELAY 3
#define DISCOVER_REQUESTED 4
/* DDNS_UPDATE_STYLE enumerations. */
#define DDNS_UPDATE_STYLE_NONE 0
#define DDNS_UPDATE_STYLE_AD_HOC 1
#define DDNS_UPDATE_STYLE_INTERIM 2
/* Server option names. */
#define SV_DEFAULT_LEASE_TIME 1
#define SV_MAX_LEASE_TIME 2
#define SV_MIN_LEASE_TIME 3
#define SV_BOOTP_LEASE_CUTOFF 4
#define SV_BOOTP_LEASE_LENGTH 5
#define SV_BOOT_UNKNOWN_CLIENTS 6
#define SV_DYNAMIC_BOOTP 7
#define SV_ALLOW_BOOTP 8
#define SV_ALLOW_BOOTING 9
#define SV_ONE_LEASE_PER_CLIENT 10
#define SV_GET_LEASE_HOSTNAMES 11
#define SV_USE_HOST_DECL_NAMES 12
#define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
#define SV_MIN_SECS 14
#define SV_FILENAME 15
#define SV_SERVER_NAME 16
#define SV_NEXT_SERVER 17
#define SV_AUTHORITATIVE 18
#define SV_VENDOR_OPTION_SPACE 19
#define SV_ALWAYS_REPLY_RFC1048 20
#define SV_SITE_OPTION_SPACE 21
#define SV_ALWAYS_BROADCAST 22
#define SV_DDNS_DOMAIN_NAME 23
#define SV_DDNS_HOST_NAME 24
#define SV_DDNS_REV_DOMAIN_NAME 25
#define SV_LEASE_FILE_NAME 26
#define SV_PID_FILE_NAME 27
#define SV_DUPLICATES 28
#define SV_DECLINES 29
#define SV_DDNS_UPDATES 30
#define SV_OMAPI_PORT 31
#define SV_LOCAL_PORT 32
#define SV_LIMITED_BROADCAST_ADDRESS 33
#define SV_REMOTE_PORT 34
#define SV_LOCAL_ADDRESS 35
#define SV_OMAPI_KEY 36
#define SV_STASH_AGENT_OPTIONS 37
#define SV_DDNS_TTL 38
#define SV_DDNS_UPDATE_STYLE 39
#define SV_CLIENT_UPDATES 40
#define SV_UPDATE_OPTIMIZATION 41
#define SV_PING_CHECKS 42
#define SV_UPDATE_STATIC_LEASES 43
#define SV_LOG_FACILITY 44
#define SV_DO_FORWARD_UPDATES 45
#define SV_PING_TIMEOUT 46
#define SV_RESERVE_INFINITE 47
#define SV_DDNS_CONFLICT_DETECT 48
#define SV_LEASEQUERY 49
#define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
#define SV_DO_REVERSE_UPDATES 51
#define SV_FQDN_REPLY 52
#define SV_PREFER_LIFETIME 53
#define SV_DHCPV6_LEASE_FILE_NAME 54
#define SV_DHCPV6_PID_FILE_NAME 55
#define SV_LIMIT_ADDRS_PER_IA 56
#define SV_LIMIT_PREFS_PER_IA 57
#define SV_DELAYED_ACK 58
#define SV_MAX_ACK_DELAY 59
#if defined(LDAP_CONFIGURATION)
# define SV_LDAP_SERVER 60
# define SV_LDAP_PORT 61
# define SV_LDAP_USERNAME 62
# define SV_LDAP_PASSWORD 63
# define SV_LDAP_BASE_DN 64
# define SV_LDAP_METHOD 65
# define SV_LDAP_DEBUG_FILE 66
# define SV_LDAP_DHCP_SERVER_CN 67
# define SV_LDAP_REFERRALS 68
#if defined (LDAP_USE_SSL)
# define SV_LDAP_SSL 69
# define SV_LDAP_TLS_REQCERT 70
# define SV_LDAP_TLS_CA_FILE 71
# define SV_LDAP_TLS_CA_DIR 72
# define SV_LDAP_TLS_CERT 73
# define SV_LDAP_TLS_KEY 74
# define SV_LDAP_TLS_CRLCHECK 75
# define SV_LDAP_TLS_CIPHERS 76
# define SV_LDAP_TLS_RANDFILE 77
#endif
#endif
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
#endif
#if !defined (DEFAULT_DELAYED_ACK)
# define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */
#endif
#if !defined (DEFAULT_ACK_DELAY_SECS)
# define DEFAULT_ACK_DELAY_SECS 0
#endif
#if !defined (DEFAULT_ACK_DELAY_USECS)
# define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
#endif
#if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
# define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */
#endif
#if defined(LDAP_CONFIGURATION)
# define SV_LDAP_SERVER 60
# define SV_LDAP_PORT 61
# define SV_LDAP_USERNAME 62
# define SV_LDAP_PASSWORD 63
# define SV_LDAP_BASE_DN 64
# define SV_LDAP_METHOD 65
# define SV_LDAP_DEBUG_FILE 66
# define SV_LDAP_DHCP_SERVER_CN 67
# define SV_LDAP_REFERRALS 68
#if defined (LDAP_USE_SSL)
# define SV_LDAP_SSL 69
# define SV_LDAP_TLS_REQCERT 70
# define SV_LDAP_TLS_CA_FILE 71
# define SV_LDAP_TLS_CA_DIR 72
# define SV_LDAP_TLS_CERT 73
# define SV_LDAP_TLS_KEY 74
# define SV_LDAP_TLS_CRLCHECK 75
# define SV_LDAP_TLS_CIPHERS 76
# define SV_LDAP_TLS_RANDFILE 77
#endif
#endif
#if !defined (DEFAULT_DEFAULT_LEASE_TIME)
# define DEFAULT_DEFAULT_LEASE_TIME 43200
#endif
#if !defined (DEFAULT_MIN_LEASE_TIME)
# define DEFAULT_MIN_LEASE_TIME 300
#endif
#if !defined (DEFAULT_MAX_LEASE_TIME)
# define DEFAULT_MAX_LEASE_TIME 86400
#endif
#if !defined (DEFAULT_DDNS_TTL)
# define DEFAULT_DDNS_TTL 3600
#endif
#if !defined (MAX_DEFAULT_DDNS_TTL)
# define MAX_DEFAULT_DDNS_TTL 3600
#endif
#if !defined (MIN_LEASE_WRITE)
# define MIN_LEASE_WRITE 15
#endif
/* Client option names */
#define CL_TIMEOUT 1
#define CL_SELECT_INTERVAL 2
#define CL_REBOOT_TIMEOUT 3
#define CL_RETRY_INTERVAL 4
#define CL_BACKOFF_CUTOFF 5
#define CL_INITIAL_INTERVAL 6
#define CL_BOOTP_POLICY 7
#define CL_SCRIPT_NAME 8
#define CL_REQUESTED_OPTIONS 9
#define CL_REQUESTED_LEASE_TIME 10
#define CL_SEND_OPTIONS 11
#define CL_MEDIA 12
#define CL_REJECT_LIST 13
#ifndef CL_DEFAULT_TIMEOUT
# define CL_DEFAULT_TIMEOUT 60
#endif
#ifndef CL_DEFAULT_SELECT_INTERVAL
# define CL_DEFAULT_SELECT_INTERVAL 0
#endif
#ifndef CL_DEFAULT_REBOOT_TIMEOUT
# define CL_DEFAULT_REBOOT_TIMEOUT 10
#endif
#ifndef CL_DEFAULT_RETRY_INTERVAL
# define CL_DEFAULT_RETRY_INTERVAL 300
#endif
#ifndef CL_DEFAULT_BACKOFF_CUTOFF
# define CL_DEFAULT_BACKOFF_CUTOFF 120
#endif
#ifndef CL_DEFAULT_INITIAL_INTERVAL
# define CL_DEFAULT_INITIAL_INTERVAL 10
#endif
#ifndef CL_DEFAULT_BOOTP_POLICY
# define CL_DEFAULT_BOOTP_POLICY P_ACCEPT
#endif
#ifndef CL_DEFAULT_REQUESTED_OPTIONS
# define CL_DEFAULT_REQUESTED_OPTIONS \
{ DHO_SUBNET_MASK, \
DHO_BROADCAST_ADDRESS, \
DHO_TIME_OFFSET, \
DHO_ROUTERS, \
DHO_DOMAIN_NAME, \
DHO_DOMAIN_NAME_SERVERS, \
DHO_HOST_NAME }
#endif
struct group_object {
OMAPI_OBJECT_PREAMBLE;
struct group_object *n_dynamic;
struct group *group;
char *name;
int flags;
#define GROUP_OBJECT_DELETED 1
#define GROUP_OBJECT_DYNAMIC 2
#define GROUP_OBJECT_STATIC 4
};
/* Group of declarations that share common parameters. */
struct group {
struct group *next;
int refcnt;
struct group_object *object;
struct subnet *subnet;
struct shared_network *shared_network;
int authoritative;
struct executable_statement *statements;
};
/* A dhcp host declaration structure. */
struct host_decl {
OMAPI_OBJECT_PREAMBLE;
struct host_decl *n_ipaddr;
struct host_decl *n_dynamic;
char *name;
struct hardware interface;
struct data_string client_identifier;
struct option *host_id_option;
struct data_string host_id;
/* XXXSK: fixed_addr should be an array of iaddr values,
not an option_cache, but it's referenced in a lot of
places, so we'll leave it for now. */
struct option_cache *fixed_addr;
struct iaddrcidrnetlist *fixed_prefix;
struct group *group;
struct group_object *named_group;
struct data_string auth_key_id;
int flags;
#define HOST_DECL_DELETED 1
#define HOST_DECL_DYNAMIC 2
#define HOST_DECL_STATIC 4
};
struct permit {
struct permit *next;
enum {
permit_unknown_clients,
permit_known_clients,
permit_authenticated_clients,
permit_unauthenticated_clients,
permit_all_clients,
permit_dynamic_bootp_clients,
permit_class,
permit_after
} type;
struct class *class;
TIME after; /* date after which this clause applies */
};
struct pool {
OMAPI_OBJECT_PREAMBLE;
struct pool *next;
struct group *group;
struct shared_network *shared_network;
struct permit *permit_list;
struct permit *prohibit_list;
struct lease *active;
struct lease *expired;
struct lease *free;
struct lease *backup;
struct lease *abandoned;
struct lease *reserved;
TIME next_event_time;
int lease_count;
int free_leases;
int backup_leases;
int index;
TIME valid_from; /* deny pool use before this date */
TIME valid_until; /* deny pool use after this date */
#if defined (FAILOVER_PROTOCOL)
dhcp_failover_state_t *failover_peer;
#endif
};
struct shared_network {
OMAPI_OBJECT_PREAMBLE;
struct shared_network *next;
char *name;
#define SHARED_IMPLICIT 1 /* This network was synthesized. */
int flags;
struct subnet *subnets;
struct interface_info *interface;
struct pool *pools;
struct ipv6_pool **ipv6_pools; /* NULL-terminated array */
int last_ipv6_pool; /* offset of last IPv6 pool
used to issue a lease */
struct group *group;
#if defined (FAILOVER_PROTOCOL)
dhcp_failover_state_t *failover_peer;
#endif
};
struct subnet {
OMAPI_OBJECT_PREAMBLE;
struct subnet *next_subnet;
struct subnet *next_sibling;
struct shared_network *shared_network;
struct interface_info *interface;
struct iaddr interface_address;
struct iaddr net;
struct iaddr netmask;
int prefix_len; /* XXX: currently for IPv6 only */
struct group *group;
};
struct collection {
struct collection *next;
const char *name;
struct class *classes;
};
/* Used as an argument to parse_clasS_decl() */
#define CLASS_TYPE_VENDOR 0
#define CLASS_TYPE_USER 1
#define CLASS_TYPE_CLASS 2
#define CLASS_TYPE_SUBCLASS 3
/* XXX classes must be reference-counted. */
struct class {
OMAPI_OBJECT_PREAMBLE;
struct class *nic; /* Next in collection. */
struct class *superclass; /* Set for spawned classes only. */
char *name; /* Not set for spawned classes. */
/* A class may be configured to permit a limited number of leases. */
int lease_limit;
int leases_consumed;
struct lease **billed_leases;
/* If nonzero, class has not been saved since it was last
modified. */
int dirty;
/* Hash table containing subclasses. */