xref: /haiku/headers/posix/net/if.h (revision 4f2fd49bdc6078128b1391191e4edac647044c3d)
1 /*
2  * Copyright 2006-2007, 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 		int		ifr_reqcap;
56 	};
57 };
58 
59 /* interface flags */
60 #define IFF_UP				0x0001
61 #define IFF_BROADCAST		0x0002	/* valid broadcast address */
62 #define IFF_LOOPBACK		0x0008
63 #define IFF_POINTOPOINT		0x0010	/* point-to-point link */
64 #define IFF_NOARP			0x0040	/* no address resolution */
65 #define IFF_AUTOUP			0x0080	/* auto dial */
66 #define IFF_PROMISC			0x0100	/* receive all packets */
67 #define IFF_ALLMULTI		0x0200	/* receive all multicast packets */
68 #define IFF_SIMPLEX			0x0800	/* doesn't receive own transmissions */
69 #define IFF_LINK			0x1000	/* has link */
70 #define IFF_AUTO_CONFIGURED	0x2000	/* has been automatically configured */
71 #define IFF_CONFIGURING		0x4000	/* auto configuration in progress */
72 #define IFF_MULTICAST		0x8000	/* supports multicast */
73 
74 struct ifconf {
75 	int			ifc_len;	/* size of buffer */
76 	union {
77 		void	*ifc_buf;
78 		struct ifreq *ifc_req;
79 		int		ifc_value;
80 	};
81 };
82 
83 /* POSIX definitions follow */
84 
85 struct if_nameindex {
86 	unsigned	if_index;	/* positive interface index */
87 	char		*if_name;	/* interface name, ie. "loopback" */
88 };
89 
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 unsigned if_nametoindex(const char *name);
96 char *if_indextoname(unsigned index, char *nameBuffer);
97 struct if_nameindex *if_nameindex(void);
98 void if_freenameindex(struct if_nameindex *interfaceArray);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif	/* _NET_IF_H */
105