From 6273eb01609ca781d3246d99e9a5d7aab48d0f0b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 3 Feb 2015 15:40:56 -0600 Subject: [PATCH] ICMPv6: This completes coding of the ICMPv6 auto-configuration feature. It is not yet functional --- examples/nettest/Kconfig | 3 +++ examples/nettest/nettest.c | 18 ++++++++++-------- examples/udp/Kconfig | 5 ++++- examples/udp/target.c | 18 ++++++++++-------- nshlib/Kconfig | 7 ++----- nshlib/nsh_netinit.c | 13 ++++++------- 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index d5cd9b610..49d885a80 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -76,6 +76,7 @@ config EXAMPLES_NETTEST_CLIENTIP endif # EXAMPLES_NETTEST_IPv4 if EXAMPLES_NETTEST_IPv6 +if !NET_ICMPv6_AUTOCONF comment "Target IPv6 address" @@ -323,6 +324,8 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8 individually. This is the eighth of the 8-values. The default for all eight values is fe00::0. +#endif /* NET_ICMPv6_AUTOCONF */ + comment "Client IPv6 address" config EXAMPLES_NETTEST_CLIENTIPv6ADDR_1 diff --git a/examples/nettest/nettest.c b/examples/nettest/nettest.c index e4c9a1db3..b03b288c1 100644 --- a/examples/nettest/nettest.c +++ b/examples/nettest/nettest.c @@ -60,8 +60,7 @@ * Private Data ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_NETTEST_IPv6 -#ifndef CONFIG_NET_ICMPv6_AUTOCONF +#if defined(CONFIG_EXAMPLES_NETTEST_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF) /* Our host IPv6 address */ static const uint16_t g_ipv6_hostaddr[8] = @@ -75,7 +74,6 @@ static const uint16_t g_ipv6_hostaddr[8] = HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_7), HTONS(CONFIG_EXAMPLES_NETTEST_IPv6ADDR_8), }; -#endif /* Default routine IPv6 address */ @@ -104,7 +102,7 @@ static const uint16_t g_ipv6_netmask[8] = HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_7), HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_8), }; -#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ +#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ /**************************************************************************** * Public Functions @@ -145,12 +143,12 @@ int nettest_main(int argc, char *argv[]) netlib_icmpv6_autoconfiguration("eth0"); -#else +#else /* CONFIG_NET_ICMPv6_AUTOCONF */ + /* Set up our fixed host address */ netlib_set_ipv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_hostaddr); -#endif /* Set up the default router address */ @@ -161,7 +159,10 @@ int nettest_main(int argc, char *argv[]) netlib_set_ipv6netmask("eth0", (FAR const struct in6_addr *)g_ipv6_netmask); -#else + +#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ +#else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ + /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); @@ -176,7 +177,8 @@ int nettest_main(int argc, char *argv[]) addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); netlib_set_ipv4netmask("eth0", &addr); -#endif + +#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ #ifdef CONFIG_EXAMPLES_NETTEST_SERVER recv_server(); diff --git a/examples/udp/Kconfig b/examples/udp/Kconfig index eecd937b0..ff357750e 100644 --- a/examples/udp/Kconfig +++ b/examples/udp/Kconfig @@ -56,6 +56,7 @@ config EXAMPLES_UDP_SERVERIP endif # EXAMPLES_UDP_IPv4 if EXAMPLES_UDP_IPv6 +if !NET_ICMPv6_AUTOCONF comment "Target IPv6 address" @@ -303,7 +304,9 @@ config EXAMPLES_UDP_IPv6NETMASK_8 individually. This is the eighth of the 8-values. The default for all eight values is fe00::0. -comment "Client IPv6 address" +#endif /* NET_ICMPv6_AUTOCONF */ + +comment "Server IPv6 address" config EXAMPLES_UDP_SERVERIPv6ADDR_1 hex "[0]" diff --git a/examples/udp/target.c b/examples/udp/target.c index 2d80ac0dc..48e28be8d 100644 --- a/examples/udp/target.c +++ b/examples/udp/target.c @@ -57,8 +57,7 @@ * Private Data ****************************************************************************/ -#ifdef CONFIG_EXAMPLES_UDP_IPv6 -#ifdef CONFIG_NET_ICMPv6_AUTOCONF +#if defined(CONFIG_EXAMPLES_UDP_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF) /* Our host IPv6 address */ static const uint16_t g_ipv6_hostaddr[8] = @@ -72,7 +71,6 @@ static const uint16_t g_ipv6_hostaddr[8] = HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_7), HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_8), }; -#endif /* Default routine IPv6 address */ @@ -101,7 +99,7 @@ static const uint16_t g_ipv6_netmask[8] = HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_7), HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_8), }; -#endif /* CONFIG_EXAMPLES_UDP_IPv6 */ +#endif /* CONFIG_EXAMPLES_UDP_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ /**************************************************************************** * Public Functions @@ -123,12 +121,12 @@ int udp_main(int argc, char *argv[]) netlib_icmpv6_autoconfiguration("eth0"); -#else +#else /* CONFIG_NET_ICMPv6_AUTOCONF */ + /* Set up our fixed host address */ netlib_set_ipv6addr("eth0", (FAR const struct in6_addr *)g_ipv6_hostaddr); -#endif /* Set up the default router address */ @@ -139,7 +137,10 @@ int udp_main(int argc, char *argv[]) netlib_set_ipv6netmask("eth0", (FAR const struct in6_addr *)g_ipv6_netmask); -#else + +#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ +#else /* CONFIG_EXAMPLES_UDP_IPv6 */ + struct in_addr addr; /* Set up our host address */ @@ -156,7 +157,8 @@ int udp_main(int argc, char *argv[]) addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK); netlib_set_ipv4netmask("eth0", &addr); -#endif + +#endif /* CONFIG_EXAMPLES_UDP_IPv6 */ #ifdef CONFIG_EXAMPLES_UDP_SERVER recv_server(); diff --git a/nshlib/Kconfig b/nshlib/Kconfig index 8bcd5eda7..dc1001020 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -930,8 +930,7 @@ config NSH_NETMASK endif # NET_IPv4 -if NET_IPv6 -if !NET_ICMPv6_AUTOCONF +if NET_IPv6 && !NET_ICMPv6_AUTOCONF comment "Target IPv6 address" @@ -1023,8 +1022,6 @@ config NSH_IPv6ADDR_8 individually. This is the last of the 8-values. The default for all eight values is fc00::2. -endif # !NET_ICMPv6_AUTOCONF - comment "Router IPv6 address" config NSH_DRIPv6ADDR_1 @@ -1189,7 +1186,7 @@ config NSH_IPv6NETMASK_8 individually. This is the eighth of the 8-values. The default for all eight values is fe00::0. -endif #NET_IPv6 +endif #NET_IPv6 && !NET_ICMPv6_AUTOCONF endmenu # IP Address Configuration config NSH_DNS diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index c2b8bf952..1c4722909 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -131,8 +131,7 @@ static sem_t g_notify_sem; #endif -#ifdef CONFIG_NET_IPv6 -#ifndef CONFIG_NET_ICMPv6_AUTOCONF +#if defined(CONFIG_NET_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF) /* Host IPv6 address */ static const uint16_t g_ipv6_hostaddr[8] = @@ -146,7 +145,6 @@ static const uint16_t g_ipv6_hostaddr[8] = HTONS(CONFIG_NSH_IPv6ADDR_7), HTONS(CONFIG_NSH_IPv6ADDR_8), }; -#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Default routine IPv6 address */ @@ -175,7 +173,7 @@ static const uint16_t g_ipv6_netmask[8] = HTONS(CONFIG_NSH_IPv6NETMASK_7), HTONS(CONFIG_NSH_IPv6NETMASK_8), }; -#endif /* CONFIG_NET_IPv6 */ +#endif /* CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF*/ /**************************************************************************** * Private Function Prototypes @@ -260,13 +258,12 @@ static void nsh_netinit_configure(void) netlib_icmpv6_autoconfiguration(NET_DEVNAME); -#else +#else /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Set up our fixed host address */ netlib_set_ipv6addr(NET_DEVNAME, (FAR const struct in6_addr *)g_ipv6_hostaddr); -#endif /* Set up the default router address */ @@ -277,7 +274,9 @@ static void nsh_netinit_configure(void) netlib_set_ipv6netmask(NET_DEVNAME, (FAR const struct in6_addr *)g_ipv6_netmask); -#endif + +#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ +#endif /* CONFIG_NET_IPv6 */ #if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS) /* Set up the resolver */