From 3571e1f20a7403bc50c5194b874dcb26fc3a6bae Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 16 Feb 2016 16:37:09 +0200 Subject: [PATCH] net: apps: Use IPv6 link local addresses in network apps Use link local addresses instead of public IPv6 addresses in the demo applications. This way the application do not need to do any special setup. Change-Id: I9aa817c388e3f673a6597801813dd1d0a8feb6b5 Signed-off-by: Jukka Rissanen --- .../net/coap_observe_client/src/coap-observe-client.c | 5 +++++ samples/net/coap_server/src/coap-server.c | 6 +++++- samples/net/dtls_client/src/dtls-client.c | 5 +++++ samples/net/dtls_server/src/dtls-server.c | 9 ++++++--- samples/net/echo_client/src/echo-client.c | 5 +++++ samples/net/echo_server/src/echo-server.c | 5 +++++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/samples/net/coap_observe_client/src/coap-observe-client.c b/samples/net/coap_observe_client/src/coap-observe-client.c index 26b79047f96..165467b1851 100644 --- a/samples/net/coap_observe_client/src/coap-observe-client.c +++ b/samples/net/coap_observe_client/src/coap-observe-client.c @@ -61,10 +61,15 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #ifdef CONFIG_NETWORKING_WITH_IPV6 +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } #else +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } } +#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif +#else /* ipv6 */ /* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */ #define MY_IPADDR { { { 192, 0, 2, 2 } } } #define PEER_IPADDR { { { 192, 0, 2, 1 } } } diff --git a/samples/net/coap_server/src/coap-server.c b/samples/net/coap_server/src/coap-server.c index 12ce09a726b..bff615bf2ce 100644 --- a/samples/net/coap_server/src/coap-server.c +++ b/samples/net/coap_server/src/coap-server.c @@ -72,14 +72,18 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #ifdef CONFIG_NETWORKING_WITH_IPV6 +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } #else +#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } } +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif +#else /* ipv6 */ /* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */ #define MY_IPADDR { { { 192, 0, 2, 2 } } } #define PEER_IPADDR { { { 192, 0, 2, 1 } } } - #endif #ifdef CONFIG_ER_COAP_WITH_DTLS diff --git a/samples/net/dtls_client/src/dtls-client.c b/samples/net/dtls_client/src/dtls-client.c index 00ad12724fd..837a773690a 100644 --- a/samples/net/dtls_client/src/dtls-client.c +++ b/samples/net/dtls_client/src/dtls-client.c @@ -90,10 +90,15 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #ifdef CONFIG_NETWORKING_WITH_IPV6 +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } #define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #else +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } } +#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif +#else /* ipv6 */ /* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */ #define MY_IPADDR { { { 192, 0, 2, 2 } } } #define PEER_IPADDR { { { 192, 0, 2, 1 } } } diff --git a/samples/net/dtls_server/src/dtls-server.c b/samples/net/dtls_server/src/dtls-server.c index bb47a48f845..a4ad703d58d 100644 --- a/samples/net/dtls_server/src/dtls-server.c +++ b/samples/net/dtls_server/src/dtls-server.c @@ -63,14 +63,17 @@ static const unsigned char ecdsa_pub_key_y[] = { static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #ifdef CONFIG_NETWORKING_WITH_IPV6 +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ -#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } - +#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #else +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif +#else /* ipv6 */ /* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */ #define MY_IPADDR { { { 192, 0, 2, 2 } } } - #endif + #define MY_PORT 4242 #ifdef CONFIG_NETWORKING_WITH_IPV6 diff --git a/samples/net/echo_client/src/echo-client.c b/samples/net/echo_client/src/echo-client.c index ecb38f171ca..3c8496b8b9f 100644 --- a/samples/net/echo_client/src/echo-client.c +++ b/samples/net/echo_client/src/echo-client.c @@ -69,9 +69,14 @@ static uint8_t peer_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; static uint8_t my_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; #ifdef CONFIG_NETWORKING_WITH_IPV6 +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } +#else +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } } +#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif /* admin-local, dynamically allocated multicast address */ #define MCAST_IPADDR { { { 0xff, 0x84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } diff --git a/samples/net/echo_server/src/echo-server.c b/samples/net/echo_server/src/echo-server.c index ff8f3f300e1..fa5a501637a 100644 --- a/samples/net/echo_server/src/echo-server.c +++ b/samples/net/echo_server/src/echo-server.c @@ -51,9 +51,14 @@ static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #endif #if defined(CONFIG_NETWORKING_WITH_IPV6) +#if 0 /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } } #define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } } +#else +#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } } +#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } } +#endif /* admin-local, dynamically allocated multicast address */ #define MCAST_IPADDR { { { 0xff, 0x84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }