if.h revision 1.7
1/*	$NetBSD: if.h,v 1.7 2022/09/28 15:32:09 msaitoh Exp $	*/
2
3/*-
4 * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by William Studenmund and Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * Copyright (c) 1982, 1986, 1989, 1993
34 *	The Regents of the University of California.  All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 *    notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 *    notice, this list of conditions and the following disclaimer in the
43 *    documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 *    may be used to endorse or promote products derived from this software
46 *    without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 *	@(#)if.h	8.3 (Berkeley) 2/9/95
61 */
62
63#ifndef _COMPAT_NET_IF_H_
64#define _COMPAT_NET_IF_H_
65
66#include <net/route.h>
67#include <compat/sys/time.h>
68
69#define OIFNAMSIZ	16
70
71struct oifreq {
72	char	ifr_name[OIFNAMSIZ];		/* if name, e.g. "en0" */
73	union {
74		struct	sockaddr ifru_addr;
75		struct	sockaddr ifru_dstaddr;
76		struct	sockaddr ifru_broadaddr;
77		short	ifru_flags;
78		int	ifru_metric;
79		int	ifru_mtu;
80		int	ifru_dlt;
81		u_int	ifru_value;
82		void *	ifru_data;
83		struct {
84			uint32_t	b_buflen;
85			void		*b_buf;
86		} ifru_b;
87	} ifr_ifru;
88};
89struct	oifconf {
90	int	ifc_len;		/* size of associated buffer */
91	union {
92		void *	ifcu_buf;
93		struct	oifreq *ifcu_req;
94	} ifc_ifcu;
95#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
96#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
97};
98
99/* Pre-1.5 if_data struct */
100struct if_data14 {
101	/* generic interface information */
102	u_char	ifi_type;		/* ethernet, tokenring, etc. */
103	u_char	ifi_addrlen;		/* media address length */
104	u_char	ifi_hdrlen;		/* media header length */
105	u_long	ifi_mtu;		/* maximum transmission unit */
106	u_long	ifi_metric;		/* routing metric (external only) */
107	u_long	ifi_baudrate;		/* linespeed */
108	/* volatile statistics */
109	u_long	ifi_ipackets;		/* packets received on interface */
110	u_long	ifi_ierrors;		/* input errors on interface */
111	u_long	ifi_opackets;		/* packets sent on interface */
112	u_long	ifi_oerrors;		/* output errors on interface */
113	u_long	ifi_collisions;		/* collisions on csma interfaces */
114	u_long	ifi_ibytes;		/* total number of octets received */
115	u_long	ifi_obytes;		/* total number of octets sent */
116	u_long	ifi_imcasts;		/* packets received via multicast */
117	u_long	ifi_omcasts;		/* packets sent via multicast */
118	u_long	ifi_iqdrops;		/* dropped on input, this interface */
119	u_long	ifi_noproto;		/* destined for unsupported protocol */
120	struct	timeval50 ifi_lastchange;/* last operational state change */
121};
122
123/* pre-1.5 if_msghdr (ifm_data changed) */
124struct if_msghdr14 {
125	u_short	ifm_msglen;	/* to skip over non-understood messages */
126	u_char	ifm_version;	/* future binary compatibility */
127	u_char	ifm_type;	/* message type */
128	int	ifm_addrs;	/* like rtm_addrs */
129	int	ifm_flags;	/* value of if_flags */
130	u_short	ifm_index;	/* index for associated ifp */
131	struct	if_data14 ifm_data; /* statistics and other data about if */
132};
133
134void compat_14_rt_oifmsg(struct ifnet *);
135int compat_14_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *,
136    size_t);
137
138/*
139 * Structure defining statistics and other data kept regarding a network
140 * interface.
141 */
142struct if_data50 {
143	/* generic interface information */
144	u_char	ifi_type;		/* ethernet, tokenring, etc. */
145	u_char	ifi_addrlen;		/* media address length */
146	u_char	ifi_hdrlen;		/* media header length */
147	int	ifi_link_state;		/* current link state */
148	uint64_t ifi_mtu;		/* maximum transmission unit */
149	uint64_t ifi_metric;		/* routing metric (external only) */
150	uint64_t ifi_baudrate;		/* linespeed */
151	/* volatile statistics */
152	uint64_t ifi_ipackets;		/* packets received on interface */
153	uint64_t ifi_ierrors;		/* input errors on interface */
154	uint64_t ifi_opackets;		/* packets sent on interface */
155	uint64_t ifi_oerrors;		/* output errors on interface */
156	uint64_t ifi_collisions;	/* collisions on csma interfaces */
157	uint64_t ifi_ibytes;		/* total number of octets received */
158	uint64_t ifi_obytes;		/* total number of octets sent */
159	uint64_t ifi_imcasts;		/* packets received via multicast */
160	uint64_t ifi_omcasts;		/* packets sent via multicast */
161	uint64_t ifi_iqdrops;		/* dropped on input, this interface */
162	uint64_t ifi_noproto;		/* destined for unsupported protocol */
163	struct	timeval50 ifi_lastchange;/* last operational state change */
164};
165
166/*
167 * Structure defining statistics and other data kept regarding a network
168 * interface.
169 */
170struct ifdatareq50 {
171	char	ifdr_name[OIFNAMSIZ];		/* if name, e.g. "en0" */
172	struct	if_data50 ifdr_data;
173};
174
175/*
176 * Message format for use in obtaining information about interfaces
177 * from sysctl and the routing socket.
178 */
179struct if_msghdr50 {
180	u_short	ifm_msglen;	/* to skip over non-understood messages */
181	u_char	ifm_version;	/* future binary compatibility */
182	u_char	ifm_type;	/* message type */
183	int	ifm_addrs;	/* like rtm_addrs */
184	int	ifm_flags;	/* value of if_flags */
185	u_short	ifm_index;	/* index for associated ifp */
186	struct	if_data50 ifm_data;/* statistics and other data about if */
187};
188
189void compat_50_rt_oifmsg(struct ifnet *);
190int compat_50_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *,
191    size_t);
192
193/*
194 * Message format for use in obtaining information about interface addresses
195 * from sysctl and the routing socket.
196 */
197struct ifa_msghdr50 {
198	u_short	ifam_msglen;	/* to skip over non-understood messages */
199	u_char	ifam_version;	/* future binary compatibility */
200	u_char	ifam_type;	/* message type */
201	int	ifam_addrs;	/* like rtm_addrs */
202	int	ifam_flags;	/* value of ifa_flags */
203	u_short	ifam_index;	/* index for associated ifp */
204	int	ifam_metric;	/* value of ifa_metric */
205};
206
207/*
208 * Message format announcing the arrival or departure of a network interface.
209 */
210struct if_announcemsghdr50 {
211	u_short	ifan_msglen;	/* to skip over non-understood messages */
212	u_char	ifan_version;	/* future binary compatibility */
213	u_char	ifan_type;	/* message type */
214	u_short	ifan_index;	/* index for associated ifp */
215	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
216	u_short	ifan_what;	/* what type of announcement */
217};
218
219#if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
220#define	__align64	__aligned(sizeof(uint64_t))
221#else
222#define	__align64
223#endif
224/*
225 * Message format for use in obtaining information about interface addresses
226 * from sysctl and the routing socket.
227 */
228struct ifa_msghdr70 {
229	u_short	ifam_msglen __align64;
230				/* to skip over non-understood messages */
231	u_char	ifam_version;	/* future binary compatibility */
232	u_char	ifam_type;	/* message type */
233	int	ifam_addrs;	/* like rtm_addrs */
234	int	ifam_flags;	/* value of ifa_flags */
235	int	ifam_metric;	/* value of ifa_metric */
236	u_short	ifam_index;	/* index for associated ifp */
237};
238#undef __align64
239
240int compat_70_iflist_addr(struct rt_walkarg *, struct ifaddr *,
241    struct rt_addrinfo *);
242
243#endif /* _COMPAT_NET_IF_H_ */
244