1 /* $NetBSD: if.h,v 1.5 2019/12/15 16:48:26 tsutsui 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 <compat/sys/time.h> 67 68 /* Pre-1.5 if_data struct */ 69 struct if_data14 { 70 /* generic interface information */ 71 u_char ifi_type; /* ethernet, tokenring, etc. */ 72 u_char ifi_addrlen; /* media address length */ 73 u_char ifi_hdrlen; /* media header length */ 74 u_long ifi_mtu; /* maximum transmission unit */ 75 u_long ifi_metric; /* routing metric (external only) */ 76 u_long ifi_baudrate; /* linespeed */ 77 /* volatile statistics */ 78 u_long ifi_ipackets; /* packets received on interface */ 79 u_long ifi_ierrors; /* input errors on interface */ 80 u_long ifi_opackets; /* packets sent on interface */ 81 u_long ifi_oerrors; /* output errors on interface */ 82 u_long ifi_collisions; /* collisions on csma interfaces */ 83 u_long ifi_ibytes; /* total number of octets received */ 84 u_long ifi_obytes; /* total number of octets sent */ 85 u_long ifi_imcasts; /* packets received via multicast */ 86 u_long ifi_omcasts; /* packets sent via multicast */ 87 u_long ifi_iqdrops; /* dropped on input, this interface */ 88 u_long ifi_noproto; /* destined for unsupported protocol */ 89 struct timeval50 ifi_lastchange;/* last operational state change */ 90 }; 91 92 /* pre-1.5 if_msghdr (ifm_data changed) */ 93 struct if_msghdr14 { 94 u_short ifm_msglen; /* to skip over non-understood messages */ 95 u_char ifm_version; /* future binary compatibility */ 96 u_char ifm_type; /* message type */ 97 int ifm_addrs; /* like rtm_addrs */ 98 int ifm_flags; /* value of if_flags */ 99 u_short ifm_index; /* index for associated ifp */ 100 struct if_data14 ifm_data; /* statistics and other data about if */ 101 }; 102 103 void compat_14_rt_oifmsg(struct ifnet *); 104 int compat_14_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, 105 size_t); 106 107 /* 108 * Structure defining statistics and other data kept regarding a network 109 * interface. 110 */ 111 struct if_data50 { 112 /* generic interface information */ 113 u_char ifi_type; /* ethernet, tokenring, etc. */ 114 u_char ifi_addrlen; /* media address length */ 115 u_char ifi_hdrlen; /* media header length */ 116 int ifi_link_state; /* current link state */ 117 u_quad_t ifi_mtu; /* maximum transmission unit */ 118 u_quad_t ifi_metric; /* routing metric (external only) */ 119 u_quad_t ifi_baudrate; /* linespeed */ 120 /* volatile statistics */ 121 u_quad_t ifi_ipackets; /* packets received on interface */ 122 u_quad_t ifi_ierrors; /* input errors on interface */ 123 u_quad_t ifi_opackets; /* packets sent on interface */ 124 u_quad_t ifi_oerrors; /* output errors on interface */ 125 u_quad_t ifi_collisions; /* collisions on csma interfaces */ 126 u_quad_t ifi_ibytes; /* total number of octets received */ 127 u_quad_t ifi_obytes; /* total number of octets sent */ 128 u_quad_t ifi_imcasts; /* packets received via multicast */ 129 u_quad_t ifi_omcasts; /* packets sent via multicast */ 130 u_quad_t ifi_iqdrops; /* dropped on input, this interface */ 131 u_quad_t ifi_noproto; /* destined for unsupported protocol */ 132 struct timeval50 ifi_lastchange;/* last operational state change */ 133 }; 134 135 /* 136 * Message format for use in obtaining information about interfaces 137 * from sysctl and the routing socket. 138 */ 139 struct if_msghdr50 { 140 u_short ifm_msglen; /* to skip over non-understood messages */ 141 u_char ifm_version; /* future binary compatibility */ 142 u_char ifm_type; /* message type */ 143 int ifm_addrs; /* like rtm_addrs */ 144 int ifm_flags; /* value of if_flags */ 145 u_short ifm_index; /* index for associated ifp */ 146 struct if_data50 ifm_data;/* statistics and other data about if */ 147 }; 148 149 void compat_50_rt_oifmsg(struct ifnet *); 150 int compat_50_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *, 151 size_t); 152 153 /* 154 * Message format for use in obtaining information about interface addresses 155 * from sysctl and the routing socket. 156 */ 157 struct ifa_msghdr50 { 158 u_short ifam_msglen; /* to skip over non-understood messages */ 159 u_char ifam_version; /* future binary compatibility */ 160 u_char ifam_type; /* message type */ 161 int ifam_addrs; /* like rtm_addrs */ 162 int ifam_flags; /* value of ifa_flags */ 163 u_short ifam_index; /* index for associated ifp */ 164 int ifam_metric; /* value of ifa_metric */ 165 }; 166 167 /* 168 * Message format announcing the arrival or departure of a network interface. 169 */ 170 struct if_announcemsghdr50 { 171 u_short ifan_msglen; /* to skip over non-understood messages */ 172 u_char ifan_version; /* future binary compatibility */ 173 u_char ifan_type; /* message type */ 174 u_short ifan_index; /* index for associated ifp */ 175 char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 176 u_short ifan_what; /* what type of announcement */ 177 }; 178 179 #if !defined(_KERNEL) || !defined(COMPAT_RTSOCK) 180 #define __align64 __aligned(sizeof(uint64_t)) 181 #else 182 #define __align64 183 #endif 184 /* 185 * Message format for use in obtaining information about interface addresses 186 * from sysctl and the routing socket. 187 */ 188 struct ifa_msghdr70 { 189 u_short ifam_msglen __align64; 190 /* to skip over non-understood messages */ 191 u_char ifam_version; /* future binary compatibility */ 192 u_char ifam_type; /* message type */ 193 int ifam_addrs; /* like rtm_addrs */ 194 int ifam_flags; /* value of ifa_flags */ 195 int ifam_metric; /* value of ifa_metric */ 196 u_short ifam_index; /* index for associated ifp */ 197 }; 198 #undef __align64 199 200 int compat_70_iflist_addr(struct rt_walkarg *, struct ifaddr *, 201 struct rt_addrinfo *); 202 203 #endif /* _COMPAT_NET_IF_H_ */ 204