diff options
author | David Hankins <dhankins@isc.org> | 2006-06-01 20:23:18 +0000 |
---|---|---|
committer | David Hankins <dhankins@isc.org> | 2006-06-01 20:23:18 +0000 |
commit | f7fdb21693ec2f2ef44d8e8bebc4609e4d7b67c7 (patch) | |
tree | 32c2431210e7b34feaf85d66f714ce928655a48d /includes | |
parent | ee912528163bb70b3c0de65608f9d05fff03044d (diff) | |
download | isc-dhcp-f7fdb21693ec2f2ef44d8e8bebc4609e4d7b67c7.tar.gz |
- Varying option space code and length bit widths (8/16/32) are now
supported. This is a milestone in acheiving RFC 3925 "VIVSO" and
DHCPv6 support. [ISC-Bugs #15979]
Diffstat (limited to 'includes')
-rw-r--r-- | includes/dhcp.h | 5 | ||||
-rw-r--r-- | includes/dhcpd.h | 110 | ||||
-rw-r--r-- | includes/dhctoken.h | 4 | ||||
-rw-r--r-- | includes/omapip/hash.h | 53 | ||||
-rw-r--r-- | includes/tree.h | 12 |
5 files changed, 144 insertions, 40 deletions
diff --git a/includes/dhcp.h b/includes/dhcp.h index 38a594ea..cb4ac5ab 100644 --- a/includes/dhcp.h +++ b/includes/dhcp.h @@ -149,6 +149,8 @@ struct dhcp_packet { #define DHO_FQDN 81 #define DHO_DHCP_AGENT_OPTIONS 82 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ +#define DHO_VIVCO_SUBOPTIONS 124 +#define DHO_VIVSO_SUBOPTIONS 125 /* The DHO_AUTHENTICATE option is not a standard yet, so I've allocated an option out of the "local" option space for it on a temporary basis. Once an option code number is assigned, I will @@ -183,3 +185,6 @@ struct dhcp_packet { #define FQDN_DOMAINNAME 7 #define FQDN_FQDN 8 #define FQDN_SUBOPTION_COUNT 8 + +/* Enterprise Suboptions: */ +#define VENDOR_ISC_SUBOPTIONS 2495 diff --git a/includes/dhcpd.h b/includes/dhcpd.h index dc6582cd..a1c36a39 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -64,7 +64,8 @@ struct hash_table; typedef struct hash_table group_hash_t; typedef struct hash_table universe_hash_t; -typedef struct hash_table option_hash_t; +typedef struct hash_table option_name_hash_t; +typedef struct hash_table option_code_hash_t; typedef struct hash_table dns_zone_hash_t; typedef struct hash_table lease_hash_t; typedef struct hash_table host_hash_t; @@ -79,6 +80,86 @@ typedef struct hash_table class_hash_t; #include <isc-dhcp/result.h> #include <omapip/omapip_p.h> +#if !defined (BYTE_NAME_HASH_SIZE) +# define BYTE_NAME_HASH_SIZE 401 /* Default would be rediculous. */ +#endif +#if !defined (BYTE_CODE_HASH_SIZE) +# define BYTE_CODE_HASH_SIZE 254 /* Default would be rediculous. */ +#endif + +#if !defined (WORD_NAME_HASH_SIZE) +# define WORD_NAME_HASH_SIZE 0 /* Default. */ +#endif +#if !defined (WORD_CODE_HASH_SIZE) +# define WORD_CODE_HASH_SIZE 0 /* Default. */ +#endif + +#if !defined (QUAD_NAME_HASH_SIZE) +# define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE +#endif +#if !defined (QUAD_CODE_HASH_SIZE) +# define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE +#endif + +#if !defined (DNS_HASH_SIZE) +# define DNS_HASH_SIZE 0 /* Default. */ +#endif + +/* Default size to use for name/code hashes on user-defined option spaces. */ +#if !defined (DEFAULT_SPACE_HASH_SIZE) +# define DEFAULT_SPACE_HASH_SIZE 11 +#endif + +#if !defined (NWIP_HASH_SIZE) +# define NWIP_HASH_SIZE 11 /* A really small table. */ +#endif + +#if !defined (FQDN_HASH_SIZE) +# define FQDN_HASH_SIZE 7 /* A rediculously small table. */ +#endif + +#if !defined (VIVCO_HASH_SIZE) +# define VIVCO_HASH_SIZE QUAD_CODE_HASH_SIZE +#endif + +#if !defined (VIVSO_HASH_SIZE) +# define VIVSO_HASH_SIZE VIVCO_HASH_SIZE +#endif + +#if !defined (VIV_ISC_HASH_SIZE) +# define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */ +#endif + +#if !defined (UNIVERSE_HASH_SIZE) +# define UNIVERSE_HASH_SIZE 11 /* A really small table. */ +#endif + +#if !defined (GROUP_HASH_SIZE) +# define GROUP_HASH_SIZE 0 /* Default. */ +#endif + +#if !defined (HOST_HASH_SIZE) +# define HOST_HASH_SIZE 0 /* Default. */ +#endif + +#if !defined (LEASE_HASH_SIZE) +# define LEASE_HASH_SIZE 0 /* Default. */ +#endif + +#if !defined (SCLASS_HASH_SIZE) +# define SCLASS_HASH_SIZE 1009 /* A less than gigantic sized table. */ +#endif + +#if !defined (AGENT_HASH_SIZE) +# define AGENT_HASH_SIZE 11 /* A really small table. */ +#endif + +#if !defined (SERVER_HASH_SIZE) +# define SERVER_HASH_SIZE (sizeof(server_options) / sizeof(struct option)) +#endif + + + #if !defined (OPTION_HASH_SIZE) # define OPTION_HASH_SIZE 17 # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */ @@ -997,7 +1078,10 @@ typedef unsigned char option_mask [16]; HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t) HASH_FUNCTIONS_DECL (universe, const char *, struct universe, universe_hash_t) -HASH_FUNCTIONS_DECL (option, const char *, struct option, option_hash_t) +HASH_FUNCTIONS_DECL (option_name, const char *, struct option, + option_name_hash_t) +HASH_FUNCTIONS_DECL (option_code, const unsigned *, struct option, + option_code_hash_t) HASH_FUNCTIONS_DECL (dns_zone, const char *, struct dns_zone, dns_zone_hash_t) HASH_FUNCTIONS_DECL (lease, const unsigned char *, struct lease, lease_hash_t) HASH_FUNCTIONS_DECL (host, const unsigned char *, struct host_decl, host_hash_t) @@ -1044,7 +1128,7 @@ struct option_cache *lookup_hashed_option PROTO ((struct universe *, unsigned)); int save_option_buffer (struct universe *, struct option_state *, struct buffer *, unsigned char *, unsigned, - struct option *, int); + unsigned, int); void save_option PROTO ((struct universe *, struct option_state *, struct option_cache *)); void save_hashed_option PROTO ((struct universe *, @@ -1255,7 +1339,8 @@ unsigned char *parse_numeric_aggregate PROTO ((struct parse *, void convert_num PROTO ((struct parse *, unsigned char *, const char *, int, unsigned)); TIME parse_date PROTO ((struct parse *)); -struct option *parse_option_name PROTO ((struct parse *, int, int *)); +isc_result_t parse_option_name PROTO ((struct parse *, int, int *, + struct option **)); void parse_option_space_decl PROTO ((struct parse *)); int parse_option_code_definition PROTO ((struct parse *, struct option *)); int parse_base64 (struct data_string *, struct parse *); @@ -1494,11 +1579,13 @@ struct lease_state *new_lease_state PROTO ((const char *, int)); struct domain_search_list *new_domain_search_list PROTO ((const char *, int)); struct name_server *new_name_server PROTO ((const char *, int)); void free_name_server PROTO ((struct name_server *, const char *, int)); -struct option *new_option PROTO ((const char *, int)); +struct option *new_option PROTO ((const char *, const char *, int)); +int option_reference(struct option **dest, struct option *src, + const char * file, int line); +int option_dereference(struct option **dest, const char *file, int line); int group_allocate (struct group **, const char *, int); int group_reference (struct group **, struct group *, const char *, int); int group_dereference (struct group **, const char *, int); -void free_option PROTO ((struct option *, const char *, int)); struct universe *new_universe PROTO ((const char *, int)); void free_universe PROTO ((struct universe *, const char *, int)); void free_domain_search_list PROTO ((struct domain_search_list *, @@ -1835,12 +1922,10 @@ OMAPI_OBJECT_ALLOC_DECL (interface, struct interface_info, dhcp_type_interface) /* tables.c */ +extern char *default_option_format; extern struct universe dhcp_universe; -extern struct option dhcp_options [256]; extern struct universe nwip_universe; -extern struct option nwip_options [256]; extern struct universe fqdn_universe; -extern struct option fqdn_options [256]; extern int dhcp_option_default_priority_list []; extern int dhcp_option_default_priority_list_count; extern const char *hardware_types [256]; @@ -1862,9 +1947,7 @@ extern const char *dhcp_flink_state_names []; extern const char *binding_state_names []; extern struct universe agent_universe; -extern struct option agent_options [256]; extern struct universe server_universe; -extern struct option server_options [256]; extern struct enumeration ddns_styles; extern struct enumeration syslog_enum; @@ -1959,8 +2042,7 @@ int write_failover_state (dhcp_failover_state_t *); #endif int db_printable PROTO ((const char *)); int db_printable_len PROTO ((const unsigned char *, unsigned)); -isc_result_t write_named_billing_class(const unsigned char *, unsigned, - void *); +isc_result_t write_named_billing_class(const void *, unsigned, void *); void write_billing_classes (void); int write_billing_class PROTO ((struct class *)); void commit_leases_timeout PROTO ((void *)); @@ -2504,7 +2586,7 @@ void hw_hash_add PROTO ((struct lease *)); void hw_hash_delete PROTO ((struct lease *)); int write_leases PROTO ((void)); int lease_enqueue (struct lease *); -isc_result_t lease_instantiate(const unsigned char *, unsigned, void *); +isc_result_t lease_instantiate(const void *, unsigned, void *); void expire_all_pools PROTO ((void)); void dump_subnets PROTO ((void)); #if defined (DEBUG_MEMORY_LEAKAGE) || \ diff --git a/includes/dhctoken.h b/includes/dhctoken.h index 88bf0264..73a7ff0d 100644 --- a/includes/dhctoken.h +++ b/includes/dhctoken.h @@ -312,6 +312,10 @@ enum dhcp_token { ATSFP = 616, LCASE = 617, UCASE = 618 + WIDTH = 619, + LENGTH = 620, + HASH = 621, + SIZE = 622 }; #define is_identifier(x) ((x) >= FIRST_TOKEN && \ diff --git a/includes/omapip/hash.h b/includes/omapip/hash.h index a194accc..5bda95fa 100644 --- a/includes/omapip/hash.h +++ b/includes/omapip/hash.h @@ -35,15 +35,20 @@ #ifndef OMAPI_HASH_H #define OMAPI_HASH_H -#define DEFAULT_HASH_SIZE 9973 +#if !defined (DEFAULT_HASH_SIZE) +# define DEFAULT_HASH_SIZE 9973 +#endif + +#if !defined (KEY_HASH_SIZE) +# define KEY_HASH_SIZE 1009 +#endif /* The purpose of the hashed_object_t struct is to not match anything else. */ typedef struct { int foo; } hashed_object_t; -typedef isc_result_t (*hash_foreach_func)(const unsigned char *, unsigned, - void *); +typedef isc_result_t (*hash_foreach_func)(const void *, unsigned, void *); typedef int (*hash_reference) (hashed_object_t **, hashed_object_t *, const char *, int); typedef int (*hash_dereference) (hashed_object_t **, const char *, int); @@ -63,7 +68,7 @@ struct hash_table { hash_reference referencer; hash_dereference dereferencer; hash_comparator_t cmp; - int (*do_hash) (const unsigned char *, unsigned, unsigned); + unsigned (*do_hash)(const void *, unsigned, unsigned); }; struct named_hash { @@ -80,26 +85,24 @@ void name##_hash_delete (hashtype *, bufarg, unsigned, \ int name##_hash_lookup (type **, hashtype *, bufarg, unsigned, \ const char *, int); \ int name##_hash_foreach (hashtype *, hash_foreach_func); \ -int name##_new_hash (hashtype **, int, const char *, int); \ +int name##_new_hash (hashtype **, unsigned, const char *, int); \ void name##_free_hash_table (hashtype **, const char *, int); -#define HASH_FUNCTIONS(name, bufarg, type, hashtype, ref, deref) \ +#define HASH_FUNCTIONS(name, bufarg, type, hashtype, ref, deref, hasher) \ void name##_hash_add (hashtype *table, \ bufarg buf, unsigned len, type *ptr, \ const char *file, int line) \ { \ - add_hash ((struct hash_table *)table, \ - (const unsigned char *)buf, \ + add_hash ((struct hash_table *)table, buf, \ len, (hashed_object_t *)ptr, file, line); \ } \ \ -void name##_hash_delete (hashtype *table, \ - bufarg buf, unsigned len, const char *file, int line)\ +void name##_hash_delete (hashtype *table, bufarg buf, unsigned len, \ + const char *file, int line) \ { \ - delete_hash_entry ((struct hash_table *)table, \ - (const unsigned char *)buf, \ - len, file, line); \ + delete_hash_entry ((struct hash_table *)table, buf, len, \ + file, line); \ } \ \ int name##_hash_lookup (type **ptr, hashtype *table, \ @@ -107,7 +110,7 @@ int name##_hash_lookup (type **ptr, hashtype *table, \ { \ return hash_lookup ((hashed_object_t **)ptr, \ (struct hash_table *)table, \ - (const unsigned char *)buf, len, file, line); \ + buf, len, file, line); \ } \ \ int name##_hash_foreach (hashtype *table, hash_foreach_func func) \ @@ -116,11 +119,11 @@ int name##_hash_foreach (hashtype *table, hash_foreach_func func) \ func); \ } \ \ -int name##_new_hash (hashtype **tp, int c, const char *file, int line) \ +int name##_new_hash (hashtype **tp, unsigned c, const char *file, int line) \ { \ return new_hash ((struct hash_table **)tp, \ (hash_reference)ref, (hash_dereference)deref, c, \ - file, line); \ + hasher, file, line); \ } \ \ void name##_free_hash_table (hashtype **table, const char *file, int line) \ @@ -129,19 +132,25 @@ void name##_free_hash_table (hashtype **table, const char *file, int line) \ } void relinquish_hash_bucket_hunks (void); -int new_hash_table (struct hash_table **, int, const char *, int); +int new_hash_table (struct hash_table **, unsigned, const char *, int); void free_hash_table (struct hash_table **, const char *, int); struct hash_bucket *new_hash_bucket (const char *, int); void free_hash_bucket (struct hash_bucket *, const char *, int); -int new_hash (struct hash_table **, - hash_reference, hash_dereference, int, const char *, int); +int new_hash(struct hash_table **, + hash_reference, hash_dereference, unsigned, + unsigned (*do_hash)(const void *, unsigned, unsigned), + const char *, int); +unsigned do_string_hash(const void *, unsigned, unsigned); +unsigned do_case_hash(const void *, unsigned, unsigned); +unsigned do_number_hash(const void *, unsigned, unsigned); +unsigned do_ip4_hash(const void *, unsigned, unsigned); void add_hash (struct hash_table *, - const unsigned char *, unsigned, hashed_object_t *, + const void *, unsigned, hashed_object_t *, const char *, int); -void delete_hash_entry (struct hash_table *, const unsigned char *, +void delete_hash_entry (struct hash_table *, const void *, unsigned, const char *, int); int hash_lookup (hashed_object_t **, struct hash_table *, - const unsigned char *, unsigned, const char *, int); + const void *, unsigned, const char *, int); int hash_foreach (struct hash_table *, hash_foreach_func); int casecmp (const void *s, const void *t, unsigned long len); diff --git a/includes/tree.h b/includes/tree.h index b12bc9ec..e70a6123 100644 --- a/includes/tree.h +++ b/includes/tree.h @@ -324,18 +324,22 @@ struct universe { struct option_state *, struct option_state *, struct binding_scope **, struct universe *); + u_int32_t (*get_tag) (const unsigned char *); void (*store_tag) PROTO ((unsigned char *, u_int32_t)); + u_int32_t (*get_length) (const unsigned char *); void (*store_length) PROTO ((unsigned char *, u_int32_t)); int tag_size, length_size; - option_hash_t *hash; - struct option *options [256]; + unsigned end; + option_name_hash_t *name_hash; + option_code_hash_t *code_hash; struct option *enc_opt; int index; }; struct option { - const char *name; - const char *format; + char *name; + char *format; struct universe *universe; unsigned code; + int refcnt; }; |