summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-07-08 00:57:37 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-07-08 00:57:37 +0000
commit073bf89fea1fc8960b9af881d6d7e437e5590a07 (patch)
treee88a596c2a32d8f52d421e3391adcfdca0dbe4b9
parentcd1c07d3baff0d7820bc33af4c1cc0411babb92c (diff)
Eliminate unused code and associated parameters.
ok deraadt@
-rw-r--r--sbin/dhclient/dhclient.c11
-rw-r--r--sbin/dhclient/dhcpd.h8
-rw-r--r--sbin/dhclient/options.c94
3 files changed, 20 insertions, 93 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 43211880cf0..6af9e243b7e 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.71 2005/07/07 20:03:40 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.72 2005/07/08 00:57:36 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1392,8 +1392,7 @@ make_discover(struct interface_info *ip, struct client_lease *lease)
}
/* Set up the option buffer... */
- ip->client->packet_length = cons_options(&ip->client->packet, 0,
- options, 0, 0, 0, NULL, 0);
+ ip->client->packet_length = cons_options(&ip->client->packet, options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;
@@ -1466,8 +1465,7 @@ make_request(struct interface_info *ip, struct client_lease * lease)
}
/* Set up the option buffer... */
- ip->client->packet_length = cons_options(&ip->client->packet, 0,
- options, 0, 0, 0, NULL, 0);
+ ip->client->packet_length = cons_options(&ip->client->packet, options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;
@@ -1535,8 +1533,7 @@ make_decline(struct interface_info *ip, struct client_lease *lease)
}
/* Set up the option buffer... */
- ip->client->packet_length = cons_options(&ip->client->packet, 0,
- options, 0, 0, 0, NULL, 0);
+ ip->client->packet_length = cons_options(&ip->client->packet, options);
if (ip->client->packet_length < BOOTP_MIN_LEN)
ip->client->packet_length = BOOTP_MIN_LEN;
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 38484c5791c..c080e793f46 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.35 2005/07/07 20:03:40 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.36 2005/07/08 00:57:36 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -245,10 +245,8 @@ struct hash_table {
/* External definitions... */
/* options.c */
-int cons_options(struct dhcp_packet *, int,
- struct option_data *, int, int, int, u_int8_t *, int);
-char *pretty_print_option(unsigned int,
- unsigned char *, int, int, int);
+int cons_options(struct dhcp_packet *, struct option_data *);
+char *pretty_print_option(unsigned int, unsigned char *, int, int, int);
void do_packet(struct interface_info *, struct dhcp_packet *,
int, unsigned int, struct iaddr, struct hardware *);
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index a1301f47f0d..7653883c003 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.17 2005/07/07 20:03:40 krw Exp $ */
+/* $OpenBSD: options.c,v 1.18 2005/07/08 00:57:36 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -51,7 +51,7 @@ int bad_options_max = 5;
void parse_options(struct packet *);
void parse_option_buffer(struct packet *, unsigned char *, int);
int store_options(unsigned char *, int, struct option_data *,
- unsigned char *, int, int, int, int);
+ unsigned char *, int, int, int);
/*
@@ -196,24 +196,13 @@ parse_option_buffer(struct packet *packet,
* vendor options using the same routine.
*/
int
-cons_options(struct dhcp_packet *outpacket,
- int mms, struct option_data *options,
- int overload, /* Overload flags that may be set. */
- int terminate, int bootpp, u_int8_t *prl, int prl_len)
+cons_options(struct dhcp_packet *outpacket, struct option_data *options)
{
unsigned char priority_list[300], buffer[4096];
int priority_len, main_buffer_size, mainbufix, bufix;
int option_size, length;
- if (mms)
- main_buffer_size = mms - DHCP_FIXED_LEN;
- else if (bootpp)
- main_buffer_size = 64;
- else
- main_buffer_size = 576 - DHCP_FIXED_LEN;
-
- if (main_buffer_size > sizeof(buffer))
- main_buffer_size = sizeof(buffer);
+ main_buffer_size = 576 - DHCP_FIXED_LEN;
/* Preload the option priority list with mandatory options. */
priority_len = 0;
@@ -222,33 +211,13 @@ cons_options(struct dhcp_packet *outpacket,
priority_list[priority_len++] = DHO_DHCP_LEASE_TIME;
priority_list[priority_len++] = DHO_DHCP_MESSAGE;
- /*
- * If the client has provided a list of options that it wishes
- * returned, use it to prioritize. Otherwise, prioritize based
- * on the default priority list.
- */
- if (prl) {
- if (prl_len + priority_len > sizeof(priority_list))
- prl_len = sizeof(priority_list) - priority_len;
-
- memcpy(&priority_list[priority_len], prl, prl_len);
- priority_len += prl_len;
- prl = priority_list;
- } else {
- memcpy(&priority_list[priority_len],
- dhcp_option_default_priority_list,
- sizeof_dhcp_option_default_priority_list);
- priority_len += sizeof_dhcp_option_default_priority_list;
- }
+ memcpy(&priority_list[priority_len], dhcp_option_default_priority_list,
+ sizeof_dhcp_option_default_priority_list);
+ priority_len += sizeof_dhcp_option_default_priority_list;
/* Copy the options into the big buffer... */
- option_size = store_options(
- buffer,
- (main_buffer_size - 7 + ((overload & 1) ? DHCP_FILE_LEN : 0) +
- ((overload & 2) ? DHCP_SNAME_LEN : 0)),
- options, priority_list, priority_len, main_buffer_size,
- (main_buffer_size + ((overload & 1) ? DHCP_FILE_LEN : 0)),
- terminate);
+ option_size = store_options( buffer, (main_buffer_size - 7), options,
+ priority_list, priority_len, main_buffer_size, main_buffer_size);
/* Put the cookie up front... */
memcpy(outpacket->options, DHCP_OPTIONS_COOKIE, 4);
@@ -279,31 +248,6 @@ cons_options(struct dhcp_packet *outpacket,
buffer, main_buffer_size - mainbufix);
bufix = main_buffer_size - mainbufix;
length = DHCP_FIXED_NON_UDP + mainbufix;
- if (overload & 1) {
- if (option_size - bufix <= DHCP_FILE_LEN) {
- memcpy(outpacket->file,
- &buffer[bufix], option_size - bufix);
- mainbufix = option_size - bufix;
- if (mainbufix < DHCP_FILE_LEN)
- outpacket->file[mainbufix++] = (char)DHO_END;
- while (mainbufix < DHCP_FILE_LEN)
- outpacket->file[mainbufix++] = (char)DHO_PAD;
- } else {
- memcpy(outpacket->file,
- &buffer[bufix], DHCP_FILE_LEN);
- bufix += DHCP_FILE_LEN;
- }
- }
- if ((overload & 2) && option_size < bufix) {
- memcpy(outpacket->sname,
- &buffer[bufix], option_size - bufix);
-
- mainbufix = option_size - bufix;
- if (mainbufix < DHCP_SNAME_LEN)
- outpacket->file[mainbufix++] = (char)DHO_END;
- while (mainbufix < DHCP_SNAME_LEN)
- outpacket->file[mainbufix++] = (char)DHO_PAD;
- }
}
return (length);
}
@@ -314,9 +258,9 @@ cons_options(struct dhcp_packet *outpacket,
int
store_options(unsigned char *buffer, int buflen, struct option_data *options,
unsigned char *priority_list, int priority_len, int first_cutoff,
- int second_cutoff, int terminate)
+ int second_cutoff)
{
- int bufix = 0, option_stored[256], i, ix, tto;
+ int bufix = 0, option_stored[256], i, ix;
/* Zero out the stored-lengths array. */
memset(option_stored, 0, sizeof(option_stored));
@@ -352,13 +296,6 @@ store_options(unsigned char *buffer, int buflen, struct option_data *options,
/* We should now have a constant length for the option. */
length = options[code].len;
- /* Do we add a NUL? */
- if (terminate && dhcp_options[code].format[0] == 't') {
- length++;
- tto = 1;
- } else
- tto = 0;
-
/* Try to store the option. */
/*
@@ -398,13 +335,8 @@ store_options(unsigned char *buffer, int buflen, struct option_data *options,
/* Everything looks good - copy it in! */
buffer[bufix] = code;
buffer[bufix + 1] = incr;
- if (tto && incr == length) {
- memcpy(buffer + bufix + 2,
- options[code].data + ix, incr - 1);
- buffer[bufix + 2 + incr - 1] = 0;
- } else
- memcpy(buffer + bufix + 2,
- options[code].data + ix, incr);
+ memcpy(buffer + bufix + 2, options[code].data + ix,
+ incr);
length -= incr;
ix += incr;
bufix += 2 + incr;