Annotation of embedaddon/dhcp/includes/dhcpd.h, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>