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