summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2020-06-09 17:22:06 +0200
committerDenys Vlasenko2020-06-09 17:22:06 +0200
commit0cad5f9b6dd80858c3ebb3893e04d2378eddc872 (patch)
tree9891b5120accfee3a260c2b8563b1a464287966e /networking
parent002be6e821eedfa190c5b060e7b61acb306c2a92 (diff)
downloadbusybox-0cad5f9b6dd80858c3ebb3893e04d2378eddc872.zip
busybox-0cad5f9b6dd80858c3ebb3893e04d2378eddc872.tar.gz
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>
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/common.c2
-rw-r--r--networking/udhcp/common.h2
-rw-r--r--networking/udhcp/domain_codec.c27
3 files changed, 18 insertions, 13 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 9ec752d..16bf697 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -431,7 +431,7 @@ static NOINLINE void attach_option(
#if ENABLE_FEATURE_UDHCP_RFC3397
if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
/* reuse buffer and length for RFC1035-formatted string */
- allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);
+ allocated = buffer = (char *)dname_enc(/*NULL, 0,*/ buffer, &length);
}
#endif
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 60255ee..73f860a 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
#endif
#if ENABLE_FEATURE_UDHCP_RFC3397 || ENABLE_FEATURE_UDHCPC6_RFC3646 || ENABLE_FEATURE_UDHCPC6_RFC4704
char *dname_dec(const uint8_t *cstr, int clen, const char *pre) FAST_FUNC;
-uint8_t *dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen) FAST_FUNC;
+uint8_t *dname_enc(/*const uint8_t *cstr, int clen,*/ const char *src, int *retlen) FAST_FUNC;
#endif
struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC;
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c
index b7a3a53..752c0a8 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)
return ret;
}
-/* Convert a domain name (src) from human-readable "foo.blah.com" format into
+/* Convert a domain name (src) from human-readable "foo.BLAH.com" format into
* RFC1035 encoding "\003foo\004blah\003com\000". Return allocated string, or
* NULL if an error occurs.
*/
-static uint8_t *convert_dname(const char *src)
+static uint8_t *convert_dname(const char *src, int *retlen)
{
uint8_t c, *res, *lenptr, *dst;
int len;
@@ -129,6 +129,7 @@ static uint8_t *convert_dname(const char *src)
/* label too long, too short, or two '.'s in a row? abort */
if (len > NS_MAXLABEL || len == 0 || (c == '.' && *src == '.')) {
free(res);
+ *retlen = 0;
return NULL;
}
*lenptr = len;
@@ -144,13 +145,16 @@ static uint8_t *convert_dname(const char *src)
if (dst - res >= NS_MAXCDNAME) { /* dname too long? abort */
free(res);
+ *retlen = 0;
return NULL;
}
- *dst = 0;
+ *dst++ = 0;
+ *retlen = dst - res;
return res;
}
+#if 0 //UNUSED
/* Returns the offset within cstr at which dname can be found, or -1 */
static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname)
{
@@ -188,28 +192,27 @@ static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname)
return -1;
}
+#endif
+uint8_t* FAST_FUNC dname_enc(/*const uint8_t *cstr, int clen,*/ const char *src, int *retlen)
+{
+#if 0 //UNUSED, was intended for long, repetitive DHCP_DOMAIN_SEARCH options?
+ uint8_t *d, *dname;
/* Computes string to be appended to cstr so that src would be added to
* the compression (best case, it's a 2-byte pointer to some offset within
* cstr; worst case, it's all of src, converted to <4>host<3>com<0> format).
* The computed string is returned directly; its length is returned via retlen;
* NULL and 0, respectively, are returned if an error occurs.
*/
-uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int *retlen)
-{
- uint8_t *d, *dname;
- int off;
-
- dname = convert_dname(src);
+ dname = convert_dname(src, retlen);
if (dname == NULL) {
- *retlen = 0;
return NULL;
}
d = dname;
while (*d) {
if (cstr) {
- off = find_offset(cstr, clen, d);
+ int off = find_offset(cstr, clen, d);
if (off >= 0) { /* found a match, add pointer and return */
*d++ = NS_CMPRSFLGS | (off >> 8);
*d = off;
@@ -221,6 +224,8 @@ uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int
*retlen = d - dname + 1;
return dname;
+#endif
+ return convert_dname(src, retlen);
}
#ifdef DNS_COMPR_TESTING