Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Unified Diff: runtime/bin/socket_macos.cc

Issue 17640008: Add reverse dns lookup as a method on InternetAddress. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index 42f128c58d93e0c6c210b5561fcbbb49cd258e3b..a8cb7e0858aa805e81d17e19dfb6db7500459e41 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -221,6 +221,28 @@ AddressList<SocketAddress>* Socket::LookupAddress(const char* host,
}
+const char* Socket::ReverseLookup(RawAddr addr, OSError** os_error) {
+ char* host = new char[NI_MAXHOST];
+ int status = TEMP_FAILURE_RETRY(getnameinfo(
+ &addr.addr,
+ SocketAddress::GetAddrLength(&addr),
+ host,
+ NI_MAXHOST,
+ NULL,
+ 0,
+ NI_NAMEREQD));
+ if (status != 0) {
+ ASSERT(*os_error == NULL);
+ *os_error = new OSError(status,
+ gai_strerror(status),
+ OSError::kGetAddressInfo);
+ delete host;
+ return NULL;
+ }
+ return host;
+}
+
+
static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) {
int family = ifa->ifa_addr->sa_family;
if (lookup_family == family) return true;

Powered by Google App Engine
This is Rietveld 408576698