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

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
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_patch.dart » ('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) 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 bool Socket::ReverseLookup(RawAddr addr,
225 char* host,
226 intptr_t host_len,
227 OSError** os_error) {
228 ASSERT(host_len >= NI_MAXHOST);
229 int status = TEMP_FAILURE_RETRY(getnameinfo(
230 &addr.addr,
231 SocketAddress::GetAddrLength(&addr),
232 host,
233 host_len,
234 NULL,
235 0,
236 NI_NAMEREQD));
237 if (status != 0) {
238 ASSERT(*os_error == NULL);
239 *os_error = new OSError(status,
240 gai_strerror(status),
241 OSError::kGetAddressInfo);
242 return false;
243 }
244 return true;
245 }
246
247
224 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { 248 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) {
225 int family = ifa->ifa_addr->sa_family; 249 int family = ifa->ifa_addr->sa_family;
226 if (lookup_family == family) return true; 250 if (lookup_family == family) return true;
227 if (lookup_family == AF_UNSPEC && 251 if (lookup_family == AF_UNSPEC &&
228 (family == AF_INET || family == AF_INET6)) { 252 (family == AF_INET || family == AF_INET6)) {
229 return true; 253 return true;
230 } 254 }
231 return false; 255 return false;
232 } 256 }
233 257
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 IPPROTO_TCP, 380 IPPROTO_TCP,
357 TCP_NODELAY, 381 TCP_NODELAY,
358 reinterpret_cast<char *>(&on), 382 reinterpret_cast<char *>(&on),
359 sizeof(on))) == 0; 383 sizeof(on))) == 0;
360 } 384 }
361 385
362 } // namespace bin 386 } // namespace bin
363 } // namespace dart 387 } // namespace dart
364 388
365 #endif // defined(TARGET_OS_MACOS) 389 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698