]>
Commit | Line | Data |
---|---|---|
7f1deee6 | 1 | /* ifaddrs.h -- declarations for getting network interface addresses |
04277e02 | 2 | Copyright (C) 2002-2019 Free Software Foundation, Inc. |
7f1deee6 RM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
7f1deee6 RM |
18 | |
19 | #ifndef _IFADDRS_H | |
20 | #define _IFADDRS_H 1 | |
21 | ||
22 | #include <features.h> | |
23 | #include <sys/socket.h> | |
24 | ||
25 | __BEGIN_DECLS | |
26 | ||
27 | /* The `getifaddrs' function generates a linked list of these structures. | |
28 | Each element of the list describes one network interface. */ | |
29 | struct ifaddrs | |
30 | { | |
31 | struct ifaddrs *ifa_next; /* Pointer to the next structure. */ | |
32 | ||
33 | char *ifa_name; /* Name of this network interface. */ | |
34 | unsigned int ifa_flags; /* Flags as from SIOCGIFFLAGS ioctl. */ | |
35 | ||
36 | struct sockaddr *ifa_addr; /* Network address of this interface. */ | |
37 | struct sockaddr *ifa_netmask; /* Netmask of this interface. */ | |
38 | union | |
39 | { | |
40 | /* At most one of the following two is valid. If the IFF_BROADCAST | |
41 | bit is set in `ifa_flags', then `ifa_broadaddr' is valid. If the | |
42 | IFF_POINTOPOINT bit is set, then `ifa_dstaddr' is valid. | |
43 | It is never the case that both these bits are set at once. */ | |
44 | struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */ | |
45 | struct sockaddr *ifu_dstaddr; /* Point-to-point destination address. */ | |
46 | } ifa_ifu; | |
47 | /* These very same macros are defined by <net/if.h> for `struct ifaddr'. | |
48 | So if they are defined already, the existing definitions will be fine. */ | |
49 | # ifndef ifa_broadaddr | |
50 | # define ifa_broadaddr ifa_ifu.ifu_broadaddr | |
51 | # endif | |
52 | # ifndef ifa_dstaddr | |
53 | # define ifa_dstaddr ifa_ifu.ifu_dstaddr | |
54 | # endif | |
55 | ||
56 | void *ifa_data; /* Address-specific data (may be unused). */ | |
57 | }; | |
58 | ||
59 | ||
60 | /* Create a linked list of `struct ifaddrs' structures, one for each | |
61 | network interface on the host machine. If successful, store the | |
62 | list in *IFAP and return 0. On errors, return -1 and set `errno'. | |
63 | ||
64 | The storage returned in *IFAP is allocated dynamically and can | |
65 | only be properly freed by passing it to `freeifaddrs'. */ | |
66 | extern int getifaddrs (struct ifaddrs **__ifap) __THROW; | |
67 | ||
68 | /* Reclaim the storage allocated by a previous `getifaddrs' call. */ | |
69 | extern void freeifaddrs (struct ifaddrs *__ifa) __THROW; | |
70 | ||
71 | __END_DECLS | |
72 | ||
73 | #endif /* ifaddrs.h */ |