xref: /freebsd/sys/net/if.h (revision 511cdd16490be50aeb350b3a681c265c7bd00cf9)
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
34511cdd16SDavid Greenman  * $Id: if.h,v 1.13 1994/12/21 22:56:59 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  */
64df708ff1SBruce Evans 
656c4b1b79SPoul-Henning Kamp #include <sys/socket.h>			/* for struct sockaddr */
66df708ff1SBruce Evans 
67df8bae1dSRodney W. Grimes #ifndef _TIME_ /*  XXX fast fix for SNMP, going away soon */
68df8bae1dSRodney W. Grimes #include <sys/time.h>
69df8bae1dSRodney W. Grimes #endif
70df8bae1dSRodney W. Grimes 
71df8bae1dSRodney W. Grimes #ifdef __STDC__
72df8bae1dSRodney W. Grimes /*
73df8bae1dSRodney W. Grimes  * Forward structure declarations for function prototypes [sic].
74df8bae1dSRodney W. Grimes  */
75df8bae1dSRodney W. Grimes struct	mbuf;
76df8bae1dSRodney W. Grimes struct	proc;
77df8bae1dSRodney W. Grimes struct	rtentry;
78df8bae1dSRodney W. Grimes struct	socket;
79df8bae1dSRodney W. Grimes struct	ether_header;
80df8bae1dSRodney W. Grimes #endif
81df8bae1dSRodney W. Grimes /*
82df8bae1dSRodney W. Grimes  * Structure describing information about an interface
83df8bae1dSRodney W. Grimes  * which may be of interest to management entities.
84df8bae1dSRodney W. Grimes  */
85df8bae1dSRodney W. Grimes /*
86df8bae1dSRodney W. Grimes  * Structure defining a queue for a network interface.
87df8bae1dSRodney W. Grimes  *
88df8bae1dSRodney W. Grimes  * (Would like to call this struct ``if'', but C isn't PL/1.)
89df8bae1dSRodney W. Grimes  */
90df8bae1dSRodney W. Grimes 
91df8bae1dSRodney W. Grimes struct ifnet {
92df8bae1dSRodney W. Grimes 	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */
93df8bae1dSRodney W. Grimes 	struct	ifnet *if_next;		/* all struct ifnets are chained */
94df8bae1dSRodney W. Grimes 	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */
95df8bae1dSRodney W. Grimes         int	if_pcount;		/* number of promiscuous listeners */
96df8bae1dSRodney W. Grimes 	caddr_t	if_bpf;			/* packet filter structure */
97df8bae1dSRodney W. Grimes 	u_short	if_index;		/* numeric abbreviation for this if  */
98df8bae1dSRodney W. Grimes 	short	if_unit;		/* sub-unit for lower level driver */
99df8bae1dSRodney W. Grimes 	short	if_timer;		/* time 'til if_watchdog called */
100df8bae1dSRodney W. Grimes 	short	if_flags;		/* up/down, broadcast, etc. */
101df8bae1dSRodney W. Grimes 	struct	if_data {
102df8bae1dSRodney W. Grimes /* generic interface information */
103df8bae1dSRodney W. Grimes 		u_char	ifi_type;	/* ethernet, tokenring, etc */
104995add1aSGarrett Wollman 		u_char	ifi_physical; 	/* e.g., AUI, Thinnet, 10base-T, etc */
105df8bae1dSRodney W. Grimes 		u_char	ifi_addrlen;	/* media address length */
106df8bae1dSRodney W. Grimes 		u_char	ifi_hdrlen;	/* media header length */
107df8bae1dSRodney W. Grimes 		u_long	ifi_mtu;	/* maximum transmission unit */
108df8bae1dSRodney W. Grimes 		u_long	ifi_metric;	/* routing metric (external only) */
109df8bae1dSRodney W. Grimes 		u_long	ifi_baudrate;	/* linespeed */
110df8bae1dSRodney W. Grimes /* volatile statistics */
111df8bae1dSRodney W. Grimes 		u_long	ifi_ipackets;	/* packets received on interface */
112df8bae1dSRodney W. Grimes 		u_long	ifi_ierrors;	/* input errors on interface */
113df8bae1dSRodney W. Grimes 		u_long	ifi_opackets;	/* packets sent on interface */
114df8bae1dSRodney W. Grimes 		u_long	ifi_oerrors;	/* output errors on interface */
115df8bae1dSRodney W. Grimes 		u_long	ifi_collisions;	/* collisions on csma interfaces */
116df8bae1dSRodney W. Grimes 		u_long	ifi_ibytes;	/* total number of octets received */
117df8bae1dSRodney W. Grimes 		u_long	ifi_obytes;	/* total number of octets sent */
118df8bae1dSRodney W. Grimes 		u_long	ifi_imcasts;	/* packets received via multicast */
119df8bae1dSRodney W. Grimes 		u_long	ifi_omcasts;	/* packets sent via multicast */
120df8bae1dSRodney W. Grimes 		u_long	ifi_iqdrops;	/* dropped on input, this interface */
121df8bae1dSRodney W. Grimes 		u_long	ifi_noproto;	/* destined for unsupported protocol */
122df8bae1dSRodney W. Grimes 		struct	timeval ifi_lastchange;/* last updated */
123df8bae1dSRodney W. Grimes 	}	if_data;
124df8bae1dSRodney W. Grimes /* procedure handles */
12526f9a767SRodney W. Grimes 	void	(*if_init)		/* init routine */
126df8bae1dSRodney W. Grimes 		__P((int));
127df8bae1dSRodney W. Grimes 	int	(*if_output)		/* output routine (enqueue) */
128df8bae1dSRodney W. Grimes 		__P((struct ifnet *, struct mbuf *, struct sockaddr *,
129df8bae1dSRodney W. Grimes 		     struct rtentry *));
13026f9a767SRodney W. Grimes 	void	(*if_start)		/* initiate output routine */
131df8bae1dSRodney W. Grimes 		__P((struct ifnet *));
132df8bae1dSRodney W. Grimes 	int	(*if_done)		/* output complete routine */
133df8bae1dSRodney W. Grimes 		__P((struct ifnet *));	/* (XXX not used; fake prototype) */
134df8bae1dSRodney W. Grimes 	int	(*if_ioctl)		/* ioctl routine */
135df8bae1dSRodney W. Grimes 		__P((struct ifnet *, int, caddr_t));
13626f9a767SRodney W. Grimes 	void	(*if_reset)
137df8bae1dSRodney W. Grimes 		__P((int));		/* new autoconfig will permit removal */
13826f9a767SRodney W. Grimes 	void	(*if_watchdog)		/* timer routine */
139df8bae1dSRodney W. Grimes 		__P((int));
140df8bae1dSRodney W. Grimes 	struct	ifqueue {
141df8bae1dSRodney W. Grimes 		struct	mbuf *ifq_head;
142df8bae1dSRodney W. Grimes 		struct	mbuf *ifq_tail;
143df8bae1dSRodney W. Grimes 		int	ifq_len;
144df8bae1dSRodney W. Grimes 		int	ifq_maxlen;
145df8bae1dSRodney W. Grimes 		int	ifq_drops;
146df8bae1dSRodney W. Grimes 	} if_snd;			/* output queue */
147df8bae1dSRodney W. Grimes };
148df8bae1dSRodney W. Grimes #define	if_mtu		if_data.ifi_mtu
149df8bae1dSRodney W. Grimes #define	if_type		if_data.ifi_type
150995add1aSGarrett Wollman #define if_physical	if_data.ifi_physical
151df8bae1dSRodney W. Grimes #define	if_addrlen	if_data.ifi_addrlen
152df8bae1dSRodney W. Grimes #define	if_hdrlen	if_data.ifi_hdrlen
153df8bae1dSRodney W. Grimes #define	if_metric	if_data.ifi_metric
154df8bae1dSRodney W. Grimes #define	if_baudrate	if_data.ifi_baudrate
155df8bae1dSRodney W. Grimes #define	if_ipackets	if_data.ifi_ipackets
156df8bae1dSRodney W. Grimes #define	if_ierrors	if_data.ifi_ierrors
157df8bae1dSRodney W. Grimes #define	if_opackets	if_data.ifi_opackets
158df8bae1dSRodney W. Grimes #define	if_oerrors	if_data.ifi_oerrors
159df8bae1dSRodney W. Grimes #define	if_collisions	if_data.ifi_collisions
160df8bae1dSRodney W. Grimes #define	if_ibytes	if_data.ifi_ibytes
161df8bae1dSRodney W. Grimes #define	if_obytes	if_data.ifi_obytes
162df8bae1dSRodney W. Grimes #define	if_imcasts	if_data.ifi_imcasts
163df8bae1dSRodney W. Grimes #define	if_omcasts	if_data.ifi_omcasts
164df8bae1dSRodney W. Grimes #define	if_iqdrops	if_data.ifi_iqdrops
165df8bae1dSRodney W. Grimes #define	if_noproto	if_data.ifi_noproto
166df8bae1dSRodney W. Grimes #define	if_lastchange	if_data.ifi_lastchange
167b30cbe4aSGarrett Wollman #define if_rawoutput(if, m, sa) if_output(if, m, sa, (struct rtentry *)0)
168df8bae1dSRodney W. Grimes 
169df8bae1dSRodney W. Grimes #define	IFF_UP		0x1		/* interface is up */
170df8bae1dSRodney W. Grimes #define	IFF_BROADCAST	0x2		/* broadcast address valid */
171df8bae1dSRodney W. Grimes #define	IFF_DEBUG	0x4		/* turn on debugging */
172df8bae1dSRodney W. Grimes #define	IFF_LOOPBACK	0x8		/* is a loopback net */
173df8bae1dSRodney W. Grimes #define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
174df8bae1dSRodney W. Grimes #define	IFF_NOTRAILERS	0x20		/* avoid use of trailers */
175df8bae1dSRodney W. Grimes #define	IFF_RUNNING	0x40		/* resources allocated */
176df8bae1dSRodney W. Grimes #define	IFF_NOARP	0x80		/* no address resolution protocol */
177df8bae1dSRodney W. Grimes #define	IFF_PROMISC	0x100		/* receive all packets */
178df8bae1dSRodney W. Grimes #define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
179df8bae1dSRodney W. Grimes #define	IFF_OACTIVE	0x400		/* transmission in progress */
180df8bae1dSRodney W. Grimes #define	IFF_SIMPLEX	0x800		/* can't hear own transmissions */
181df8bae1dSRodney W. Grimes #define	IFF_LINK0	0x1000		/* per link layer defined bit */
182df8bae1dSRodney W. Grimes #define	IFF_LINK1	0x2000		/* per link layer defined bit */
183df8bae1dSRodney W. Grimes #define	IFF_LINK2	0x4000		/* per link layer defined bit */
18437be1da8SGarrett Wollman #define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
185df8bae1dSRodney W. Grimes #define	IFF_MULTICAST	0x8000		/* supports multicast */
186df8bae1dSRodney W. Grimes 
187df8bae1dSRodney W. Grimes /* flags set internally only: */
188df8bae1dSRodney W. Grimes #define	IFF_CANTCHANGE \
189df8bae1dSRodney W. Grimes 	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
190df8bae1dSRodney W. Grimes 	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
191df8bae1dSRodney W. Grimes 
192995add1aSGarrett Wollman 
193995add1aSGarrett Wollman /*
194995add1aSGarrett Wollman  * These really don't belong here, but there's no other obviously appropriate
195995add1aSGarrett Wollman  * location.
196995add1aSGarrett Wollman  */
197995add1aSGarrett Wollman #define IFP_AUI		0
198995add1aSGarrett Wollman #define IFP_10BASE2	1
199995add1aSGarrett Wollman #define IFP_10BASET	2
200995add1aSGarrett Wollman /* etc. */
201995add1aSGarrett Wollman 
202df8bae1dSRodney W. Grimes /*
203df8bae1dSRodney W. Grimes  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
204df8bae1dSRodney W. Grimes  * input routines have queues of messages stored on ifqueue structures
205df8bae1dSRodney W. Grimes  * (defined above).  Entries are added to and deleted from these structures
206df8bae1dSRodney W. Grimes  * by these macros, which should be called with ipl raised to splimp().
207df8bae1dSRodney W. Grimes  */
208df8bae1dSRodney W. Grimes #define	IF_QFULL(ifq)		((ifq)->ifq_len >= (ifq)->ifq_maxlen)
209df8bae1dSRodney W. Grimes #define	IF_DROP(ifq)		((ifq)->ifq_drops++)
210df8bae1dSRodney W. Grimes #define	IF_ENQUEUE(ifq, m) { \
211df8bae1dSRodney W. Grimes 	(m)->m_nextpkt = 0; \
212df8bae1dSRodney W. Grimes 	if ((ifq)->ifq_tail == 0) \
213df8bae1dSRodney W. Grimes 		(ifq)->ifq_head = m; \
214df8bae1dSRodney W. Grimes 	else \
215df8bae1dSRodney W. Grimes 		(ifq)->ifq_tail->m_nextpkt = m; \
216df8bae1dSRodney W. Grimes 	(ifq)->ifq_tail = m; \
217df8bae1dSRodney W. Grimes 	(ifq)->ifq_len++; \
218df8bae1dSRodney W. Grimes }
219df8bae1dSRodney W. Grimes #define	IF_PREPEND(ifq, m) { \
220df8bae1dSRodney W. Grimes 	(m)->m_nextpkt = (ifq)->ifq_head; \
221df8bae1dSRodney W. Grimes 	if ((ifq)->ifq_tail == 0) \
222df8bae1dSRodney W. Grimes 		(ifq)->ifq_tail = (m); \
223df8bae1dSRodney W. Grimes 	(ifq)->ifq_head = (m); \
224df8bae1dSRodney W. Grimes 	(ifq)->ifq_len++; \
225df8bae1dSRodney W. Grimes }
226df8bae1dSRodney W. Grimes #define	IF_DEQUEUE(ifq, m) { \
227df8bae1dSRodney W. Grimes 	(m) = (ifq)->ifq_head; \
228df8bae1dSRodney W. Grimes 	if (m) { \
229df8bae1dSRodney W. Grimes 		if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
230df8bae1dSRodney W. Grimes 			(ifq)->ifq_tail = 0; \
231df8bae1dSRodney W. Grimes 		(m)->m_nextpkt = 0; \
232df8bae1dSRodney W. Grimes 		(ifq)->ifq_len--; \
233df8bae1dSRodney W. Grimes 	} \
234df8bae1dSRodney W. Grimes }
235df8bae1dSRodney W. Grimes 
236df8bae1dSRodney W. Grimes #define	IFQ_MAXLEN	50
237df8bae1dSRodney W. Grimes #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
238df8bae1dSRodney W. Grimes 
239df8bae1dSRodney W. Grimes /*
240df8bae1dSRodney W. Grimes  * The ifaddr structure contains information about one address
241df8bae1dSRodney W. Grimes  * of an interface.  They are maintained by the different address families,
242df8bae1dSRodney W. Grimes  * are allocated and attached when an address is set, and are linked
243df8bae1dSRodney W. Grimes  * together so all addresses for an interface can be located.
244df8bae1dSRodney W. Grimes  */
245df8bae1dSRodney W. Grimes struct ifaddr {
246df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_addr;	/* address of interface */
247df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_dstaddr;	/* other end of p-to-p link */
248df8bae1dSRodney W. Grimes #define	ifa_broadaddr	ifa_dstaddr	/* broadcast address interface */
249df8bae1dSRodney W. Grimes 	struct	sockaddr *ifa_netmask;	/* used to determine subnet */
250df8bae1dSRodney W. Grimes 	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
251df8bae1dSRodney W. Grimes 	struct	ifaddr *ifa_next;	/* next address for interface */
25267df6ed3SBruce Evans 	void	(*ifa_rtrequest)	/* check or clean routes (+ or -)'d */
25367df6ed3SBruce Evans 		__P((int, struct rtentry *, struct sockaddr *));
254df8bae1dSRodney W. Grimes 	u_short	ifa_flags;		/* mostly rt_flags for cloning */
255df8bae1dSRodney W. Grimes 	short	ifa_refcnt;		/* extra to malloc for link info */
256df8bae1dSRodney W. Grimes 	int	ifa_metric;		/* cost of going out this interface */
257df8bae1dSRodney W. Grimes #ifdef notdef
258df8bae1dSRodney W. Grimes 	struct	rtentry *ifa_rt;	/* XXXX for ROUTETOIF ????? */
259df8bae1dSRodney W. Grimes #endif
260df8bae1dSRodney W. Grimes };
261df8bae1dSRodney W. Grimes #define	IFA_ROUTE	RTF_UP		/* route installed */
262df8bae1dSRodney W. Grimes 
263df8bae1dSRodney W. Grimes /*
264df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interfaces
265df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
266df8bae1dSRodney W. Grimes  */
267df8bae1dSRodney W. Grimes struct if_msghdr {
268df8bae1dSRodney W. Grimes 	u_short	ifm_msglen;	/* to skip over non-understood messages */
269df8bae1dSRodney W. Grimes 	u_char	ifm_version;	/* future binary compatability */
270df8bae1dSRodney W. Grimes 	u_char	ifm_type;	/* message type */
271df8bae1dSRodney W. Grimes 	int	ifm_addrs;	/* like rtm_addrs */
272df8bae1dSRodney W. Grimes 	int	ifm_flags;	/* value of if_flags */
273df8bae1dSRodney W. Grimes 	u_short	ifm_index;	/* index for associated ifp */
274df8bae1dSRodney W. Grimes 	struct	if_data ifm_data;/* statistics and other data about if */
275df8bae1dSRodney W. Grimes };
276df8bae1dSRodney W. Grimes 
277df8bae1dSRodney W. Grimes /*
278df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interface addresses
279df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
280df8bae1dSRodney W. Grimes  */
281df8bae1dSRodney W. Grimes struct ifa_msghdr {
282df8bae1dSRodney W. Grimes 	u_short	ifam_msglen;	/* to skip over non-understood messages */
283df8bae1dSRodney W. Grimes 	u_char	ifam_version;	/* future binary compatability */
284df8bae1dSRodney W. Grimes 	u_char	ifam_type;	/* message type */
285df8bae1dSRodney W. Grimes 	int	ifam_addrs;	/* like rtm_addrs */
286df8bae1dSRodney W. Grimes 	int	ifam_flags;	/* value of ifa_flags */
287df8bae1dSRodney W. Grimes 	u_short	ifam_index;	/* index for associated ifp */
288df8bae1dSRodney W. Grimes 	int	ifam_metric;	/* value of ifa_metric */
289df8bae1dSRodney W. Grimes };
290df8bae1dSRodney W. Grimes 
291df8bae1dSRodney W. Grimes /*
292df8bae1dSRodney W. Grimes  * Interface request structure used for socket
293df8bae1dSRodney W. Grimes  * ioctl's.  All interface ioctl's must have parameter
294df8bae1dSRodney W. Grimes  * definitions which begin with ifr_name.  The
295df8bae1dSRodney W. Grimes  * remainder may be interface specific.
296df8bae1dSRodney W. Grimes  */
297df8bae1dSRodney W. Grimes struct	ifreq {
298df8bae1dSRodney W. Grimes #define	IFNAMSIZ	16
299df8bae1dSRodney W. Grimes 	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
300df8bae1dSRodney W. Grimes 	union {
301df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_addr;
302df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_dstaddr;
303df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_broadaddr;
304df8bae1dSRodney W. Grimes 		short	ifru_flags;
305df8bae1dSRodney W. Grimes 		int	ifru_metric;
306a7028af7SDavid Greenman 		int	ifru_mtu;
307074c4a4eSGarrett Wollman 		int	ifru_phys;
308df8bae1dSRodney W. Grimes 		caddr_t	ifru_data;
309df8bae1dSRodney W. Grimes 	} ifr_ifru;
310df8bae1dSRodney W. Grimes #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
311df8bae1dSRodney W. Grimes #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
312df8bae1dSRodney W. Grimes #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
313df8bae1dSRodney W. Grimes #define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
314df8bae1dSRodney W. Grimes #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
315a7028af7SDavid Greenman #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
316511cdd16SDavid Greenman #define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
317df8bae1dSRodney W. Grimes #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
318df8bae1dSRodney W. Grimes };
319df8bae1dSRodney W. Grimes 
320df8bae1dSRodney W. Grimes struct ifaliasreq {
321df8bae1dSRodney W. Grimes 	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
322df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_addr;
323df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_broadaddr;
324df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_mask;
325df8bae1dSRodney W. Grimes };
326df8bae1dSRodney W. Grimes 
327df8bae1dSRodney W. Grimes /*
328df8bae1dSRodney W. Grimes  * Structure used in SIOCGIFCONF request.
329df8bae1dSRodney W. Grimes  * Used to retrieve interface configuration
330df8bae1dSRodney W. Grimes  * for machine (useful for programs which
331df8bae1dSRodney W. Grimes  * must know all networks accessible).
332df8bae1dSRodney W. Grimes  */
333df8bae1dSRodney W. Grimes struct	ifconf {
334df8bae1dSRodney W. Grimes 	int	ifc_len;		/* size of associated buffer */
335df8bae1dSRodney W. Grimes 	union {
336df8bae1dSRodney W. Grimes 		caddr_t	ifcu_buf;
337df8bae1dSRodney W. Grimes 		struct	ifreq *ifcu_req;
338df8bae1dSRodney W. Grimes 	} ifc_ifcu;
339df8bae1dSRodney W. Grimes #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
340df8bae1dSRodney W. Grimes #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
341df8bae1dSRodney W. Grimes };
342df8bae1dSRodney W. Grimes 
343df8bae1dSRodney W. Grimes #include <net/if_arp.h>
344df8bae1dSRodney W. Grimes 
345df8bae1dSRodney W. Grimes #ifdef KERNEL
346df8bae1dSRodney W. Grimes #define	IFAFREE(ifa) \
347df8bae1dSRodney W. Grimes 	if ((ifa)->ifa_refcnt <= 0) \
348df8bae1dSRodney W. Grimes 		ifafree(ifa); \
349df8bae1dSRodney W. Grimes 	else \
350df8bae1dSRodney W. Grimes 		(ifa)->ifa_refcnt--;
351df8bae1dSRodney W. Grimes 
352df8bae1dSRodney W. Grimes struct	ifnet	*ifnet;
353df8bae1dSRodney W. Grimes 
354df8bae1dSRodney W. Grimes void	ether_ifattach __P((struct ifnet *));
355df8bae1dSRodney W. Grimes void	ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
356df8bae1dSRodney W. Grimes int	ether_output __P((struct ifnet *,
357df8bae1dSRodney W. Grimes 	   struct mbuf *, struct sockaddr *, struct rtentry *));
358df8bae1dSRodney W. Grimes char	*ether_sprintf __P((u_char *));
359df8bae1dSRodney W. Grimes 
360df8bae1dSRodney W. Grimes void	if_attach __P((struct ifnet *));
361df8bae1dSRodney W. Grimes void	if_down __P((struct ifnet *));
362df8bae1dSRodney W. Grimes void	if_qflush __P((struct ifqueue *));
363df8bae1dSRodney W. Grimes void	if_slowtimo __P((void *));
364df8bae1dSRodney W. Grimes void	if_up __P((struct ifnet *));
365df8bae1dSRodney W. Grimes #ifdef vax
366df8bae1dSRodney W. Grimes void	ifubareset __P((int));
367df8bae1dSRodney W. Grimes #endif
368df8bae1dSRodney W. Grimes int	ifconf __P((int, caddr_t));
369f23b4c91SGarrett Wollman /*void	ifinit __P((void));*/ /* declared in systm.h for main() */
370df8bae1dSRodney W. Grimes int	ifioctl __P((struct socket *, int, caddr_t, struct proc *));
371df8bae1dSRodney W. Grimes int	ifpromisc __P((struct ifnet *, int));
372df8bae1dSRodney W. Grimes struct	ifnet *ifunit __P((char *));
373df8bae1dSRodney W. Grimes 
374df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithaddr __P((struct sockaddr *));
375df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithaf __P((int));
376df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *));
377df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithnet __P((struct sockaddr *));
378df8bae1dSRodney W. Grimes struct	ifaddr *ifa_ifwithroute __P((int, struct sockaddr *,
379df8bae1dSRodney W. Grimes 					struct sockaddr *));
380df8bae1dSRodney W. Grimes struct	ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));
381df8bae1dSRodney W. Grimes void	ifafree __P((struct ifaddr *));
382df8bae1dSRodney W. Grimes void	link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
383df8bae1dSRodney W. Grimes 
384df8bae1dSRodney W. Grimes int	loioctl __P((struct ifnet *, int, caddr_t));
38526f9a767SRodney W. Grimes void	loopattach __P((void));
386df8bae1dSRodney W. Grimes int	looutput __P((struct ifnet *,
387df8bae1dSRodney W. Grimes 	   struct mbuf *, struct sockaddr *, struct rtentry *));
388df8bae1dSRodney W. Grimes void	lortrequest __P((int, struct rtentry *, struct sockaddr *));
389df708ff1SBruce Evans #endif /* KERNEL */
390cea1da3bSPaul Richards 
391df708ff1SBruce Evans #endif /* !_NET_IF_H_ */
392