ISC DHCP 4.4.3-P1
A reference DHCPv4 and DHCPv6 implementation
 
Loading...
Searching...
No Matches
options.c File Reference
#include "dhcpd.h"
#include <omapip/omapip_p.h>
#include <limits.h>

Go to the source code of this file.

Data Structures

struct  vsio_state
 

Macros

#define DHCP_OPTION_DATA
 
#define PRIORITY_COUNT   300
 
#define MAX_OUTPUT_SIZE   32*1024
 

Functions

int parse_options (struct packet *packet)
 
int parse_option_buffer (struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *universe)
 
struct universefind_option_universe (struct option *eopt, const char *uname)
 
int parse_encapsulated_suboptions (struct option_state *options, struct option *eopt, const unsigned char *buffer, unsigned len, struct universe *eu, const char *uname)
 
int fqdn_universe_decode (struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *u)
 
int cons_options (struct packet *inpacket, struct dhcp_packet *outpacket, struct lease *lease, struct client_state *client_state, int mms, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, int overload_avail, int terminate, int bootpp, struct data_string *prl, const char *vuname)
 
int store_options6 (char *buf, int buflen, struct option_state *opt_state, struct packet *packet, const int *required_opts, struct data_string *oro)
 
int store_options (int *ocount, unsigned char *buffer, unsigned index, unsigned buflen, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, unsigned *priority_list, int priority_len, unsigned first_cutoff, int second_cutoff, int terminate, const char *vuname)
 
int format_has_text (char *format) const
 
int format_min_length (char *format, struct option_cache *oc) const
 
const char * pretty_print_option (struct option *option, const unsigned char *data, unsigned len, int emit_commas, int emit_quotes)
 
int get_option (struct data_string *result, struct universe *universe, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct option_state *options, struct binding_scope **scope, unsigned code, const char *file, int line)
 
int get_option_int (int *result, struct universe *universe, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct option_state *options, struct binding_scope **scope, unsigned code, const char *file, int line)
 
void set_option (struct universe *universe, struct option_state *options, struct option_cache *option, enum statement_op op)
 
struct option_cachelookup_option (struct universe *universe, struct option_state *options, unsigned code)
 
struct option_cachelookup_hashed_option (struct universe *universe, struct option_state *options, unsigned code)
 
int save_option_buffer (struct universe *universe, struct option_state *options, struct buffer *bp, unsigned char *buffer, unsigned length, unsigned code, int terminatep)
 
int append_option_buffer (struct universe *universe, struct option_state *options, struct buffer *bp, unsigned char *buffer, unsigned length, unsigned code, int terminatep)
 
void build_server_oro (struct data_string *server_oro, struct option_state *options, const char *file, int line)
 
void save_option (struct universe *universe, struct option_state *options, struct option_cache *oc)
 
void also_save_option (struct universe *universe, struct option_state *options, struct option_cache *oc)
 
void save_hashed_option (struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
 
void delete_option (struct universe *universe, struct option_state *options, int code)
 
void delete_hashed_option (struct universe *universe, struct option_state *options, int code)
 
int option_cache_dereference (struct option_cache **ptr, const char *file, int line)
 
int hashed_option_state_dereference (struct universe *universe, struct option_state *state, const char *file, int line)
 
int append_option (struct data_string *dst, struct universe *universe, struct option *option, struct data_string *src)
 
int store_option (struct data_string *result, struct universe *universe, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc)
 
int option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct data_string *name)
 
int hashed_option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
 
int nwip_option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
 
int fqdn_option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
 
struct option_cachelookup_fqdn6_option (struct universe *universe, struct option_state *options, unsigned code)
 
