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

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..ee40ec8d4d3fa1810c3fd6658f6c0acef0d76b06 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -486,6 +486,31 @@ static CObject* LookupRequest(const CObjectArray& request) {
}
+static CObject* ReverseLookupRequest(const CObjectArray& request) {
+ if (request.Length() == 2 &&
+ request[1]->IsTypedData()) {
+ CObjectExternalUint8Array addr_object(request[1]);
+ RawAddr addr;
+ memmove(reinterpret_cast<void *>(&addr),
+ addr_object.Data(),
+ addr_object.Length());
+ OSError* os_error = NULL;
Søren Gjesse 2013/06/25 10:26:16 How about this: char host[MAX_HOST_LEN]; // NI_M
Anders Johnsen 2013/06/25 11:27:36 Done.
+ const char* host = Socket::ReverseLookup(addr, &os_error);
+ CObject* result = NULL;
+ if (host != NULL) {
+ result = new CObjectString(CObject::NewString(host));
+ delete[] host;
+ } else {
+ 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 +577,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