[dhcp-agent-commits] dhcp-agent/src dhcp-lease.c,1.1,1.2 dhcp-lease.h,1.1,1.2 dhcp-server-conf.c,1.1
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv21226/src Modified Files: dhcp-lease.c dhcp-lease.h dhcp-server-conf.c dhcp-server-conf.h dhcp-server-control.c dhcp-server.c Log Message: more stuff for the server which still doesn't work Index: dhcp-lease.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-lease.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-lease.c 2 Jul 2003 15:23:30 -0000 1.1 --- dhcp-lease.c 6 Jul 2003 05:37:44 -0000 1.2 *************** *** 40,43 **** --- 40,45 ---- lease_constraint_t *constraint = xcalloc(sizeof(lease_constraint_t)); char *hostname; + list_t *address_range; + // ip_addr_t range_top, range_bottom; constraint->constraint_type = constraint_type; *************** *** 54,57 **** --- 56,66 ---- break; + case LEASE_CONSTRAINT_ADDRESS_RANGE: + address_range = data; + + hostname = data; + constraint->data.hostname = xstrdup(hostname); + break; + default: FATAL_MESSAGE("illegal constraint type passed. this is a bug report me."); *************** *** 69,74 **** break; ! case LEASE_CONSTRAINT_HARDWARE_ADDRESS: /* fall through. */ ! case LEASE_CONSTRAINT_NONE: /* fall through. */ default: break; --- 78,84 ---- break; ! case LEASE_CONSTRAINT_ADDRESS_RANGE: /* fall through. */ ! case LEASE_CONSTRAINT_HARDWARE_ADDRESS: /* fall through. */ ! case LEASE_CONSTRAINT_NONE: /* fall through. */ default: break; *************** *** 93,97 **** lease_def->constraint = constraint; ! lease_def->addr_range = ip_addr_range; /* copy our dhcp options we'll pass. */ --- 103,107 ---- lease_def->constraint = constraint; ! // lease_def->addr_range = ip_addr_range; /* copy our dhcp options we'll pass. */ Index: dhcp-lease.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-lease.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-lease.h 2 Jul 2003 15:23:30 -0000 1.1 --- dhcp-lease.h 6 Jul 2003 05:37:44 -0000 1.2 *************** *** 35,38 **** --- 35,42 ---- eth_addr_t hw_address; /* hardware address. */ char *hostname; /* hostname. */ + struct { + ip_addr_t bottom_range; + ip_addr_t top_range; + } range; /* range of addresses. */ } data; *************** *** 44,48 **** lease_constraint_t *constraint; /* constraints if any. */ ! ip_addr_t addr_range; /* address range. */ list_t *options; /* options to be passed. */ --- 48,54 ---- lease_constraint_t *constraint; /* constraints if any. */ ! ip_addr_t addr_net; /* network_address. */ ! ip_addr_t netmask; /* network netmask. */ ! list_t *options; /* options to be passed. */ *************** *** 65,69 **** /* constants. */ ! enum lease_constraint_type { LEASE_CONSTRAINT_NONE = 0, LEASE_CONSTRAINT_HARDWARE_ADDRESS, LEASE_CONSTRAINT_HOSTNAME }; /* prototypes. */ --- 71,75 ---- /* constants. */ ! enum lease_constraint_type { LEASE_CONSTRAINT_NONE = 0, LEASE_CONSTRAINT_HARDWARE_ADDRESS, LEASE_CONSTRAINT_HOSTNAME, LEASE_CONSTRAINT_ADDRESS_RANGE }; /* prototypes. */ Index: dhcp-server-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-conf.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-server-conf.c 5 Jul 2003 19:17:48 -0000 1.1 --- dhcp-server-conf.c 6 Jul 2003 05:37:44 -0000 1.2 *************** *** 34,37 **** --- 34,38 ---- #include "dhcp-conf-var.h" #include "dhcp-server-conf.h" + #include "dhcp-server-defaults.h" static const char *var_strings[] = { *************** *** 49,52 **** --- 50,57 ---- static const arg_symbol_t *var_arg_symbols[] = { var_symbols, NULL, NULL }; + static const arg_type_t range_lease_arg_types[] = { CONF_IDENTIFIER, CONF_ADDRESS, CONF_ADDRESS, CONF_GROUP}; + static const char **range_lease_arg_strings[] = { var_strings, NULL, NULL }; + static const arg_symbol_t *range_lease_arg_symbols[] = { var_symbols, NULL, NULL }; + /* command structures. */ *************** *** 61,66 **** --- 66,82 ---- }; + /* set command. */ + static const command_t range_lease = { + DIRECTIVE_RANGE_LEASE, + "range-lease", + 4, + range_lease_arg_strings, + range_lease_arg_types, + range_lease_arg_symbols, + }; + static const command_t *commands[] = { &command_set, + &range_lease, NULL, }; *************** *** 68,72 **** /* forward declaration of directive handlers. */ ! static int directive_set_handler(server_conf_t *server_conf, directive_t *directive); /* indexed by directive types in dhcp-client-conf.h . */ --- 84,88 ---- /* forward declaration of directive handlers. */ ! static int directive_set_handler(server_conf_t *server_conf, directive_t *directive, void *group_data); /* indexed by directive types in dhcp-client-conf.h . */ *************** *** 180,184 **** /* read in the compiled directives. */ ! if(directive_handlers[directive->command_code](sc, directive)) return 1; } --- 196,200 ---- /* read in the compiled directives. */ ! if(directive_handlers[directive->command_code](sc, directive, NULL)) return 1; } *************** *** 191,195 **** * * * * * * * * * * * */ ! static int directive_set_handler(server_conf_t *server_conf, directive_t *directive) { list_t *args; --- 207,211 ---- * * * * * * * * * * * */ ! static int directive_set_handler(server_conf_t *server_conf, directive_t *directive, void *group_data) { list_t *args; *************** *** 214,218 **** * * * * * * * * * * */ ! server_conf_t *create_server_conf(const char *interface) { server_conf_t *sc; --- 230,234 ---- * * * * * * * * * * */ ! server_conf_t *server_conf_create(const char *interface) { server_conf_t *sc; *************** *** 221,227 **** sc->interface = interface; sc->conf_file = get_conf_options_fname(interface); ! ! sc->variables = list_create(); sc->lease_defs = list_create(); if(server_conf_load_options(sc)) { --- 237,247 ---- sc->interface = interface; sc->conf_file = get_conf_options_fname(interface); ! ! /* setup lease definitions. */ sc->lease_defs = list_create(); + + /* set defaults. */ + sc->default_rebind_percent = SERVER_DEFAULT_REBIND_PERCENT; + sc->default_renew_percent = SERVER_DEFAULT_RENEW_PERCENT; if(server_conf_load_options(sc)) { Index: dhcp-server-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-conf.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-server-conf.h 5 Jul 2003 19:17:48 -0000 1.1 --- dhcp-server-conf.h 6 Jul 2003 05:37:44 -0000 1.2 *************** *** 30,34 **** typedef struct { - list_t *variables; /* variable settings. */ list_t *lease_defs; /* list of lease definitions. */ --- 30,33 ---- *************** *** 41,54 **** } server_conf_t; ! typedef int (*directive_handler_t)(server_conf_t *server_conf, directive_t *directive_data); /* constants. */ enum var_symbols { SERVER_VAR_RENEW_PERCENT = 0, SERVER_VAR_REBIND_PERCENT }; ! enum directive_types { DIRECTIVE_SET = 0 }; /* prototypes. */ ! extern server_conf_t *create_server_conf(const char *interface); extern void server_conf_destroy(server_conf_t *sc); --- 40,53 ---- } server_conf_t; ! typedef int (*directive_handler_t)(server_conf_t *server_conf, directive_t *directive_data, void *group_data); /* constants. */ enum var_symbols { SERVER_VAR_RENEW_PERCENT = 0, SERVER_VAR_REBIND_PERCENT }; ! enum directive_types { DIRECTIVE_SET = 0, DIRECTIVE_RANGE_LEASE }; /* prototypes. */ ! extern server_conf_t *server_conf_create(const char *interface); extern void server_conf_destroy(server_conf_t *sc); Index: dhcp-server-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-control.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-server-control.c 5 Jul 2003 19:17:48 -0000 1.1 --- dhcp-server-control.c 6 Jul 2003 05:37:44 -0000 1.2 *************** *** 43,47 **** /* read configuration information. */ ! if((dhcp_server_control->server_conf = create_server_conf(interface)) == NULL) { FATAL_MESSAGE("could not read configuration file"); } --- 43,47 ---- /* read configuration information. */ ! if((dhcp_server_control->server_conf = server_conf_create(interface)) == NULL) { FATAL_MESSAGE("could not read configuration file"); } *************** *** 68,73 **** /* create rawnet handler. */ ! dhcp_server_control->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), -1, sport, ! dport, 0, 0); return dhcp_server_control; } --- 68,78 ---- /* create rawnet handler. */ ! if((dhcp_server_control->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), -1, sport, ! dport, 0, 0)) == NULL) { ! FATAL_MESSAGE("could not create raw network handler."); ! } ! ! stringbuffer_destroy(filter); ! return dhcp_server_control; } Index: dhcp-server.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-server.c 5 Jul 2003 19:17:48 -0000 1.2 --- dhcp-server.c 6 Jul 2003 05:37:44 -0000 1.3 *************** *** 159,162 **** --- 159,163 ---- commands[command_code](interface_name); + exit(0); } |