support _BSD_SOURCE feature test macro
[musl] / include / net / if.h
1 #ifndef _NET_IF_H
2 #define _NET_IF_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #define IF_NAMESIZE 16
9
10 struct if_nameindex
11 {
12         unsigned int if_index;
13         char *if_name;
14 };
15
16 unsigned int if_nametoindex (const char *);
17 char *if_indextoname (unsigned int, char *);
18 struct if_nameindex *if_nameindex (void);
19 void if_freenameindex (struct if_nameindex *);
20
21
22
23
24 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
25
26 #include <sys/socket.h>
27
28 #define IFF_UP  0x1
29 #define IFF_BROADCAST 0x2
30 #define IFF_DEBUG 0x4
31 #define IFF_LOOPBACK 0x8
32 #define IFF_POINTOPOINT 0x10
33 #define IFF_NOTRAILERS 0x20
34 #define IFF_RUNNING 0x40
35 #define IFF_NOARP 0x80
36 #define IFF_PROMISC 0x100
37 #define IFF_ALLMULTI 0x200
38 #define IFF_MASTER 0x400
39 #define IFF_SLAVE 0x800
40 #define IFF_MULTICAST 0x1000
41 #define IFF_PORTSEL 0x2000
42 #define IFF_AUTOMEDIA 0x4000
43 #define IFF_DYNAMIC 0x8000
44
45 struct ifaddr {
46         struct sockaddr ifa_addr;
47         union {
48                 struct sockaddr ifu_broadaddr;
49                 struct sockaddr ifu_dstaddr;
50         } ifa_ifu;
51         struct iface *ifa_ifp;
52         struct ifaddr *ifa_next;
53 };
54
55 #define ifa_broadaddr   ifa_ifu.ifu_broadaddr
56 #define ifa_dstaddr     ifa_ifu.ifu_dstaddr
57
58 struct ifmap {
59         unsigned long int mem_start;
60         unsigned long int mem_end;
61         unsigned short int base_addr;
62         unsigned char irq;
63         unsigned char dma;
64         unsigned char port;
65 };
66
67 #define IFHWADDRLEN     6
68 #define IFNAMSIZ        IF_NAMESIZE
69
70 struct ifreq {
71         union {
72                 char ifrn_name[IFNAMSIZ];
73         } ifr_ifrn;
74         union {
75                 struct sockaddr ifru_addr;
76                 struct sockaddr ifru_dstaddr;
77                 struct sockaddr ifru_broadaddr;
78                 struct sockaddr ifru_netmask;
79                 struct sockaddr ifru_hwaddr;
80                 short int ifru_flags;
81                 int ifru_ivalue;
82                 int ifru_mtu;
83                 struct ifmap ifru_map;
84                 char ifru_slave[IFNAMSIZ];
85                 char ifru_newname[IFNAMSIZ];
86                 void *ifru_data;
87         } ifr_ifru;
88 };
89
90 #define ifr_name        ifr_ifrn.ifrn_name
91 #define ifr_hwaddr      ifr_ifru.ifru_hwaddr
92 #define ifr_addr        ifr_ifru.ifru_addr
93 #define ifr_dstaddr     ifr_ifru.ifru_dstaddr
94 #define ifr_broadaddr   ifr_ifru.ifru_broadaddr
95 #define ifr_netmask     ifr_ifru.ifru_netmask
96 #define ifr_flags       ifr_ifru.ifru_flags
97 #define ifr_metric      ifr_ifru.ifru_ivalue
98 #define ifr_mtu         ifr_ifru.ifru_mtu
99 #define ifr_map         ifr_ifru.ifru_map
100 #define ifr_slave       ifr_ifru.ifru_slave
101 #define ifr_data        ifr_ifru.ifru_data
102 #define ifr_ifindex     ifr_ifru.ifru_ivalue
103 #define ifr_bandwidth   ifr_ifru.ifru_ivalue
104 #define ifr_qlen        ifr_ifru.ifru_ivalue
105 #define ifr_newname     ifr_ifru.ifru_newname
106 #define _IOT_ifreq      _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0)
107 #define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0)
108 #define _IOT_ifreq_int  _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0)
109
110 struct ifconf {
111         int ifc_len;            
112         union {
113                 void *ifcu_buf;
114                 struct ifreq *ifcu_req;
115         } ifc_ifcu;
116 };
117
118 #define ifc_buf         ifc_ifcu.ifcu_buf
119 #define ifc_req         ifc_ifcu.ifcu_req
120 #define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0)
121
122 #endif
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif