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

Side by Side Diff: runtime/bin/socket_android.cc

Issue 17860002: Fix runtime build for Android (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) 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
11 #include <string.h> // NOLINT 11 #include <string.h> // NOLINT
12 #include <sys/stat.h> // NOLINT 12 #include <sys/stat.h> // NOLINT
13 #include <unistd.h> // NOLINT 13 #include <unistd.h> // NOLINT
14 #include <netinet/tcp.h> // NOLINT 14 #include <netinet/tcp.h> // NOLINT
15 #include <ifaddrs.h> // NOLINT
16 15
17 #include "bin/fdutils.h" 16 #include "bin/fdutils.h"
18 #include "bin/file.h" 17 #include "bin/file.h"
19 #include "bin/log.h" 18 #include "bin/log.h"
20 #include "bin/socket.h" 19 #include "bin/socket.h"
21 20
22 21
23 namespace dart { 22 namespace dart {
24 namespace bin { 23 namespace bin {
25 24
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ASSERT(*os_error == NULL); 238 ASSERT(*os_error == NULL);
240 *os_error = new OSError(status, 239 *os_error = new OSError(status,
241 gai_strerror(status), 240 gai_strerror(status),
242 OSError::kGetAddressInfo); 241 OSError::kGetAddressInfo);
243 return false; 242 return false;
244 } 243 }
245 return true; 244 return true;
246 } 245 }
247 246
248 247
249 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) {
250 int family = ifa->ifa_addr->sa_family;
251 if (lookup_family == family) return true;
252 if (lookup_family == AF_UNSPEC &&
253 (family == AF_INET || family == AF_INET6)) {
254 return true;
255 }
256 return false;
257 }
258
259
260 AddressList<InterfaceSocketAddress>* Socket::ListInterfaces( 248 AddressList<InterfaceSocketAddress>* Socket::ListInterfaces(
261 int type, 249 int type,
262 OSError** os_error) { 250 OSError** os_error) {
263 struct ifaddrs* ifaddr; 251 // The ifaddrs.h header is not provided on Android. An Android
264 252 // implementation would have to use IOCTL or netlink.
265 int status = getifaddrs(&ifaddr); 253 return NULL;
266 if (status != 0) {
267 ASSERT(*os_error == NULL);
268 *os_error = new OSError(status,
269 gai_strerror(status),
270 OSError::kGetAddressInfo);
271 return NULL;
272 }
273
274 int lookup_family = SocketAddress::FromType(type);
275
276 intptr_t count = 0;
277 for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
278 if (ShouldIncludeIfaAddrs(ifa, lookup_family)) count++;
279 }
280
281 AddressList<InterfaceSocketAddress>* addresses =
282 new AddressList<InterfaceSocketAddress>(count);
283 int i = 0;
284 for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
285 if (ShouldIncludeIfaAddrs(ifa, lookup_family)) {
286 addresses->SetAt(i, new InterfaceSocketAddress(
287 ifa->ifa_addr, strdup(ifa->ifa_name)));
288 i++;
289 }
290 }
291 freeifaddrs(ifaddr);
292 return addresses;
293 } 254 }
294 255
295 256
296 intptr_t ServerSocket::CreateBindListen(RawAddr addr, 257 intptr_t ServerSocket::CreateBindListen(RawAddr addr,
297 intptr_t port, 258 intptr_t port,
298 intptr_t backlog, 259 intptr_t backlog,
299 bool v6_only) { 260 bool v6_only) {
300 intptr_t fd; 261 intptr_t fd;
301 262
302 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 263 fd = TEMP_FAILURE_RETRY(socket(addr.ss.ss_family, SOCK_STREAM, 0));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 SOL_TCP, 352 SOL_TCP,
392 TCP_NODELAY, 353 TCP_NODELAY,
393 reinterpret_cast<char *>(&on), 354 reinterpret_cast<char *>(&on),
394 sizeof(on))) == 0; 355 sizeof(on))) == 0;
395 } 356 }
396 357
397 } // namespace bin 358 } // namespace bin
398 } // namespace dart 359 } // namespace dart
399 360
400 #endif // defined(TARGET_OS_ANDROID) 361 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_unsupported.cc ('k') | runtime/embedders/openglui/common/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698