diff options
Diffstat (limited to 'apps/examples/udp/target.c')
-rw-r--r-- | apps/examples/udp/target.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/apps/examples/udp/target.c b/apps/examples/udp/target.c index 8b72978f3..711fe0d02 100644 --- a/apps/examples/udp/target.c +++ b/apps/examples/udp/target.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/udp/target.c * - * Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2011, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -37,7 +37,8 @@ * Included Files ****************************************************************************/ -#include <nuttx/config.h> +#include "config.h" + #include <stdio.h> #include <debug.h> @@ -56,6 +57,50 @@ * Private Data ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_UDP_IPv6 +/* Our host IPv6 address */ + +static const uint16_t g_ipv6_hostaddr[8] = +{ + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_1), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_2), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_3), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_4), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_5), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_6), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_7), + HTONS(CONFIG_EXAMPLES_UDP_IPv6ADDR_8), +}; + +/* Default routine IPv6 address */ + +static const uint16_t g_ipv6_draddr[8] = +{ + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_1), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_2), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_3), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_4), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_5), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_6), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_7), + HTONS(CONFIG_EXAMPLES_UDP_DRIPv6ADDR_8), +}; + +/* IPv6 netmask */ + +static const uint16_t g_ipv6_netmask[8] = +{ + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_1), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_2), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_3), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_4), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_5), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_6), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_7), + HTONS(CONFIG_EXAMPLES_UDP_IPv6NETMASK_8), +}; +#endif /* CONFIG_EXAMPLES_UDP_IPv6 */ + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -70,6 +115,22 @@ int main(int argc, FAR char *argv[]) int udp_main(int argc, char *argv[]) #endif { +#ifdef CONFIG_EXAMPLES_UDP_IPv6 + /* Set up our host address */ + + netlib_set_ipv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_hostaddr); + + /* Set up the default router address */ + + netlib_set_dripv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_draddr); + + /* Setup the subnet mask */ + + netlib_set_ipv6netmask("eth0", + (FAR const struct in6_addr *)g_ipv6_netmask); +#else struct in_addr addr; /* Set up our host address */ @@ -86,6 +147,7 @@ int udp_main(int argc, char *argv[]) addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK); netlib_set_ipv4netmask("eth0", &addr); +#endif #ifdef CONFIG_EXAMPLES_UDP_SERVER recv_server(); |