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* ifu_broadaddr;
43         /// Point-to-point destination addresss
44         sockaddr* if_dstaddr;
45     }
46 
47     /// Address specific data
48     void* ifa_data;
49 };
50 
51 /// Returns: linked list of ifaddrs structures describing interfaces
52 int getifaddrs(ifaddrs** );
53 /// Frees the linked list returned by getifaddrs
54 void freeifaddrs(ifaddrs* );
55