Annotation of embedaddon/dhcp/includes/tree.h, revision 1.1

1.1     ! misho       1: /* tree.h
        !             2: 
        !             3:    Definitions for address trees... */
        !             4: 
        !             5: /*
        !             6:  * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
        !             7:  * Copyright (c) 2004,2007-2009 by Internet Systems Consortium, Inc. ("ISC")
        !             8:  * Copyright (c) 1996-2003 by Internet Software Consortium
        !             9:  *
        !            10:  * Permission to use, copy, modify, and distribute this software for any
        !            11:  * purpose with or without fee is hereby granted, provided that the above
        !            12:  * copyright notice and this permission notice appear in all copies.
        !            13:  *
        !            14:  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
        !            15:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            16:  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
        !            17:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            18:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            19:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
        !            20:  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            21:  *
        !            22:  *   Internet Systems Consortium, Inc.
        !            23:  *   950 Charter Street
        !            24:  *   Redwood City, CA 94063
        !            25:  *   <info@isc.org>
        !            26:  *   https://www.isc.org/
        !            27:  *
        !            28:  * This software has been written for Internet Systems Consortium
        !            29:  * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
        !            30:  * To learn more about Internet Systems Consortium, see
        !            31:  * ``https://www.isc.org/''.  To learn more about Vixie Enterprises,
        !            32:  * see ``http://www.vix.com''.   To learn more about Nominum, Inc., see
        !            33:  * ``http://www.nominum.com''.
        !            34:  */
        !            35: 
        !            36: /* A pair of pointers, suitable for making a linked list. */
        !            37: typedef struct _pair {
        !            38:        caddr_t car;
        !            39:        struct _pair *cdr;
        !            40: } *pair;
        !            41: 
        !            42: struct option_chain_head {
        !            43:        int refcnt;
        !            44:        pair first;
        !            45: };
        !            46: 
        !            47: struct enumeration_value {
        !            48:        const char *name;
        !            49:        u_int8_t value;
        !            50: };
        !            51: 
        !            52: struct enumeration {
        !            53:        struct enumeration *next;
        !            54:        const char *name;
        !            55:        unsigned width;
        !            56:        struct enumeration_value *values;
        !            57: };     
        !            58: 
        !            59: /* Tree node types... */
        !            60: #define TREE_CONCAT            1
        !            61: #define TREE_HOST_LOOKUP       2
        !            62: #define TREE_CONST             3
        !            63: #define TREE_LIMIT             4
        !            64: #define TREE_DATA_EXPR         5
        !            65: 
        !            66: /* A data buffer with a reference count. */
        !            67: struct buffer {
        !            68:        int refcnt;
        !            69:        unsigned char data [1];
        !            70: };
        !            71: 
        !            72: /* XXX The mechanism by which data strings are returned is currently
        !            73:    XXX broken: rather than returning an ephemeral pointer, we create
        !            74:    XXX a reference to the data in the caller's space, which the caller
        !            75:    XXX then has to dereference - instead, the reference should be
        !            76:    XXX ephemeral by default and be made a persistent reference explicitly. */
        !            77: /* XXX on the other hand, it seems to work pretty nicely, so maybe the
        !            78:    XXX above comment is meshuggenah. */
        !            79: /* XXX I think the above comment tries to say this: 
        !            80:    XXX    http://tinyurl.com/2tjqre */
        !            81: 
        !            82: /* A string of data bytes, possibly accompanied by a larger buffer. */
        !            83: struct data_string {
        !            84:        struct buffer *buffer;
        !            85:        const unsigned char *data;
        !            86:        unsigned len;   /* Does not include NUL terminator, if any. */
        !            87:        int terminated;
        !            88: };
        !            89: 
        !            90: enum expression_context {
        !            91:        context_any, /* indefinite */
        !            92:        context_boolean,
        !            93:        context_data,
        !            94:        context_numeric,
        !            95:        context_dns,
        !            96:        context_data_or_numeric, /* indefinite */
        !            97:        context_function
        !            98: };
        !            99: 
        !           100: struct fundef {
        !           101:        int refcnt;
        !           102:        struct string_list *args;
        !           103:        struct executable_statement *statements;
        !           104: };
        !           105: 
        !           106: struct binding_value {
        !           107:        int refcnt;
        !           108:        enum {
        !           109:                binding_boolean,
        !           110:                binding_data,
        !           111:                binding_numeric,
        !           112:                binding_dns,
        !           113:                binding_function
        !           114:        } type;
        !           115:        union value {
        !           116:                struct data_string data;
        !           117:                unsigned long intval;
        !           118:                int boolean;
        !           119: #if defined (NSUPDATE)
        !           120:                ns_updrec *dns;
        !           121: #endif
        !           122:                struct fundef *fundef;
        !           123:                struct binding_value *bv;
        !           124:        } value;
        !           125: };
        !           126: 
        !           127: struct binding {
        !           128:        struct binding *next;
        !           129:        char *name;
        !           130:        struct binding_value *value;
        !           131: };
        !           132: 
        !           133: struct binding_scope {
        !           134:        int refcnt;
        !           135:        struct binding_scope *outer;
        !           136:        struct binding *bindings;
        !           137: };
        !           138: 
        !           139: /* Expression tree structure. */
        !           140: 
        !           141: enum expr_op {
        !           142:        expr_none,
        !           143:        expr_match,
        !           144:        expr_check,
        !           145:        expr_equal,
        !           146:        expr_substring,
        !           147:        expr_suffix,
        !           148:        expr_concat,
        !           149:        expr_host_lookup,
        !           150:        expr_and,
        !           151:        expr_or,
        !           152:        expr_not,
        !           153:        expr_option,
        !           154:        expr_hardware,
        !           155:        expr_packet,
        !           156:        expr_const_data,
        !           157:        expr_extract_int8,
        !           158:        expr_extract_int16,
        !           159:        expr_extract_int32,
        !           160:        expr_encode_int8,
        !           161:        expr_encode_int16,
        !           162:        expr_encode_int32,
        !           163:        expr_const_int,
        !           164:        expr_exists,
        !           165:        expr_encapsulate,
        !           166:        expr_known,
        !           167:        expr_reverse,
        !           168:        expr_leased_address,
        !           169:        expr_binary_to_ascii,
        !           170:        expr_config_option,
        !           171:        expr_host_decl_name,
        !           172:        expr_pick_first_value,
        !           173:        expr_lease_time,
        !           174:        expr_dns_transaction,
        !           175:        expr_static,
        !           176:        expr_ns_add,
        !           177:        expr_ns_delete,
        !           178:        expr_ns_exists,
        !           179:        expr_ns_not_exists,
        !           180:        expr_not_equal,
        !           181:        expr_null,
        !           182:        expr_variable_exists,
        !           183:        expr_variable_reference,
        !           184:        expr_filename,
        !           185:        expr_sname,
        !           186:        expr_arg,
        !           187:        expr_funcall,
        !           188:        expr_function,
        !           189:        expr_add,
        !           190:        expr_subtract,
        !           191:        expr_multiply,
        !           192:        expr_divide,
        !           193:        expr_remainder,
        !           194:        expr_binary_and,
        !           195:        expr_binary_or,
        !           196:        expr_binary_xor,
        !           197:        expr_client_state,
        !           198:        expr_ucase,
        !           199:        expr_lcase,
        !           200:        expr_regex_match,
        !           201:        expr_iregex_match
        !           202: };
        !           203: 
        !           204: struct expression {
        !           205:        int refcnt;
        !           206:        enum expr_op op;
        !           207:        union expr_union {
        !           208:                struct {
        !           209:                        struct expression *expr;
        !           210:                        struct expression *offset;
        !           211:                        struct expression *len;
        !           212:                } substring;
        !           213:                struct expression *equal [2];
        !           214:                struct expression *and [2];
        !           215:                struct expression *or [2];
        !           216:                struct expression *not;
        !           217:                struct expression *add;
        !           218:                struct expression *subtract;
        !           219:                struct expression *multiply;
        !           220:                struct expression *divide;
        !           221:                struct expression *remainder;
        !           222:                struct collection *check;
        !           223:                struct {
        !           224:                        struct expression *expr;
        !           225:                        struct expression *len;
        !           226:                } suffix;
        !           227:                struct expression *lcase;
        !           228:                struct expression *ucase;
        !           229:                struct option *option;
        !           230:                struct option *config_option;
        !           231:                struct {
        !           232:                        struct expression *offset;
        !           233:                        struct expression *len;
        !           234:                } packet;
        !           235:                struct data_string const_data;
        !           236:                struct expression *extract_int;
        !           237:                struct expression *encode_int;
        !           238:                unsigned long const_int;
        !           239:                struct expression *concat [2];
        !           240:                struct dns_host_entry *host_lookup;
        !           241:                struct option *exists;
        !           242:                struct data_string encapsulate;
        !           243:                struct {
        !           244:                        struct expression *base;
        !           245:                        struct expression *width;
        !           246:                        struct expression *separator;
        !           247:                        struct expression *buffer;
        !           248:                } b2a;
        !           249:                struct {
        !           250:                        struct expression *width;
        !           251:                        struct expression *buffer;
        !           252:                } reverse;
        !           253:                struct {
        !           254:                        struct expression *car;
        !           255:                        struct expression *cdr;
        !           256:                } pick_first_value;
        !           257:                struct {
        !           258:                        struct expression *car;
        !           259:                        struct expression *cdr;
        !           260:                } dns_transaction;
        !           261:                struct {
        !           262:                        unsigned rrclass;
        !           263:                        unsigned rrtype;
        !           264:                        struct expression *rrname;
        !           265:                        struct expression *rrdata;
        !           266:                        struct expression *ttl;
        !           267:                } ns_add;
        !           268:                struct {
        !           269:                        unsigned rrclass;
        !           270:                        unsigned rrtype;
        !           271:                        struct expression *rrname;
        !           272:                        struct expression *rrdata;
        !           273:                } ns_delete, ns_exists, ns_not_exists;
        !           274:                char *variable;
        !           275:                struct {
        !           276:                        struct expression *val;
        !           277:                        struct expression *next;
        !           278:                } arg;
        !           279:                struct {
        !           280:                        char *name;
        !           281:                        struct expression *arglist;
        !           282:                } funcall;
        !           283:                struct fundef *func;
        !           284:        } data;
        !           285:        int flags;
        !           286: #      define EXPR_EPHEMERAL   1
        !           287: };             
        !           288: 
        !           289: /* DNS host entry structure... */
        !           290: struct dns_host_entry {
        !           291:        int refcnt;
        !           292:        TIME timeout;
        !           293:        struct data_string data;
        !           294:        char hostname [1];
        !           295: };
        !           296: 
        !           297: struct option_cache; /* forward */
        !           298: struct packet; /* forward */
        !           299: struct option_state; /* forward */
        !           300: struct decoded_option_state; /* forward */
        !           301: struct lease; /* forward */
        !           302: struct client_state; /* forward */
        !           303: 
        !           304: struct universe {
        !           305:        const char *name;
        !           306:        struct option_cache *(*lookup_func) (struct universe *,
        !           307:                                             struct option_state *,
        !           308:                                             unsigned);
        !           309:        void (*save_func) (struct universe *, struct option_state *,
        !           310:                           struct option_cache *, isc_boolean_t);
        !           311:        void (*foreach) (struct packet *,
        !           312:                         struct lease *, struct client_state *,
        !           313:                         struct option_state *, struct option_state *,
        !           314:                         struct binding_scope **, struct universe *, void *,
        !           315:                         void (*) (struct option_cache *, struct packet *,
        !           316:                                   struct lease *, struct client_state *,
        !           317:                                   struct option_state *,
        !           318:                                   struct option_state *,
        !           319:                                   struct binding_scope **,
        !           320:                                   struct universe *, void *));
        !           321:        void (*delete_func) (struct universe *universe,
        !           322:                             struct option_state *, int);
        !           323:        int (*option_state_dereference) (struct universe *,
        !           324:                                         struct option_state *,
        !           325:                                         const char *, int);
        !           326:        int (*decode) (struct option_state *,
        !           327:                       const unsigned char *, unsigned, struct universe *);
        !           328:        int (*encapsulate) (struct data_string *, struct packet *,
        !           329:                            struct lease *, struct client_state *,
        !           330:                            struct option_state *, struct option_state *,
        !           331:                            struct binding_scope **,
        !           332:                            struct universe *);
        !           333:        u_int32_t (*get_tag) (const unsigned char *);
        !           334:        void (*store_tag) (unsigned char *, u_int32_t);
        !           335:        u_int32_t (*get_length) (const unsigned char *);
        !           336:        void (*store_length) (unsigned char *, u_int32_t);
        !           337:        int tag_size, length_size;
        !           338:        unsigned site_code_min, end;
        !           339:        option_name_hash_t *name_hash;
        !           340:        option_code_hash_t *code_hash;
        !           341:        struct option *enc_opt;
        !           342:        int index;
        !           343: 
        !           344:        /* Flags should probably become condensed. */
        !           345:        int concat_duplicates;
        !           346: };
        !           347: 
        !           348: struct option {
        !           349:        const char *name;
        !           350:        const char *format;
        !           351:        struct universe *universe;
        !           352:        unsigned code;
        !           353:        int refcnt;
        !           354: };

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