diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-02-03 16:19:08 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-02-03 16:19:08 -0600 |
commit | 75ef2d9d0b2df68a7914d8eeeb7a70024b7d79c5 (patch) | |
tree | f15e7eb83b334eaabe2ec25454fea4a3c264282a /nuttx | |
parent | c58d132a95d6b912e53c355c3fcc65a64e75bd6a (diff) | |
download | px4-nuttx-75ef2d9d0b2df68a7914d8eeeb7a70024b7d79c5.tar.gz px4-nuttx-75ef2d9d0b2df68a7914d8eeeb7a70024b7d79c5.tar.bz2 px4-nuttx-75ef2d9d0b2df68a7914d8eeeb7a70024b7d79c5.zip |
ICMPv6: Some initial bugfix from first tests of the ICMPv6 auto-configuration logic. so far so good but a lot more testing is needed
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/net/icmpv6/icmpv6_autoconfig.c | 27 | ||||
-rw-r--r-- | nuttx/net/icmpv6/icmpv6_input.c | 2 |
2 files changed, 22 insertions, 7 deletions
diff --git a/nuttx/net/icmpv6/icmpv6_autoconfig.c b/nuttx/net/icmpv6/icmpv6_autoconfig.c index 747651e3d..2c0a9a9c9 100644 --- a/nuttx/net/icmpv6/icmpv6_autoconfig.c +++ b/nuttx/net/icmpv6/icmpv6_autoconfig.c @@ -38,7 +38,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET_ICMPv6_AUTOCONF #include <stdint.h> #include <string.h> @@ -55,6 +54,8 @@ #include "netdev/netdev.h" #include "icmpv6/icmpv6.h" +#ifdef CONFIG_NET_ICMPv6_AUTOCONF + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -230,6 +231,7 @@ int icmpv6_send_rsolicit(FAR struct net_driver_s *dev) while (!state.snd_sent); icmpv6_callback_free(state.snd_cb); + ret = OK; errout_with_semaphore: sem_destroy(&state.snd_sem); @@ -380,15 +382,22 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) * fe80 0000 0000 0000 0000 xxxx xxxx xxxx */ - lladdr[0] = 0xfe80; /* 10-bit address + 6 zeroes */ - memset(&lladdr[1], 0, 4* sizeof(uint16_t)); /* 64 more zeroes */ - memcpy(&lladdr[5], dev->d_mac.ether_addr_octet, sizeof(struct ether_addr)); /* 48-bit Ethernet address */ + lladdr[0] = HTONS(0xfe80); /* 10-bit address + 6 zeroes */ + memset(&lladdr[1], 0, 4* sizeof(uint16_t)); /* 64 more zeroes */ + memcpy(&lladdr[5], dev->d_mac.ether_addr_octet, + sizeof(struct ether_addr)); /* 48-bit Ethernet address */ nvdbg("lladdr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", lladdr[0], lladdr[1], lladdr[2], lladdr[3], lladdr[4], lladdr[6], lladdr[6], lladdr[7]); #ifdef CONFIG_NET_ICMPv6_NEIGHBOR + /* Bring the interface up with no IP address */ + + save = net_lock(); + netdev_ifup(dev); + net_unlock(save); + /* 2. Link-Local Address Uniqueness Test: The node tests to ensure that * the address it generated isn't for some reason already in use on the * local network. (This is very unlikely to be an issue if the link-local @@ -402,12 +411,20 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) */ ret = icmpv6_neighbor(lladdr); + + /* Take the interface back down */ + + save = net_lock(); + netdev_ifdown(dev); + net_unlock(save); + if (ret == OK) { /* Hmmm... someone else responded to our Neighbor Solicitation. We * have not back-up plan in place. Just bail. */ + ndbg("ERROR: IP conflict\n"); return -EEXIST; } #endif @@ -418,11 +435,11 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) * on the wider Internet (since link-local addresses are not routed). */ + save = net_lock(); net_ipv6addr_copy(dev->d_ipv6addr, lladdr); /* Bring the interface up with the new, temporary IP address */ - save = net_lock(); netdev_ifup(dev); /* 4. Router Contact: The node next attempts to contact a local router for diff --git a/nuttx/net/icmpv6/icmpv6_input.c b/nuttx/net/icmpv6/icmpv6_input.c index 8aeaddfe8..b834bb9c9 100644 --- a/nuttx/net/icmpv6/icmpv6_input.c +++ b/nuttx/net/icmpv6/icmpv6_input.c @@ -43,7 +43,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#ifdef CONFIG_NET #include <stdint.h> #include <string.h> @@ -410,4 +409,3 @@ icmpv_send_nothing: } #endif /* CONFIG_NET_ICMPv6 */ -#endif /* CONFIG_NET */ |