dhcpcd-discuss

120:sip-server option

Egil Hjelmeland

Wed Dec 07 13:55:38 2011

Here is a patch against dhcpcd-5.2.12 which completes the 120 sip-server option support. I have tested it agains dnsmasq, both IP address lists and domain lists works.

Best regards
Egil Hjelmeland

--- dhcp.c.orig	2011-12-05 15:55:06.000000000 +0100
+++ dhcp.c	2011-12-07 14:24:20.000000000 +0100
@@ -159,6 +159,7 @@
 	{ 114,	STRING,		"default_url" },
 	{ 118,	IPV4,		"subnet_selection" },
 	{ 119,	STRING | RFC3397,	"domain_search" },
+	{ 120,	STRING | RFC3361,	"sip_server" },
 	{ 0, 0, NULL }
 };
 
@@ -620,11 +621,11 @@
 		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;
@@ -1198,6 +1199,15 @@
 	if (type & RFC3442)
 		return decode_rfc3442(s, len, dl, data);
 
+	if (type & RFC3361) {
+		char *str= decode_rfc3361(dl, data);
+		if (!str) return -1;
+		l = strlen(str);
+	        print_string(s, len, l , (uint8_t *)str);
+		free(str);
+		return l;
+	}
+	
 	if (type & STRING) {
 		/* Some DHCP servers return NULL strings */
 		if (*data == '\0')

Follow-Ups:
Re: 120:sip-server optionRoy Marples
Archive administrator: postmaster@marples.name