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>
This commit is contained in:
parent
002be6e821
commit
0cad5f9b6d
@ -431,7 +431,7 @@ static NOINLINE void attach_option(
|
|||||||
#if ENABLE_FEATURE_UDHCP_RFC3397
|
#if ENABLE_FEATURE_UDHCP_RFC3397
|
||||||
if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
|
if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
|
||||||
/* reuse buffer and length for RFC1035-formatted 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
|
#endif
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ void udhcp_add_simple_option(struct dhcp_packet *packet, uint8_t code, uint32_t
|
|||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_UDHCP_RFC3397 || ENABLE_FEATURE_UDHCPC6_RFC3646 || ENABLE_FEATURE_UDHCPC6_RFC4704
|
#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;
|
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
|
#endif
|
||||||
struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC;
|
struct option_set *udhcp_find_option(struct option_set *opt_list, uint8_t code) FAST_FUNC;
|
||||||
|
|
||||||
|
@ -109,11 +109,11 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre)
|
|||||||
return ret;
|
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
|
* RFC1035 encoding "\003foo\004blah\003com\000". Return allocated string, or
|
||||||
* NULL if an error occurs.
|
* 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;
|
uint8_t c, *res, *lenptr, *dst;
|
||||||
int len;
|
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 */
|
/* label too long, too short, or two '.'s in a row? abort */
|
||||||
if (len > NS_MAXLABEL || len == 0 || (c == '.' && *src == '.')) {
|
if (len > NS_MAXLABEL || len == 0 || (c == '.' && *src == '.')) {
|
||||||
free(res);
|
free(res);
|
||||||
|
*retlen = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*lenptr = len;
|
*lenptr = len;
|
||||||
@ -144,13 +145,16 @@ static uint8_t *convert_dname(const char *src)
|
|||||||
|
|
||||||
if (dst - res >= NS_MAXCDNAME) { /* dname too long? abort */
|
if (dst - res >= NS_MAXCDNAME) { /* dname too long? abort */
|
||||||
free(res);
|
free(res);
|
||||||
|
*retlen = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dst = 0;
|
*dst++ = 0;
|
||||||
|
*retlen = dst - res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 //UNUSED
|
||||||
/* Returns the offset within cstr at which dname can be found, or -1 */
|
/* 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)
|
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;
|
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
|
/* 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
|
* 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).
|
* 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;
|
* The computed string is returned directly; its length is returned via retlen;
|
||||||
* NULL and 0, respectively, are returned if an error occurs.
|
* 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)
|
dname = convert_dname(src, retlen);
|
||||||
{
|
|
||||||
uint8_t *d, *dname;
|
|
||||||
int off;
|
|
||||||
|
|
||||||
dname = convert_dname(src);
|
|
||||||
if (dname == NULL) {
|
if (dname == NULL) {
|
||||||
*retlen = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = dname;
|
d = dname;
|
||||||
while (*d) {
|
while (*d) {
|
||||||
if (cstr) {
|
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 */
|
if (off >= 0) { /* found a match, add pointer and return */
|
||||||
*d++ = NS_CMPRSFLGS | (off >> 8);
|
*d++ = NS_CMPRSFLGS | (off >> 8);
|
||||||
*d = off;
|
*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;
|
*retlen = d - dname + 1;
|
||||||
return dname;
|
return dname;
|
||||||
|
#endif
|
||||||
|
return convert_dname(src, retlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DNS_COMPR_TESTING
|
#ifdef DNS_COMPR_TESTING
|
||||||
|
Loading…
Reference in New Issue
Block a user