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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) { 214 if (c->ai_family == AF_INET || c->ai_family == AF_INET6) {
215 addresses->SetAt(i, new SocketAddress(c->ai_addr)); 215 addresses->SetAt(i, new SocketAddress(c->ai_addr));
216 i++; 216 i++;
217 } 217 }
218 } 218 }
219 freeaddrinfo(info); 219 freeaddrinfo(info);
220 return addresses; 220 return addresses;
221 } 221 }
222 222
223 223
224 const char* Socket::ReverseLookup(RawAddr addr, OSError** os_error) {
225 char* host = new char[NI_MAXHOST];
226 int status = TEMP_FAILURE_RETRY(getnameinfo(
227 &addr.addr,
228 SocketAddress::GetAddrLength(&addr),
229 host,
230 NI_MAXHOST,
231 NULL,
232 0,
233 NI_NAMEREQD));
234 if (status != 0) {
235 ASSERT(*os_error == NULL);
236 *os_error = new OSError(status,
237 gai_strerror(status),
238 OSError::kGetAddressInfo);
239 delete host;
240 return NULL;
241 }
242 return host;
243 }
244
245
224 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { 246 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) {
225 int family = ifa->ifa_addr->sa_family; 247 int family = ifa->ifa_addr->sa_family;
226 if (lookup_family == family) return true; 248 if (lookup_family == family) return true;
227 if (lookup_family == AF_UNSPEC && 249 if (lookup_family == AF_UNSPEC &&
228 (family == AF_INET || family == AF_INET6)) { 250 (family == AF_INET || family == AF_INET6)) {
229 return true; 251 return true;
230 } 252 }
231 return false; 253 return false;
232 } 254 }
233 255
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 IPPROTO_TCP, 378 IPPROTO_TCP,
357 TCP_NODELAY, 379 TCP_NODELAY,
358 reinterpret_cast<char *>(&on), 380 reinterpret_cast<char *>(&on),
359 sizeof(on))) == 0; 381 sizeof(on))) == 0;
360 } 382 }
361 383
362 } // namespace bin 384 } // namespace bin
363 } // namespace dart 385 } // namespace dart
364 386
365 #endif // defined(TARGET_OS_MACOS) 387 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698