changeset 281:f03f795bb953 draft

Add -S to optionally request a Microsoft CSR. -SS only request a Microsoft CSR and not a normal.
author Roy Marples <roy@marples.name>
date Tue, 15 Jan 2008 14:34:28 +0000
parents 593e3a20fbe2
children 34dc93285adf
files dhcp.c dhcp.h dhcpcd.8.in dhcpcd.c dhcpcd.h
diffstat 5 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp.c	Wed Jan 09 15:51:04 2008 +0000
+++ b/dhcp.c	Tue Jan 15 14:34:28 2008 +0000
@@ -205,9 +205,17 @@
 			}
 			*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 @@
 	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 @@
 				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 @@
 	   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 {
--- a/dhcp.h	Wed Jan 09 15:51:04 2008 +0000
+++ b/dhcp.h	Tue Jan 15 14:34:28 2008 +0000
@@ -104,6 +104,7 @@
 	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
 };
 
--- a/dhcpcd.8.in	Wed Jan 09 15:51:04 2008 +0000
+++ b/dhcpcd.8.in	Tue Jan 15 14:34:28 2008 +0000
@@ -3,7 +3,7 @@
 dhcpcd \- DHCP client daemon
 .SH SYNOPSIS
 dhcpcd
-\%[\-dknpAEGHMLNRTY]
+\%[\-dknpAEGHMLNRSTY]
 \%[\-c\ script]
 \%[\-h\ hostname]
 \%[\-i\ vendorClassID]
@@ -301,6 +301,17 @@
 .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.
--- a/dhcpcd.c	Wed Jan 09 15:51:04 2008 +0000
+++ b/dhcpcd.c	Tue Jan 15 14:34:28 2008 +0000
@@ -80,17 +80,18 @@
 	{"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 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] <interface>\n");
@@ -383,6 +384,9 @@
 			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");
--- a/dhcpcd.h	Wed Jan 09 15:51:04 2008 +0000
+++ b/dhcpcd.h	Tue Jan 15 14:34:28 2008 +0000
@@ -77,6 +77,7 @@
 	bool doinform;
 	bool dorequest;
 	bool doipv4ll;
+	int domscsr;
 
 	struct in_addr request_address;
 	struct in_addr request_netmask;