| 1 |
/******************************************************************************* |
| 2 |
|
| 3 |
D binding for the interface addresses querying |
| 4 |
|
| 5 |
Defines functions getifaddrs/freeifaddrs and the structure |
| 6 |
they operate on. |
| 7 |
|
| 8 |
getifaddrs(3) get interface addresses |
| 9 |
freeifaddrs(3) deallocates the structure returned from getifaddrs |
| 10 |
|
| 11 |
Copyright: Copyright (c) 2016 Sociomantic Labs. All rights reserved. |
| 12 |
License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). |
| 13 |
Authors: Nemanja Boric |
| 14 |
|
| 15 |
*******************************************************************************/ |
| 16 |
|
| 17 |
module core.sys.linux.ifaddrs; |
| 18 |
|
| 19 |
import core.sys.posix.sys.socket; |
| 20 |
|
| 21 |
version (linux): |
| 22 |
extern (C): |
| 23 |
nothrow: |
| 24 |
@nogc: |
| 25 |
|
| 26 |
struct ifaddrs |
| 27 |
{ |
| 28 |
/// Next item in the list |
| 29 |
ifaddrs* ifa_next; |
| 30 |
/// Name of the interface |
| 31 |
char* ifa_name; |
| 32 |
/// Flags from SIOCGIFFLAGS |
| 33 |
uint ifa_flags; |
| 34 |
/// Address of interface |
| 35 |
sockaddr* ifa_addr; |
| 36 |
/// Netmask of interface |
| 37 |
sockaddr* ifa_netmask; |
| 38 |
|
| 39 |
union |
| 40 |
{ |
| 41 |
/// Broadcast address of the interface |
| 42 |
sockaddr* ifa_broadaddr; |
| 43 |
|
| 44 |
/// Point-to-point destination addresss |
| 45 |
sockaddr* ifa_dstaddr; |
| 46 |
} |
| 47 |
|
| 48 |
deprecated("druntime declared this incorrectly before. The correct name is ifa_broadaddr.") |
| 49 |
alias ifu_broadaddr = ifa_broadaddr; |
| 50 |
|
| 51 |
deprecated("druntime declared this incorrectly before. The correct name is ifa_dstaddr.") |
| 52 |
alias if_dstaddr = ifa_dstaddr; |
| 53 |
|
| 54 |
/// Address specific data |
| 55 |
void* ifa_data; |
| 56 |
} |
| 57 |
|
| 58 |
/// Returns: linked list of ifaddrs structures describing interfaces |
| 59 |
int getifaddrs(ifaddrs** ); |
| 60 |
/// Frees the linked list returned by getifaddrs |
| 61 |
void freeifaddrs(ifaddrs* ); |