dart-sdk/runtime/bin/ifaddrs-android.h
Zichang Guo 78340fdf82 [vm] Support ListInterfaces for android
Support ListInterfaces() for android. If android api level during build time
is greater than or equal to 24, it will use getifaddrs() from android ndk.
Since it didn't support until 24. Otherwise, use system call to query the
network interfaces.

Bug: https://github.com/dart-lang/sdk/issues/36449
Change-Id: I615b31b804b751382b775ad9c6af4411b123d5ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98949
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-04-19 16:38:44 +00:00

34 lines
888 B
C++

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_IFADDRS_ANDROID_H_
#define RUNTIME_BIN_IFADDRS_ANDROID_H_
#if defined(ANDROID) && __ANDROID_API__ < 24
#include <sys/socket.h>
namespace dart {
namespace bin {
struct ifaddrs {
struct ifaddrs* ifa_next;
char* ifa_name;
unsigned int ifa_flags;
struct sockaddr* ifa_addr;
struct sockaddr* ifa_netmask;
union {
struct sockaddr* ifu_broadaddr;
struct sockaddr* ifu_dstaddr;
} ifa_ifu;
void* ifa_data;
};
void freeifaddrs(struct ifaddrs* __ptr);
int getifaddrs(struct ifaddrs** __list_ptr);
} // namespace bin
} // namespace dart
#endif // defined(ANDROID) && __ANDROID_API__ < 24
#endif // RUNTIME_BIN_IFADDRS_ANDROID_H_