[gPXE-devel] [PATCH 03/31] [ipv6] actually set an ipv6 address on an interface in the "ipv6" command
matthew at theiselins.net
matthew at theiselins.net
Fri Jul 8 10:28:12 EDT 2011
From: Matthew Iselin <matthew at theiselins.net>
Signed-off-by: Matthew Iselin <matthew at theiselins.net>
---
src/net/ipv6.c | 6 +++---
src/usr/ip6mgmt.c | 13 ++++++++++---
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 5ce4e1a..9925435 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -49,7 +49,7 @@ static LIST_HEAD ( miniroutes );
* Add IPv6 minirouting table entry
*
* @v netdev Network device
- * @v prefix Destination prefix
+ * @v prefix Destination prefix (in bits)
* @v address Address of the interface
* @v gateway Gateway address (or ::0 for no gateway)
* @ret miniroute Routing table entry, or NULL
@@ -60,7 +60,7 @@ add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix,
struct in6_addr gateway ) {
struct ipv6_miniroute *miniroute;
- DBG("ipv6 add: %s/%d ", inet6_ntoa(address), prefix_len * 8);
+ DBG("ipv6 add: %s/%d ", inet6_ntoa(address), prefix_len);
DBG("gw %s\n", inet6_ntoa(gateway));
miniroute = malloc ( sizeof ( *miniroute ) );
@@ -91,7 +91,7 @@ add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix,
static void del_ipv6_miniroute ( struct ipv6_miniroute *miniroute ) {
DBG("ipv6 del: %s/%d\n", inet6_ntoa(miniroute->address),
- miniroute->prefix_len * 8);
+ miniroute->prefix_len);
netdev_put ( miniroute->netdev );
list_del ( &miniroute->list );
diff --git a/src/usr/ip6mgmt.c b/src/usr/ip6mgmt.c
index 0809c7b..f0b69d4 100644
--- a/src/usr/ip6mgmt.c
+++ b/src/usr/ip6mgmt.c
@@ -34,8 +34,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
/* Maximum length of the link-layer address we'll insert as an EUI-64. */
#define AUTOCONF_LL_MAX 6
-int ip6_autoconf ( struct net_device *netdev __unused ) {
- struct in6_addr ip6addr;
+int ip6_autoconf ( struct net_device *netdev ) {
+ struct in6_addr ip6addr, ip6zero;
size_t ll_size;
int rc;
@@ -50,6 +50,7 @@ int ip6_autoconf ( struct net_device *netdev __unused ) {
/* Create the host ID part of the IPv6 address from the Link-Layer
* address on the netdevice. */
memset ( &ip6addr, 0, sizeof (struct in6_addr) );
+ memset ( &ip6zero, 0, sizeof (struct in6_addr) );
ll_size = netdev->ll_protocol->ll_addr_len;
if ( ll_size < 6 ) {
@@ -69,7 +70,13 @@ int ip6_autoconf ( struct net_device *netdev __unused ) {
ip6addr.s6_addr[0] = 0xFE;
ip6addr.s6_addr[1] = 0x80;
- DBG( "ip6 autoconfig address is %s\n", inet6_ntoa(ip6addr) );
+ /* TODO: send a few neighbour solicits on this address before we take
+ * it (once NDP is implemented). */
+
+ DBG( "ipv6 autoconfig address is %s\n", inet6_ntoa(ip6addr) );
+
+ /* Add as a route. */
+ add_ipv6_address ( netdev, ip6addr, 10, ip6addr, ip6zero );
return 0;
}
--
1.7.2.5
More information about the gPXE-devel
mailing list