if_var.h revision 191161
1139823Simp/*-
221259Swollman * Copyright (c) 1982, 1986, 1989, 1993
321259Swollman *	The Regents of the University of California.  All rights reserved.
421259Swollman *
521259Swollman * Redistribution and use in source and binary forms, with or without
621259Swollman * modification, are permitted provided that the following conditions
721259Swollman * are met:
821259Swollman * 1. Redistributions of source code must retain the above copyright
921259Swollman *    notice, this list of conditions and the following disclaimer.
1021259Swollman * 2. Redistributions in binary form must reproduce the above copyright
1121259Swollman *    notice, this list of conditions and the following disclaimer in the
1221259Swollman *    documentation and/or other materials provided with the distribution.
1321259Swollman * 4. Neither the name of the University nor the names of its contributors
1421259Swollman *    may be used to endorse or promote products derived from this software
1521259Swollman *    without specific prior written permission.
1621259Swollman *
1721259Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1821259Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1921259Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2021259Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2121259Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2221259Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2321259Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2421259Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2521259Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2621259Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2721259Swollman * SUCH DAMAGE.
2821259Swollman *
2921259Swollman *	From: @(#)if.h	8.1 (Berkeley) 6/10/93
3050477Speter * $FreeBSD: head/sys/net/if_var.h 191161 2009-04-16 23:05:10Z kmacy $
3121259Swollman */
3221259Swollman
3321259Swollman#ifndef	_NET_IF_VAR_H_
3421259Swollman#define	_NET_IF_VAR_H_
3521259Swollman
3621259Swollman/*
3721259Swollman * Structures defining a network interface, providing a packet
3821259Swollman * transport mechanism (ala level 0 of the PUP protocols).
3921259Swollman *
4021259Swollman * Each interface accepts output datagrams of a specified maximum
4121259Swollman * length, and provides higher level routines with input datagrams
4221259Swollman * received from its medium.
4321259Swollman *
4421259Swollman * Output occurs when the routine if_output is called, with three parameters:
4521259Swollman *	(*ifp->if_output)(ifp, m, dst, rt)
4621259Swollman * Here m is the mbuf chain to be sent and dst is the destination address.
4721259Swollman * The output routine encapsulates the supplied datagram if necessary,
4821259Swollman * and then transmits it on its medium.
4921259Swollman *
5021259Swollman * On input, each interface unwraps the data received by it, and either
51108533Sschweikh * places it on the input queue of an internetwork datagram routine
5221259Swollman * and posts the associated software interrupt, or passes the datagram to a raw
5321259Swollman * packet input routine.
5421259Swollman *
5521259Swollman * Routines exist for locating interfaces by their addresses
56108533Sschweikh * or for locating an interface on a certain network, as well as more general
5721259Swollman * routing and gateway routines maintaining information used to locate
5821259Swollman * interfaces.  These routines live in the files if.c and route.c
5921259Swollman */
6021259Swollman
6121259Swollman#ifdef __STDC__
6221259Swollman/*
6321259Swollman * Forward structure declarations for function prototypes [sic].
6421259Swollman */
6521259Swollmanstruct	mbuf;
6683366Sjulianstruct	thread;
6721259Swollmanstruct	rtentry;
6885074Srustruct	rt_addrinfo;
6921259Swollmanstruct	socket;
7021259Swollmanstruct	ether_header;
71142215Sglebiusstruct	carp_if;
72155051Sglebiusstruct  ifvlantrunk;
73191148Skmacystruct	route;
7421259Swollman#endif
7521259Swollman
7621259Swollman#include <sys/queue.h>		/* get TAILQ macros */
7721259Swollman
7869224Sjlemon#ifdef _KERNEL
7969152Sjlemon#include <sys/mbuf.h>
80126264Smlaier#include <sys/eventhandler.h>
81186207Skmacy#include <sys/buf_ring.h>
8269224Sjlemon#endif /* _KERNEL */
8374914Sjhb#include <sys/lock.h>		/* XXX */
8474914Sjhb#include <sys/mutex.h>		/* XXX */
85186199Skmacy#include <sys/rwlock.h>		/* XXX */
8683130Sjlemon#include <sys/event.h>		/* XXX */
87132712Srwatson#include <sys/_task.h>
8869152Sjlemon
89121816Sbrooks#define	IF_DUNIT_NONE	-1
90121816Sbrooks
91130416Smlaier#include <altq/if_altq.h>
92130416Smlaier
9360938SjakeTAILQ_HEAD(ifnethead, ifnet);	/* we use TAILQs so that the order of */
9460938SjakeTAILQ_HEAD(ifaddrhead, ifaddr);	/* instantiation is preserved in the list */
9560938SjakeTAILQ_HEAD(ifprefixhead, ifprefix);
9672084SphkTAILQ_HEAD(ifmultihead, ifmultiaddr);
97159781SmlaierTAILQ_HEAD(ifgrouphead, ifg_group);
9821259Swollman
9921259Swollman/*
10021259Swollman * Structure defining a queue for a network interface.
10121259Swollman */
10221259Swollmanstruct	ifqueue {
10321259Swollman	struct	mbuf *ifq_head;
10421259Swollman	struct	mbuf *ifq_tail;
10521259Swollman	int	ifq_len;
10621259Swollman	int	ifq_maxlen;
10721259Swollman	int	ifq_drops;
10869152Sjlemon	struct	mtx ifq_mtx;
10921259Swollman};
11021259Swollman
11121259Swollman/*
11221259Swollman * Structure defining a network interface.
11321259Swollman *
11421259Swollman * (Would like to call this struct ``if'', but C isn't PL/1.)
11521259Swollman */
11684380Smjacob
11721259Swollmanstruct ifnet {
11821259Swollman	void	*if_softc;		/* pointer to driver state */
119147256Sbrooks	void	*if_l2com;		/* pointer to protocol bits */
12060938Sjake	TAILQ_ENTRY(ifnet) if_link; 	/* all struct ifnets are chained */
121121816Sbrooks	char	if_xname[IFNAMSIZ];	/* external name (name + unit) */
122121816Sbrooks	const char *if_dname;		/* driver name */
123121816Sbrooks	int	if_dunit;		/* unit or IF_DUNIT_NONE */
12421259Swollman	struct	ifaddrhead if_addrhead;	/* linked list of addresses per if */
125128291Sluigi		/*
126128291Sluigi		 * if_addrhead is the list of all addresses associated to
127128315Sluigi		 * an interface.
128128315Sluigi		 * Some code in the kernel assumes that first element
129128315Sluigi		 * of the list has type AF_LINK, and contains sockaddr_dl
130128315Sluigi		 * addresses which store the link-level address and the name
131128291Sluigi		 * of the interface.
132128315Sluigi		 * However, access to the AF_LINK address through this
133152315Sru		 * field is deprecated. Use if_addr or ifaddr_byindex() instead.
134128291Sluigi		 */
135133741Sjmg	struct	knlist if_klist;	/* events attached to this if */
13683130Sjlemon	int	if_pcount;		/* number of promiscuous listeners */
137142901Sglebius	struct	carp_if *if_carp;	/* carp interface structure */
13821259Swollman	struct	bpf_if *if_bpf;		/* packet filter structure */
13921259Swollman	u_short	if_index;		/* numeric abbreviation for this if  */
14021259Swollman	short	if_timer;		/* time 'til if_watchdog called */
141155051Sglebius	struct  ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */
142102052Ssobomax	int	if_flags;		/* up/down, broadcast, etc. */
143162070Sandre	int	if_capabilities;	/* interface features & capabilities */
144162070Sandre	int	if_capenable;		/* enabled features & capabilities */
14521259Swollman	void	*if_linkmib;		/* link-type-specific MIB data */
14621259Swollman	size_t	if_linkmiblen;		/* length of above data */
14721259Swollman	struct	if_data if_data;
14821404Swollman	struct	ifmultihead if_multiaddrs; /* multicast addresses configured */
14921404Swollman	int	if_amcount;		/* number of all-multicast requests */
15021259Swollman/* procedure handles */
15121259Swollman	int	(*if_output)		/* output routine (enqueue) */
15292725Salfred		(struct ifnet *, struct mbuf *, struct sockaddr *,
153191148Skmacy		     struct route *);
154106931Ssam	void	(*if_input)		/* input routine (from h/w driver) */
155106931Ssam		(struct ifnet *, struct mbuf *);
15621259Swollman	void	(*if_start)		/* initiate output routine */
15792725Salfred		(struct ifnet *);
15821259Swollman	int	(*if_ioctl)		/* ioctl routine */
15992725Salfred		(struct ifnet *, u_long, caddr_t);
16021259Swollman	void	(*if_watchdog)		/* timer routine */
16192725Salfred		(struct ifnet *);
16221259Swollman	void	(*if_init)		/* Init routine */
16392725Salfred		(void *);
16421404Swollman	int	(*if_resolvemulti)	/* validate/resolve multicast */
16592725Salfred		(struct ifnet *, struct sockaddr **, struct sockaddr *);
166189230Srwatson	void	(*if_qflush)		/* flush any queues */
167189230Srwatson		(struct ifnet *);
168189230Srwatson	int	(*if_transmit)		/* initiate output routine */
169189230Srwatson		(struct ifnet *, struct mbuf *);
170152315Sru	struct	ifaddr	*if_addr;	/* pointer to link-level address */
171174388Skmacy	void	*if_llsoftc;		/* link layer softc */
172148265Srwatson	int	if_drv_flags;		/* driver-managed status flags */
173130416Smlaier	struct  ifaltq if_snd;		/* output queue (includes altq) */
174123220Simp	const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
175127828Sluigi
176146986Sthompsa	void	*if_bridge;		/* bridge glue */
177146986Sthompsa
178122524Srwatson	struct	label *if_label;	/* interface MAC label */
179121161Sume
180127828Sluigi	/* these are only used by IPv6 */
181127828Sluigi	struct	ifprefixhead if_prefixhead; /* list of prefixes per if */
182121161Sume	void	*if_afdata[AF_MAX];
183121470Sume	int	if_afdata_initialized;
184186199Skmacy	struct	rwlock if_afdata_lock;
185145320Sglebius	struct	task if_linktask;	/* task for link change events */
186148640Srwatson	struct	mtx if_addr_mtx;	/* mutex to protect address lists */
187186119Sqingli
188152209Sthompsa	LIST_ENTRY(ifnet) if_clones;	/* interfaces of a cloner */
189159781Smlaier	TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
190159781Smlaier					/* protected by if_addr_mtx */
191159781Smlaier	void	*if_pf_kif;
192168793Sthompsa	void	*if_lagg;		/* lagg glue */
193189230Srwatson
194189230Srwatson	/*
195189230Srwatson	 * Spare fields are added so that we can modify sensitive data
196189230Srwatson	 * structures without changing the kernel binary interface, and must
197189230Srwatson	 * be used with care where binary compatibility is required.
198189230Srwatson	 */
199189230Srwatson	void	*if_pspare[8];
200189230Srwatson	int	if_ispare[4];
20121259Swollman};
20269152Sjlemon
20392725Salfredtypedef void if_init_f_t(void *);
20421259Swollman
205128376Sluigi/*
206128376Sluigi * XXX These aliases are terribly dangerous because they could apply
207128376Sluigi * to anything.
208128376Sluigi */
20921259Swollman#define	if_mtu		if_data.ifi_mtu
21021259Swollman#define	if_type		if_data.ifi_type
21121259Swollman#define if_physical	if_data.ifi_physical
21221259Swollman#define	if_addrlen	if_data.ifi_addrlen
21321259Swollman#define	if_hdrlen	if_data.ifi_hdrlen
21421259Swollman#define	if_metric	if_data.ifi_metric
215128871Sandre#define	if_link_state	if_data.ifi_link_state
21621259Swollman#define	if_baudrate	if_data.ifi_baudrate
21758698Sjlemon#define	if_hwassist	if_data.ifi_hwassist
21821259Swollman#define	if_ipackets	if_data.ifi_ipackets
21921259Swollman#define	if_ierrors	if_data.ifi_ierrors
22021259Swollman#define	if_opackets	if_data.ifi_opackets
22121259Swollman#define	if_oerrors	if_data.ifi_oerrors
22221259Swollman#define	if_collisions	if_data.ifi_collisions
22321259Swollman#define	if_ibytes	if_data.ifi_ibytes
22421259Swollman#define	if_obytes	if_data.ifi_obytes
22521259Swollman#define	if_imcasts	if_data.ifi_imcasts
22621259Swollman#define	if_omcasts	if_data.ifi_omcasts
22721259Swollman#define	if_iqdrops	if_data.ifi_iqdrops
22821259Swollman#define	if_noproto	if_data.ifi_noproto
22921259Swollman#define	if_lastchange	if_data.ifi_lastchange
230136950Sjmg#define if_rawoutput(if, m, sa) if_output(if, m, sa, (struct rtentry *)NULL)
23121259Swollman
23253541Sshin/* for compatibility with other BSDs */
23353541Sshin#define	if_addrlist	if_addrhead
23453541Sshin#define	if_list		if_link
235160981Sbrooks#define	if_name(ifp)	((ifp)->if_xname)
23653541Sshin
23721259Swollman/*
238148640Srwatson * Locks for address lists on the network interface.
239148640Srwatson */
240148640Srwatson#define	IF_ADDR_LOCK_INIT(if)	mtx_init(&(if)->if_addr_mtx,		\
241148640Srwatson				    "if_addr_mtx", NULL, MTX_DEF)
242148640Srwatson#define	IF_ADDR_LOCK_DESTROY(if)	mtx_destroy(&(if)->if_addr_mtx)
243148640Srwatson#define	IF_ADDR_LOCK(if)	mtx_lock(&(if)->if_addr_mtx)
244148640Srwatson#define	IF_ADDR_UNLOCK(if)	mtx_unlock(&(if)->if_addr_mtx)
245148640Srwatson#define	IF_ADDR_LOCK_ASSERT(if)	mtx_assert(&(if)->if_addr_mtx, MA_OWNED)
246148640Srwatson
247148640Srwatson/*
24821259Swollman * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
24921259Swollman * are queues of messages stored on ifqueue structures
25021259Swollman * (defined above).  Entries are added to and deleted from these structures
25121259Swollman * by these macros, which should be called with ipl raised to splimp().
25221259Swollman */
25372200Sbmilekic#define IF_LOCK(ifq)		mtx_lock(&(ifq)->ifq_mtx)
25472200Sbmilekic#define IF_UNLOCK(ifq)		mtx_unlock(&(ifq)->ifq_mtx)
255130416Smlaier#define	IF_LOCK_ASSERT(ifq)	mtx_assert(&(ifq)->ifq_mtx, MA_OWNED)
25669152Sjlemon#define	_IF_QFULL(ifq)		((ifq)->ifq_len >= (ifq)->ifq_maxlen)
25769152Sjlemon#define	_IF_DROP(ifq)		((ifq)->ifq_drops++)
25869152Sjlemon#define	_IF_QLEN(ifq)		((ifq)->ifq_len)
25921259Swollman
26069152Sjlemon#define	_IF_ENQUEUE(ifq, m) do { 				\
26169152Sjlemon	(m)->m_nextpkt = NULL;					\
26269152Sjlemon	if ((ifq)->ifq_tail == NULL) 				\
26369152Sjlemon		(ifq)->ifq_head = m; 				\
26469152Sjlemon	else 							\
26569152Sjlemon		(ifq)->ifq_tail->m_nextpkt = m; 		\
26669152Sjlemon	(ifq)->ifq_tail = m; 					\
26769152Sjlemon	(ifq)->ifq_len++; 					\
26869152Sjlemon} while (0)
26969152Sjlemon
27069152Sjlemon#define IF_ENQUEUE(ifq, m) do {					\
27169152Sjlemon	IF_LOCK(ifq); 						\
27269152Sjlemon	_IF_ENQUEUE(ifq, m); 					\
27369152Sjlemon	IF_UNLOCK(ifq); 					\
27469152Sjlemon} while (0)
27569152Sjlemon
27669152Sjlemon#define	_IF_PREPEND(ifq, m) do {				\
27769152Sjlemon	(m)->m_nextpkt = (ifq)->ifq_head; 			\
27869152Sjlemon	if ((ifq)->ifq_tail == NULL) 				\
27969152Sjlemon		(ifq)->ifq_tail = (m); 				\
28069152Sjlemon	(ifq)->ifq_head = (m); 					\
28169152Sjlemon	(ifq)->ifq_len++; 					\
28269152Sjlemon} while (0)
28369152Sjlemon
28469152Sjlemon#define IF_PREPEND(ifq, m) do {		 			\
28569152Sjlemon	IF_LOCK(ifq); 						\
28669152Sjlemon	_IF_PREPEND(ifq, m); 					\
28769152Sjlemon	IF_UNLOCK(ifq); 					\
28869152Sjlemon} while (0)
28969152Sjlemon
29069152Sjlemon#define	_IF_DEQUEUE(ifq, m) do { 				\
29169152Sjlemon	(m) = (ifq)->ifq_head; 					\
29269152Sjlemon	if (m) { 						\
293136950Sjmg		if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL)	\
29469152Sjlemon			(ifq)->ifq_tail = NULL; 		\
29569152Sjlemon		(m)->m_nextpkt = NULL; 				\
29669152Sjlemon		(ifq)->ifq_len--; 				\
29769152Sjlemon	} 							\
29869152Sjlemon} while (0)
29969152Sjlemon
30069152Sjlemon#define IF_DEQUEUE(ifq, m) do { 				\
30169152Sjlemon	IF_LOCK(ifq); 						\
30269152Sjlemon	_IF_DEQUEUE(ifq, m); 					\
30369152Sjlemon	IF_UNLOCK(ifq); 					\
30469152Sjlemon} while (0)
30569152Sjlemon
306130416Smlaier#define	_IF_POLL(ifq, m)	((m) = (ifq)->ifq_head)
307130416Smlaier#define	IF_POLL(ifq, m)		_IF_POLL(ifq, m)
308130416Smlaier
309130416Smlaier#define _IF_DRAIN(ifq) do { 					\
31069152Sjlemon	struct mbuf *m; 					\
31169152Sjlemon	for (;;) { 						\
31269152Sjlemon		_IF_DEQUEUE(ifq, m); 				\
31369152Sjlemon		if (m == NULL) 					\
31469152Sjlemon			break; 					\
31569152Sjlemon		m_freem(m); 					\
31669152Sjlemon	} 							\
31769152Sjlemon} while (0)
31869152Sjlemon
319130416Smlaier#define IF_DRAIN(ifq) do {					\
320130416Smlaier	IF_LOCK(ifq);						\
321130416Smlaier	_IF_DRAIN(ifq);						\
322130416Smlaier	IF_UNLOCK(ifq);						\
323130416Smlaier} while(0)
324130416Smlaier
32555205Speter#ifdef _KERNEL
326126264Smlaier/* interface address change event */
327126264Smlaiertypedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
328126264SmlaierEVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
329126264Smlaier/* new interface arrival event */
330126264Smlaiertypedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
331126264SmlaierEVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
332126264Smlaier/* interface departure event */
333126264Smlaiertypedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *);
334126264SmlaierEVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
335126264Smlaier
336159781Smlaier/*
337159781Smlaier * interface groups
338159781Smlaier */
339159781Smlaierstruct ifg_group {
340159781Smlaier	char				 ifg_group[IFNAMSIZ];
341159781Smlaier	u_int				 ifg_refcnt;
342159781Smlaier	void				*ifg_pf_kif;
343159781Smlaier	TAILQ_HEAD(, ifg_member)	 ifg_members;
344159781Smlaier	TAILQ_ENTRY(ifg_group)		 ifg_next;
345159781Smlaier};
346159781Smlaier
347159781Smlaierstruct ifg_member {
348159781Smlaier	TAILQ_ENTRY(ifg_member)	 ifgm_next;
349159781Smlaier	struct ifnet		*ifgm_ifp;
350159781Smlaier};
351159781Smlaier
352159781Smlaierstruct ifg_list {
353159781Smlaier	struct ifg_group	*ifgl_group;
354159781Smlaier	TAILQ_ENTRY(ifg_list)	 ifgl_next;
355159781Smlaier};
356159781Smlaier
357159781Smlaier/* group attach event */
358159781Smlaiertypedef void (*group_attach_event_handler_t)(void *, struct ifg_group *);
359159781SmlaierEVENTHANDLER_DECLARE(group_attach_event, group_attach_event_handler_t);
360159781Smlaier/* group detach event */
361159781Smlaiertypedef void (*group_detach_event_handler_t)(void *, struct ifg_group *);
362159781SmlaierEVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t);
363159781Smlaier/* group change event */
364159781Smlaiertypedef void (*group_change_event_handler_t)(void *, const char *);
365159781SmlaierEVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
366159781Smlaier
367121470Sume#define	IF_AFDATA_LOCK_INIT(ifp)	\
368186199Skmacy	rw_init(&(ifp)->if_afdata_lock, "if_afdata")
369121470Sume
370186199Skmacy#define	IF_AFDATA_WLOCK(ifp)	rw_wlock(&(ifp)->if_afdata_lock)
371186199Skmacy#define	IF_AFDATA_RLOCK(ifp)	rw_rlock(&(ifp)->if_afdata_lock)
372186199Skmacy#define	IF_AFDATA_WUNLOCK(ifp)	rw_wunlock(&(ifp)->if_afdata_lock)
373186199Skmacy#define	IF_AFDATA_RUNLOCK(ifp)	rw_runlock(&(ifp)->if_afdata_lock)
374186199Skmacy#define	IF_AFDATA_LOCK(ifp)	IF_AFDATA_WLOCK(ifp)
375186199Skmacy#define	IF_AFDATA_UNLOCK(ifp)	IF_AFDATA_WUNLOCK(ifp)
376186199Skmacy#define	IF_AFDATA_TRYLOCK(ifp)	rw_try_wlock(&(ifp)->if_afdata_lock)
377186199Skmacy#define	IF_AFDATA_DESTROY(ifp)	rw_destroy(&(ifp)->if_afdata_lock)
378186119Sqingli
379186199Skmacy#define	IF_AFDATA_LOCK_ASSERT(ifp)	rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED)
380186199Skmacy#define	IF_AFDATA_UNLOCK_ASSERT(ifp)	rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED)
381186199Skmacy
382137065Srwatsonint	if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp,
383137065Srwatson	    int adjust);
384130416Smlaier#define	IF_HANDOFF(ifq, m, ifp)			\
385130416Smlaier	if_handoff((struct ifqueue *)ifq, m, ifp, 0)
386130416Smlaier#define	IF_HANDOFF_ADJ(ifq, m, ifp, adj)	\
387130416Smlaier	if_handoff((struct ifqueue *)ifq, m, ifp, adj)
38821259Swollman
389132712Srwatsonvoid	if_start(struct ifnet *);
390132712Srwatson
391130416Smlaier#define	IFQ_ENQUEUE(ifq, m, err)					\
392130416Smlaierdo {									\
393130416Smlaier	IF_LOCK(ifq);							\
394130416Smlaier	if (ALTQ_IS_ENABLED(ifq))					\
395130416Smlaier		ALTQ_ENQUEUE(ifq, m, NULL, err);			\
396130416Smlaier	else {								\
397130416Smlaier		if (_IF_QFULL(ifq)) {					\
398130416Smlaier			m_freem(m);					\
399130416Smlaier			(err) = ENOBUFS;				\
400130416Smlaier		} else {						\
401130416Smlaier			_IF_ENQUEUE(ifq, m);				\
402130416Smlaier			(err) = 0;					\
403130416Smlaier		}							\
404130416Smlaier	}								\
405130416Smlaier	if (err)							\
406130416Smlaier		(ifq)->ifq_drops++;					\
407130416Smlaier	IF_UNLOCK(ifq);							\
408130416Smlaier} while (0)
40921259Swollman
410130416Smlaier#define	IFQ_DEQUEUE_NOLOCK(ifq, m)					\
411130416Smlaierdo {									\
412130416Smlaier	if (TBR_IS_ENABLED(ifq))					\
413130508Smlaier		(m) = tbr_dequeue_ptr(ifq, ALTDQ_REMOVE);		\
414130416Smlaier	else if (ALTQ_IS_ENABLED(ifq))					\
415130416Smlaier		ALTQ_DEQUEUE(ifq, m);					\
416130416Smlaier	else								\
417130416Smlaier		_IF_DEQUEUE(ifq, m);					\
418130416Smlaier} while (0)
419130416Smlaier
420130416Smlaier#define	IFQ_DEQUEUE(ifq, m)						\
421130416Smlaierdo {									\
422130416Smlaier	IF_LOCK(ifq);							\
423130416Smlaier	IFQ_DEQUEUE_NOLOCK(ifq, m);					\
424130416Smlaier	IF_UNLOCK(ifq);							\
425130416Smlaier} while (0)
426130416Smlaier
427130416Smlaier#define	IFQ_POLL_NOLOCK(ifq, m)						\
428130416Smlaierdo {									\
429130416Smlaier	if (TBR_IS_ENABLED(ifq))					\
430130508Smlaier		(m) = tbr_dequeue_ptr(ifq, ALTDQ_POLL);			\
431130416Smlaier	else if (ALTQ_IS_ENABLED(ifq))					\
432130416Smlaier		ALTQ_POLL(ifq, m);					\
433130416Smlaier	else								\
434130416Smlaier		_IF_POLL(ifq, m);					\
435130416Smlaier} while (0)
436130416Smlaier
437130416Smlaier#define	IFQ_POLL(ifq, m)						\
438130416Smlaierdo {									\
439130416Smlaier	IF_LOCK(ifq);							\
440130416Smlaier	IFQ_POLL_NOLOCK(ifq, m);					\
441130416Smlaier	IF_UNLOCK(ifq);							\
442130416Smlaier} while (0)
443130416Smlaier
444130416Smlaier#define	IFQ_PURGE_NOLOCK(ifq)						\
445130416Smlaierdo {									\
446130416Smlaier	if (ALTQ_IS_ENABLED(ifq)) {					\
447130416Smlaier		ALTQ_PURGE(ifq);					\
448130416Smlaier	} else								\
449130416Smlaier		_IF_DRAIN(ifq);						\
450130416Smlaier} while (0)
451130416Smlaier
452130416Smlaier#define	IFQ_PURGE(ifq)							\
453130416Smlaierdo {									\
454130416Smlaier	IF_LOCK(ifq);							\
455130416Smlaier	IFQ_PURGE_NOLOCK(ifq);						\
456130416Smlaier	IF_UNLOCK(ifq);							\
457130416Smlaier} while (0)
458130416Smlaier
459130416Smlaier#define	IFQ_SET_READY(ifq)						\
460130416Smlaier	do { ((ifq)->altq_flags |= ALTQF_READY); } while (0)
461130416Smlaier
462130416Smlaier#define	IFQ_LOCK(ifq)			IF_LOCK(ifq)
463130416Smlaier#define	IFQ_UNLOCK(ifq)			IF_UNLOCK(ifq)
464130416Smlaier#define	IFQ_LOCK_ASSERT(ifq)		IF_LOCK_ASSERT(ifq)
465130416Smlaier#define	IFQ_IS_EMPTY(ifq)		((ifq)->ifq_len == 0)
466130416Smlaier#define	IFQ_INC_LEN(ifq)		((ifq)->ifq_len++)
467130416Smlaier#define	IFQ_DEC_LEN(ifq)		(--(ifq)->ifq_len)
468130416Smlaier#define	IFQ_INC_DROPS(ifq)		((ifq)->ifq_drops++)
469130416Smlaier#define	IFQ_SET_MAXLEN(ifq, len)	((ifq)->ifq_maxlen = (len))
470130416Smlaier
471148886Srwatson/*
472148886Srwatson * The IFF_DRV_OACTIVE test should really occur in the device driver, not in
473148886Srwatson * the handoff logic, as that flag is locked by the device driver.
474148886Srwatson */
475130416Smlaier#define	IFQ_HANDOFF_ADJ(ifp, m, adj, err)				\
476130416Smlaierdo {									\
477130416Smlaier	int len;							\
478130416Smlaier	short mflags;							\
479130416Smlaier									\
480130416Smlaier	len = (m)->m_pkthdr.len;					\
481130416Smlaier	mflags = (m)->m_flags;						\
482130416Smlaier	IFQ_ENQUEUE(&(ifp)->if_snd, m, err);				\
483130416Smlaier	if ((err) == 0) {						\
484130416Smlaier		(ifp)->if_obytes += len + (adj);			\
485130416Smlaier		if (mflags & M_MCAST)					\
486130416Smlaier			(ifp)->if_omcasts++;				\
487148886Srwatson		if (((ifp)->if_drv_flags & IFF_DRV_OACTIVE) == 0)	\
488132712Srwatson			if_start(ifp);					\
489130416Smlaier	}								\
490130416Smlaier} while (0)
491130416Smlaier
492130416Smlaier#define	IFQ_HANDOFF(ifp, m, err)					\
493130512Smlaier	IFQ_HANDOFF_ADJ(ifp, m, 0, err)
494130416Smlaier
495130416Smlaier#define	IFQ_DRV_DEQUEUE(ifq, m)						\
496130416Smlaierdo {									\
497130416Smlaier	(m) = (ifq)->ifq_drv_head;					\
498130416Smlaier	if (m) {							\
499130416Smlaier		if (((ifq)->ifq_drv_head = (m)->m_nextpkt) == NULL)	\
500130416Smlaier			(ifq)->ifq_drv_tail = NULL;			\
501130416Smlaier		(m)->m_nextpkt = NULL;					\
502130416Smlaier		(ifq)->ifq_drv_len--;					\
503130416Smlaier	} else {							\
504130416Smlaier		IFQ_LOCK(ifq);						\
505130416Smlaier		IFQ_DEQUEUE_NOLOCK(ifq, m);				\
506130416Smlaier		while ((ifq)->ifq_drv_len < (ifq)->ifq_drv_maxlen) {	\
507130416Smlaier			struct mbuf *m0;				\
508130416Smlaier			IFQ_DEQUEUE_NOLOCK(ifq, m0);			\
509130416Smlaier			if (m0 == NULL)					\
510130416Smlaier				break;					\
511130416Smlaier			m0->m_nextpkt = NULL;				\
512130416Smlaier			if ((ifq)->ifq_drv_tail == NULL)		\
513130416Smlaier				(ifq)->ifq_drv_head = m0;		\
514130416Smlaier			else						\
515130416Smlaier				(ifq)->ifq_drv_tail->m_nextpkt = m0;	\
516130416Smlaier			(ifq)->ifq_drv_tail = m0;			\
517130416Smlaier			(ifq)->ifq_drv_len++;				\
518130416Smlaier		}							\
519130416Smlaier		IFQ_UNLOCK(ifq);					\
520130416Smlaier	}								\
521130416Smlaier} while (0)
522130416Smlaier
523130416Smlaier#define	IFQ_DRV_PREPEND(ifq, m)						\
524130416Smlaierdo {									\
525130416Smlaier	(m)->m_nextpkt = (ifq)->ifq_drv_head;				\
526132152Smlaier	if ((ifq)->ifq_drv_tail == NULL)				\
527132152Smlaier		(ifq)->ifq_drv_tail = (m);				\
528130416Smlaier	(ifq)->ifq_drv_head = (m);					\
529130416Smlaier	(ifq)->ifq_drv_len++;						\
530130416Smlaier} while (0)
531130416Smlaier
532130416Smlaier#define	IFQ_DRV_IS_EMPTY(ifq)						\
533130416Smlaier	(((ifq)->ifq_drv_len == 0) && ((ifq)->ifq_len == 0))
534130416Smlaier
535130416Smlaier#define	IFQ_DRV_PURGE(ifq)						\
536130416Smlaierdo {									\
537132152Smlaier	struct mbuf *m, *n = (ifq)->ifq_drv_head;			\
538132152Smlaier	while((m = n) != NULL) {					\
539132152Smlaier		n = m->m_nextpkt;					\
540130416Smlaier		m_freem(m);						\
541130416Smlaier	}								\
542130416Smlaier	(ifq)->ifq_drv_head = (ifq)->ifq_drv_tail = NULL;		\
543130416Smlaier	(ifq)->ifq_drv_len = 0;						\
544130416Smlaier	IFQ_PURGE(ifq);							\
545130416Smlaier} while (0)
546130416Smlaier
547186207Skmacy#ifdef _KERNEL
548186213Skmacystatic __inline void
549186213Skmacydrbr_stats_update(struct ifnet *ifp, int len, int mflags)
550186213Skmacy{
551186213Skmacy
552186213Skmacy	ifp->if_obytes += len;
553186213Skmacy	if (mflags & M_MCAST)
554186213Skmacy		ifp->if_omcasts++;
555186213Skmacy}
556186213Skmacy
557186207Skmacystatic __inline int
558186213Skmacydrbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
559186207Skmacy{
560186207Skmacy	int error = 0;
561186213Skmacy	int len = m->m_pkthdr.len;
562186213Skmacy	int mflags = m->m_flags;
563186207Skmacy
564191033Skmacy#ifdef ALTQ
565191033Skmacy	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
566191033Skmacy		IFQ_ENQUEUE(&ifp->if_snd, m, error);
567191033Skmacy		return (error);
568191033Skmacy	}
569191033Skmacy#endif
570186207Skmacy	if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) {
571186207Skmacy		br->br_drops++;
572186213Skmacy		_IF_DROP(&ifp->if_snd);
573186207Skmacy		m_freem(m);
574186213Skmacy	} else
575186213Skmacy		drbr_stats_update(ifp, len, mflags);
576186213Skmacy
577186207Skmacy	return (error);
578186207Skmacy}
579186207Skmacy
580186207Skmacystatic __inline void
581186207Skmacydrbr_free(struct buf_ring *br, struct malloc_type *type)
582186207Skmacy{
583186207Skmacy	struct mbuf *m;
584186207Skmacy
585186207Skmacy	while ((m = buf_ring_dequeue_sc(br)) != NULL)
586186207Skmacy		m_freem(m);
587186207Skmacy
588186207Skmacy	buf_ring_free(br, type);
589186207Skmacy}
590191033Skmacy
591191033Skmacystatic __inline struct mbuf *
592191033Skmacydrbr_dequeue(struct ifnet *ifp, struct buf_ring *br)
593191033Skmacy{
594191033Skmacy#ifdef ALTQ
595191033Skmacy	struct mbuf *m;
596191033Skmacy
597191033Skmacy	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
598191033Skmacy		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
599191033Skmacy		return (m);
600191033Skmacy	}
601186207Skmacy#endif
602191033Skmacy	return (buf_ring_dequeue_sc(br));
603191033Skmacy}
604186207Skmacy
605191033Skmacystatic __inline int
606191033Skmacydrbr_empty(struct ifnet *ifp, struct buf_ring *br)
607191033Skmacy{
608191033Skmacy#ifdef ALTQ
609191033Skmacy	if (ALTQ_IS_ENABLED(&ifp->if_snd))
610191033Skmacy		return (IFQ_DRV_IS_EMPTY(&ifp->if_snd));
611191033Skmacy#endif
612191033Skmacy	return (buf_ring_empty(br));
613191033Skmacy}
614191033Skmacy#endif
61549459Sbrian/*
61649459Sbrian * 72 was chosen below because it is the size of a TCP/IP
61749459Sbrian * header (40) + the minimum mss (32).
61849459Sbrian */
61949459Sbrian#define	IF_MINMTU	72
62049459Sbrian#define	IF_MAXMTU	65535
62149459Sbrian
62255205Speter#endif /* _KERNEL */
62321259Swollman
62421259Swollman/*
62521259Swollman * The ifaddr structure contains information about one address
62621259Swollman * of an interface.  They are maintained by the different address families,
62721259Swollman * are allocated and attached when an address is set, and are linked
62821259Swollman * together so all addresses for an interface can be located.
629128291Sluigi *
630128291Sluigi * NOTE: a 'struct ifaddr' is always at the beginning of a larger
631128291Sluigi * chunk of malloc'ed memory, where we store the three addresses
632128291Sluigi * (ifa_addr, ifa_dstaddr and ifa_netmask) referenced here.
63321259Swollman */
63421259Swollmanstruct ifaddr {
63521259Swollman	struct	sockaddr *ifa_addr;	/* address of interface */
63621259Swollman	struct	sockaddr *ifa_dstaddr;	/* other end of p-to-p link */
63721259Swollman#define	ifa_broadaddr	ifa_dstaddr	/* broadcast address interface */
63821259Swollman	struct	sockaddr *ifa_netmask;	/* used to determine subnet */
63967334Sjoe	struct	if_data if_data;	/* not all members are meaningful */
64021259Swollman	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
64160938Sjake	TAILQ_ENTRY(ifaddr) ifa_link;	/* queue macro glue */
64221259Swollman	void	(*ifa_rtrequest)	/* check or clean routes (+ or -)'d */
64392725Salfred		(int, struct rtentry *, struct rt_addrinfo *);
64421259Swollman	u_short	ifa_flags;		/* mostly rt_flags for cloning */
64547254Spb	u_int	ifa_refcnt;		/* references to this structure */
64621259Swollman	int	ifa_metric;		/* cost of going out this interface */
64728845Sjulian	int (*ifa_claim_addr)		/* check if an addr goes to this if */
64892725Salfred		(struct ifaddr *, struct sockaddr *);
649108033Shsu	struct mtx ifa_mtx;
65021259Swollman};
65121259Swollman#define	IFA_ROUTE	RTF_UP		/* route installed */
65221259Swollman
65353541Sshin/* for compatibility with other BSDs */
65453541Sshin#define	ifa_list	ifa_link
65553541Sshin
656108033Shsu#define	IFA_LOCK_INIT(ifa)	\
657108033Shsu    mtx_init(&(ifa)->ifa_mtx, "ifaddr", NULL, MTX_DEF)
658108033Shsu#define	IFA_LOCK(ifa)		mtx_lock(&(ifa)->ifa_mtx)
659108033Shsu#define	IFA_UNLOCK(ifa)		mtx_unlock(&(ifa)->ifa_mtx)
660108033Shsu#define	IFA_DESTROY(ifa)	mtx_destroy(&(ifa)->ifa_mtx)
661108033Shsu
66221404Swollman/*
66352904Sshin * The prefix structure contains information about one prefix
66452904Sshin * of an interface.  They are maintained by the different address families,
665108470Sschweikh * are allocated and attached when a prefix or an address is set,
66653541Sshin * and are linked together so all prefixes for an interface can be located.
66752904Sshin */
66852904Sshinstruct ifprefix {
66952904Sshin	struct	sockaddr *ifpr_prefix;	/* prefix of interface */
67052904Sshin	struct	ifnet *ifpr_ifp;	/* back-pointer to interface */
67160938Sjake	TAILQ_ENTRY(ifprefix) ifpr_list; /* queue macro glue */
67252904Sshin	u_char	ifpr_plen;		/* prefix length in bits */
67352904Sshin	u_char	ifpr_type;		/* protocol dependent prefix type */
67452904Sshin};
67552904Sshin
67652904Sshin/*
67721404Swollman * Multicast address structure.  This is analogous to the ifaddr
67821404Swollman * structure except that it keeps track of multicast addresses.
67921404Swollman */
68021404Swollmanstruct ifmultiaddr {
68172084Sphk	TAILQ_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */
68221434Swollman	struct	sockaddr *ifma_addr; 	/* address this membership is for */
68321434Swollman	struct	sockaddr *ifma_lladdr;	/* link-layer translation, if any */
68421434Swollman	struct	ifnet *ifma_ifp;	/* back-pointer to interface */
68521434Swollman	u_int	ifma_refcount;		/* reference count */
68621434Swollman	void	*ifma_protospec;	/* protocol-specific state, if any */
687167729Sbms	struct	ifmultiaddr *ifma_llifma; /* pointer to ifma for ifma_lladdr */
68821404Swollman};
68921404Swollman
69055205Speter#ifdef _KERNEL
691108036Shsu#define	IFAFREE(ifa)					\
692108036Shsu	do {						\
693108036Shsu		IFA_LOCK(ifa);				\
694108036Shsu		KASSERT((ifa)->ifa_refcnt > 0,		\
695108036Shsu		    ("ifa %p !(ifa_refcnt > 0)", ifa));	\
696108036Shsu		if (--(ifa)->ifa_refcnt == 0) {		\
697108036Shsu			IFA_DESTROY(ifa);		\
698108036Shsu			free(ifa, M_IFADDR);		\
699108036Shsu		} else 					\
700108036Shsu			IFA_UNLOCK(ifa);		\
70146568Speter	} while (0)
70221259Swollman
703108036Shsu#define IFAREF(ifa)					\
704108036Shsu	do {						\
705108036Shsu		IFA_LOCK(ifa);				\
706108036Shsu		++(ifa)->ifa_refcnt;			\
707108036Shsu		IFA_UNLOCK(ifa);			\
708108033Shsu	} while (0)
709108033Shsu
710186199Skmacyextern	struct rwlock ifnet_lock;
711108298Shsu#define	IFNET_LOCK_INIT() \
712186199Skmacy   rw_init_flags(&ifnet_lock, "ifnet",  RW_RECURSE)
713186199Skmacy#define	IFNET_WLOCK()		rw_wlock(&ifnet_lock)
714186199Skmacy#define	IFNET_WUNLOCK()		rw_wunlock(&ifnet_lock)
715186199Skmacy#define	IFNET_WLOCK_ASSERT()	rw_assert(&ifnet_lock, RA_LOCKED)
716186199Skmacy#define	IFNET_RLOCK()		rw_rlock(&ifnet_lock)
717186199Skmacy#define	IFNET_RUNLOCK()		rw_runlock(&ifnet_lock)
718108172Shsu
71983130Sjlemonstruct ifindex_entry {
72087914Sjlemon	struct	ifnet *ife_ifnet;
721130585Sphk	struct cdev *ife_dev;
72283130Sjlemon};
72383130Sjlemon
724180042Srwatsonstruct ifnet	*ifnet_byindex(u_short idx);
725181892Skmacy
726128315Sluigi/*
727128315Sluigi * Given the index, ifaddr_byindex() returns the one and only
728128315Sluigi * link-level ifaddr for the interface. You are not supposed to use
729128315Sluigi * it to traverse the list of addresses associated to the interface.
730128315Sluigi */
731180042Srwatsonstruct ifaddr	*ifaddr_byindex(u_short idx);
732180042Srwatsonstruct cdev	*ifdev_byindex(u_short idx);
73383130Sjlemon
734186048Sbz#ifdef VIMAGE_GLOBALS
73521259Swollmanextern	struct ifnethead ifnet;
73671791Speterextern	struct ifnet *loif;	/* first loopback interface */
73721259Swollmanextern	int if_index;
738186048Sbz#endif
739186048Sbzextern	int ifqmaxlen;
74021259Swollman
741159781Smlaierint	if_addgroup(struct ifnet *, const char *);
742159781Smlaierint	if_delgroup(struct ifnet *, const char *);
74392725Salfredint	if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **);
74492725Salfredint	if_allmulti(struct ifnet *, int);
745147256Sbrooksstruct	ifnet* if_alloc(u_char);
74692725Salfredvoid	if_attach(struct ifnet *);
74792725Salfredint	if_delmulti(struct ifnet *, struct sockaddr *);
748167729Sbmsvoid	if_delmulti_ifma(struct ifmultiaddr *);
74992725Salfredvoid	if_detach(struct ifnet *);
750146620Speadarvoid	if_purgeaddrs(struct ifnet *);
751177617Ssamvoid	if_purgemaddrs(struct ifnet *);
75292725Salfredvoid	if_down(struct ifnet *);
753167732Sbmsstruct ifmultiaddr *
754167732Sbms	if_findmulti(struct ifnet *, struct sockaddr *);
755147256Sbrooksvoid	if_free(struct ifnet *);
756147256Sbrooksvoid	if_free_type(struct ifnet *, u_char);
757121816Sbrooksvoid	if_initname(struct ifnet *, const char *, int);
758138542Ssamvoid	if_link_state_change(struct ifnet *, int);
759103900Sbrooksint	if_printf(struct ifnet *, const char *, ...) __printflike(2, 3);
760191161Skmacyvoid	if_qflush(struct ifnet *);
76192725Salfredint	if_setlladdr(struct ifnet *, const u_char *, int);
76292725Salfredvoid	if_up(struct ifnet *);
76392725Salfred/*void	ifinit(void);*/ /* declared in systm.h for main() */
76492725Salfredint	ifioctl(struct socket *, u_long, caddr_t, struct thread *);
76592725Salfredint	ifpromisc(struct ifnet *, int);
76692725Salfredstruct	ifnet *ifunit(const char *);
76721259Swollman
768185162Skmacyvoid	ifq_attach(struct ifaltq *, struct ifnet *ifp);
769185162Skmacyvoid	ifq_detach(struct ifaltq *);
770185162Skmacy
77192725Salfredstruct	ifaddr *ifa_ifwithaddr(struct sockaddr *);
772162068Sandrestruct	ifaddr *ifa_ifwithbroadaddr(struct sockaddr *);
77392725Salfredstruct	ifaddr *ifa_ifwithdstaddr(struct sockaddr *);
77492725Salfredstruct	ifaddr *ifa_ifwithnet(struct sockaddr *);
77592725Salfredstruct	ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *);
776178888Sjulianstruct	ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int);
777178888Sjulian
77892725Salfredstruct	ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *);
77921259Swollman
78092725Salfredint	if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen);
78121434Swollman
782147256Sbrookstypedef	void *if_com_alloc_t(u_char type, struct ifnet *ifp);
783147256Sbrookstypedef	void if_com_free_t(void *com, u_char type);
784147256Sbrooksvoid	if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f);
785147256Sbrooksvoid	if_deregister_com_alloc(u_char type);
786147256Sbrooks
78784931Sfjoe#define IF_LLADDR(ifp)							\
788152315Sru    LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
78984931Sfjoe
79087902Sluigi#ifdef DEVICE_POLLING
791150789Sglebiusenum poll_cmd {	POLL_ONLY, POLL_AND_CHECK_STATUS };
79287902Sluigi
79392725Salfredtypedef	void poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count);
79492725Salfredint    ether_poll_register(poll_handler_t *h, struct ifnet *ifp);
79592725Salfredint    ether_poll_deregister(struct ifnet *ifp);
79687902Sluigi#endif /* DEVICE_POLLING */
79787902Sluigi
79855205Speter#endif /* _KERNEL */
79921259Swollman
80021259Swollman#endif /* !_NET_IF_VAR_H_ */
801