Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
#ifndef _NET_IF_H
2
#define _NET_IF_H
3
 
4
#include 
5
#include 
6
 
7
__BEGIN_DECLS
8
 
9
/* Standard interface flags. */
10
#define IFF_UP		0x1		/* interface is up		*/
11
#define IFF_BROADCAST	0x2		/* broadcast address valid	*/
12
#define IFF_DEBUG	0x4		/* turn on debugging		*/
13
#define IFF_LOOPBACK	0x8		/* is a loopback net		*/
14
#define IFF_POINTOPOINT	0x10		/* interface is has p-p link	*/
15
#define IFF_NOTRAILERS	0x20		/* avoid use of trailers	*/
16
#define IFF_RUNNING	0x40		/* resources allocated		*/
17
#define IFF_NOARP	0x80		/* no ARP protocol		*/
18
#define IFF_PROMISC	0x100		/* receive all packets		*/
19
#define IFF_ALLMULTI	0x200		/* receive all multicast packets*/
20
 
21
#define IFF_MASTER	0x400		/* master of a load balancer 	*/
22
#define IFF_SLAVE	0x800		/* slave of a load balancer	*/
23
 
24
#define IFF_MULTICAST	0x1000		/* Supports multicast		*/
25
 
26
#define IFF_VOLATILE	(IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING)
27
 
28
#define IFF_PORTSEL	0x2000          /* can set media type		*/
29
#define IFF_AUTOMEDIA	0x4000		/* auto media select active	*/
30
#define IFF_DYNAMIC	0x8000		/* dialup device with changing addresses*/
31
 
32
struct ifmap {
33
  unsigned long mem_start;
34
  unsigned long mem_end;
35
  unsigned short base_addr;
36
  unsigned char irq;
37
  unsigned char dma;
38
  unsigned char port;
39
  /* 3 bytes spare */
40
};
41
 
42
struct ifreq {
43
#define IFHWADDRLEN	6
44
#define IFNAMSIZ	16
45
  union
46
  {
47
    char	ifrn_name[IFNAMSIZ];		/* if name, e.g. "en0" */
48
  } ifr_ifrn;
49
  union {
50
    struct sockaddr ifru_addr;
51
    struct sockaddr ifru_dstaddr;
52
    struct sockaddr ifru_broadaddr;
53
    struct sockaddr ifru_netmask;
54
    struct  sockaddr ifru_hwaddr;
55
    short ifru_flags;
56
    int ifru_ivalue;
57
    int ifru_mtu;
58
    struct ifmap ifru_map;
59
    char ifru_slave[IFNAMSIZ];	/* Just fits the size */
60
    char ifru_newname[IFNAMSIZ];
61
    char* ifru_data;
62
  } ifr_ifru;
63
};
64
 
65
#define ifr_name	ifr_ifrn.ifrn_name	/* interface name 	*/
66
#define ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address 		*/
67
#define ifr_addr	ifr_ifru.ifru_addr	/* address		*/
68
#define ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk	*/
69
#define ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address	*/
70
#define ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask	*/
71
#define ifr_flags	ifr_ifru.ifru_flags	/* flags		*/
72
#define ifr_metric	ifr_ifru.ifru_ivalue	/* metric		*/
73
#define ifr_mtu		ifr_ifru.ifru_mtu	/* mtu			*/
74
#define ifr_map		ifr_ifru.ifru_map	/* device map		*/
75
#define ifr_slave	ifr_ifru.ifru_slave	/* slave device		*/
76
#define ifr_data	ifr_ifru.ifru_data	/* for use by interface	*/
77
#define ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index	*/
78
#define ifr_bandwidth	ifr_ifru.ifru_ivalue    /* link bandwidth	*/
79
#define ifr_qlen	ifr_ifru.ifru_ivalue	/* Queue length 	*/
80
#define ifr_newname	ifr_ifru.ifru_newname	/* New name		*/
81
 
82
struct ifconf {
83
  int ifc_len;			/* size of buffer	*/
84
  union {
85
    char *			ifcu_buf;
86
    struct	ifreq 		*ifcu_req;
87
  } ifc_ifcu;
88
};
89
 
90
#define ifc_buf ifc_ifcu.ifcu_buf		/* buffer address	*/
91
#define ifc_req ifc_ifcu.ifcu_req		/* array of structures	*/
92
 
93
unsigned int if_nametoindex (const char *ifname) __THROW;
94
char *if_indextoname (unsigned int ifindex, char *ifname) __THROW;
95
 
96
struct if_nameindex {
97
  unsigned int if_index;
98
  char *if_name;
99
};
100
 
101
struct if_nameindex* if_nameindex(void) __THROW;
102
void if_freenameindex(struct if_nameindex* ptr) __THROW;
103
 
104
__END_DECLS
105
 
106
#endif