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

Unified Diff: runtime/bin/socket.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
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket.cc
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
index a5e64dd2095f712c06bc49b5ae86eb603353494e..eccf606682b27ac36a0fe8c7569c2e69dcec1b1b 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -486,6 +486,30 @@ static CObject* LookupRequest(const CObjectArray& request) {
}
+static CObject* ReverseLookupRequest(const CObjectArray& request) {
+ if (request.Length() == 2 &&
+ request[1]->IsTypedData()) {
+ CObjectUint8Array addr_object(request[1]);
+ RawAddr addr;
+ memmove(reinterpret_cast<void *>(&addr),
+ addr_object.Buffer(),
+ addr_object.Length());
+ OSError* os_error = NULL;
+ const intptr_t kMaxHostLength = 1025;
+ char host[kMaxHostLength];
+ if (Socket::ReverseLookup(addr, host, kMaxHostLength, &os_error)) {
+ return new CObjectString(CObject::NewString(host));
+ } else {
+ CObject* result = CObject::NewOSError(os_error);
+ delete os_error;
+ return result;
+ }
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
+
static CObject* ListInterfacesRequest(const CObjectArray& request) {
if (request.Length() == 2 &&
request[1]->IsInt32()) {
@@ -552,6 +576,9 @@ void SocketService(Dart_Port dest_port_id,
case Socket::kListInterfacesRequest:
response = ListInterfacesRequest(request);
break;
+ case Socket::kReverseLookupRequest:
+ response = ReverseLookupRequest(request);
+ break;
default:
UNREACHABLE();
}
« no previous file with comments | « runtime/bin/socket.h ('k') | runtime/bin/socket_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698