Thread: [dhcp-agent-commits] dhcp-agent/src dhcp-arp-discovery.c,1.3,1.4 dhcp-cache-entry.c,1.5,1.6 dhcp-cli
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src
In directory sc8-pr-cvs1:/tmp/cvs-serv25981/src
Modified Files:
dhcp-arp-discovery.c dhcp-cache-entry.c dhcp-client-cache.c
dhcp-client-conf.c dhcp-client-states.c dhcp-client.c
dhcp-com.c dhcp-conf.c dhcp-convert.c dhcp-icmp-discovery.c
dhcp-interface.c dhcp-librawnet.h dhcp-libutil.h dhcp-list.c
dhcp-sniff.c dhcp-sysconf.c dhcp-timer.c
Log Message:
redid list object
Index: dhcp-arp-discovery.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-arp-discovery.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dhcp-arp-discovery.c 16 Nov 2002 00:23:42 -0000 1.3
--- dhcp-arp-discovery.c 2 Jan 2003 04:23:01 -0000 1.4
***************
*** 41,49 ****
list_t *argument_list = data;
! net = argument_list->data;
! if(argument_list->next)
! addr = argument_list->next->data;
! else {
! WARN_MESSAGE("check arp reply: no address passed to function -- skipping");
return 0;
}
--- 41,49 ----
list_t *argument_list = data;
! net = list_first(argument_list);
! addr = list_second(argument_list);
!
! if(addr == NULL) {
! WARN_MESSAGE("no address passed to function -- skipping");
return 0;
}
***************
*** 71,80 ****
eth_addr_t *mac_addr)
{
! list_t *arg_list = NULL;
unsigned char *sender_addr;
int retval;
! arg_list = add_to_list(arg_list, &address);
! arg_list = add_to_list(arg_list, net);
/* 0 for source ip, address to discover for dest, our
--- 71,81 ----
eth_addr_t *mac_addr)
{
! list_t *arg_list;
unsigned char *sender_addr;
int retval;
! arg_list = list_create();
! list_add(arg_list, &address);
! list_add(arg_list, net);
/* 0 for source ip, address to discover for dest, our
***************
*** 102,111 ****
memcpy(mac_addr->data, sender_addr, ETH_ADDR_LEN);
! /* just free up pair. FIXME: this isn't good because we're
! * breaking the list blackbox. we need a better way to do this.
! * the datums don't need to be freed since we keep them on the stack. */
!
! xfree(arg_list->next);
! xfree(arg_list);
return 0;
--- 103,107 ----
memcpy(mac_addr->data, sender_addr, ETH_ADDR_LEN);
! list_destroy(arg_list, NULL);
return 0;
***************
*** 114,117 ****
--- 110,114 ----
/* wops error. this is bad. */
ERROR_MESSAGE("received error from raw network handler.");
+ list_destroy(arg_list, NULL);
return 1;
***************
*** 123,129 ****
}
! /* FIXME: ditto (see above) */
! xfree(arg_list->next);
! xfree(arg_list);
WARN_MESSAGE("timeout on discovery.");
--- 120,124 ----
}
! list_destroy(arg_list, NULL);
WARN_MESSAGE("timeout on discovery.");
Index: dhcp-cache-entry.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-cache-entry.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** dhcp-cache-entry.c 16 Dec 2002 10:04:32 -0000 1.5
--- dhcp-cache-entry.c 2 Jan 2003 04:23:01 -0000 1.6
***************
*** 68,72 ****
void cache_entry_purge_list(list_t *cache_list)
{
! purge_list(cache_list, cache_entry_destroy_l);
return;
}
--- 68,72 ----
void cache_entry_purge_list(list_t *cache_list)
{
! list_destroy(cache_list, cache_entry_destroy_l);
return;
}
Index: dhcp-client-cache.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-cache.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** dhcp-client-cache.c 30 Dec 2002 03:41:51 -0000 1.12
--- dhcp-client-cache.c 2 Jan 2003 04:23:01 -0000 1.13
***************
*** 47,51 ****
cc = xmalloc(sizeof(client_cache_t));
cc->interface = interface; /* don't copy just point. */
! cc->vars = NULL;
return cc;
--- 47,51 ----
cc = xmalloc(sizeof(client_cache_t));
cc->interface = interface; /* don't copy just point. */
! cc->vars = list_create();
return cc;
***************
*** 57,61 ****
{
cache_entry_purge_list(cc->vars);
! cc->vars = NULL;
return;
}
--- 57,61 ----
{
cache_entry_purge_list(cc->vars);
! cc->vars = list_create();
return;
}
***************
*** 207,211 ****
while((cache_entry = read_next_cache_var(varfile)) != NULL)
! cc->vars = add_to_list(cc->vars, cache_entry);
destroy_varfile(varfile);
--- 207,211 ----
while((cache_entry = read_next_cache_var(varfile)) != NULL)
! list_add(cc->vars, cache_entry);
destroy_varfile(varfile);
***************
*** 292,306 ****
void *(*convert_func) (unsigned char tag, char *string))
{
! list_t *options = NULL;
! list_t *cache;
cache_entry_t *ce;
void *data;
! for(cache = cc->vars; cache; cache = cache->next) {
- ce = cache->data;
data = convert_func(atoi(ce->name), ce->value);
if(data != NULL) { /* we need to silently ignore nulls here so that the timer only converter works. */
! options = add_to_list(options, data);
}
--- 292,307 ----
void *(*convert_func) (unsigned char tag, char *string))
{
! list_t *options;
cache_entry_t *ce;
void *data;
! options = list_create();
!
! list_rewind(cc->vars);
! while((ce = list_next(cc->vars)) != NULL) {
data = convert_func(atoi(ce->name), ce->value);
if(data != NULL) { /* we need to silently ignore nulls here so that the timer only converter works. */
! list_add(options, data);
}
***************
*** 318,322 ****
{
FILE *fp;
- list_t *list_ptr;
char *name;
char *val;
--- 319,322 ----
***************
*** 332,342 ****
return -1;
! for(list_ptr = options; list_ptr; list_ptr = list_ptr->next) {
/* Run coversion routines to store internally in
* serialized (string) state. */
- opt = list_ptr->data;
-
if(option_convert_handlers[opt->tag].serialize == NULL)
continue;
--- 332,341 ----
return -1;
! list_rewind(options);
! while((opt = list_next(options)) != NULL) {
/* Run coversion routines to store internally in
* serialized (string) state. */
if(option_convert_handlers[opt->tag].serialize == NULL)
continue;
***************
*** 374,378 ****
char *string))
{
-
list_t *options;
--- 373,376 ----
Index: dhcp-client-conf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** dhcp-client-conf.c 23 Dec 2002 00:51:24 -0000 1.14
--- dhcp-client-conf.c 2 Jan 2003 04:23:01 -0000 1.15
***************
*** 36,39 ****
--- 36,40 ----
#include "dhcp-options-strings.h"
+ /* FIXME: check for destroy params mem leak. */
/* * * * * * * * * * * * * * * * * * *
***************
*** 236,242 ****
int i;
! for(;strings; strings = strings->next) {
!
! option_string = strings->data;
for(i = 0; i <= MAX_OPTIONS_HANDLED; i++) {
--- 237,242 ----
int i;
! list_rewind(strings);
! for(option_string = list_next(strings); option_string; option_string = list_next(strings)) {
for(i = 0; i <= MAX_OPTIONS_HANDLED; i++) {
***************
*** 386,393 ****
/* now process group. */
! for(directive_list = directive_data;
! directive_list;directive_list = directive_list->next) {
- directive = directive_list->data;
if(directive_handlers[directive->command_code](params, directive, group_type, group_data))
return 1;
--- 386,393 ----
/* now process group. */
! directive_list = directive_data;
! list_rewind(directive_list);
! while((directive = list_next(directive_list)) != NULL) {
if(directive_handlers[directive->command_code](params, directive, group_type, group_data))
return 1;
***************
*** 406,411 ****
args = directive->arguments;
! var_symbol = args->data;
! var_value = args->next->next->data;
if(client_conf_set_variable(params, *var_symbol, var_value)) {
--- 406,411 ----
args = directive->arguments;
! var_symbol = list_get_by_index(args, 0);
! var_value = list_get_by_index(args, 3);
if(client_conf_set_variable(params, *var_symbol, var_value)) {
***************
*** 424,428 ****
args = directive->arguments;
! string_list = args->data;
if(fill_option_bit_array_from_string_list(string_list, params->request_options))
--- 424,428 ----
args = directive->arguments;
! string_list = list_first(args);
if(fill_option_bit_array_from_string_list(string_list, params->request_options))
***************
*** 439,443 ****
args = directive->arguments;
! string_list = args->data;
if(fill_option_bit_array_from_string_list(string_list, params->required_options))
--- 439,443 ----
args = directive->arguments;
! string_list = list_first(args);
if(fill_option_bit_array_from_string_list(string_list, params->required_options))
***************
*** 455,465 ****
conf_params_t *new_params;
directive_group_t new_group_type;
! /* FIXME: check for the same group specified twice.
! * this gives us a bit of compression in the unlikely
! * case of a broken config file. */
!
! args = directive_data;
! server_symbol = args->data;
switch(*server_symbol) {
--- 455,463 ----
conf_params_t *new_params;
directive_group_t new_group_type;
+ directive_t *directive;
! directive = directive_data;
! args = directive->arguments;
! server_symbol = list_first(args);
switch(*server_symbol) {
***************
*** 483,488 ****
}
! address_data = args->next->data;
! directives = args->next->next->data;
new_params = xcalloc(sizeof(conf_params_t));
--- 481,486 ----
}
! address_data = list_get_by_index(args, 1);
! directives = list_get_by_index(args, 2);
new_params = xcalloc(sizeof(conf_params_t));
***************
*** 490,494 ****
return 1;
! params->lower_params = add_to_list(params->lower_params, new_params);
return 0;
--- 488,495 ----
return 1;
! if(params->lower_params == NULL)
! params->lower_params = list_create();
!
! list_add(params->lower_params, new_params);
return 0;
***************
*** 504,509 ****
args = directive->arguments;
! var_symbol = args->data;
! var_value = args->next->next->data;
if(client_conf_set_variable_boolean(params, *var_symbol, *var_value)) {
--- 505,510 ----
args = directive->arguments;
! var_symbol = list_get_by_index(args, 0);
! var_value = list_get_by_index(args, 2);
if(client_conf_set_variable_boolean(params, *var_symbol, *var_value)) {
***************
*** 526,529 ****
--- 527,531 ----
cc->interface = interface;
cc->conf_file = get_conf_options_fname(cc);
+ cc->parameters.lower_params = list_create();
cc->parameters.group_type = DIRECTIVE_GROUP_NULL; /* set top level to catchall group. */
***************
*** 542,555 ****
conf_params_t *lower_params;
! for(params_list = params->lower_params;
! params_list; params_list = params_list->next) {
!
! lower_params = params_list->data;
params_destroy(lower_params, 0);
-
}
if(params->client_hostname)
xfree(params->client_hostname);
if(!topflag)
--- 544,559 ----
conf_params_t *lower_params;
! params_list = params->lower_params;
! list_rewind(params_list);
! for(lower_params = list_next(params_list); lower_params;
! lower_params = list_next(params_list)) {
params_destroy(lower_params, 0);
}
if(params->client_hostname)
xfree(params->client_hostname);
+
+ list_destroy(params->lower_params, NULL);
+ params->lower_params = NULL;
if(!topflag)
Index: dhcp-client-states.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** dhcp-client-states.c 30 Dec 2002 21:54:37 -0000 1.23
--- dhcp-client-states.c 2 Jan 2003 04:23:01 -0000 1.24
***************
*** 47,60 ****
static list_t *client_build_release_option_list(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
dhcp_option_t *option;
/* client_id: RFC2131 says we MAY */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! options = add_to_list(options, option);
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_RELEASE_TM);
! options = add_to_list(options, option);
return options;
--- 47,62 ----
static list_t *client_build_release_option_list(dhcp_client_control_t *dc)
{
! list_t *options;
dhcp_option_t *option;
+ options = list_create();
+
/* client_id: RFC2131 says we MAY */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! list_add(options, option);
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_RELEASE_TM);
! list_add(options, option);
return options;
***************
*** 65,84 ****
static list_t *client_build_option_list(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
dhcp_option_t *option;
const char *hostname;
/* dhcp max DHCP message size:
* should go into globconf. */
option = dhcp_build_max_message_size_option(MAX_MESSAGE_SIZE);
! options = add_to_list(options, option);
/* client_id */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! options = add_to_list(options, option);
/* class_id */
option = dhcp_build_class_id(dc->class_id);
! options = add_to_list(options, option);
/* hostname if available */
--- 67,87 ----
static list_t *client_build_option_list(dhcp_client_control_t *dc)
{
! list_t *options;
dhcp_option_t *option;
const char *hostname;
+ options = list_create();
/* dhcp max DHCP message size:
* should go into globconf. */
option = dhcp_build_max_message_size_option(MAX_MESSAGE_SIZE);
! list_add(options, option);
/* client_id */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! list_add(options, option);
/* class_id */
option = dhcp_build_class_id(dc->class_id);
! list_add(options, option);
/* hostname if available */
***************
*** 87,91 ****
/* if we have one set it. */
option = dhcp_build_hostname(hostname);
! options = add_to_list(options, option);
}
--- 90,94 ----
/* if we have one set it. */
option = dhcp_build_hostname(hostname);
! list_add(options, option);
}
***************
*** 96,116 ****
static list_t *client_build_discover_option_list(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
! list_t *requested_options = NULL;
dhcp_option_t *option;
option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf));
if(option == NULL) {
WARN_MESSAGE("sending with empty parameter request list");
} else {
! options = add_to_list(options, option);
}
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_DISCOVER_TM);
! options = add_to_list(options, option);
requested_options = client_build_option_list(dc);
! options = join_lists(options, requested_options);
return options;
--- 99,120 ----
static list_t *client_build_discover_option_list(dhcp_client_control_t *dc)
{
! list_t *options;
! list_t *requested_options;
dhcp_option_t *option;
+ options = list_create();
option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf));
if(option == NULL) {
WARN_MESSAGE("sending with empty parameter request list");
} else {
! list_add(options, option);
}
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_DISCOVER_TM);
! list_add(options, option);
requested_options = client_build_option_list(dc);
! list_join(options, requested_options); /* this destroys requested_options */
return options;
***************
*** 120,133 ****
static list_t *client_build_request_option_list(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
! list_t *requested_options = NULL;
dhcp_option_t *option;
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_REQUEST_TM);
! options = add_to_list(options, option);
requested_options = client_build_option_list(dc);
! options = join_lists(options, requested_options);
return options;
--- 124,138 ----
static list_t *client_build_request_option_list(dhcp_client_control_t *dc)
{
! list_t *options;
! list_t *requested_options;
dhcp_option_t *option;
+ options = list_create();
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_REQUEST_TM);
! list_add(options, option);
requested_options = client_build_option_list(dc);
! list_join(options, requested_options); /* this destroys requested_options */
return options;
***************
*** 137,150 ****
static list_t *client_build_renew_option_list(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
dhcp_option_t *option;
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_REQUEST_TM);
! options = add_to_list(options, option);
/* client_id */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! options = add_to_list(options, option);
return options;
--- 142,156 ----
static list_t *client_build_renew_option_list(dhcp_client_control_t *dc)
{
! list_t *options;
dhcp_option_t *option;
+ options = list_create();
/* dhcp message type. */
option = dhcp_build_message_type(DHCP_REQUEST_TM);
! list_add(options, option);
/* client_id */
option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1));
! list_add(options, option);
return options;
***************
*** 229,233 ****
/* is rawnet happy with the packet? */
! if(((!rawnet_is_valid(dc->rawnet)) "&&
/* is it a DHCP packet? */
--- 235,239 ----
/* is rawnet happy with the packet? */
! if(((!rawnet_is_valid(dc->rawnet)) &&
/* is it a DHCP packet? */
***************
*** 305,309 ****
dhcp_client_update_secs(dc);
! rawnet_dhcp_update(dc->rawnet, (uint16_t)dc->secs);
return;
}
--- 311,315 ----
dhcp_client_update_secs(dc);
! rawnet_dhcp_update(dc->rawnet, (uint16_t)dc->secs); /* FIXME: this may be an integer overflow. */
return;
}
***************
*** 316,320 ****
timer_options = client_cache_load_option_timer_string_list(dc->cache, 0);
! if(timer_options == NULL) {
FATAL_MESSAGE("no timers to setup. we should have least one: lease time");
exit(1);
--- 322,326 ----
timer_options = client_cache_load_option_timer_string_list(dc->cache, 0);
! if(list_get_len(timer_options) == 0) {
FATAL_MESSAGE("no timers to setup. we should have least one: lease time");
exit(1);
***************
*** 405,409 ****
int client_discover_offer(dhcp_client_control_t *dc)
{
! list_t *options = NULL;
int retval;
--- 411,415 ----
int client_discover_offer(dhcp_client_control_t *dc)
{
! list_t *options;
int retval;
***************
*** 460,471 ****
if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_REQUESTED_IP_ADDRESS))
! dc->rawnet->dhcp_p->options =
! add_to_list(dc->rawnet->dhcp_p->options,
! dhcp_build_requested_ip_address(dhcp_get_yiaddr(dc->rawnet->dhcp_p)));
if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_SERVER_IDENTIFIER))
! dc->rawnet->dhcp_p->options =
! add_to_list(dc->rawnet->dhcp_p->options,
! dhcp_build_server_identifier(dhcp_get_siaddr(dc->rawnet->dhcp_p)));
/* dump cache file. */
--- 466,475 ----
if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_REQUESTED_IP_ADDRESS))
! list_add(dc->rawnet->dhcp_p->options,
! dhcp_build_requested_ip_address(dhcp_get_yiaddr(dc->rawnet->dhcp_p)));
if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_SERVER_IDENTIFIER))
! list_add(dc->rawnet->dhcp_p->options,
! dhcp_build_server_identifier(dhcp_get_siaddr(dc->rawnet->dhcp_p)));
/* dump cache file. */
***************
*** 493,502 ****
cache_options = client_cache_load_option_network_list(dc->cache, 0);
! if(cache_options == NULL) {
ERROR_MESSAGE("could not load cache.");
return STATE_FATAL_ERROR;
}
! options = join_lists(options, cache_options);
/* Our options cleared by build_* since they are passed
--- 497,507 ----
cache_options = client_cache_load_option_network_list(dc->cache, 0);
! if(list_get_len(cache_options) == 0) {
!
ERROR_MESSAGE("could not load cache.");
return STATE_FATAL_ERROR;
}
! list_join(options, cache_options); /* destroys cache_options. */
/* Our options cleared by build_* since they are passed
***************
*** 584,588 ****
options = client_cache_load_option_string_list(dc->cache, 0);
! if(options == NULL) {
ERROR_MESSAGE("received empty configuration cache! cannot configure host");
return STATE_FATAL_ERROR;
--- 589,593 ----
options = client_cache_load_option_string_list(dc->cache, 0);
! if(list_get_len(options) == 0) {
ERROR_MESSAGE("received empty configuration cache! cannot configure host");
return STATE_FATAL_ERROR;
***************
*** 672,676 ****
* need them: FIXME, revamp into one network module that uses
* raw or user level networking depending on our interface's
! * state */
rawnet_up(dc->rawnet);
--- 677,681 ----
* need them: FIXME, revamp into one network module that uses
* raw or user level networking depending on our interface's
! * state. */
rawnet_up(dc->rawnet);
***************
*** 697,702 ****
cached_options = client_cache_load_option_string_list(dc->cache, 0);
! if(cached_options != NULL)
! do_sysconf_cleanup(cached_options, dc);
cache_entry_purge_list(cached_options);
--- 702,706 ----
cached_options = client_cache_load_option_string_list(dc->cache, 0);
! do_sysconf_cleanup(cached_options, dc);
cache_entry_purge_list(cached_options);
***************
*** 715,719 ****
list_t *options;
int retval;
-
INFO_MESSAGE("attempting DHCP RENEW");
--- 719,722 ----
Index: dhcp-client.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** dhcp-client.c 31 Dec 2002 10:30:59 -0000 1.20
--- dhcp-client.c 2 Jan 2003 04:23:01 -0000 1.21
***************
*** 166,174 ****
interface_list = rawnet_list_inactive_interfaces();
! if(interface_list == NULL)
return NULL;
! first_interface = xstrdup(interface_list->data);
! purge_list(interface_list, NULL);
return first_interface;
}
--- 166,176 ----
interface_list = rawnet_list_inactive_interfaces();
! if(list_get_len(interface_list) == 0) {
! list_destroy(interface_list, xfree);
return NULL;
+ }
! first_interface = xstrdup(list_first(interface_list));
! list_destroy(interface_list, xfree);
return first_interface;
}
Index: dhcp-com.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-com.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** dhcp-com.c 27 Dec 2002 02:52:30 -0000 1.7
--- dhcp-com.c 2 Jan 2003 04:23:01 -0000 1.8
***************
*** 42,47 ****
dhcp = xmalloc(sizeof(dhcp_obj));
! dhcp->options = NULL;
! dhcp->options_seek = NULL;
return dhcp;
--- 42,46 ----
dhcp = xmalloc(sizeof(dhcp_obj));
! dhcp->options = list_create();
return dhcp;
***************
*** 52,77 ****
void dhcp_purge_option_list(list_t *options)
{
- list_t *list_ptr, *tmp;
- dhcp_option_t *option;
-
/* Free up options. */
! if(options) {
!
! list_ptr = options;
!
! while(list_ptr) {
!
! tmp = list_ptr->next;
! option = list_ptr->data;
!
! xfree(option->data);
! xfree(option);
! xfree(list_ptr);
!
! list_ptr = tmp;
! }
! }
!
return;
}
--- 51,57 ----
void dhcp_purge_option_list(list_t *options)
{
/* Free up options. */
! list_destroy(options, xfree);
return;
}
***************
*** 82,87 ****
{
dhcp_purge_option_list(dhcp->options);
! dhcp->options = NULL;
! dhcp->options_seek = NULL;
return;
--- 62,66 ----
{
dhcp_purge_option_list(dhcp->options);
! dhcp->options = list_create();
return;
***************
*** 177,181 ****
break;
! dhcp->options = add_to_end_of_list(dhcp->options, option);
len -= (optlen + 2);
--- 156,160 ----
break;
! list_add_to_end(dhcp->options, option);
len -= (optlen + 2);
***************
*** 184,189 ****
}
- dhcp->options_seek = dhcp->options;
-
return;
}
--- 163,166 ----
***************
*** 336,340 ****
void dhcp_reset_option_seek(dhcp_obj * dhcp)
{
! dhcp->options_seek = dhcp->options;
}
--- 313,317 ----
void dhcp_reset_option_seek(dhcp_obj * dhcp)
{
! list_rewind(dhcp->options);
}
***************
*** 343,356 ****
dhcp_option_t *dhcp_get_next_option(dhcp_obj * dhcp)
{
! dhcp_option_t *rval;
!
! if(dhcp->options_seek == NULL)
! return NULL;
!
! rval = dhcp->options_seek->data;
!
! dhcp->options_seek = dhcp->options_seek->next;
!
! return rval;
}
--- 320,324 ----
dhcp_option_t *dhcp_get_next_option(dhcp_obj * dhcp)
{
! return(list_next(dhcp->options));
}
***************
*** 462,471 ****
{
uint16_t len = 0;
- list_t *opts;
dhcp_option_t *opt;
int padding;
! for(opts = options; opts; opts = opts->next) {
! opt = opts->data;
len += 2; /* for tag and len bytes. */
--- 430,438 ----
{
uint16_t len = 0;
dhcp_option_t *opt;
int padding;
! list_rewind(options);
! while((opt = list_next(options)) != NULL) {
len += 2; /* for tag and len bytes. */
***************
*** 691,695 ****
{
dhcp->options = options;
- dhcp->options_seek = options;
return;
}
--- 658,661 ----
Index: dhcp-conf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-conf.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** dhcp-conf.c 22 Dec 2002 08:31:29 -0000 1.8
--- dhcp-conf.c 2 Jan 2003 04:23:01 -0000 1.9
***************
*** 106,112 ****
static void directive_destroy(directive_t *directive)
{
! list_t *type_ptr, *arg_ptr;
! list_t *tmp;
! arg_type_t arg_type;
arg_ptr = directive->arguments;
--- 106,113 ----
static void directive_destroy(directive_t *directive)
{
! list_t *arg_ptr;
! list_t *type_ptr;
! arg_type_t *arg_type;
! void *arg_data;
arg_ptr = directive->arguments;
***************
*** 116,139 ****
* and call the destroy routine per argument. */
! while(type_ptr) {
!
! /* FIXME: one of the limitations of the list code we're
! * using is that we cannot perform single purges. fix
! * later. just do raw list code here. */
! arg_type = *(arg_type_t *)type_ptr->data;
! argument_destroyers[arg_type](arg_ptr->data);
! arg_type_destroy((arg_type_t *)type_ptr->data);
! tmp = type_ptr->next;
! xfree(type_ptr);
! type_ptr = tmp;
- tmp = arg_ptr->next;
- xfree(arg_ptr);
- arg_ptr = tmp;
}
return;
}
--- 117,143 ----
* and call the destroy routine per argument. */
! list_rewind(type_ptr);
! list_rewind(arg_ptr);
! while((arg_type = list_next(type_ptr)) != NULL) {
! /* each arg_type tells us which destructor to call on the
! * argument data. */
! arg_data = list_next(arg_ptr);
! /* we're automatically rewound after any removal. */
! /* this won't free up the datums themselves. */
! list_remove_by_datum(type_ptr, arg_type);
! list_remove_by_datum(arg_ptr, arg_data);
!
! /* now destroy ourselves. */
! argument_destroyers[*arg_type](arg_data);
! arg_type_destr...
[truncated message content] |