From: Roy Marples Date: Tue, 15 Jan 2008 14:34:28 +0000 (+0000) Subject: Add -S to optionally request a Microsoft CSR. -SS only request a Microsoft CSR and... X-Git-Tag: v3.2.3~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0642e6be9ec68559bd7053f04683d2fca1881a2f;p=thirdparty%2Fdhcpcd.git Add -S to optionally request a Microsoft CSR. -SS only request a Microsoft CSR and not a normal. --- diff --git a/dhcp.c b/dhcp.c index 22cdd5b8..1550ce69 100644 --- a/dhcp.c +++ b/dhcp.c @@ -205,9 +205,17 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp, } *p++ = DHCP_NETMASK; *p++ = DHCP_BROADCAST; - *p++ = DHCP_CSR; - /* RFC 3442 states classless static routes should be before routers - * and static routes as classless static routes override them both */ + + /* -S means request CSR and MSCSR + * -SS means only request MSCSR incase DHCP message + * is too big */ + if (options->domscsr < 2) + *p++ = DHCP_CSR; + if (options->domscsr > 0) + *p++ = DHCP_MSCSR; + /* RFC 3442 states classless static routes should be + * before routers and static routes as classless static + * routes override them both */ *p++ = DHCP_STATICROUTE; *p++ = DHCP_ROUTERS; *p++ = DHCP_HOSTNAME; @@ -575,6 +583,7 @@ int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message) route_t *static_routes = NULL; route_t *static_routesp = NULL; route_t *csr = NULL; + route_t *mscsr = NULL; bool in_overload = false; bool parse_sname = false; bool parse_file = false; @@ -764,6 +773,12 @@ parse_start: csr = decode_CSR (p, length); break; + case DHCP_MSCSR: + MIN_LENGTH (5); + free_route (mscsr); + mscsr = decode_CSR (p, length); + break; + #ifdef ENABLE_INFO case DHCP_SIPSERVER: free (dhcp->sipservers); @@ -856,6 +871,11 @@ eexit: static routes and routers according to RFC 3442 */ if (csr) { dhcp->routes = csr; + free_route (mscsr); + free_route (routers); + free_route (static_routes); + } else if (mscsr) { + dhcp->routes = mscsr; free_route (routers); free_route (static_routes); } else { diff --git a/dhcp.h b/dhcp.h index 1a7de892..fc75fd4c 100644 --- a/dhcp.h +++ b/dhcp.h @@ -104,6 +104,7 @@ enum DHCP_OPTIONS DHCP_DNSSEARCH = 119, /* RFC 3397 */ DHCP_SIPSERVER = 120, /* RFC 3361 */ DHCP_CSR = 121, /* RFC 3442 */ + DHCP_MSCSR = 249, /* MS code for RFC 3442 */ DHCP_END = 255 }; diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 038e9644..48983664 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -3,7 +3,7 @@ dhcpcd \- DHCP client daemon .SH SYNOPSIS dhcpcd -\%[\-dknpAEGHMLNRTY] +\%[\-dknpAEGHMLNRSTY] \%[\-c\ script] \%[\-h\ hostname] \%[\-i\ vendorClassID] @@ -301,6 +301,17 @@ from replacing .I /etc/resolv.conf or using resolvconf. .TP +.BI \-S +Makes +.B dhcpcd +request Microsoft CSR option 249 as well as the normal CSR option 121. +Subsquent +.BI \-S +options disable the requesting of the normal CSR if the dhcp message returned +is too big. +Ideally, DHCP servers should start responding to option 121 so +that users don't have to deal with this mess. +.TP .BI \-T dhcpcd sends out a DHCP_DISCOVER message and then prints the values returned to stdout. It does not configure the interface or touch the .info files. diff --git a/dhcpcd.c b/dhcpcd.c index 8bb65277..37bbd9c4 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -80,17 +80,18 @@ static const struct option longopts[] = { {"nogateway", no_argument, NULL, 'G'}, {"sethostname", no_argument, NULL, 'H'}, {"clientid", optional_argument, NULL, 'I'}, - {"noipv4ll", no_argument, NULL, 'L'}, + {"noipv4ll", no_argument, NULL, 'L'}, {"nomtu", no_argument, NULL, 'M'}, {"nontp", no_argument, NULL, 'N'}, {"nodns", no_argument, NULL, 'R'}, + {"msscr", no_argument, NULL, 'S'}, {"test", no_argument, NULL, 'T'}, {"nonis", no_argument, NULL, 'Y'}, {"help", no_argument, &dohelp, 1}, {"version", no_argument, &doversion, 1}, #ifdef THERE_IS_NO_FORK - {"daemonised", no_argument, NULL, 'f'}, - {"skiproutes", required_argument, NULL, 'g'}, + {"daemonised", no_argument, NULL, 'f'}, + {"skiproutes", required_argument, NULL, 'g'}, #endif {NULL, 0, NULL, 0} }; @@ -139,7 +140,7 @@ static pid_t read_pid (const char *pidfile) static void usage (void) { - printf ("usage: "PACKAGE" [-adknpEGHMNRTY] [-c script] [-h hostname] [-i classID]\n" + printf ("usage: "PACKAGE" [-adknpEGHMNRSTY] [-c script] [-h hostname] [-i classID]\n" " [-l leasetime] [-m metric] [-r ipaddress] [-s ipaddress]\n" " [-t timeout] [-u userclass] [-F none | ptr | both]\n" " [-I clientID] \n"); @@ -383,6 +384,9 @@ int main(int argc, char **argv) case 'R': options->dodns = false; break; + case 'S': + options->domscsr++; + break; case 'T': #ifndef ENABLE_INFO logger (LOG_ERR, "info support not compiled into dhcpcd"); diff --git a/dhcpcd.h b/dhcpcd.h index 70caf988..d2e3aa86 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -77,6 +77,7 @@ typedef struct options_t { bool doinform; bool dorequest; bool doipv4ll; + int domscsr; struct in_addr request_address; struct in_addr request_netmask;