From: Roy Marples Date: Wed, 6 Aug 2008 22:12:37 +0000 (+0000) Subject: Revert FQDN to ASCII encoding as I cannot find out what RFC4702 really means for... X-Git-Tag: v4.0.2~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4971c6237d01d56a1a6fb34df8568682c7638032;p=thirdparty%2Fdhcpcd.git Revert FQDN to ASCII encoding as I cannot find out what RFC4702 really means for encoding :/ --- diff --git a/dhcp.c b/dhcp.c index 1ad19c03..578ec112 100644 --- a/dhcp.c +++ b/dhcp.c @@ -713,8 +713,6 @@ make_message(struct dhcp_message **message, uint32_t ul; uint16_t sz; const struct dhcp_opt *opt; - uint8_t *d; - const char *c, *e; dhcp = xzalloc(sizeof (*dhcp)); m = (uint8_t *)dhcp; @@ -832,9 +830,9 @@ make_message(struct dhcp_message **message, memcpy(p, options->hostname, options->hostname[0] + 1); p += options->hostname[0] + 1; } else { - /* Draft IETF DHC-FQDN option (81) */ + /* IETF DHC-FQDN option (81), RFC4702 */ *p++ = DHCP_FQDN; - *p++ = options->hostname[0] + 5; + *p++ = options->hostname[0] + 3; /* * Flags: 0000NEOS * S: 1 => Client requests Server to update @@ -845,22 +843,19 @@ make_message(struct dhcp_message **message, * N: 1 => Client requests Server to not * update DNS */ - *p++ = (options->fqdn & 0x9) | 0x4; + *p++ = (options->fqdn & 0x9); + /* FIXME: We should use DNS format as + * RFC4702 claims ASCII is deprecated. + * However I cannot find anything that says + * what this encoding actually is, so we + * use ASCII. + * To flip the encoding bit, set it like so + * *p++ = (options->fqdn & 0x9) | 0x4; */ *p++ = 0; /* from server for PTR RR */ *p++ = 0; /* from server for A RR if S=1 */ - c = options->hostname + 1; - e = c + options->hostname[0]; - d = p++; - while (c < e) { - if (*c == '.') { - *d = p - d - 1; - d = p++; - } else - *p++ = (uint8_t) *c; - c++; - } - *d = p - d - 1; - *p++ = 0; + memcpy(p, options->hostname + 1, + options->hostname[0]); + p += options->hostname[0]; } }