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