xref: /freebsd/sys/net/if.h (revision cea1da3be2dd73c9fb2a1bd844f1959cb10c172b)
1df8bae1dSRodney W. Grimes /*
2df8bae1dSRodney W. Grimes  * Copyright (c) 1982, 1986, 1989, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
7df8bae1dSRodney W. Grimes  * are met:
8df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13df8bae1dSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
14df8bae1dSRodney W. Grimes  *    must display the following acknowledgement:
15df8bae1dSRodney W. Grimes  *	This product includes software developed by the University of
16df8bae1dSRodney W. Grimes  *	California, Berkeley and its contributors.
17df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
18df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
19df8bae1dSRodney W. Grimes  *    without specific prior written permission.
20df8bae1dSRodney W. Grimes  *
21df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
32df8bae1dSRodney W. Grimes  *
33df8bae1dSRodney W. Grimes  *	@(#)if.h	8.1 (Berkeley) 6/10/93
34cea1da3bSPaul Richards  * $Id: if.h,v 1.5 1994/08/18 22:35:20 wollman Exp $
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
37cea1da3bSPaul Richards #ifndef _NET_IF_H_
38cea1da3bSPaul Richards #define _NET_IF_H_
39cea1da3bSPaul Richards 
40df8bae1dSRodney W. Grimes /*
41df8bae1dSRodney W. Grimes  * Structures defining a network interface, providing a packet
42df8bae1dSRodney W. Grimes  * transport mechanism (ala level 0 of the PUP protocols).
43df8bae1dSRodney W. Grimes  *
44df8bae1dSRodney W. Grimes  * Each interface accepts output datagrams of a specified maximum
45df8bae1dSRodney W. Grimes  * length, and provides higher level routines with input datagrams
46df8bae1dSRodney W. Grimes  * received from its medium.
47df8bae1dSRodney W. Grimes  *
48df8bae1dSRodney W. Grimes  * Output occurs when the routine if_output is called, with three parameters:
49df8bae1dSRodney W. Grimes  *	(*ifp->if_output)(ifp, m, dst, rt)
50df8bae1dSRodney W. Grimes  * Here m is the mbuf chain to be sent and dst is the destination address.
51df8bae1dSRodney W. Grimes  * The output routine encapsulates the supplied datagram if necessary,
52df8bae1dSRodney W. Grimes  * and then transmits it on its medium.
53df8bae1dSRodney W. Grimes  *
54df8bae1dSRodney W. Grimes  * On input, each interface unwraps the data received by it, and either
55df8bae1dSRodney W. Grimes  * places it on the input queue of a internetwork datagram routine
56df8bae1dSRodney W. Grimes  * and posts the associated software interrupt, or passes the datagram to a raw
57df8bae1dSRodney W. Grimes  * packet input routine.
58df8bae1dSRodney W. Grimes  *
59df8bae1dSRodney W. Grimes  * Routines exist for locating interfaces by their addresses
60df8bae1dSRodney W. Grimes  * or for locating a interface on a certain network, as well as more general
61df8bae1dSRodney W. Grimes  * routing and gateway routines maintaining information used to locate
62df8bae1dSRodney W. Grimes  * interfaces.  These routines live in the files if.c and route.c
63df8bae1dSRodney W. Grimes  */
64df8bae1dSRodney W. Grimes #ifndef _TIME_ /*  XXX fast fix for SNMP, going away soon */
65df8bae1dSRodney W. Grimes #include <sys/time.h>
66df8bae1dSRodney W. Grimes #endif
67df8bae1dSRodney W. Grimes 
68df8bae1dSRodney W. Grimes #ifdef __STDC__
69df8bae1dSRodney W. Grimes /*
70df8bae1dSRodney W. Grimes  * Forward structure declarations for function prototypes [sic].
71df8bae1dSRodney W. Grimes  */
72df8bae1dSRodney W. Grimes struct	mbuf;
73df8bae1dSRodney W. Grimes struct	proc;
74df8bae1dSRodney W. Grimes struct	rtentry;
75df8bae1dSRodney W. Grimes struct	socket;
76df8bae1dSRodney W. Grimes struct	ether_header;
77df8bae1dSRodney W. Grimes #endif
78df8bae1dSRodney W. Grimes /*
79df8bae1dSRodney W. Grimes  * Structure describing information about an interface
80df8bae1dSRodney W. Grimes  * which may be of interest to management entities.
81df8bae1dSRodney W. Grimes  */
82df8bae1dSRodney W. Grimes /*
83df8bae1dSRodney W. Grimes  * Structure defining a queue for a network interface.
84df8bae1dSRodney W. Grimes  *
85df8bae1dSRodney W. Grimes  * (Would like to call this struct ``if'', but C isn't PL/1.)
86df8bae1dSRodney W. Grimes  */
87df8bae1dSRodney W. Grimes 
88df8bae1dSRodney W. Grimes struct ifnet {
89df8bae1dSRodney W. Grimes 	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */
90df8bae1dSRodney W. Grimes 	struct	ifnet *if_next;		/* all struct ifnets are chained */
91df8bae1dSRodney W. Grimes 	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */
92df8bae1dSRodney W. Grimes         int	if_pcount;		/* number of promiscuous listeners */
93df8bae1dSRodney W. Grimes 	caddr_t	if_bpf;			/* packet filter structure */
94df8bae1dSRodney W. Grimes 	u_short	if_index;		/* numeric abbreviation for this if  */
95df8bae1dSRodney W. Grimes 	short	if_unit;		/* sub-unit for lower level driver */
96df8bae1dSRodney W. Grimes 	short	if_timer;		/* time 'til if_watchdog called */
97df8bae1dSRodney W. Grimes 	short	if_flags;		/* up/down, broadcast, etc. */
98df8bae1dSRodney W. Grimes 	struct	if_data {
99df8bae1dSRodney W. Grimes /* generic interface information */
100df8bae1dSRodney W. Grimes 		u_char	ifi_type;	/* ethernet, tokenring, etc */
101df8bae1dSRodney W. Grimes 		u_char	ifi_addrlen;	/* media address length */
102df8bae1dSRodney W. Grimes 		u_char	ifi_hdrlen;	/* media header length */
103df8bae1dSRodney W. Grimes 		u_long	ifi_mtu;	/* maximum transmission unit */
104df8bae1dSRodney W. Grimes 		u_long	ifi_metric;	/* routing metric (external only) */
105df8bae1dSRodney W. Grimes 		u_long	ifi_baudrate;	/* linespeed */
106df8bae1dSRodney W. Grimes /* volatile statistics */
107df8bae1dSRodney W. Grimes 		u_long	ifi_ipackets;	/* packets received on interface */
108df8bae1dSRodney W. Grimes 		u_long	ifi_ierrors;	/* input errors on interface */
109df8bae1dSRodney W. Grimes 		u_long	ifi_opackets;	/* packets sent on interface */
110df8bae1dSRodney W. Grimes 		u_long	ifi_oerrors;	/* output errors on interface */
111df8bae1dSRodney W. Grimes 		u_long	ifi_collisions;	/* collisions on csma interfaces */
112df8bae1dSRodney W. Grimes 		u_long	ifi_ibytes;	/* total number of octets received */
113df8bae1dSRodney W. Grimes 		u_long	ifi_obytes;	/* total number of octets sent */
114df8bae1dSRodney W. Grimes 		u_long	ifi_imcasts;	/* packets received via multicast */
115df8bae1dSRodney W. Grimes 		u_long	ifi_omcasts;	/* packets sent via multicast */
116df8bae1dSRodney W. Grimes 		u_long	ifi_iqdrops;	/* dropped on input, this interface */
117df8bae1dSRodney W. Grimes 		u_long	ifi_noproto;	/* destined for unsupported protocol */
118df8bae1dSRodney W. Grimes 		struct	timeval ifi_lastchange;/* last updated */
119df8bae1dSRodney W. Grimes 	}	if_data;
120df8bae1dSRodney W. Grimes /* procedure handles */
12126f9a767SRodney W. Grimes 	void	(*if_init)		/* init routine */
122df8bae1dSRodney W. Grimes 		__P((int));
123df8bae1dSRodney W. Grimes 	int	(*if_output)		/* output routine (enqueue) */
124df8bae1dSRodney W. Grimes 		__P((struct ifnet *, struct mbuf *, struct sockaddr *,
125df8bae1dSRodney W. Grimes 		     struct rtentry *));
12626f9a767SRodney W. Grimes 	void	(*if_start)		/* initiate output routine */
127df8bae1dSRodney W. Grimes 		__P((struct ifnet *));
128df8bae1dSRodney W. Grimes 	int	(*if_done)		/* output complete routine */
129df8bae1dSRodney W. Grimes 		__P((struct ifnet *));	/* (XXX not used; fake prototype) */
130df8bae1dSRodney W. Grimes 	int	(*if_ioctl)		/* ioctl routine */
131df8bae1dSRodney W. Grimes 		__P((struct ifnet *, int, caddr_t));
13226f9a767SRodney W. Grimes 	void	(*if_reset)
133df8bae1dSRodney W. Grimes 		__P((int));		/* new autoconfig will permit removal */
13426f9a767SRodney W. Grimes 	void	(*if_watchdog)		/* timer routine */
135df8bae1dSRodney W. Grimes 		__P((int));
136df8bae1dSRodney W. Grimes 	struct	ifqueue {
137df8bae1dSRodney W. Grimes 		struct	mbuf *ifq_head;
138df8bae1dSRodney W. Grimes 		struct	mbuf *ifq_tail;
139df8bae1dSRodney W. Grimes 		int	ifq_len;
140df8bae1dSRodney W. Grimes 		int	ifq_maxlen;
141df8bae1dSRodney W. Grimes 		int	ifq_drops;
142df8bae1dSRodney W. Grimes 	} if_snd;			/* output queue */
143df8bae1dSRodney W. Grimes };
144df8bae1dSRodney W. Grimes #define	if_mtu		if_data.ifi_mtu
145df8bae1dSRodney W. Grimes #define	if_type		if_data.ifi_type
146df8bae1dSRodney W. Grimes #define	if_addrlen	if_data.ifi_addrlen
147df8bae1dSRodney W. Grimes #define	if_hdrlen	if_data.ifi_hdrlen
148df8bae1dSRodney W. Grimes #define	if_metric	if_data.ifi_metric
149df8bae1dSRodney W. Grimes #define	if_baudrate	if_data.ifi_baudrate
150df8bae1dSRodney W. Grimes #define	if_ipackets	if_data.ifi_ipackets
151df8bae1dSRodney W. Grimes #define	if_ierrors	if_data.ifi_ierrors
152df8bae1dSRodney W. Grimes #define	if_opackets	if_data.ifi_opackets
153df8bae1dSRodney W. Grimes #define	if_oerrors	if_data.ifi_oerrors
154df8bae1dSRodney W. Grimes #define	if_collisions	if_data.ifi_collisions
155df8bae1dSRodney W. Grimes #define	if_ibytes	if_data.ifi_ibytes
156df8bae1dSRodney W. Grimes #define	if_obytes	if_data.ifi_obytes
157df8bae1dSRodney W. Grimes #define	if_imcasts	if_data.ifi_imcasts
158df8bae1dSRodney W. Grimes #define	if_omcasts	if_data.ifi_omcasts
159df8bae1dSRodney W. Grimes #define	if_iqdrops	if_data.ifi_iqdrops
160df8bae1dSRodney W. Grimes #define	if_noproto	if_data.ifi_noproto
161df8bae1dSRodney W. Grimes #define	if_lastchange	if_data.ifi_lastchange
162df8bae1dSRodney W. Grimes 
163df8bae1dSRodney W. Grimes #define	IFF_UP		0x1		/* interface is up */
164df8bae1dSRodney W. Grimes #define	IFF_BROADCAST	0x2		/* broadcast address valid */
165df8bae1dSRodney W. Grimes #define	IFF_DEBUG	0x4		/* turn on debugging */
166df8bae1dSRodney W. Grimes #define	IFF_LOOPBACK	0x8		/* is a loopback net */
167df8bae1dSRodney W. Grimes #define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
168df8bae1dSRodney W. Grimes #define	IFF_NOTRAILERS	0x20		/* avoid use of trailers */
169df8bae1dSRodney W. Grimes #define	IFF_RUNNING	0x40		/* resources allocated */
170df8bae1dSRodney W. Grimes #define	IFF_NOARP	0x80		/* no address resolution protocol */
171df8bae1dSRodney W. Grimes #define	IFF_PROMISC	0x100		/* receive all packets */
172df8bae1dSRodney W. Grimes #define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
173df8bae1dSRodney W. Grimes #define	IFF_OACTIVE	0x400		/* transmission in progress */
174df8bae1dSRodney W. Grimes #define	IFF_SIMPLEX	0x800		/* can't hear own transmissions */
175df8bae1dSRodney W. Grimes #define	IFF_LINK0	0x1000		/* per link layer defined bit */
176df8bae1dSRodney W. Grimes #define	IFF_LINK1	0x2000		/* per link layer defined bit */
177df8bae1dSRodney W. Grimes #define	IFF_LINK2	0x4000		/* per link layer defined bit */
178df8bae1dSRodney W. Grimes #define	IFF_MULTICAST	0x8000		/* supports multicast */
179df8bae1dSRodney W. Grimes 
180df8bae1dSRodney W. Grimes /* flags set internally only: */
181df8bae1dSRodney W. Grimes #define	IFF_CANTCHANGE \
182df8bae1dSRodney W. Grimes 	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
183df8bae1dSRodney W. Grimes 	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
184df8bae1dSRodney W. Grimes 
185df8bae1dSRodney W. Grimes /*
186df8bae1dSRodney W. Grimes  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
187df8bae1dSRodney W. Grimes  * input routines have queues of messages stored on ifqueue structures
188df8bae1dSRodney W. Grimes  * (defined above).  Entries are added to and deleted from these structures
189df8bae1dSRodney W. Grimes  * by these macros, which should be called with ipl raised to splimp().
190df8bae1dSRodney W. Grimes  */
191df8bae1dSRodney W. Grimes #define	IF_QFULL(ifq)		((ifq)->ifq_len >= (ifq)->ifq_maxlen)
192df8bae1dSRodney W. Grimes #define	IF_DROP(ifq)		((ifq)->ifq_drops++)
193df8bae1dSRodney W. Grimes #define	IF_ENQUEUE(ifq, m) { \
194df8bae1dSRodney W. Grimes 	(m)->m_nextpkt = 0; \
195df8bae1dSRodney W. Grimes 	if ((ifq)->ifq_tail == 0) \
196df8bae1dSRodney W. Grimes 		(ifq)->ifq_head = m; \
197df8bae1dSRodney W. Grimes 	else \
198df8bae1dSRodney W. Grimes 		(ifq)->ifq_tail->m_nextpkt = m; \
199df8bae1dSRodney W. Grimes 	(ifq)->ifq_tail = m; \
200df8bae1dSRodney W. Grimes 	(ifq)->ifq_len++; \
201df8bae1dSRodney W. Grimes }
202df8bae1dSRodney W. Grimes #define	IF_PREPEND(ifq, m) { \
203df8bae1dSRodney W. Grimes 	(m)->m_nextpkt = (ifq)->ifq_head; \
204df8bae1dSRodney W. Grimes 	if ((ifq)->ifq_tail == 0) \
205df8bae1dSRodney W. Grimes 		(ifq)->ifq_tail = (m); \
206df8bae1dSRodney W. Grimes 	(ifq)->ifq_head = (m); \
207df8bae1dSRodney W. Grimes 	(ifq)->ifq_len++; \
208df8bae1dSRodney W. Grimes }
209df8bae1dSRodney W. Grimes #define	IF_DEQUEUE(ifq, m) { \
210df8bae1dSRodney W. Grimes 	(m) = (ifq)->ifq_head; \
211df8bae1dSRodney W. Grimes 	if (m) { \
212df8bae1dSRodney W. Grimes 		if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
213df8bae1dSRodney W. Grimes 			(ifq)->ifq_tail = 0; \
214df8bae1dSRodney W. Grimes 		(m)->m_nextpkt = 0; \
215df8bae1dSRodney W. Grimes 		(ifq)->ifq_len--; \
216df8bae1dSRodney W. Grimes 	} \
217df8bae1dSRodney W. Grimes }
218df8bae1dSRodney W. Grimes 
219df8bae1dSRodney W. Grimes #define	IFQ_MAXLEN	50
220df8bae1dSRodney W. Grimes #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
221df8bae1dSRodney W. Grimes 
222df8bae1dSRodney W. Grimes /*
223df8bae1dSRodney W. Grimes  * The ifaddr structure contains information about one address
224df8bae1dSRodney W. Grimes  * of an interface.  They are maintained by the different address families,
225df8bae1dSRodney W. Grimes  * are allocated and attached when an address is set, and are linked
226df8bae1dSRodney W. Grimes  * together so all addresses for an interface can be located.
227df8bae1dSRodney W. Grimes  */
228df8bae1dSRodney W. Grimes struct ifaddr {
229df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_addr;	/* address of interface */
230df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_dstaddr;	/* other end of p-to-p link */
231df8bae1dSRodney W. Grimes #define	ifa_broadaddr	ifa_dstaddr	/* broadcast address interface */
232df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_netmask;	/* used to determine subnet */
233df8bae1dSRodney W. Grimes 	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
234df8bae1dSRodney W. Grimes 	struct	ifaddr *ifa_next;	/* next address for interface */
235df8bae1dSRodney W. Grimes 	void	(*ifa_rtrequest)();	/* check or clean routes (+ or -)'d */
236df8bae1dSRodney W. Grimes 	u_short	ifa_flags;		/* mostly rt_flags for cloning */
237df8bae1dSRodney W. Grimes 	short	ifa_refcnt;		/* extra to malloc for link info */
238df8bae1dSRodney W. Grimes 	int	ifa_metric;		/* cost of going out this interface */
239df8bae1dSRodney W. Grimes #ifdef notdef
240df8bae1dSRodney W. Grimes 	struct	rtentry *ifa_rt;	/* XXXX for ROUTETOIF ????? */
241df8bae1dSRodney W. Grimes #endif
242df8bae1dSRodney W. Grimes };
243df8bae1dSRodney W. Grimes #define	IFA_ROUTE	RTF_UP		/* route installed */
244df8bae1dSRodney W. Grimes 
245df8bae1dSRodney W. Grimes /*
246df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interfaces
247df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
248df8bae1dSRodney W. Grimes  */
249df8bae1dSRodney W. Grimes struct if_msghdr {
250df8bae1dSRodney W. Grimes 	u_short	ifm_msglen;	/* to skip over non-understood messages */
251df8bae1dSRodney W. Grimes 	u_char	ifm_version;	/* future binary compatability */
252df8bae1dSRodney W. Grimes 	u_char	ifm_type;	/* message type */
253df8bae1dSRodney W. Grimes 	int	ifm_addrs;	/* like rtm_addrs */
254df8bae1dSRodney W. Grimes 	int	ifm_flags;	/* value of if_flags */
255df8bae1dSRodney W. Grimes 	u_short	ifm_index;	/* index for associated ifp */
256df8bae1dSRodney W. Grimes 	struct	if_data ifm_data;/* statistics and other data about if */
257df8bae1dSRodney W. Grimes };
258df8bae1dSRodney W. Grimes 
259df8bae1dSRodney W. Grimes /*
260df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interface addresses
261df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
262df8bae1dSRodney W. Grimes  */
263df8bae1dSRodney W. Grimes struct ifa_msghdr {
264df8bae1dSRodney W. Grimes 	u_short	ifam_msglen;	/* to skip over non-understood messages */
265df8bae1dSRodney W. Grimes 	u_char	ifam_version;	/* future binary compatability */
266df8bae1dSRodney W. Grimes 	u_char	ifam_type;	/* message type */
267df8bae1dSRodney W. Grimes 	int	ifam_addrs;	/* like rtm_addrs */
268df8bae1dSRodney W. Grimes 	int	ifam_flags;	/* value of ifa_flags */
269df8bae1dSRodney W. Grimes 	u_short	ifam_index;	/* index for associated ifp */
270df8bae1dSRodney W. Grimes 	int	ifam_metric;	/* value of ifa_metric */
271df8bae1dSRodney W. Grimes };
272df8bae1dSRodney W. Grimes 
273df8bae1dSRodney W. Grimes /*
274df8bae1dSRodney W. Grimes  * Interface request structure used for socket
275df8bae1dSRodney W. Grimes  * ioctl's.  All interface ioctl's must have parameter
276df8bae1dSRodney W. Grimes  * definitions which begin with ifr_name.  The
277df8bae1dSRodney W. Grimes  * remainder may be interface specific.
278df8bae1dSRodney W. Grimes  */
279df8bae1dSRodney W. Grimes struct	ifreq {
280df8bae1dSRodney W. Grimes #define	IFNAMSIZ	16
281df8bae1dSRodney W. Grimes 	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
282df8bae1dSRodney W. Grimes 	union {
283df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_addr;
284df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_dstaddr;
285df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_broadaddr;
286df8bae1dSRodney W. Grimes 		short	ifru_flags;
287df8bae1dSRodney W. Grimes 		int	ifru_metric;
288a7028af7SDavid Greenman 		int	ifru_mtu;
289df8bae1dSRodney W. Grimes 		caddr_t	ifru_data;
290df8bae1dSRodney W. Grimes 	} ifr_ifru;
291df8bae1dSRodney W. Grimes #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
292df8bae1dSRodney W. Grimes #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
293df8bae1dSRodney W. Grimes #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
294df8bae1dSRodney W. Grimes #define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
295df8bae1dSRodney W. Grimes #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
296a7028af7SDavid Greenman #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
297df8bae1dSRodney W. Grimes #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
298df8bae1dSRodney W. Grimes };
299df8bae1dSRodney W. Grimes 
300df8bae1dSRodney W. Grimes struct ifaliasreq {
301df8bae1dSRodney W. Grimes 	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
302df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_addr;
303df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_broadaddr;
304df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_mask;
305df8bae1dSRodney W. Grimes };
306df8bae1dSRodney W. Grimes 
307df8bae1dSRodney W. Grimes /*
308df8bae1dSRodney W. Grimes  * Structure used in SIOCGIFCONF request.
309df8bae1dSRodney W. Grimes  * Used to retrieve interface configuration
310df8bae1dSRodney W. Grimes  * for machine (useful for programs which
311df8bae1dSRodney W. Grimes  * must know all networks accessible).
312df8bae1dSRodney W. Grimes  */
313df8bae1dSRodney W. Grimes struct	ifconf {
314df8bae1dSRodney W. Grimes 	int	ifc_len;		/* size of associated buffer */
315df8bae1dSRodney W. Grimes 	union {
316df8bae1dSRodney W. Grimes 		caddr_t	ifcu_buf;
317df8bae1dSRodney W. Grimes 		struct	ifreq *ifcu_req;
318df8bae1dSRodney W. Grimes 	} ifc_ifcu;
319df8bae1dSRodney W. Grimes #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
320df8bae1dSRodney W. Grimes #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
321df8bae1dSRodney W. Grimes };
322df8bae1dSRodney W. Grimes 
323df8bae1dSRodney W. Grimes #include <net/if_arp.h>
324df8bae1dSRodney W. Grimes 
325df8bae1dSRodney W. Grimes #ifdef KERNEL
326df8bae1dSRodney W. Grimes #define	IFAFREE(ifa) \
327df8bae1dSRodney W. Grimes 	if ((ifa)->ifa_refcnt <= 0) \
328df8bae1dSRodney W. Grimes 		ifafree(ifa); \
329df8bae1dSRodney W. Grimes 	else \
330df8bae1dSRodney W. Grimes 		(ifa)->ifa_refcnt--;
331df8bae1dSRodney W. Grimes 
332df8bae1dSRodney W. Grimes struct	ifnet	*ifnet;
333df8bae1dSRodney W. Grimes 
334df8bae1dSRodney W. Grimes void	ether_ifattach __P((struct ifnet *));
335df8bae1dSRodney W. Grimes void	ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
336df8bae1dSRodney W. Grimes int	ether_output __P((struct ifnet *,
337df8bae1dSRodney W. Grimes 	   struct mbuf *, struct sockaddr *, struct rtentry *));
338df8bae1dSRodney W. Grimes char	*ether_sprintf __P((u_char *));
339df8bae1dSRodney W. Grimes 
340df8bae1dSRodney W. Grimes void	if_attach __P((struct ifnet *));
341df8bae1dSRodney W. Grimes void	if_down __P((struct ifnet *));
342df8bae1dSRodney W. Grimes void	if_qflush __P((struct ifqueue *));
343df8bae1dSRodney W. Grimes void	if_slowtimo __P((void *));
344df8bae1dSRodney W. Grimes void	if_up __P((struct ifnet *));
345df8bae1dSRodney W. Grimes #ifdef vax
346df8bae1dSRodney W. Grimes void	ifubareset __P((int));
347df8bae1dSRodney W. Grimes #endif
348df8bae1dSRodney W. Grimes int	ifconf __P((int, caddr_t));
349f23b4c91SGarrett Wollman /*void	ifinit __P((void));*/ /* declared in systm.h for main() */
350df8bae1dSRodney W. Grimes int	ifioctl __P((struct socket *, int, caddr_t, struct proc *));
351df8bae1dSRodney W. Grimes int	ifpromisc __P((struct ifnet *, int));
352df8bae1dSRodney W. Grimes struct	ifnet *ifunit __P((char *));
353df8bae1dSRodney W. Grimes 
354df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithaddr __P((struct sockaddr *));
355df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithaf __P((int));
356df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *));
357df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithnet __P((struct sockaddr *));
358df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithroute __P((int, struct sockaddr *,
359df8bae1dSRodney W. Grimes 					struct sockaddr *));
360df8bae1dSRodney W. Grimes struct	ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));
361df8bae1dSRodney W. Grimes void	ifafree __P((struct ifaddr *));
362df8bae1dSRodney W. Grimes void	link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
363df8bae1dSRodney W. Grimes 
364df8bae1dSRodney W. Grimes int	loioctl __P((struct ifnet *, int, caddr_t));
36526f9a767SRodney W. Grimes void	loopattach __P((void));
366df8bae1dSRodney W. Grimes int	looutput __P((struct ifnet *,
367df8bae1dSRodney W. Grimes 	   struct mbuf *, struct sockaddr *, struct rtentry *));
368df8bae1dSRodney W. Grimes void	lortrequest __P((int, struct rtentry *, struct sockaddr *));
369df8bae1dSRodney W. Grimes #endif
370cea1da3bSPaul Richards 
371cea1da3bSPaul Richards #endif
372