diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-01-18 10:51:53 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-01-18 10:51:53 -0600 |
commit | 9b147dd2ac5cb89fc6b0738dff6b6c0b7f653fe5 (patch) | |
tree | 2bbb028fb53624ae3439b635aa92e67881b79ccd | |
parent | c9d81ef037125e2b97a0ad3999193d3933c11f8b (diff) | |
download | px4-nuttx-9b147dd2ac5cb89fc6b0738dff6b6c0b7f653fe5.tar.gz px4-nuttx-9b147dd2ac5cb89fc6b0738dff6b6c0b7f653fe5.tar.bz2 px4-nuttx-9b147dd2ac5cb89fc6b0738dff6b6c0b7f653fe5.zip |
apps/netutils/dnsclient: Can select to be either IPv4 or IPv6, but not both (IPv6 still does not compile)
-rw-r--r-- | apps/include/netutils/dnsclient.h | 4 | ||||
-rw-r--r-- | apps/netutils/dnsclient/Kconfig | 15 | ||||
-rw-r--r-- | apps/netutils/dnsclient/dns_resolver.c | 2 | ||||
-rw-r--r-- | apps/netutils/dnsclient/dns_socket.c | 25 |
4 files changed, 31 insertions, 15 deletions
diff --git a/apps/include/netutils/dnsclient.h b/apps/include/netutils/dnsclient.h index c4639f908..6261ece91 100644 --- a/apps/include/netutils/dnsclient.h +++ b/apps/include/netutils/dnsclient.h @@ -141,8 +141,8 @@ void dns_setserver(FAR const struct in_addr *dnsserver); * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 -void dns_getserver(FAR const struct in_addr *dnsserver); +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 +void dns_getserver(FAR struct in6_addr *dnsserver); #else void dns_getserver(FAR struct in_addr *dnsserver); #endif diff --git a/apps/netutils/dnsclient/Kconfig b/apps/netutils/dnsclient/Kconfig index 1bdf7a585..f3d622cbf 100644 --- a/apps/netutils/dnsclient/Kconfig +++ b/apps/netutils/dnsclient/Kconfig @@ -12,6 +12,21 @@ config NETUTILS_DNSCLIENT if NETUTILS_DNSCLIENT +choice + prompt "Internet Protocol" + default NETUTILS_DNSCLIENT_IPv4 if NET_IPv4 + default NETUTILS_DNSCLIENT_IPv6 if NET_IPv6 && !NET_IPv4 + +config NETUTILS_DNSCLIENT_IPv4 + bool "IPv4" + depends on NET_IPv4 + +config NETUTILS_DNSCLIENT_IPv6 + bool "IPv6" + depends on NET_IPv6 + +endchoice # Internet Protocol + config NETUTILS_DNSCLIENT_ENTRIES int "Number of DNS resolver entries" default 8 diff --git a/apps/netutils/dnsclient/dns_resolver.c b/apps/netutils/dnsclient/dns_resolver.c index 0507d8df7..9ee802009 100644 --- a/apps/netutils/dnsclient/dns_resolver.c +++ b/apps/netutils/dnsclient/dns_resolver.c @@ -113,7 +113,7 @@ int dns_query(FAR const char *hostname, FAR in_addr_t *ipaddr) * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 int dns_whois(FAR const char *name, FAR struct sockaddr_in6 *addr) #else int dns_whois(FAR const char *name, FAR struct sockaddr_in *addr) diff --git a/apps/netutils/dnsclient/dns_socket.c b/apps/netutils/dnsclient/dns_socket.c index 9c2895437..76cf64a33 100644 --- a/apps/netutils/dnsclient/dns_socket.c +++ b/apps/netutils/dnsclient/dns_socket.c @@ -101,7 +101,7 @@ # define RECV_BUFFER_SIZE 96 #endif -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 # define ADDRLEN sizeof(struct sockaddr_in6) #else # define ADDRLEN sizeof(struct sockaddr_in) @@ -136,7 +136,7 @@ struct dns_answer uint16_t class; uint16_t ttl[2]; uint16_t len; -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 struct in6_addr ipaddr; #else struct in_addr ipaddr; @@ -151,7 +151,7 @@ struct namemap uint8_t seqno; uint8_t err; char name[32]; -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 struct in6_addr ipaddr; #else struct in_addr ipaddr; @@ -163,7 +163,7 @@ struct namemap ****************************************************************************/ static uint8_t g_seqno; -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 static struct sockaddr_in6 g_dnsserver; #else static struct sockaddr_in g_dnsserver; @@ -209,7 +209,7 @@ static FAR unsigned char *dns_parse_name(FAR unsigned char *query) * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 static int dns_send_query(int sockfd, FAR const char *name, FAR struct sockaddr_in6 *addr) #else @@ -264,7 +264,7 @@ static int dns_send_query(int sockfd, FAR const char *name, * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 # error "Not implemented" #else static int dns_recv_response(int sockfd, FAR struct sockaddr_in *addr) @@ -502,7 +502,7 @@ int dns_query_sock(int sockfd, FAR const char *hostname, FAR in_addr_t *ipaddr) #else -# ifdef CONFIG_NET_IPv6 +# ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 struct sockaddr_in6 addr; # else struct sockaddr_in addr; @@ -540,7 +540,7 @@ int dns_query_sock(int sockfd, FAR const char *hostname, FAR in_addr_t *ipaddr) * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 void dns_setserver(FAR const struct in6_addr *dnsserver) #else void dns_setserver(FAR const struct in_addr *dnsserver) @@ -548,7 +548,8 @@ void dns_setserver(FAR const struct in_addr *dnsserver) { g_dnsserver.sin_family = AF_INET; g_dnsserver.sin_port = HTONS(53); -#ifdef CONFIG_NET_IPv6 + +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 memcpy(&g_dnsserver.sin6_addr, dnsserver, ADDRLEN); #else g_dnsserver.sin_addr.s_addr = dnsserver->s_addr; @@ -563,13 +564,13 @@ void dns_setserver(FAR const struct in_addr *dnsserver) * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 void dns_getserver(FAR struct in6_addr *dnsserver) #else void dns_getserver(FAR struct in_addr *dnsserver) #endif { -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 memcpy(dnsserver, &g_dnsserver.sin6_addr, ADDRLEN); #else dnsserver->s_addr = g_dnsserver.sin_addr.s_addr; @@ -584,7 +585,7 @@ void dns_getserver(FAR struct in_addr *dnsserver) * ****************************************************************************/ -#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NETUTILS_DNSCLIENT_IPv6 int dns_whois_socket(int sockfd, FAR const char *name, FAR struct sockaddr_in6 *addr) #else |