Home | History | Annotate | Line # | Download | only in net
      1  1.7   msaitoh /*	$NetBSD: if.h,v 1.7 2022/09/28 15:32:09 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.7   msaitoh #include <net/route.h>
     67  1.2  christos #include <compat/sys/time.h>
     68  1.2  christos 
     69  1.7   msaitoh #define OIFNAMSIZ	16
     70  1.7   msaitoh 
     71  1.7   msaitoh struct oifreq {
     72  1.7   msaitoh 	char	ifr_name[OIFNAMSIZ];		/* if name, e.g. "en0" */
     73  1.7   msaitoh 	union {
     74  1.7   msaitoh 		struct	sockaddr ifru_addr;
     75  1.7   msaitoh 		struct	sockaddr ifru_dstaddr;
     76  1.7   msaitoh 		struct	sockaddr ifru_broadaddr;
     77  1.7   msaitoh 		short	ifru_flags;
     78  1.7   msaitoh 		int	ifru_metric;
     79  1.7   msaitoh 		int	ifru_mtu;
     80  1.7   msaitoh 		int	ifru_dlt;
     81  1.7   msaitoh 		u_int	ifru_value;
     82  1.7   msaitoh 		void *	ifru_data;
     83  1.7   msaitoh 		struct {
     84  1.7   msaitoh 			uint32_t	b_buflen;
     85  1.7   msaitoh 			void		*b_buf;
     86  1.7   msaitoh 		} ifru_b;
     87  1.7   msaitoh 	} ifr_ifru;
     88  1.7   msaitoh };
     89  1.7   msaitoh struct	oifconf {
     90  1.7   msaitoh 	int	ifc_len;		/* size of associated buffer */
     91  1.7   msaitoh 	union {
     92  1.7   msaitoh 		void *	ifcu_buf;
     93  1.7   msaitoh 		struct	oifreq *ifcu_req;
     94  1.7   msaitoh 	} ifc_ifcu;
     95  1.7   msaitoh #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
     96  1.7   msaitoh #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
     97  1.7   msaitoh };
     98  1.7   msaitoh 
     99  1.2  christos /* Pre-1.5 if_data struct */
    100  1.2  christos struct if_data14 {
    101  1.2  christos 	/* generic interface information */
    102  1.2  christos 	u_char	ifi_type;		/* ethernet, tokenring, etc. */
    103  1.2  christos 	u_char	ifi_addrlen;		/* media address length */
    104  1.2  christos 	u_char	ifi_hdrlen;		/* media header length */
    105  1.2  christos 	u_long	ifi_mtu;		/* maximum transmission unit */
    106  1.2  christos 	u_long	ifi_metric;		/* routing metric (external only) */
    107  1.2  christos 	u_long	ifi_baudrate;		/* linespeed */
    108  1.2  christos 	/* volatile statistics */
    109  1.2  christos 	u_long	ifi_ipackets;		/* packets received on interface */
    110  1.2  christos 	u_long	ifi_ierrors;		/* input errors on interface */
    111  1.2  christos 	u_long	ifi_opackets;		/* packets sent on interface */
    112  1.2  christos 	u_long	ifi_oerrors;		/* output errors on interface */
    113  1.2  christos 	u_long	ifi_collisions;		/* collisions on csma interfaces */
    114  1.2  christos 	u_long	ifi_ibytes;		/* total number of octets received */
    115  1.2  christos 	u_long	ifi_obytes;		/* total number of octets sent */
    116  1.2  christos 	u_long	ifi_imcasts;		/* packets received via multicast */
    117  1.2  christos 	u_long	ifi_omcasts;		/* packets sent via multicast */
    118  1.2  christos 	u_long	ifi_iqdrops;		/* dropped on input, this interface */
    119  1.2  christos 	u_long	ifi_noproto;		/* destined for unsupported protocol */
    120  1.2  christos 	struct	timeval50 ifi_lastchange;/* last operational state change */
    121  1.2  christos };
    122  1.2  christos 
    123  1.2  christos /* pre-1.5 if_msghdr (ifm_data changed) */
    124  1.2  christos struct if_msghdr14 {
    125  1.2  christos 	u_short	ifm_msglen;	/* to skip over non-understood messages */
    126  1.2  christos 	u_char	ifm_version;	/* future binary compatibility */
    127  1.2  christos 	u_char	ifm_type;	/* message type */
    128  1.2  christos 	int	ifm_addrs;	/* like rtm_addrs */
    129  1.2  christos 	int	ifm_flags;	/* value of if_flags */
    130  1.2  christos 	u_short	ifm_index;	/* index for associated ifp */
    131  1.2  christos 	struct	if_data14 ifm_data; /* statistics and other data about if */
    132  1.2  christos };
    133  1.2  christos 
    134  1.3      matt void compat_14_rt_oifmsg(struct ifnet *);
    135  1.2  christos int compat_14_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *,
    136  1.2  christos     size_t);
    137  1.2  christos 
    138  1.2  christos /*
    139  1.2  christos  * Structure defining statistics and other data kept regarding a network
    140  1.2  christos  * interface.
    141  1.2  christos  */
    142  1.2  christos struct if_data50 {
    143  1.2  christos 	/* generic interface information */
    144  1.2  christos 	u_char	ifi_type;		/* ethernet, tokenring, etc. */
    145  1.2  christos 	u_char	ifi_addrlen;		/* media address length */
    146  1.2  christos 	u_char	ifi_hdrlen;		/* media header length */
    147  1.2  christos 	int	ifi_link_state;		/* current link state */
    148  1.6   msaitoh 	uint64_t ifi_mtu;		/* maximum transmission unit */
    149  1.6   msaitoh 	uint64_t ifi_metric;		/* routing metric (external only) */
    150  1.6   msaitoh 	uint64_t ifi_baudrate;		/* linespeed */
    151  1.2  christos 	/* volatile statistics */
    152  1.6   msaitoh 	uint64_t ifi_ipackets;		/* packets received on interface */
    153  1.6   msaitoh 	uint64_t ifi_ierrors;		/* input errors on interface */
    154  1.6   msaitoh 	uint64_t ifi_opackets;		/* packets sent on interface */
    155  1.6   msaitoh 	uint64_t ifi_oerrors;		/* output errors on interface */
    156  1.6   msaitoh 	uint64_t ifi_collisions;	/* collisions on csma interfaces */
    157  1.6   msaitoh 	uint64_t ifi_ibytes;		/* total number of octets received */
    158  1.6   msaitoh 	uint64_t ifi_obytes;		/* total number of octets sent */
    159  1.6   msaitoh 	uint64_t ifi_imcasts;		/* packets received via multicast */
    160  1.6   msaitoh 	uint64_t ifi_omcasts;		/* packets sent via multicast */
    161  1.6   msaitoh 	uint64_t ifi_iqdrops;		/* dropped on input, this interface */
    162  1.6   msaitoh 	uint64_t ifi_noproto;		/* destined for unsupported protocol */
    163  1.2  christos 	struct	timeval50 ifi_lastchange;/* last operational state change */
    164  1.2  christos };
    165  1.2  christos 
    166  1.2  christos /*
    167  1.7   msaitoh  * Structure defining statistics and other data kept regarding a network
    168  1.7   msaitoh  * interface.
    169  1.7   msaitoh  */
    170  1.7   msaitoh struct ifdatareq50 {
    171  1.7   msaitoh 	char	ifdr_name[OIFNAMSIZ];		/* if name, e.g. "en0" */
    172  1.7   msaitoh 	struct	if_data50 ifdr_data;
    173  1.7   msaitoh };
    174  1.7   msaitoh 
    175  1.7   msaitoh /*
    176  1.2  christos  * Message format for use in obtaining information about interfaces
    177  1.2  christos  * from sysctl and the routing socket.
    178  1.2  christos  */
    179  1.2  christos struct if_msghdr50 {
    180  1.2  christos 	u_short	ifm_msglen;	/* to skip over non-understood messages */
    181  1.2  christos 	u_char	ifm_version;	/* future binary compatibility */
    182  1.2  christos 	u_char	ifm_type;	/* message type */
    183  1.2  christos 	int	ifm_addrs;	/* like rtm_addrs */
    184  1.2  christos 	int	ifm_flags;	/* value of if_flags */
    185  1.2  christos 	u_short	ifm_index;	/* index for associated ifp */
    186  1.2  christos 	struct	if_data50 ifm_data;/* statistics and other data about if */
    187  1.2  christos };
    188  1.2  christos 
    189  1.3      matt void compat_50_rt_oifmsg(struct ifnet *);
    190  1.2  christos int compat_50_iflist(struct ifnet *, struct rt_walkarg *, struct rt_addrinfo *,
    191  1.2  christos     size_t);
    192  1.2  christos 
    193  1.3      matt /*
    194  1.3      matt  * Message format for use in obtaining information about interface addresses
    195  1.3      matt  * from sysctl and the routing socket.
    196  1.3      matt  */
    197  1.3      matt struct ifa_msghdr50 {
    198  1.3      matt 	u_short	ifam_msglen;	/* to skip over non-understood messages */
    199  1.3      matt 	u_char	ifam_version;	/* future binary compatibility */
    200  1.3      matt 	u_char	ifam_type;	/* message type */
    201  1.3      matt 	int	ifam_addrs;	/* like rtm_addrs */
    202  1.3      matt 	int	ifam_flags;	/* value of ifa_flags */
    203  1.3      matt 	u_short	ifam_index;	/* index for associated ifp */
    204  1.3      matt 	int	ifam_metric;	/* value of ifa_metric */
    205  1.3      matt };
    206  1.3      matt 
    207  1.3      matt /*
    208  1.3      matt  * Message format announcing the arrival or departure of a network interface.
    209  1.3      matt  */
    210  1.3      matt struct if_announcemsghdr50 {
    211  1.3      matt 	u_short	ifan_msglen;	/* to skip over non-understood messages */
    212  1.3      matt 	u_char	ifan_version;	/* future binary compatibility */
    213  1.3      matt 	u_char	ifan_type;	/* message type */
    214  1.3      matt 	u_short	ifan_index;	/* index for associated ifp */
    215  1.3      matt 	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
    216  1.3      matt 	u_short	ifan_what;	/* what type of announcement */
    217  1.3      matt };
    218  1.3      matt 
    219  1.4       roy #if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
    220  1.4       roy #define	__align64	__aligned(sizeof(uint64_t))
    221  1.4       roy #else
    222  1.4       roy #define	__align64
    223  1.4       roy #endif
    224  1.4       roy /*
    225  1.4       roy  * Message format for use in obtaining information about interface addresses
    226  1.4       roy  * from sysctl and the routing socket.
    227  1.4       roy  */
    228  1.4       roy struct ifa_msghdr70 {
    229  1.4       roy 	u_short	ifam_msglen __align64;
    230  1.4       roy 				/* to skip over non-understood messages */
    231  1.4       roy 	u_char	ifam_version;	/* future binary compatibility */
    232  1.4       roy 	u_char	ifam_type;	/* message type */
    233  1.4       roy 	int	ifam_addrs;	/* like rtm_addrs */
    234  1.4       roy 	int	ifam_flags;	/* value of ifa_flags */
    235  1.4       roy 	int	ifam_metric;	/* value of ifa_metric */
    236  1.4       roy 	u_short	ifam_index;	/* index for associated ifp */
    237  1.4       roy };
    238  1.4       roy #undef __align64
    239  1.4       roy 
    240  1.4       roy int compat_70_iflist_addr(struct rt_walkarg *, struct ifaddr *,
    241  1.4       roy     struct rt_addrinfo *);
    242  1.4       roy 
    243  1.2  christos #endif /* _COMPAT_NET_IF_H_ */
    244