Allow option to enable IP address conversions even when the IP address family is not supported.

This commit is contained in:
Gregory Nutt 2016-12-04 09:06:08 -06:00
parent d92a7886a4
commit 7c4e3e21b8
4 changed files with 28 additions and 18 deletions

View File

@ -575,6 +575,16 @@ config TLS_NELEM
endif # TLS
config LIBC_IPv4_ADDRCONV
bool "IPv4 address conversions"
default n
depends on !NET_IPv4
config LIBC_IPv6_ADDRCONV
bool "IPv6 address conversions"
default n
depends on !NET_IPv6
config LIBC_NETDB
bool
default n

View File

@ -44,7 +44,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#ifdef CONFIG_NET_IPv4
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_LIBC_IPv4_ADDRCONV)
/****************************************************************************
* Public Functions
@ -78,4 +78,4 @@ FAR char *_inet_ntoa(in_addr_t in)
return buffer;
}
#endif
#endif /* CONFIG_NET_IPv4 */
#endif /* CONFIG_NET_IPv4 || CONFIG_LIBC_IPv4_ADDRCONV */

View File

@ -62,10 +62,10 @@
*/
#ifdef CONFIG_NETDB_HOSTFILE
# undef CONFIG_NET_IPv4
# undef CONFIG_NET_IPv6
# define CONFIG_NET_IPv4 1
# define CONFIG_NET_IPv6 1
# undef CONFIG_LIBC_IPv4_ADDRCONV
# undef CONFIG_LIBC_IPv6_ADDRCONV
# define CONFIG_LIBC_IPv4_ADDRCONV 1
# define CONFIG_LIBC_IPv6_ADDRCONV 1
#endif
/****************************************************************************
@ -97,7 +97,7 @@
*
****************************************************************************/
#ifdef CONFIG_NET_IPv4
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_LIBC_IPv4_ADDRCONV)
static int inet_ipv4_ntop(FAR const void *src, FAR char *dest, socklen_t size)
{
FAR char *ptr;
@ -141,7 +141,7 @@ static int inet_ipv4_ntop(FAR const void *src, FAR char *dest, socklen_t size)
*
****************************************************************************/
#ifdef CONFIG_NET_IPv6
#if defined(CONFIG_NET_IPv6) || defined(CONFIG_LIBC_IPv6_ADDRCONV)
static int inet_ipv6_ntop(FAR const void *src, FAR char *dest, socklen_t size)
{
FAR const struct in6_addr *in6_addr;
@ -265,13 +265,13 @@ FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dest,
switch (af)
{
#ifdef CONFIG_NET_IPv4
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_LIBC_IPv4_ADDRCONV)
case AF_INET:
ret = inet_ipv4_ntop(src, dest, size);
break;
#endif
#ifdef CONFIG_NET_IPv6
#if defined(CONFIG_NET_IPv6) || defined(CONFIG_LIBC_IPv6_ADDRCONV)
case AF_INET6:
ret = inet_ipv6_ntop(src, dest, size);
break;

View File

@ -64,10 +64,10 @@
*/
#ifdef CONFIG_NETDB_HOSTFILE
# undef CONFIG_NET_IPv4
# undef CONFIG_NET_IPv6
# define CONFIG_NET_IPv4 1
# define CONFIG_NET_IPv6 1
# undef CONFIG_LIBC_IPv4_ADDRCONV
# undef CONFIG_LIBC_IPv6_ADDRCONV
# define CONFIG_LIBC_IPv4_ADDRCONV 1
# define CONFIG_LIBC_IPv6_ADDRCONV 1
#endif
/****************************************************************************
@ -93,7 +93,7 @@
*
****************************************************************************/
#ifdef CONFIG_NET_IPv4
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_LIBC_IPv4_ADDRCONV)
static int inet_ipv4_pton(FAR const char *src, FAR void *dest)
{
size_t srcoffset;
@ -203,7 +203,7 @@ static int inet_ipv4_pton(FAR const char *src, FAR void *dest)
*
****************************************************************************/
#ifdef CONFIG_NET_IPv6
#if defined(CONFIG_NET_IPv6) || defined(CONFIG_LIBC_IPv6_ADDRCONV)
static int inet_ipv6_pton(FAR const char *src, FAR void *dest)
{
size_t srcoffset;
@ -393,12 +393,12 @@ int inet_pton(int af, FAR const char *src, FAR void *dest)
switch (af)
{
#ifdef CONFIG_NET_IPv4
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_LIBC_IPv4_ADDRCONV)
case AF_INET:
return inet_ipv4_pton(src, dest);
#endif
#ifdef CONFIG_NET_IPv6
#if defined(CONFIG_NET_IPv6) || defined(CONFIG_LIBC_IPv6_ADDRCONV)
case AF_INET6:
return inet_ipv6_pton(src, dest);
#endif