diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 08f7b8295a7..fcebc699660 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -499,17 +499,14 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) * Name: localhost_initialize * * Description: - * Initialize the Ethernet controller and driver + * Initialize the localhost, loopback network driver * * Parameters: - * intf - In the case where there are multiple EMACs, this value - * identifies which EMAC is to be initialized. + * None * * Returned Value: * OK on success; Negated errno on failure. * - * Assumptions: - * ****************************************************************************/ int localhost_initialize(void) @@ -554,7 +551,7 @@ int localhost_initialize(void) #ifdef CONFIG_NET_IPv6 net_ipv6addr_copy(priv->lo_dev.d_ipv6addr, g_lo_ipv6addr); net_ipv6addr_copy(priv->lo_dev.d_ipv6draddr, g_lo_ipv6addr); - net_ipv6addr_copy(priv->lo_dev.d_ipv6netmask, g_ipv6_alloneaddr); + net_ipv6addr_copy(priv->lo_dev.d_ipv6netmask, g_lo_ipv6mask); #endif /* Put the network in the UP state */ diff --git a/include/nuttx/net/loopback.h b/include/nuttx/net/loopback.h index f2ebd7a6baa..dac01afec2e 100644 --- a/include/nuttx/net/loopback.h +++ b/include/nuttx/net/loopback.h @@ -51,17 +51,6 @@ #ifdef CONFIG_NET_LOOPBACK -/**************************************************************************** - * Public Type Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ /**************************************************************************** * Public Data ****************************************************************************/ @@ -82,9 +71,15 @@ EXTERN const char g_lo_hostname[]; /* Local loopback addresses */ +#ifdef CONFIG_NET_IPv4 EXTERN const in_addr_t g_lo_ipv4addr; EXTERN const in_addr_t g_lo_ipv4mask; +#endif + +#ifdef CONFIG_NET_IPv6 EXTERN const net_ipv6addr_t g_lo_ipv6addr; +EXTERN const net_ipv6addr_t g_lo_ipv6mask; +#endif /**************************************************************************** * Public Function Prototypes @@ -94,17 +89,14 @@ EXTERN const net_ipv6addr_t g_lo_ipv6addr; * Name: localhost_initialize * * Description: - * Initialize the Ethernet controller and driver + * Initialize the localhost, loopback network driver * * Parameters: - * intf - In the case where there are multiple EMACs, this value - * identifies which EMAC is to be initialized. + * None * * Returned Value: * OK on success; Negated errno on failure. * - * Assumptions: - * ****************************************************************************/ #ifdef CONFIG_NETDEV_LOOPBACK diff --git a/net/loopback/lo_globals.c b/net/loopback/lo_globals.c index 270fdb0b91b..d6be4a5ab31 100644 --- a/net/loopback/lo_globals.c +++ b/net/loopback/lo_globals.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/loopback/lo_globals.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,19 +49,31 @@ * Public Data ****************************************************************************/ +#ifdef CONFIG_LIBC_NETDB /* Local loopback hostname */ const char g_lo_hostname[] = "localhost"; +#endif /* Local loopback addresses */ +#ifdef CONFIG_NET_IPv4 const in_addr_t g_lo_ipv4addr = HTONL(0x7f000001); const in_addr_t g_lo_ipv4mask = HTONL(0xff000000); +#endif + +#ifdef CONFIG_NET_IPv6 const net_ipv6addr_t g_lo_ipv6addr = { HTONS(0), HTONS(0), HTONS(0), HTONS(0), HTONS(0), HTONS(0), HTONS(0), HTONS(1) }; +const net_ipv6addr_t g_lo_ipv6mask = +{ + HTONS(0xffff), HTONS(0xffff), HTONS(0xffff), HTONS(0xffff), + HTONS(0xffff), HTONS(0xffff), HTONS(0xffff), HTONS(0xffff) +}; +#endif /**************************************************************************** * Public Functions