]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add -S to optionally request a Microsoft CSR. -SS only request a Microsoft CSR and...
authorRoy Marples <roy@marples.name>
Tue, 15 Jan 2008 14:34:28 +0000 (14:34 +0000)
committerRoy Marples <roy@marples.name>
Tue, 15 Jan 2008 14:34:28 +0000 (14:34 +0000)
dhcp.c
dhcp.h
dhcpcd.8.in
dhcpcd.c
dhcpcd.h

diff --git a/dhcp.c b/dhcp.c
index 22cdd5b8384ddc5c695a7cecd8e16ed3f5451122..1550ce692d3cff36c18b03da2e2f06afa34056b3 100644 (file)
--- 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 1a7de8920a3f622db5598de09cd86b42a7e06f8d..fc75fd4cef4433fd6092774d69c03d06fbe9026d 100644 (file)
--- 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
 };
 
index 038e96440931b612e8fa3986d00a9ee3a76567ff..489836645642b42303113250f53d766289853ba0 100644 (file)
@@ -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.
index 8bb65277721a6ae50c39e91159a60084b61d8f58..37bbd9c45f42c6e810a63f9cdb7fd4732382eb58 100644 (file)
--- 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] <interface>\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");
index 70caf98840f7881071491b88fe9e7c2311c0cb38..d2e3aa86212d024fd19ad63e13aee16a161c537d 100644 (file)
--- 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;