[Dhcp-agent-commits] dhcp-agent dhcp-agent.h,1.62,1.63 dhcp-client-states.c,1.33,1.34 dhcp-com.c,1.1
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv1355 Modified Files: dhcp-agent.h dhcp-client-states.c dhcp-com.c dhcp-convert.h dhcp-globconf.c dhcp-globconf.h Log Message: added atleast/exact option for client options retrieval Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** dhcp-agent.h 30 Jun 2002 08:23:45 -0000 1.62 --- dhcp-agent.h 30 Jun 2002 21:22:15 -0000 1.63 *************** *** 579,582 **** --- 579,583 ---- extern int dhcp_option_is_valid(unsigned char tag, unsigned char tag_len); extern int dhcp_have_atleast_requested_options(dhcp_obj *dhcp, unsigned char *option); + extern int dhcp_have_exact_requested_options(dhcp_obj *dhcp, unsigned char *options); extern int dhcp_have_option(dhcp_obj *dhcp, unsigned char tag); extern int dhcp_is_file_overload(dhcp_obj *dhcp); Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-states.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** dhcp-client-states.c 30 Jun 2002 08:23:45 -0000 1.33 --- dhcp-client-states.c 30 Jun 2002 21:22:15 -0000 1.34 *************** *** 32,35 **** --- 32,57 ---- #include <dhcp-net.h> + /* Check the requested options. + * We use the globconf option. */ + + static int client_check_requested_options(dhcp_client_control_t *dc) + { + const char *policy = glob_conf_get_val(CLIENT_OPTION_POLICY); + + if(policy == NULL) + policy = "atleast"; + + if(string_matches(policy, "exact")) + return(dhcp_have_exact_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); + else if(!strcmp(policy, "atleast")) + return(dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); + else /* bad policy : warn and use atleast */ { + warn_message("%s : set to bad value %s", CLIENT_OPTION_POLICY_S, policy); + warn_message("going to use \"atleast\""); + return(dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); + } + + } + /* Along with the parameter request list we always build these options * upon creating new dhcp packets. */ *************** *** 102,106 **** if(client_check_dhcp(dc) || dhcp_is_type(dc->rawnet->dhcp_p, DHCP_OFFER_TM) || ! dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)) return 1; else --- 124,128 ---- if(client_check_dhcp(dc) || dhcp_is_type(dc->rawnet->dhcp_p, DHCP_OFFER_TM) || ! client_check_requested_options(dc)) return 1; else Index: dhcp-com.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-com.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-com.c 30 Jun 2002 08:23:45 -0000 1.10 --- dhcp-com.c 30 Jun 2002 21:22:15 -0000 1.11 *************** *** 459,463 **** for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { if(options[i] && !dhcp_have_option(dhcp, i)) ! return 1; } --- 459,477 ---- for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { if(options[i] && !dhcp_have_option(dhcp, i)) ! return 1; ! } ! ! return 0; ! } ! ! int dhcp_have_exact_requested_options(dhcp_obj *dhcp, unsigned char *options) ! { ! int i; ! ! for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { ! if(options[i] && !dhcp_have_option(dhcp, i)) ! return 1; ! if(!options[i] && dhcp_have_option(dhcp, i)) ! return 1; } Index: dhcp-convert.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-convert.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-convert.h 17 Jun 2002 13:23:08 -0000 1.2 --- dhcp-convert.h 30 Jun 2002 21:22:15 -0000 1.3 *************** *** 89,92 **** --- 89,93 ---- extern char *validate_network_string_to_string(const unsigned char *data, int len); + extern char *validate_string_to_string(const unsigned char *data, int len); extern void *strdup_wrap(const char *s); extern void *strdup_wrap_net(const char *s, unsigned char *ret_len); Index: dhcp-globconf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-globconf.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-globconf.c 30 Jun 2002 08:23:45 -0000 1.10 --- dhcp-globconf.c 30 Jun 2002 21:22:15 -0000 1.11 *************** *** 37,41 **** /* change this before... */ ! #define GLOBAL_OPTIONS_LEN 3 /* ... changing size of this */ --- 37,41 ---- /* change this before... */ ! #define GLOBAL_OPTIONS_LEN 4 /* ... changing size of this */ *************** *** 43,49 **** * do not change order unless you change defines in dhcp-globconf.h! */ static glob_conf_t global_config_options[] = { ! { "client-dhcp-retries", string_to_int32, int32_to_string, sizeof(int32_t), DHCP_CLIENT_RETRIES_S, NULL }, ! { "client-icmp-retries", string_to_int32, int32_to_string, sizeof(int32_t), DHCP_CLIENT_RETRIES_S, NULL }, ! { "client-hostname", strdup_wrap, validate_network_string_to_string, 0, NULL, NULL }, }; --- 43,50 ---- * do not change order unless you change defines in dhcp-globconf.h! */ static glob_conf_t global_config_options[] = { ! { "client-dhcp-retries", string_to_int32, int32_to_string, sizeof(int32_t), CLIENT_RETRIES_S, NULL }, ! { "client-icmp-retries", string_to_int32, int32_to_string, sizeof(int32_t), CLIENT_RETRIES_S, NULL }, ! { "client-hostname", strdup_wrap, validate_string_to_string, 0, NULL, NULL }, ! { "client-options-policy", strdup_wrap, validate_string_to_string, 0, CLIENT_OPTION_POLICY_S, NULL }, }; Index: dhcp-globconf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-globconf.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-globconf.h 17 Jun 2002 13:23:08 -0000 1.4 --- dhcp-globconf.h 30 Jun 2002 21:22:15 -0000 1.5 *************** *** 43,52 **** /* indexes to values. */ ! #define CLIENT_DHCP_RETRIES 0 ! #define CLIENT_ICMP_RETRIES 1 ! #define CLIENT_HOSTNAME 2 /* default string values. */ ! #define DHCP_CLIENT_RETRIES_S "3" /* governs all retries. */ #endif /* GLOBAL_CONF_H */ --- 43,54 ---- /* indexes to values. */ ! #define CLIENT_DHCP_RETRIES 0 ! #define CLIENT_ICMP_RETRIES 1 ! #define CLIENT_HOSTNAME 2 ! #define CLIENT_OPTION_POLICY 3 /* default string values. */ ! #define CLIENT_RETRIES_S "3" /* governs all retries. */ ! #define CLIENT_OPTION_POLICY_S "atleast" /* default policy on accepting options. */ #endif /* GLOBAL_CONF_H */ |