diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-27 21:15:08 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-27 21:15:08 +0000 |
commit | 5066473d411d6a474af3393d1b62a58ee3313861 (patch) | |
tree | 7649f98fbe056b9b7f87893f70b5b50cc5007fe9 /networking/udhcp/files.c | |
parent | 966bb4376665e0cf22e64f7901fb956edbd2f1a9 (diff) | |
download | busybox-w32-5066473d411d6a474af3393d1b62a58ee3313861.tar.gz busybox-w32-5066473d411d6a474af3393d1b62a58ee3313861.tar.bz2 busybox-w32-5066473d411d6a474af3393d1b62a58ee3313861.zip |
udhcp: optionally support RFC3397 (by Gabriel L. Somlo <somlo@cmu.edu>)
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r-- | networking/udhcp/files.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index e35f50a17..ab6f4a3e4 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -104,6 +104,12 @@ static void attach_option(struct option_set **opt_list, | |||
104 | if (!existing) { | 104 | if (!existing) { |
105 | DEBUG("Attaching option %s to list", option->name); | 105 | DEBUG("Attaching option %s to list", option->name); |
106 | 106 | ||
107 | #if ENABLE_FEATURE_RFC3397 | ||
108 | if ((option->flags & TYPE_MASK) == OPTION_STR1035) | ||
109 | /* reuse buffer and length for RFC1035-formatted string */ | ||
110 | buffer = dname_enc(NULL, 0, buffer, &length); | ||
111 | #endif | ||
112 | |||
107 | /* make a new option */ | 113 | /* make a new option */ |
108 | new = xmalloc(sizeof(struct option_set)); | 114 | new = xmalloc(sizeof(struct option_set)); |
109 | new->data = xmalloc(length + 2); | 115 | new->data = xmalloc(length + 2); |
@@ -117,12 +123,22 @@ static void attach_option(struct option_set **opt_list, | |||
117 | 123 | ||
118 | new->next = *curr; | 124 | new->next = *curr; |
119 | *curr = new; | 125 | *curr = new; |
126 | #if ENABLE_FEATURE_RFC3397 | ||
127 | if ((option->flags & TYPE_MASK) == OPTION_STR1035 && buffer != NULL) | ||
128 | free(buffer); | ||
129 | #endif | ||
120 | return; | 130 | return; |
121 | } | 131 | } |
122 | 132 | ||
123 | /* add it to an existing option */ | 133 | /* add it to an existing option */ |
124 | DEBUG("Attaching option %s to existing member of list", option->name); | 134 | DEBUG("Attaching option %s to existing member of list", option->name); |
125 | if (option->flags & OPTION_LIST) { | 135 | if (option->flags & OPTION_LIST) { |
136 | #if ENABLE_FEATURE_RFC3397 | ||
137 | if ((option->flags & TYPE_MASK) == OPTION_STR1035) | ||
138 | /* reuse buffer and length for RFC1035-formatted string */ | ||
139 | buffer = dname_enc(existing->data + 2, | ||
140 | existing->data[OPT_LEN], buffer, &length); | ||
141 | #endif | ||
126 | if (existing->data[OPT_LEN] + length <= 255) { | 142 | if (existing->data[OPT_LEN] + length <= 255) { |
127 | existing->data = xrealloc(existing->data, | 143 | existing->data = xrealloc(existing->data, |
128 | existing->data[OPT_LEN] + length + 3); | 144 | existing->data[OPT_LEN] + length + 3); |
@@ -137,6 +153,10 @@ static void attach_option(struct option_set **opt_list, | |||
137 | memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); | 153 | memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); |
138 | existing->data[OPT_LEN] += length; | 154 | existing->data[OPT_LEN] += length; |
139 | } /* else, ignore the data, we could put this in a second option in the future */ | 155 | } /* else, ignore the data, we could put this in a second option in the future */ |
156 | #if ENABLE_FEATURE_RFC3397 | ||
157 | if ((option->flags & TYPE_MASK) == OPTION_STR1035 && buffer != NULL) | ||
158 | free(buffer); | ||
159 | #endif | ||
140 | } /* else, ignore the new data */ | 160 | } /* else, ignore the new data */ |
141 | } | 161 | } |
142 | 162 | ||
@@ -183,6 +203,9 @@ static int read_opt(const char *const_line, void *arg) | |||
183 | if (retval) retval = read_ip(val, buffer + 4); | 203 | if (retval) retval = read_ip(val, buffer + 4); |
184 | break; | 204 | break; |
185 | case OPTION_STRING: | 205 | case OPTION_STRING: |
206 | #if ENABLE_FEATURE_RFC3397 | ||
207 | case OPTION_STR1035: | ||
208 | #endif | ||
186 | length = strlen(val); | 209 | length = strlen(val); |
187 | if (length > 0) { | 210 | if (length > 0) { |
188 | if (length > 254) length = 254; | 211 | if (length > 254) length = 254; |