2 * Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
10 #include <sys/socket.h>
13 #define IF_NAMESIZE 32
15 /* BSD specific/proprietary part */
17 #define IFNAMSIZ IF_NAMESIZE
19 struct ifreq_stream_stats
{
23 uint32_t multicast_packets
;
28 struct ifreq_stream_stats receive
;
29 struct ifreq_stream_stats send
;
34 char ifr_name
[IF_NAMESIZE
];
36 struct sockaddr ifr_addr
;
37 struct sockaddr ifr_dstaddr
;
38 struct sockaddr ifr_broadaddr
;
39 struct sockaddr ifr_mask
;
40 struct ifreq_stats ifr_stats
;
41 struct route_entry ifr_route
;
54 /* used with SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET */
56 char ifra_name
[IF_NAMESIZE
];
58 struct sockaddr_storage ifra_addr
;
60 struct sockaddr_storage ifra_broadaddr
;
61 struct sockaddr_storage ifra_destination
;
63 struct sockaddr_storage ifra_mask
;
67 /* used with SIOCGIFMEDIA */
69 char ifm_name
[IF_NAMESIZE
];
81 #define IFF_BROADCAST 0x0002 /* valid broadcast address */
82 #define IFF_LOOPBACK 0x0008
83 #define IFF_POINTOPOINT 0x0010 /* point-to-point link */
84 #define IFF_NOARP 0x0040 /* no address resolution */
85 #define IFF_AUTOUP 0x0080 /* auto dial */
86 #define IFF_PROMISC 0x0100 /* receive all packets */
87 #define IFF_ALLMULTI 0x0200 /* receive all multicast packets */
88 #define IFF_SIMPLEX 0x0800 /* doesn't receive own transmissions */
89 #define IFF_LINK 0x1000 /* has link */
90 #define IFF_AUTO_CONFIGURED 0x2000
91 #define IFF_CONFIGURING 0x4000
92 #define IFF_MULTICAST 0x8000 /* supports multicast */
94 /* interface alias flags */
95 #define IFAF_AUTO_CONFIGURED 0x0001 /* has been automatically configured */
96 #define IFAF_CONFIGURING 0x0002 /* auto configuration in progress */
99 /* used with SIOCGIFCOUNT, and SIOCGIFCONF */
101 int ifc_len
; /* size of buffer */
104 struct ifreq
* ifc_req
;
109 /* Macro that returns the size of a single address within a SIOCGIFCONF buffer;
110 it looks like this because of compatibility with other platforms. */
111 #define _SIZEOF_ADDR_IFREQ(request) \
112 (IF_NAMESIZE + (request).ifr_addr.sa_len > (int)sizeof(struct ifreq) \
113 ? IF_NAMESIZE + (request).ifr_addr.sa_len : sizeof(struct ifreq))
116 /* POSIX definitions follow */
118 struct if_nameindex
{
119 unsigned if_index
; /* positive interface index */
120 char* if_name
; /* interface name, ie. "loopback" */
128 unsigned if_nametoindex(const char* name
);
129 char* if_indextoname(unsigned interfaceIndex
, char* nameBuffer
);
130 struct if_nameindex
* if_nameindex(void);
131 void if_freenameindex(struct if_nameindex
* interfaceArray
);
138 #endif /* _NET_IF_H */