From 19e8effd134678d9467e328090717b10cef0c208 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 5 Jan 2012 11:42:08 +0200 Subject: dhcpv6: Support stateless DHCPv6 See relevant parts from these RFCs: RFC 3315 - DHCP for IPv6 RFC 3646 - DNS configuration options for DHCP for IPv6 RFC 3736 - Stateless DHCP service for IPv6 RFC 4075 - SNTP configuration option for DHCPv6 The patch does not support authenticated information messages. --- gdhcp/client.c | 34 ++++++++++++++++++++++++++++++++++ gdhcp/gdhcp.h | 2 ++ 2 files changed, 36 insertions(+) (limited to 'gdhcp') diff --git a/gdhcp/client.c b/gdhcp/client.c index be8905c8..32ed4aa1 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -254,6 +254,15 @@ static void add_dhcpv6_request_options(GDHCPClient *dhcp_client, (*ptr_buf) += len; break; + case G_DHCPV6_ORO: + break; + + case G_DHCPV6_DNS_SERVERS: + break; + + case G_DHCPV6_SNTP_SERVERS: + break; + default: break; } @@ -1335,8 +1344,33 @@ static GList *get_dhcpv6_option_value_list(GDHCPClient *dhcp_client, unsigned char *value) { GList *list = NULL; + char *str; + int i; switch (code) { + case G_DHCPV6_DNS_SERVERS: /* RFC 3646, chapter 3 */ + case G_DHCPV6_SNTP_SERVERS: /* RFC 4075, chapter 4 */ + if (len % 16) { + debug(dhcp_client, + "%s server list length (%d) is invalid", + code == G_DHCPV6_DNS_SERVERS ? "DNS" : "SNTP", + len); + return NULL; + } + for (i = 0; i < len; i += 16) { + + str = g_try_malloc0(INET6_ADDRSTRLEN+1); + if (str == NULL) + return list; + + if (inet_ntop(AF_INET6, &value[i], str, + INET6_ADDRSTRLEN) == NULL) + g_free(str); + else + list = g_list_append(list, str); + } + break; + default: break; } diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h index 5c0e2ee5..c0385d4f 100644 --- a/gdhcp/gdhcp.h +++ b/gdhcp/gdhcp.h @@ -73,6 +73,8 @@ typedef enum { #define G_DHCPV6_SERVERID 2 #define G_DHCPV6_ORO 6 #define G_DHCPV6_STATUS_CODE 13 +#define G_DHCPV6_DNS_SERVERS 23 +#define G_DHCPV6_SNTP_SERVERS 31 typedef enum { G_DHCPV6_DUID_LLT = 1, -- cgit v1.2.3