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

Side by Side Diff: runtime/bin/socket_android.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, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <stdio.h> // NOLINT 9 #include <stdio.h> // NOLINT
10 #include <stdlib.h> // NOLINT 10 #include <stdlib.h> // NOLINT
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { 215 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) {
216 addresses->SetAt(i, new SocketAddress(c->ai_addr)); 216 addresses->SetAt(i, new SocketAddress(c->ai_addr));
217 i++; 217 i++;
218 } 218 }
219 } 219 }
220 freeaddrinfo(info); 220 freeaddrinfo(info);
221 return addresses; 221 return addresses;
222 } 222 }
223 223
224 224
225 bool Socket::ReverseLookup(RawAddr addr,
226 char* host,
227 intptr_t host_len,
228 OSError** os_error) {
229 ASSERT(host_len >= NI_MAXHOST);
230 int status = TEMP_FAILURE_RETRY(getnameinfo(
231 &addr.addr,
232 SocketAddress::GetAddrLength(&addr),
233 host,
234 host_len,
235 NULL,
236 0,
237 NI_NAMEREQD));
238 if (status != 0) {
239 ASSERT(*os_error == NULL);
240 *os_error = new OSError(status,
241 gai_strerror(status),
242 OSError::kGetAddressInfo);
243 return false;
244 }
245 return true;
246 }
247
248
225 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { 249 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) {
226 int family = ifa->ifa_addr->sa_family; 250 int family = ifa->ifa_addr->sa_family;
227 if (lookup_family == family) return true; 251 if (lookup_family == family) return true;
228 if (lookup_family == AF_UNSPEC && 252 if (lookup_family == AF_UNSPEC &&
229 (family == AF_INET || family == AF_INET6)) { 253 (family == AF_INET || family == AF_INET6)) {
230 return true; 254 return true;
231 } 255 }
232 return false; 256 return false;
233 } 257 }
234 258
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 SOL_TCP, 391 SOL_TCP,
368 TCP_NODELAY, 392 TCP_NODELAY,
369 reinterpret_cast<char *>(&on), 393 reinterpret_cast<char *>(&on),
370 sizeof(on))) == 0; 394 sizeof(on))) == 0;
371 } 395 }
372 396
373 } // namespace bin 397 } // namespace bin
374 } // namespace dart 398 } // namespace dart
375 399
376 #endif // defined(TARGET_OS_ANDROID) 400 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698