[ipxe-devel] [PATCH 07/11] dhcpv6: make ipv6 address user-settable

Hannes Reinecke hare at suse.de
Thu May 7 09:25:02 UTC 2015


DHCPv6 returns the IPv6 address as a sub-option to
the DHCPV6_IA_NA option, but there is no reason
why it shouldn't be visible from the shell.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 src/net/udp/dhcpv6.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/net/udp/dhcpv6.c b/src/net/udp/dhcpv6.c
index e3953d2..2d14c41 100644
--- a/src/net/udp/dhcpv6.c
+++ b/src/net/udp/dhcpv6.c
@@ -215,7 +215,7 @@ static int dhcpv6_iaaddr ( struct dhcpv6_option_list *options, uint32_t iaid,
 		return -EINVAL;
 
 	/* Check identity association ID */
-	if ( ia_na->iaid != htonl ( iaid ) )
+	if ( iaid != (uint32)-1 && ia_na->iaid != htonl ( iaid ) )
 		return -EINVAL;
 
 	/* Construct IA_NA sub-options list */
@@ -300,6 +300,19 @@ static int dhcpv6_fetch ( struct settings *settings,
 	size_t option_len;
 
 	/* Find option */
+	if (setting->tag == DHCPV6_IAADDR) {
+		struct in6_addr ip6_addr;
+		int rc;
+
+		rc = dhcpv6_iaaddr( &dhcpv6set->options, -1, &ip6_addr );
+		if ( rc != 0 )
+			return rc;
+		option_len = sizeof (struct in6_addr);
+		if (len > option_len)
+			len = option_len;
+		memcpy( data, (char *)&ip6_addr, len );
+		return option_len;
+	}
 	option = dhcpv6_option ( &dhcpv6set->options, setting->tag );
 	if ( ! option )
 		return -ENOENT;
@@ -988,6 +1001,15 @@ int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
 	return rc;
 }
 
+/** IPv6 address setting */
+const struct setting ip6_setting __setting ( SETTING_IP_EXTRA, ip6 ) = {
+	.name = "ip6",
+	.description = "IPv6 address",
+	.tag = DHCPV6_IAADDR,
+	.type = &setting_type_ipv6,
+	.scope = &ipv6_scope,
+};
+
 /** Boot filename setting */
 const struct setting filename6_setting __setting ( SETTING_BOOT, filename ) = {
 	.name = "filename",
-- 
1.8.4.5




More information about the ipxe-devel mailing list