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