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 /networking/udhcp/domain_codec.c | |
parent | 002be6e821eedfa190c5b060e7b61acb306c2a92 (diff) |
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/udhcp/domain_codec.c')
-rw-r--r-- | networking/udhcp/domain_codec.c | 27 |
1 files changed, 16 insertions, 11 deletions
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) 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 |