xref: /haiku/headers/posix/net/if.h (revision f23596149e0d173463f70629581aa10cc305d32e)
1 /*
2  * Copyright 2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _NET_IF_H
6 #define _NET_IF_H
7 
8 
9 #include <net/route.h>
10 #include <sys/socket.h>
11 
12 
13 #define IF_NAMESIZE	32
14 
15 /* BSD specific/proprietary part */
16 
17 #define IFNAMSIZ IF_NAMESIZE
18 
19 struct ifreq_parameter {
20 	char		base_name[IF_NAMESIZE];
21 	char		device[128];
22 	uint8_t		sub_type;
23 };
24 
25 struct ifreq_stream_stats {
26 	uint32_t	packets;
27 	uint32_t	errors;
28 	uint64_t	bytes;
29 	uint32_t	multicast_packets;
30 	uint32_t	dropped;
31 };
32 
33 struct ifreq_stats {
34 	struct ifreq_stream_stats receive;
35 	struct ifreq_stream_stats send;
36 	uint32_t	collisions;
37 };
38 
39 struct ifreq {
40 	char		ifr_name[IF_NAMESIZE];
41 	union {
42 		struct sockaddr ifr_addr;
43 		struct sockaddr ifr_dstaddr;
44 		struct sockaddr ifr_broadaddr;
45 		struct sockaddr ifr_mask;
46 		struct ifreq_parameter ifr_parameter;
47 		struct ifreq_stats ifr_stats;
48 		struct route_entry ifr_route;
49 		int		ifr_flags;
50 		int		ifr_index;
51 		int		ifr_metric;
52 		int		ifr_mtu;
53 		int		ifr_media;
54 		int		ifr_type;
55 	};
56 };
57 
58 /* interface flags */
59 #define IFF_UP			0x0001
60 #define IFF_BROADCAST	0x0002	/* valid broadcast address */
61 #define IFF_LOOPBACK	0x0008
62 #define IFF_POINTOPOINT	0x0010	/* point-to-point link */
63 #define IFF_NOARP		0x0040	/* no address resolution */
64 #define IFF_AUTOUP		0x0080	/* auto dial */
65 #define IFF_PROMISC		0x0100	/* receive all packets */
66 #define IFF_ALLMULTI	0x0200	/* receive all multicast packets */
67 #define IFF_SIMPLEX		0x0800	/* doesn't receive own transmissions */
68 #define IFF_MULTICAST	0x8000	/* supports multicast */
69 
70 struct ifconf {
71 	int			ifc_len;	/* size of buffer */
72 	union {
73 		void	*ifc_buf;
74 		struct ifreq *ifc_req;
75 		int		ifc_value;
76 	};
77 };
78 
79 /* POSIX definitions follow */
80 
81 struct if_nameindex {
82 	unsigned	if_index;	/* positive interface index */
83 	char		*if_name;	/* interface name, ie. "loopback" */
84 };
85 
86 
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
90 
91 unsigned if_nametoindex(const char *name);
92 char *if_indextoname(unsigned index, char *nameBuffer);
93 struct if_nameindex *if_nameindex(void);
94 void if_freenameindex(struct if_nameindex *interfaceArray);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif	/* _NET_IF_H */
101