]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix SIP server support, RFC 3361 which has been broken since dhcpcd-3.3.
authorRoy Marples <roy@marples.name>
Fri, 9 Dec 2011 19:40:05 +0000 (19:40 +0000)
committerRoy Marples <roy@marples.name>
Fri, 9 Dec 2011 19:40:05 +0000 (19:40 +0000)
Thanks to Egil Hjelmeland.

dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 65c477b5d674163b2b4de3208462a26255574d27..450e4e72fb7e39dc6178147b289f5d42fd8d88cf 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -160,6 +160,7 @@ static const struct dhcp_opt const dhcp_opts[] = {
        { 114,  STRING,         "default_url" },
        { 118,  IPV4,           "subnet_selection" },
        { 119,  STRING | RFC3397,       "domain_search" },
+       { 120,  STRING | RFC3361,       "sip_server" },
        { 212,  RFC5969,        "sixrd" },
        { 0, 0, NULL }
 };
@@ -621,11 +622,11 @@ decode_rfc3361(int dl, const uint8_t *data)
                addr.s_addr = INADDR_BROADCAST;
                l = ((dl / sizeof(addr.s_addr)) * ((4 * 4) + 1)) + 1;
                sip = p = xmalloc(l);
-               while (l != 0) {
+               while (dl != 0) {
                        memcpy(&addr.s_addr, data, sizeof(addr.s_addr));
                        data += sizeof(addr.s_addr);
                        p += snprintf(p, l - (p - sip), "%s ", inet_ntoa(addr));
-                       l -= sizeof(addr.s_addr);
+                       dl -= sizeof(addr.s_addr);
                }
                *--p = '\0';
                break;
@@ -1264,6 +1265,15 @@ print_option(char *s, ssize_t len, int type, int dl, const uint8_t *data)
                return l;
        }
 
+       if (type & RFC3361) {
+               if ((tmp = decode_rfc3361(dl, data)) == NULL)
+                       return -1;
+               l = strlen(tmp);
+               print_string(s, len, l, (uint8_t *)tmp);
+               free(tmp);
+               return l;
+       }
+
        if (type & RFC3442)
                return decode_rfc3442(s, len, dl, data);