diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-09 17:22:06 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-06-09 17:22:06 +0200 |
commit | 0cad5f9b6dd80858c3ebb3893e04d2378eddc872 (patch) | |
tree | 9891b5120accfee3a260c2b8563b1a464287966e | |
parent | 002be6e821eedfa190c5b060e7b61acb306c2a92 (diff) | |
download | busybox-w32-0cad5f9b6dd80858c3ebb3893e04d2378eddc872.tar.gz busybox-w32-0cad5f9b6dd80858c3ebb3893e04d2378eddc872.tar.bz2 busybox-w32-0cad5f9b6dd80858c3ebb3893e04d2378eddc872.zip |
udhcp: comment out unused domain compression code
function old new delta
attach_option 411 406 -5
dname_enc 381 167 -214
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-219) Total: -219 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/udhcp/common.c | 2 | ||||
-rw-r--r-- | networking/udhcp/common.h | 2 | ||||
-rw-r--r-- | networking/udhcp/domain_codec.c | 27 |
3 files changed, 18 insertions, 13 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 9ec752dfc..16bf69707 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -431,7 +431,7 @@ static NOINLINE void attach_option( | |||
431 | #if ENABLE_FEATURE_UDHCP_RFC3397 | 431 | #if ENABLE_FEATURE_UDHCP_RFC3397 |
432 | if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { | 432 | if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) { |
433 | /* reuse buffer and length for RFC1035-formatted string */ | 433 | /* reuse buffer and length for RFC1035-formatted string */ |
434 | allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length); | 434 | allocated = buffer = (char *)dname_enc(/*NULL, 0,*/ buffer, &length); |
435 | } | 435 | } |
436 | #endif | 436 | #endif |
437 | 437 | ||
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 60255eefa..73f860a77 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -218,7 +218,7 @@ void udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t | |||
218 | #endif | 218 | #endif |
219 | #if ENABLE_FEATURE_UDHCP_RFC3397 || ENABLE_FEATURE_UDHCPC6_RFC3646 || ENABLE_FEATURE_UDHCPC6_RFC4704 | 219 | #if ENABLE_FEATURE_UDHCP_RFC3397 || ENABLE_FEATURE_UDHCPC6_RFC3646 || ENABLE_FEATURE_UDHCPC6_RFC4704 |
220 | char *dname_dec(const uint8_t *cstr, int clen, const char *pre) FAST_FUNC; | 220 | char *dname_dec(const uint8_t *cstr, int clen, const char *pre) FAST_FUNC; |
221 | uint8_t *dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen) FAST_FUNC; | 221 | uint8_t *dname_enc(/*const uint8_t *cstr, int clen,*/ const char *src, int *retlen) FAST_FUNC; |
222 | #endif | 222 | #endif |
223 | struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC; | 223 | struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC; |
224 | 224 | ||
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c index b7a3a5353..752c0a863 100644 --- a/networking/udhcp/domain_codec.c +++ b/networking/udhcp/domain_codec.c | |||
@@ -109,11 +109,11 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre) | |||
109 | return ret; | 109 | return ret; |
110 | } | 110 | } |
111 | 111 | ||
112 | /* Convert a domain name (src) from human-readable "foo.blah.com" format into | 112 | /* Convert a domain name (src) from human-readable "foo.BLAH.com" format into |
113 | * RFC1035 encoding "\003foo\004blah\003com\000". Return allocated string, or | 113 | * RFC1035 encoding "\003foo\004blah\003com\000". Return allocated string, or |
114 | * NULL if an error occurs. | 114 | * NULL if an error occurs. |
115 | */ | 115 | */ |
116 | static uint8_t *convert_dname(const char *src) | 116 | static uint8_t *convert_dname(const char *src, int *retlen) |
117 | { | 117 | { |
118 | uint8_t c, *res, *lenptr, *dst; | 118 | uint8_t c, *res, *lenptr, *dst; |
119 | int len; | 119 | int len; |
@@ -129,6 +129,7 @@ static uint8_t *convert_dname(const char *src) | |||
129 | /* label too long, too short, or two '.'s in a row? abort */ | 129 | /* label too long, too short, or two '.'s in a row? abort */ |
130 | if (len > NS_MAXLABEL || len == 0 || (c == '.' && *src == '.')) { | 130 | if (len > NS_MAXLABEL || len == 0 || (c == '.' && *src == '.')) { |
131 | free(res); | 131 | free(res); |
132 | *retlen = 0; | ||
132 | return NULL; | 133 | return NULL; |
133 | } | 134 | } |
134 | *lenptr = len; | 135 | *lenptr = len; |
@@ -144,13 +145,16 @@ static uint8_t *convert_dname(const char *src) | |||
144 | 145 | ||
145 | if (dst - res >= NS_MAXCDNAME) { /* dname too long? abort */ | 146 | if (dst - res >= NS_MAXCDNAME) { /* dname too long? abort */ |
146 | free(res); | 147 | free(res); |
148 | *retlen = 0; | ||
147 | return NULL; | 149 | return NULL; |
148 | } | 150 | } |
149 | 151 | ||
150 | *dst = 0; | 152 | *dst++ = 0; |
153 | *retlen = dst - res; | ||
151 | return res; | 154 | return res; |
152 | } | 155 | } |
153 | 156 | ||
157 | #if 0 //UNUSED | ||
154 | /* Returns the offset within cstr at which dname can be found, or -1 */ | 158 | /* Returns the offset within cstr at which dname can be found, or -1 */ |
155 | static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname) | 159 | static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname) |
156 | { | 160 | { |
@@ -188,28 +192,27 @@ static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname) | |||
188 | 192 | ||
189 | return -1; | 193 | return -1; |
190 | } | 194 | } |
195 | #endif | ||
191 | 196 | ||
197 | uint8_t* FAST_FUNC dname_enc(/*const uint8_t *cstr, int clen,*/ const char *src, int *retlen) | ||
198 | { | ||
199 | #if 0 //UNUSED, was intended for long, repetitive DHCP_DOMAIN_SEARCH options? | ||
200 | uint8_t *d, *dname; | ||
192 | /* Computes string to be appended to cstr so that src would be added to | 201 | /* Computes string to be appended to cstr so that src would be added to |
193 | * the compression (best case, it's a 2-byte pointer to some offset within | 202 | * the compression (best case, it's a 2-byte pointer to some offset within |
194 | * cstr; worst case, it's all of src, converted to <4>host<3>com<0> format). | 203 | * cstr; worst case, it's all of src, converted to <4>host<3>com<0> format). |
195 | * The computed string is returned directly; its length is returned via retlen; | 204 | * The computed string is returned directly; its length is returned via retlen; |
196 | * NULL and 0, respectively, are returned if an error occurs. | 205 | * NULL and 0, respectively, are returned if an error occurs. |
197 | */ | 206 | */ |
198 | uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen) | 207 | dname = convert_dname(src, retlen); |
199 | { | ||
200 | uint8_t *d, *dname; | ||
201 | int off; | ||
202 | |||
203 | dname = convert_dname(src); | ||
204 | if (dname == NULL) { | 208 | if (dname == NULL) { |
205 | *retlen = 0; | ||
206 | return NULL; | 209 | return NULL; |
207 | } | 210 | } |
208 | 211 | ||
209 | d = dname; | 212 | d = dname; |
210 | while (*d) { | 213 | while (*d) { |
211 | if (cstr) { | 214 | if (cstr) { |
212 | off = find_offset(cstr, clen, d); | 215 | int off = find_offset(cstr, clen, d); |
213 | if (off >= 0) { /* found a match, add pointer and return */ | 216 | if (off >= 0) { /* found a match, add pointer and return */ |
214 | *d++ = NS_CMPRSFLGS | (off >> 8); | 217 | *d++ = NS_CMPRSFLGS | (off >> 8); |
215 | *d = off; | 218 | *d = off; |
@@ -221,6 +224,8 @@ uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int | |||
221 | 224 | ||
222 | *retlen = d - dname + 1; | 225 | *retlen = d - dname + 1; |
223 | return dname; | 226 | return dname; |
227 | #endif | ||
228 | return convert_dname(src, retlen); | ||
224 | } | 229 | } |
225 | 230 | ||
226 | #ifdef DNS_COMPR_TESTING | 231 | #ifdef DNS_COMPR_TESTING |