void save_fqdn6_option (struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
 
void delete_fqdn6_option (struct universe *universe, struct option_state *options, int code)
 
void fqdn6_option_space_foreach (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
 
int fqdn6_option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
 
int fqdn6_universe_decode (struct option_state *options, const unsigned char *buffer, unsigned length, struct universe *u)
 
void option_space_foreach (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
 
void suboption_foreach (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *), struct option_cache *oc, const char *vsname)
 
void hashed_option_space_foreach (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
 
void save_linked_option (struct universe *universe, struct option_state *options, struct option_cache *oc, isc_boolean_t appendp)
 
int linked_option_space_encapsulate (struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *universe)
 
void delete_linked_option (struct universe *universe, struct option_state *options, int code)
 
struct option_cachelookup_linked_option (struct universe *universe, struct option_state *options, unsigned code)
 
int linked_option_state_dereference (struct universe *universe, struct option_state *state, const char *file, int line)
 
void linked_option_space_foreach (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct universe *u, void *stuff, void(*func)(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *))
 
void do_packet (struct interface_info *interface, struct dhcp_packet *packet, unsigned len, unsigned int from_port, struct iaddr from, struct hardware *hfrom)
 
int packet6_len_okay (const char *packet, int len)
 
int pretty_escape (char **dst, char *dend, const unsigned char **src, const unsigned char *send)
 
int add_option (struct option_state *options, unsigned int option_num, void *data, unsigned int data_len)
 
int validate_packet (struct packet *packet)
 
void parse_vendor_option (struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope)
 Parse a vendor option (option 43)
 

Variables

struct optionvendor_cfg_option
 
struct option_cachefree_option_caches
 

Macro Definition Documentation

◆ DHCP_OPTION_DATA

#define DHCP_OPTION_DATA

Definition at line 29 of file options.c.

◆ MAX_OUTPUT_SIZE

#define MAX_OUTPUT_SIZE   32*1024

Definition at line 1792 of file options.c.

◆ PRIORITY_COUNT

#define PRIORITY_COUNT   300

Function Documentation

◆ add_option()

int add_option ( struct option_state * options,
unsigned int option_num,
void * data,
unsigned int data_len )

Definition at line 4480 of file options.c.

◆ also_save_option()

void also_save_option ( struct universe * universe,
struct option_state * options,
struct option_cache * oc )

Definition at line 2829 of file options.c.

◆ append_option()

int append_option ( struct data_string * dst,
struct universe * universe,
struct option * option,
struct data_string * src )

Definition at line 3041 of file options.c.

◆ append_option_buffer()

int append_option_buffer ( struct universe * universe,
struct option_state * options,
struct buffer * bp,
unsigned char * buffer,
unsigned length,
unsigned code,
int terminatep )

Definition at line 2569 of file options.c.

◆ build_server_oro()

void build_server_oro ( struct data_string * server_oro,
struct option_state * options,
const char * file,
int line )

Definition at line 2753 of file options.c.

◆ cons_options()

int cons_options ( struct packet * inpacket,
struct dhcp_packet * outpacket,
struct lease * lease,
struct client_state * client_state,
int mms,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
int overload_avail,
int terminate,
int bootpp,
struct data_string * prl,
const char * vuname )

Definition at line 538 of file options.c.

◆ delete_fqdn6_option()

void delete_fqdn6_option ( struct universe * universe,
struct option_state * options,
int code )

Definition at line 3555 of file options.c.

◆ delete_hashed_option()

void delete_hashed_option ( struct universe * universe,
struct option_state * options,
int code )

Definition at line 2918 of file options.c.

◆ delete_linked_option()

void delete_linked_option ( struct universe * universe,
struct option_state * options,
int code )

Definition at line 3949 of file options.c.

◆ delete_option()

void delete_option ( struct universe * universe,
struct option_state * options,
int code )

Definition at line 2906 of file options.c.

◆ do_packet()

void do_packet ( struct interface_info * interface,
struct dhcp_packet * packet,
unsigned len,
unsigned int from_port,
struct iaddr from,
struct hardware * hfrom )

Definition at line 4045 of file options.c.

◆ find_option_universe()

struct universe * find_option_universe ( struct option * eopt,
const char * uname )

Definition at line 292 of file options.c.

◆ format_has_text()

int format_has_text ( char * format) const

Definition at line 1629 of file options.c.

◆ format_min_length()

int format_min_length ( char * format,
struct option_cache * oc ) const

Definition at line 1692 of file options.c.

◆ fqdn6_option_space_encapsulate()

int fqdn6_option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * universe )

Definition at line 3591 of file options.c.

◆ fqdn6_option_space_foreach()

void fqdn6_option_space_foreach ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * u,
void * stuff,
void(* func )(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *) )

Definition at line 3569 of file options.c.

◆ fqdn6_universe_decode()

int fqdn6_universe_decode ( struct option_state * options,
const unsigned char * buffer,
unsigned length,
struct universe * u )

Definition at line 3690 of file options.c.

◆ fqdn_option_space_encapsulate()

int fqdn_option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * universe )

