summaryrefslogtreecommitdiffhomepage
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2005-09-22 19:03:24 +0000
committerPaul Fox <pgf@brightstareng.com>2005-09-22 19:03:24 +0000
commitb6f71645f452572640a0529fb091f71cf8a30c3e (patch)
tree37b9519c4a5cc1199dfb1563d61447d32cff3a60 /networking/udhcp/options.c
parent28de951b022d39516de271ce0ba53560aa3c5555 (diff)
move a couple of functions from common code (options.c) to udhcpd private
code (files.c) to make udhcpc a little smaller.
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c48
1 files changed, 1 insertions, 47 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 000f86c79..e81d0a757 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -7,8 +7,8 @@
#include <string.h>
#include "dhcpd.h"
-#include "files.h"
#include "options.h"
+#include "files.h"
#include "common.h"
@@ -171,49 +171,3 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
return 0;
}
-
-/* find option 'code' in opt_list */
-struct option_set *find_option(struct option_set *opt_list, char code)
-{
- while (opt_list && opt_list->data[OPT_CODE] < code)
- opt_list = opt_list->next;
-
- if (opt_list && opt_list->data[OPT_CODE] == code) return opt_list;
- else return NULL;
-}
-
-
-/* add an option to the opt_list */
-void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length)
-{
- struct option_set *existing, *new, **curr;
-
- /* add it to an existing option */
- if ((existing = find_option(*opt_list, option->code))) {
- DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name);
- if (option->flags & OPTION_LIST) {
- if (existing->data[OPT_LEN] + length <= 255) {
- existing->data = realloc(existing->data,
- existing->data[OPT_LEN] + length + 2);
- memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
- existing->data[OPT_LEN] += length;
- } /* else, ignore the data, we could put this in a second option in the future */
- } /* else, ignore the new data */
- } else {
- DEBUG(LOG_INFO, "Attaching option %s to list", option->name);
-
- /* make a new option */
- new = xmalloc(sizeof(struct option_set));
- new->data = xmalloc(length + 2);
- new->data[OPT_CODE] = option->code;
- new->data[OPT_LEN] = length;
- memcpy(new->data + 2, buffer, length);
-
- curr = opt_list;
- while (*curr && (*curr)->data[OPT_CODE] < option->code)
- curr = &(*curr)->next;
-
- new->next = *curr;
- *curr = new;
- }
-}