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