Definition at line 3417 of file options.c.

◆ fqdn_universe_decode()

int fqdn_universe_decode ( struct option_state * options,
const unsigned char * buffer,
unsigned length,
struct universe * u )

Definition at line 366 of file options.c.

◆ get_option()

int get_option ( struct data_string * result,
struct universe * universe,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct option_state * options,
struct binding_scope ** scope,
unsigned code,
const char * file,
int line )

Definition at line 2323 of file options.c.

◆ get_option_int()

int get_option_int ( int * result,
struct universe * universe,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct option_state * options,
struct binding_scope ** scope,
unsigned code,
const char * file,
int line )

Definition at line 2358 of file options.c.

◆ hashed_option_space_encapsulate()

int hashed_option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * universe )

Definition at line 3249 of file options.c.

◆ hashed_option_space_foreach()

void hashed_option_space_foreach ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * u,
void * stuff,
void(* func )(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *) )

Definition at line 3832 of file options.c.

◆ hashed_option_state_dereference()

int hashed_option_state_dereference ( struct universe * universe,
struct option_state * state,
const char * file,
int line )

Definition at line 3003 of file options.c.

◆ linked_option_space_encapsulate()

int linked_option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * universe )

Definition at line 3913 of file options.c.

◆ linked_option_space_foreach()

void linked_option_space_foreach ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * u,
void * stuff,
void(* func )(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *) )

Definition at line 4014 of file options.c.

◆ linked_option_state_dereference()

int linked_option_state_dereference ( struct universe * universe,
struct option_state * state,
const char * file,
int line )

Definition at line 4003 of file options.c.

◆ lookup_fqdn6_option()

struct option_cache * lookup_fqdn6_option ( struct universe * universe,
struct option_state * options,
unsigned code )

Definition at line 3534 of file options.c.

◆ lookup_hashed_option()

struct option_cache * lookup_hashed_option ( struct universe * universe,
struct option_state * options,
unsigned code )

Definition at line 2518 of file options.c.

◆ lookup_linked_option()

struct option_cache * lookup_linked_option ( struct universe * universe,
struct option_state * options,
unsigned code )

Definition at line 3978 of file options.c.

◆ lookup_option()

struct option_cache * lookup_option ( struct universe * universe,
struct option_state * options,
unsigned code )

Definition at line 2503 of file options.c.

◆ nwip_option_space_encapsulate()

int nwip_option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * universe )

Definition at line 3292 of file options.c.

◆ option_cache_dereference()

int option_cache_dereference ( struct option_cache ** ptr,
const char * file,
int line )

Definition at line 2953 of file options.c.

◆ option_space_encapsulate()

int option_space_encapsulate ( struct data_string * result,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct data_string * name )

Definition at line 3161 of file options.c.

◆ option_space_foreach()

void option_space_foreach ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * u,
void * stuff,
void(* func )(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *) )

Definition at line 3789 of file options.c.

◆ packet6_len_okay()

int packet6_len_okay ( const char * packet,
int len )

Definition at line 4135 of file options.c.

◆ parse_encapsulated_suboptions()

int parse_encapsulated_suboptions ( struct option_state * options,
struct option * eopt,
const unsigned char * buffer,
unsigned len,
struct universe * eu,
const char * uname )

Definition at line 337 of file options.c.

◆ parse_option_buffer()

int parse_option_buffer ( struct option_state * options,
const unsigned char * buffer,
unsigned length,
struct universe * universe )

Definition at line 119 of file options.c.

◆ parse_options()

int parse_options ( struct packet * packet)

Definition at line 49 of file options.c.

◆ parse_vendor_option()

void parse_vendor_option ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * out_options,
struct binding_scope ** scope )

Parse a vendor option (option 43)

After the server has parsed most of the options and presented the result to the user the user can set the proper vendor option space using vendor-option-space in the config file and then cause this routine to be called via parse-vendor-option in the config file. This routine will then try and find the proper universe for the vendor-option-space and parse the vendor option string based on that universe.

If the information isn't available (no vendor space, no universe for the vendor space, no vendor option in the options) or the decode fails we simply ignore the option and continue processing.

Parameters
packet- structure to hold information about the packet being processed
lease- lease structure
client_state
in_options- The incoming options, we expect to find the vendor-option (option 43, containing the string to parse) there. We shall attach decoded options there.
out_options- The options we have added as we process the packet. We expect to find the vendor-option-space there and use that to find the name of the vendor universe to use
scope
Returns
- void as there isn't much we can do about failures.

Definition at line 4618 of file options.c.

◆ pretty_escape()

int pretty_escape ( char ** dst,
char * dend,
const unsigned char ** src,
const unsigned char * send )

Definition at line 4287 of file options.c.

◆ pretty_print_option()

const char * pretty_print_option ( struct option * option,
const unsigned char * data,
unsigned len,
int emit_commas,
int emit_quotes )

Definition at line 1793 of file options.c.

◆ save_fqdn6_option()

void save_fqdn6_option ( struct universe * universe,
struct option_state * options,
struct option_cache * oc,
isc_boolean_t appendp )

Definition at line 3545 of file options.c.

◆ save_hashed_option()

void save_hashed_option ( struct universe * universe,
struct option_state * options,
struct option_cache * oc,
isc_boolean_t appendp )

Definition at line 2839 of file options.c.

◆ save_linked_option()

void save_linked_option ( struct universe * universe,
struct option_state * options,
struct option_cache * oc,
isc_boolean_t appendp )

Definition at line 3869 of file options.c.

◆ save_option()

void save_option ( struct universe * universe,
struct option_state * options,
struct option_cache * oc )

Definition at line 2818 of file options.c.

◆ save_option_buffer()

int save_option_buffer ( struct universe * universe,
struct option_state * options,
struct buffer * bp,
unsigned char * buffer,
unsigned length,
unsigned code,
int terminatep )

Definition at line 2545 of file options.c.

◆ set_option()

void set_option ( struct universe * universe,
struct option_state * options,
struct option_cache * option,
enum statement_op op )

Definition at line 2403 of file options.c.

◆ store_option()

int store_option ( struct data_string * result,
struct universe * universe,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct option_cache * oc )

Definition at line 3091 of file options.c.

◆ store_options()

int store_options ( int * ocount,
unsigned char * buffer,
unsigned index,
unsigned buflen,
struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
unsigned * priority_list,
int priority_len,
unsigned first_cutoff,
int second_cutoff,
int terminate,
const char * vuname )

Definition at line 1236 of file options.c.

◆ store_options6()

int store_options6 ( char * buf,
int buflen,
struct option_state * opt_state,
struct packet * packet,
const int * required_opts,
struct data_string * oro )

Definition at line 1048 of file options.c.

◆ suboption_foreach()

void suboption_foreach ( struct packet * packet,
struct lease * lease,
struct client_state * client_state,
struct option_state * in_options,
struct option_state * cfg_options,
struct binding_scope ** scope,
struct universe * u,
void * stuff,
void(* func )(struct option_cache *, struct packet *, struct lease *, struct client_state *, struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *),
struct option_cache * oc,
const char * vsname )

Definition at line 3808 of file options.c.

◆ validate_packet()

int validate_packet ( struct packet * packet)

Checks if received BOOTP/DHCPv4 packet is sane

Parameters
packetreceived, decoded packet
Returns
1 if packet is sane, 0 if it is not

Definition at line 4538 of file options.c.

Variable Documentation

◆ free_option_caches

struct option_cache* free_option_caches
extern

Definition at line 614 of file alloc.c.

◆ vendor_cfg_option

struct option* vendor_cfg_option

Definition at line 34 of file options.c.