summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2012-08-07 01:35:10 +0200
committerBert Belder <bertbelder@gmail.com>2012-08-07 01:57:58 +0200
commitacea4c4123b346495de79498f5b4200d6fd1bf1d (patch)
tree88ecc368e7faa381d8aaf87dd9deddb6bcd8319a /src
parente0a603a4993e995080a8926fcddbbde752a2136e (diff)
downloadnode-new-acea4c4123b346495de79498f5b4200d6fd1bf1d.tar.gz
dns: use uv_inet_ntop/uv_inet_pton instead of c-ares equivalents
Diffstat (limited to 'src')
-rw-r--r--src/cares_wrap.cc39
-rw-r--r--src/tcp_wrap.cc14
-rw-r--r--src/udp_wrap.cc15
3 files changed, 16 insertions, 52 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 3d1cb23fc2..2e509abade 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -37,21 +37,6 @@
# include <arpa/nameser.h>
#endif
-// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
-#if defined(__MINGW32__) || defined(_MSC_VER)
- extern "C" {
-# include <inet_net_pton.h>
-# include <inet_ntop.h>
- }
-# define uv_inet_pton ares_inet_pton
-# define uv_inet_ntop ares_inet_ntop
-
-#else // __POSIX__
-# include <arpa/inet.h>
-# define uv_inet_pton inet_pton
-# define uv_inet_ntop inet_ntop
-#endif
-
namespace node {
@@ -627,10 +612,10 @@ class GetHostByAddrWrap: public QueryWrap {
int length, family;
char address_buffer[sizeof(struct in6_addr)];
- if (uv_inet_pton(AF_INET, name, &address_buffer) == 1) {
+ if (uv_inet_pton(AF_INET, name, &address_buffer).code == UV_OK) {
length = sizeof(struct in_addr);
family = AF_INET;
- } else if (uv_inet_pton(AF_INET6, name, &address_buffer) == 1) {
+ } else if (uv_inet_pton(AF_INET6, name, &address_buffer).code == UV_OK) {
length = sizeof(struct in6_addr);
family = AF_INET6;
} else {
@@ -772,11 +757,15 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
if (address->ai_family == AF_INET) {
// Juggle pointers
addr = (char*) &((struct sockaddr_in*) address->ai_addr)->sin_addr;
- const char* c = uv_inet_ntop(address->ai_family, addr, ip,
- INET6_ADDRSTRLEN);
+ uv_err_t err = uv_inet_ntop(address->ai_family,
+ addr,
+ ip,
+ INET6_ADDRSTRLEN);
+ if (err.code != UV_OK)
+ continue;
// Create JavaScript string
- Local<String> s = String::New(c);
+ Local<String> s = String::New(ip);
results->Set(n, s);
n++;
}
@@ -794,11 +783,15 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
if (address->ai_family == AF_INET6) {
// Juggle pointers
addr = (char*) &((struct sockaddr_in6*) address->ai_addr)->sin6_addr;
- const char* c = uv_inet_ntop(address->ai_family, addr, ip,
- INET6_ADDRSTRLEN);
+ uv_err_t err = uv_inet_ntop(address->ai_family,
+ addr,
+ ip,
+ INET6_ADDRSTRLEN);
+ if (err.code != UV_OK)
+ continue;
// Create JavaScript string
- Local<String> s = String::New(c);
+ Local<String> s = String::New(ip);
results->Set(n, s);
n++;
}
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index 481838a5a1..778fc71f07 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -28,20 +28,6 @@
#include <stdlib.h>
-// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
-#if defined(__MINGW32__) || defined(_MSC_VER)
- extern "C" {
-# include <inet_net_pton.h>
-# include <inet_ntop.h>
- }
-# define uv_inet_pton ares_inet_pton
-# define uv_inet_ntop ares_inet_ntop
-
-#else // __POSIX__
-# include <arpa/inet.h>
-# define uv_inet_pton inet_pton
-# define uv_inet_ntop inet_ntop
-#endif
namespace node {
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index 2e9776b2e6..34fe33562c 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -30,21 +30,6 @@
#define SLAB_SIZE (1024 * 1024)
-// Temporary hack: libuv should provide uv_inet_pton and uv_inet_ntop.
-// Clean this up in tcp_wrap.cc too.
-#if defined(__MINGW32__) || defined(_MSC_VER)
- extern "C" {
-# include <inet_net_pton.h>
-# include <inet_ntop.h>
- }
-# define uv_inet_pton ares_inet_pton
-# define uv_inet_ntop ares_inet_ntop
-
-#else // __POSIX__
-# include <arpa/inet.h>
-# define uv_inet_pton inet_pton
-# define uv_inet_ntop inet_ntop
-#endif
using namespace v8;