ifq.h revision 192605
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 192605 2009-05-22 22:09:00Z zec $ 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 */ 120191688Szec struct vnet *if_vnet; /* pointer to network stack instance */ 12160938Sjake TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ 122121816Sbrooks char if_xname[IFNAMSIZ]; /* external name (name + unit) */ 123121816Sbrooks const char *if_dname; /* driver name */ 124121816Sbrooks int if_dunit; /* unit or IF_DUNIT_NONE */ 125191367Srwatson u_int if_refcount; /* reference count */ 12621259Swollman struct ifaddrhead if_addrhead; /* linked list of addresses per if */ 127128291Sluigi /* 128128291Sluigi * if_addrhead is the list of all addresses associated to 129128315Sluigi * an interface. 130128315Sluigi * Some code in the kernel assumes that first element 131128315Sluigi * of the list has type AF_LINK, and contains sockaddr_dl 132128315Sluigi * addresses which store the link-level address and the name 133128291Sluigi * of the interface. 134128315Sluigi * However, access to the AF_LINK address through this 135152315Sru * field is deprecated. Use if_addr or ifaddr_byindex() instead. 136128291Sluigi */ 137133741Sjmg struct knlist if_klist; /* events attached to this if */ 13883130Sjlemon int if_pcount; /* number of promiscuous listeners */ 139142901Sglebius struct carp_if *if_carp; /* carp interface structure */ 14021259Swollman struct bpf_if *if_bpf; /* packet filter structure */ 14121259Swollman u_short if_index; /* numeric abbreviation for this if */ 14221259Swollman short if_timer; /* time 'til if_watchdog called */ 143155051Sglebius struct ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */ 144102052Ssobomax int if_flags; /* up/down, broadcast, etc. */ 145162070Sandre int if_capabilities; /* interface features & capabilities */ 146162070Sandre int if_capenable; /* enabled features & capabilities */ 14721259Swollman void *if_linkmib; /* link-type-specific MIB data */ 14821259Swollman size_t if_linkmiblen; /* length of above data */ 14921259Swollman struct if_data if_data; 15021404Swollman struct ifmultihead if_multiaddrs; /* multicast addresses configured */ 15121404Swollman int if_amcount; /* number of all-multicast requests */ 15221259Swollman/* procedure handles */ 15321259Swollman int (*if_output) /* output routine (enqueue) */ 15492725Salfred (struct ifnet *, struct mbuf *, struct sockaddr *, 155191148Skmacy struct route *); 156106931Ssam void (*if_input) /* input routine (from h/w driver) */ 157106931Ssam (struct ifnet *, struct mbuf *); 15821259Swollman void (*if_start) /* initiate output routine */ 15992725Salfred (struct ifnet *); 16021259Swollman int (*if_ioctl) /* ioctl routine */ 16192725Salfred (struct ifnet *, u_long, caddr_t); 16221259Swollman void (*if_watchdog) /* timer routine */ 16392725Salfred (struct ifnet *); 16421259Swollman void (*if_init) /* Init routine */ 16592725Salfred (void *); 16621404Swollman int (*if_resolvemulti) /* validate/resolve multicast */ 16792725Salfred (struct ifnet *, struct sockaddr **, struct sockaddr *); 168189230Srwatson void (*if_qflush) /* flush any queues */ 169189230Srwatson (struct ifnet *); 170189230Srwatson int (*if_transmit) /* initiate output routine */ 171189230Srwatson (struct ifnet *, struct mbuf *); 172152315Sru struct ifaddr *if_addr; /* pointer to link-level address */ 173174388Skmacy void *if_llsoftc; /* link layer softc */ 174148265Srwatson int if_drv_flags; /* driver-managed status flags */ 175130416Smlaier struct ifaltq if_snd; /* output queue (includes altq) */ 176123220Simp const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ 177127828Sluigi 178146986Sthompsa void *if_bridge; /* bridge glue */ 179146986Sthompsa 180122524Srwatson struct label *if_label; /* interface MAC label */ 181121161Sume 182127828Sluigi /* these are only used by IPv6 */ 183127828Sluigi struct ifprefixhead if_prefixhead; /* list of prefixes per if */ 184121161Sume void *if_afdata[AF_MAX]; 185121470Sume int if_afdata_initialized; 186186199Skmacy struct rwlock if_afdata_lock; 187145320Sglebius struct task if_linktask; /* task for link change events */ 188148640Srwatson struct mtx if_addr_mtx; /* mutex to protect address lists */ 189186119Sqingli 190152209Sthompsa LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */ 191159781Smlaier TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ 192159781Smlaier /* protected by if_addr_mtx */ 193159781Smlaier void *if_pf_kif; 194168793Sthompsa void *if_lagg; /* lagg glue */ 195191367Srwatson u_char if_alloctype; /* if_type at time of allocation */ 196189230Srwatson 197189230Srwatson /* 198189230Srwatson * Spare fields are added so that we can modify sensitive data 199189230Srwatson * structures without changing the kernel binary interface, and must 200189230Srwatson * be used with care where binary compatibility is required. 201189230Srwatson */ 202191367Srwatson char if_cspare[3]; 203189230Srwatson void *if_pspare[8]; 204189230Srwatson int if_ispare[4]; 20521259Swollman}; 20669152Sjlemon 20792725Salfredtypedef void if_init_f_t(void *); 20821259Swollman 209128376Sluigi/* 210128376Sluigi * XXX These aliases are terribly dangerous because they could apply 211128376Sluigi * to anything. 212128376Sluigi */ 21321259Swollman#define if_mtu if_data.ifi_mtu 21421259Swollman#define if_type if_data.ifi_type 21521259Swollman#define if_physical if_data.ifi_physical 21621259Swollman#define if_addrlen if_data.ifi_addrlen 21721259Swollman#define if_hdrlen if_data.ifi_hdrlen 21821259Swollman#define if_metric if_data.ifi_metric 219128871Sandre#define if_link_state if_data.ifi_link_state 22021259Swollman#define if_baudrate if_data.ifi_baudrate 22158698Sjlemon#define if_hwassist if_data.ifi_hwassist 22221259Swollman#define if_ipackets if_data.ifi_ipackets 22321259Swollman#define if_ierrors if_data.ifi_ierrors 22421259Swollman#define if_opackets if_data.ifi_opackets 22521259Swollman#define if_oerrors if_data.ifi_oerrors 22621259Swollman#define if_collisions if_data.ifi_collisions 22721259Swollman#define if_ibytes if_data.ifi_ibytes 22821259Swollman#define if_obytes if_data.ifi_obytes 22921259Swollman#define if_imcasts if_data.ifi_imcasts 23021259Swollman#define if_omcasts if_data.ifi_omcasts 23121259Swollman#define if_iqdrops if_data.ifi_iqdrops 23221259Swollman#define if_noproto if_data.ifi_noproto 23321259Swollman#define if_lastchange if_data.ifi_lastchange 234136950Sjmg#define if_rawoutput(if, m, sa) if_output(if, m, sa, (struct rtentry *)NULL) 23521259Swollman 23653541Sshin/* for compatibility with other BSDs */ 23753541Sshin#define if_addrlist if_addrhead 23853541Sshin#define if_list if_link 239160981Sbrooks#define if_name(ifp) ((ifp)->if_xname) 24053541Sshin 24121259Swollman/* 242148640Srwatson * Locks for address lists on the network interface. 243148640Srwatson */ 244148640Srwatson#define IF_ADDR_LOCK_INIT(if) mtx_init(&(if)->if_addr_mtx, \ 245148640Srwatson "if_addr_mtx", NULL, MTX_DEF) 246148640Srwatson#define IF_ADDR_LOCK_DESTROY(if) mtx_destroy(&(if)->if_addr_mtx) 247148640Srwatson#define IF_ADDR_LOCK(if) mtx_lock(&(if)->if_addr_mtx) 248148640Srwatson#define IF_ADDR_UNLOCK(if) mtx_unlock(&(if)->if_addr_mtx) 249148640Srwatson#define IF_ADDR_LOCK_ASSERT(if) mtx_assert(&(if)->if_addr_mtx, MA_OWNED) 250148640Srwatson 251148640Srwatson/* 25221259Swollman * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq) 25321259Swollman * are queues of messages stored on ifqueue structures 25421259Swollman * (defined above). Entries are added to and deleted from these structures 25521259Swollman * by these macros, which should be called with ipl raised to splimp(). 25621259Swollman */ 25772200Sbmilekic#define IF_LOCK(ifq) mtx_lock(&(ifq)->ifq_mtx) 25872200Sbmilekic#define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx) 259130416Smlaier#define IF_LOCK_ASSERT(ifq) mtx_assert(&(ifq)->ifq_mtx, MA_OWNED) 26069152Sjlemon#define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) 26169152Sjlemon#define _IF_DROP(ifq) ((ifq)->ifq_drops++) 26269152Sjlemon#define _IF_QLEN(ifq) ((ifq)->ifq_len) 26321259Swollman 26469152Sjlemon#define _IF_ENQUEUE(ifq, m) do { \ 26569152Sjlemon (m)->m_nextpkt = NULL; \ 26669152Sjlemon if ((ifq)->ifq_tail == NULL) \ 26769152Sjlemon (ifq)->ifq_head = m; \ 26869152Sjlemon else \ 26969152Sjlemon (ifq)->ifq_tail->m_nextpkt = m; \ 27069152Sjlemon (ifq)->ifq_tail = m; \ 27169152Sjlemon (ifq)->ifq_len++; \ 27269152Sjlemon} while (0) 27369152Sjlemon 27469152Sjlemon#define IF_ENQUEUE(ifq, m) do { \ 27569152Sjlemon IF_LOCK(ifq); \ 27669152Sjlemon _IF_ENQUEUE(ifq, m); \ 27769152Sjlemon IF_UNLOCK(ifq); \ 27869152Sjlemon} while (0) 27969152Sjlemon 28069152Sjlemon#define _IF_PREPEND(ifq, m) do { \ 28169152Sjlemon (m)->m_nextpkt = (ifq)->ifq_head; \ 28269152Sjlemon if ((ifq)->ifq_tail == NULL) \ 28369152Sjlemon (ifq)->ifq_tail = (m); \ 28469152Sjlemon (ifq)->ifq_head = (m); \ 28569152Sjlemon (ifq)->ifq_len++; \ 28669152Sjlemon} while (0) 28769152Sjlemon 28869152Sjlemon#define IF_PREPEND(ifq, m) do { \ 28969152Sjlemon IF_LOCK(ifq); \ 29069152Sjlemon _IF_PREPEND(ifq, m); \ 29169152Sjlemon IF_UNLOCK(ifq); \ 29269152Sjlemon} while (0) 29369152Sjlemon 29469152Sjlemon#define _IF_DEQUEUE(ifq, m) do { \ 29569152Sjlemon (m) = (ifq)->ifq_head; \ 29669152Sjlemon if (m) { \ 297136950Sjmg if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \ 29869152Sjlemon (ifq)->ifq_tail = NULL; \ 29969152Sjlemon (m)->m_nextpkt = NULL; \ 30069152Sjlemon (ifq)->ifq_len--; \ 30169152Sjlemon } \ 30269152Sjlemon} while (0) 30369152Sjlemon 30469152Sjlemon#define IF_DEQUEUE(ifq, m) do { \ 30569152Sjlemon IF_LOCK(ifq); \ 30669152Sjlemon _IF_DEQUEUE(ifq, m); \ 30769152Sjlemon IF_UNLOCK(ifq); \ 30869152Sjlemon} while (0) 30969152Sjlemon 310130416Smlaier#define _IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) 311130416Smlaier#define IF_POLL(ifq, m) _IF_POLL(ifq, m) 312130416Smlaier 313130416Smlaier#define _IF_DRAIN(ifq) do { \ 31469152Sjlemon struct mbuf *m; \ 31569152Sjlemon for (;;) { \ 31669152Sjlemon _IF_DEQUEUE(ifq, m); \ 31769152Sjlemon if (m == NULL) \ 31869152Sjlemon break; \ 31969152Sjlemon m_freem(m); \ 32069152Sjlemon } \ 32169152Sjlemon} while (0) 32269152Sjlemon 323130416Smlaier#define IF_DRAIN(ifq) do { \ 324130416Smlaier IF_LOCK(ifq); \ 325130416Smlaier _IF_DRAIN(ifq); \ 326130416Smlaier IF_UNLOCK(ifq); \ 327130416Smlaier} while(0) 328130416Smlaier 32955205Speter#ifdef _KERNEL 330126264Smlaier/* interface address change event */ 331126264Smlaiertypedef void (*ifaddr_event_handler_t)(void *, struct ifnet *); 332126264SmlaierEVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t); 333126264Smlaier/* new interface arrival event */ 334126264Smlaiertypedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *); 335126264SmlaierEVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t); 336126264Smlaier/* interface departure event */ 337126264Smlaiertypedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *); 338126264SmlaierEVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); 339126264Smlaier 340159781Smlaier/* 341159781Smlaier * interface groups 342159781Smlaier */ 343159781Smlaierstruct ifg_group { 344159781Smlaier char ifg_group[IFNAMSIZ]; 345159781Smlaier u_int ifg_refcnt; 346159781Smlaier void *ifg_pf_kif; 347159781Smlaier TAILQ_HEAD(, ifg_member) ifg_members; 348159781Smlaier TAILQ_ENTRY(ifg_group) ifg_next; 349159781Smlaier}; 350159781Smlaier 351159781Smlaierstruct ifg_member { 352159781Smlaier TAILQ_ENTRY(ifg_member) ifgm_next; 353159781Smlaier struct ifnet *ifgm_ifp; 354159781Smlaier}; 355159781Smlaier 356159781Smlaierstruct ifg_list { 357159781Smlaier struct ifg_group *ifgl_group; 358159781Smlaier TAILQ_ENTRY(ifg_list) ifgl_next; 359159781Smlaier}; 360159781Smlaier 361159781Smlaier/* group attach event */ 362159781Smlaiertypedef void (*group_attach_event_handler_t)(void *, struct ifg_group *); 363159781SmlaierEVENTHANDLER_DECLARE(group_attach_event, group_attach_event_handler_t); 364159781Smlaier/* group detach event */ 365159781Smlaiertypedef void (*group_detach_event_handler_t)(void *, struct ifg_group *); 366159781SmlaierEVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t); 367159781Smlaier/* group change event */ 368159781Smlaiertypedef void (*group_change_event_handler_t)(void *, const char *); 369159781SmlaierEVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t); 370159781Smlaier 371121470Sume#define IF_AFDATA_LOCK_INIT(ifp) \ 372186199Skmacy rw_init(&(ifp)->if_afdata_lock, "if_afdata") 373121470Sume 374186199Skmacy#define IF_AFDATA_WLOCK(ifp) rw_wlock(&(ifp)->if_afdata_lock) 375186199Skmacy#define IF_AFDATA_RLOCK(ifp) rw_rlock(&(ifp)->if_afdata_lock) 376186199Skmacy#define IF_AFDATA_WUNLOCK(ifp) rw_wunlock(&(ifp)->if_afdata_lock) 377186199Skmacy#define IF_AFDATA_RUNLOCK(ifp) rw_runlock(&(ifp)->if_afdata_lock) 378186199Skmacy#define IF_AFDATA_LOCK(ifp) IF_AFDATA_WLOCK(ifp) 379186199Skmacy#define IF_AFDATA_UNLOCK(ifp) IF_AFDATA_WUNLOCK(ifp) 380186199Skmacy#define IF_AFDATA_TRYLOCK(ifp) rw_try_wlock(&(ifp)->if_afdata_lock) 381186199Skmacy#define IF_AFDATA_DESTROY(ifp) rw_destroy(&(ifp)->if_afdata_lock) 382186119Sqingli 383186199Skmacy#define IF_AFDATA_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED) 384186199Skmacy#define IF_AFDATA_UNLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED) 385186199Skmacy 386137065Srwatsonint if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, 387137065Srwatson int adjust); 388130416Smlaier#define IF_HANDOFF(ifq, m, ifp) \ 389130416Smlaier if_handoff((struct ifqueue *)ifq, m, ifp, 0) 390130416Smlaier#define IF_HANDOFF_ADJ(ifq, m, ifp, adj) \ 391130416Smlaier if_handoff((struct ifqueue *)ifq, m, ifp, adj) 39221259Swollman 393132712Srwatsonvoid if_start(struct ifnet *); 394132712Srwatson 395130416Smlaier#define IFQ_ENQUEUE(ifq, m, err) \ 396130416Smlaierdo { \ 397130416Smlaier IF_LOCK(ifq); \ 398130416Smlaier if (ALTQ_IS_ENABLED(ifq)) \ 399130416Smlaier ALTQ_ENQUEUE(ifq, m, NULL, err); \ 400130416Smlaier else { \ 401130416Smlaier if (_IF_QFULL(ifq)) { \ 402130416Smlaier m_freem(m); \ 403130416Smlaier (err) = ENOBUFS; \ 404130416Smlaier } else { \ 405130416Smlaier _IF_ENQUEUE(ifq, m); \ 406130416Smlaier (err) = 0; \ 407130416Smlaier } \ 408130416Smlaier } \ 409130416Smlaier if (err) \ 410130416Smlaier (ifq)->ifq_drops++; \ 411130416Smlaier IF_UNLOCK(ifq); \ 412130416Smlaier} while (0) 41321259Swollman 414130416Smlaier#define IFQ_DEQUEUE_NOLOCK(ifq, m) \ 415130416Smlaierdo { \ 416130416Smlaier if (TBR_IS_ENABLED(ifq)) \ 417130508Smlaier (m) = tbr_dequeue_ptr(ifq, ALTDQ_REMOVE); \ 418130416Smlaier else if (ALTQ_IS_ENABLED(ifq)) \ 419130416Smlaier ALTQ_DEQUEUE(ifq, m); \ 420130416Smlaier else \ 421130416Smlaier _IF_DEQUEUE(ifq, m); \ 422130416Smlaier} while (0) 423130416Smlaier 424130416Smlaier#define IFQ_DEQUEUE(ifq, m) \ 425130416Smlaierdo { \ 426130416Smlaier IF_LOCK(ifq); \ 427130416Smlaier IFQ_DEQUEUE_NOLOCK(ifq, m); \ 428130416Smlaier IF_UNLOCK(ifq); \ 429130416Smlaier} while (0) 430130416Smlaier 431130416Smlaier#define IFQ_POLL_NOLOCK(ifq, m) \ 432130416Smlaierdo { \ 433130416Smlaier if (TBR_IS_ENABLED(ifq)) \ 434130508Smlaier (m) = tbr_dequeue_ptr(ifq, ALTDQ_POLL); \ 435130416Smlaier else if (ALTQ_IS_ENABLED(ifq)) \ 436130416Smlaier ALTQ_POLL(ifq, m); \ 437130416Smlaier else \ 438130416Smlaier _IF_POLL(ifq, m); \ 439130416Smlaier} while (0) 440130416Smlaier 441130416Smlaier#define IFQ_POLL(ifq, m) \ 442130416Smlaierdo { \ 443130416Smlaier IF_LOCK(ifq); \ 444130416Smlaier IFQ_POLL_NOLOCK(ifq, m); \ 445130416Smlaier IF_UNLOCK(ifq); \ 446130416Smlaier} while (0) 447130416Smlaier 448130416Smlaier#define IFQ_PURGE_NOLOCK(ifq) \ 449130416Smlaierdo { \ 450130416Smlaier if (ALTQ_IS_ENABLED(ifq)) { \ 451130416Smlaier ALTQ_PURGE(ifq); \ 452130416Smlaier } else \ 453130416Smlaier _IF_DRAIN(ifq); \ 454130416Smlaier} while (0) 455130416Smlaier 456130416Smlaier#define IFQ_PURGE(ifq) \ 457130416Smlaierdo { \ 458130416Smlaier IF_LOCK(ifq); \ 459130416Smlaier IFQ_PURGE_NOLOCK(ifq); \ 460130416Smlaier IF_UNLOCK(ifq); \ 461130416Smlaier} while (0) 462130416Smlaier 463130416Smlaier#define IFQ_SET_READY(ifq) \ 464130416Smlaier do { ((ifq)->altq_flags |= ALTQF_READY); } while (0) 465130416Smlaier 466130416Smlaier#define IFQ_LOCK(ifq) IF_LOCK(ifq) 467130416Smlaier#define IFQ_UNLOCK(ifq) IF_UNLOCK(ifq) 468130416Smlaier#define IFQ_LOCK_ASSERT(ifq) IF_LOCK_ASSERT(ifq) 469130416Smlaier#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) 470130416Smlaier#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++) 471130416Smlaier#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len) 472130416Smlaier#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++) 473130416Smlaier#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len)) 474130416Smlaier 475148886Srwatson/* 476148886Srwatson * The IFF_DRV_OACTIVE test should really occur in the device driver, not in 477148886Srwatson * the handoff logic, as that flag is locked by the device driver. 478148886Srwatson */ 479130416Smlaier#define IFQ_HANDOFF_ADJ(ifp, m, adj, err) \ 480130416Smlaierdo { \ 481130416Smlaier int len; \ 482130416Smlaier short mflags; \ 483130416Smlaier \ 484130416Smlaier len = (m)->m_pkthdr.len; \ 485130416Smlaier mflags = (m)->m_flags; \ 486130416Smlaier IFQ_ENQUEUE(&(ifp)->if_snd, m, err); \ 487130416Smlaier if ((err) == 0) { \ 488130416Smlaier (ifp)->if_obytes += len + (adj); \ 489130416Smlaier if (mflags & M_MCAST) \ 490130416Smlaier (ifp)->if_omcasts++; \ 491148886Srwatson if (((ifp)->if_drv_flags & IFF_DRV_OACTIVE) == 0) \ 492132712Srwatson if_start(ifp); \ 493130416Smlaier } \ 494130416Smlaier} while (0) 495130416Smlaier 496130416Smlaier#define IFQ_HANDOFF(ifp, m, err) \ 497130512Smlaier IFQ_HANDOFF_ADJ(ifp, m, 0, err) 498130416Smlaier 499130416Smlaier#define IFQ_DRV_DEQUEUE(ifq, m) \ 500130416Smlaierdo { \ 501130416Smlaier (m) = (ifq)->ifq_drv_head; \ 502130416Smlaier if (m) { \ 503130416Smlaier if (((ifq)->ifq_drv_head = (m)->m_nextpkt) == NULL) \ 504130416Smlaier (ifq)->ifq_drv_tail = NULL; \ 505130416Smlaier (m)->m_nextpkt = NULL; \ 506130416Smlaier (ifq)->ifq_drv_len--; \ 507130416Smlaier } else { \ 508130416Smlaier IFQ_LOCK(ifq); \ 509130416Smlaier IFQ_DEQUEUE_NOLOCK(ifq, m); \ 510130416Smlaier while ((ifq)->ifq_drv_len < (ifq)->ifq_drv_maxlen) { \ 511130416Smlaier struct mbuf *m0; \ 512130416Smlaier IFQ_DEQUEUE_NOLOCK(ifq, m0); \ 513130416Smlaier if (m0 == NULL) \ 514130416Smlaier break; \ 515130416Smlaier m0->m_nextpkt = NULL; \ 516130416Smlaier if ((ifq)->ifq_drv_tail == NULL) \ 517130416Smlaier (ifq)->ifq_drv_head = m0; \ 518130416Smlaier else \ 519130416Smlaier (ifq)->ifq_drv_tail->m_nextpkt = m0; \ 520130416Smlaier (ifq)->ifq_drv_tail = m0; \ 521130416Smlaier (ifq)->ifq_drv_len++; \ 522130416Smlaier } \ 523130416Smlaier IFQ_UNLOCK(ifq); \ 524130416Smlaier } \ 525130416Smlaier} while (0) 526130416Smlaier 527130416Smlaier#define IFQ_DRV_PREPEND(ifq, m) \ 528130416Smlaierdo { \ 529130416Smlaier (m)->m_nextpkt = (ifq)->ifq_drv_head; \ 530132152Smlaier if ((ifq)->ifq_drv_tail == NULL) \ 531132152Smlaier (ifq)->ifq_drv_tail = (m); \ 532130416Smlaier (ifq)->ifq_drv_head = (m); \ 533130416Smlaier (ifq)->ifq_drv_len++; \ 534130416Smlaier} while (0) 535130416Smlaier 536130416Smlaier#define IFQ_DRV_IS_EMPTY(ifq) \ 537130416Smlaier (((ifq)->ifq_drv_len == 0) && ((ifq)->ifq_len == 0)) 538130416Smlaier 539130416Smlaier#define IFQ_DRV_PURGE(ifq) \ 540130416Smlaierdo { \ 541132152Smlaier struct mbuf *m, *n = (ifq)->ifq_drv_head; \ 542132152Smlaier while((m = n) != NULL) { \ 543132152Smlaier n = m->m_nextpkt; \ 544130416Smlaier m_freem(m); \ 545130416Smlaier } \ 546130416Smlaier (ifq)->ifq_drv_head = (ifq)->ifq_drv_tail = NULL; \ 547130416Smlaier (ifq)->ifq_drv_len = 0; \ 548130416Smlaier IFQ_PURGE(ifq); \ 549130416Smlaier} while (0) 550130416Smlaier 551186207Skmacy#ifdef _KERNEL 552186213Skmacystatic __inline void 553186213Skmacydrbr_stats_update(struct ifnet *ifp, int len, int mflags) 554186213Skmacy{ 555186213Skmacy 556186213Skmacy ifp->if_obytes += len; 557186213Skmacy if (mflags & M_MCAST) 558186213Skmacy ifp->if_omcasts++; 559186213Skmacy} 560186213Skmacy 561186207Skmacystatic __inline int 562186213Skmacydrbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m) 563186207Skmacy{ 564186207Skmacy int error = 0; 565186213Skmacy int len = m->m_pkthdr.len; 566186213Skmacy int mflags = m->m_flags; 567186207Skmacy 568191033Skmacy#ifdef ALTQ 569191033Skmacy if (ALTQ_IS_ENABLED(&ifp->if_snd)) { 570191033Skmacy IFQ_ENQUEUE(&ifp->if_snd, m, error); 571191033Skmacy return (error); 572191033Skmacy } 573191033Skmacy#endif 574186207Skmacy if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) { 575186207Skmacy br->br_drops++; 576186213Skmacy _IF_DROP(&ifp->if_snd); 577186207Skmacy m_freem(m); 578186213Skmacy } else 579186213Skmacy drbr_stats_update(ifp, len, mflags); 580186213Skmacy 581186207Skmacy return (error); 582186207Skmacy} 583186207Skmacy 584186207Skmacystatic __inline void 585186207Skmacydrbr_free(struct buf_ring *br, struct malloc_type *type) 586186207Skmacy{ 587186207Skmacy struct mbuf *m; 588186207Skmacy 589186207Skmacy while ((m = buf_ring_dequeue_sc(br)) != NULL) 590186207Skmacy m_freem(m); 591186207Skmacy 592186207Skmacy buf_ring_free(br, type); 593186207Skmacy} 594191033Skmacy 595191033Skmacystatic __inline struct mbuf * 596191033Skmacydrbr_dequeue(struct ifnet *ifp, struct buf_ring *br) 597191033Skmacy{ 598191033Skmacy#ifdef ALTQ 599191033Skmacy struct mbuf *m; 600191033Skmacy 601191033Skmacy if (ALTQ_IS_ENABLED(&ifp->if_snd)) { 602191033Skmacy IFQ_DRV_DEQUEUE(&ifp->if_snd, m); 603191033Skmacy return (m); 604191033Skmacy } 605186207Skmacy#endif 606191033Skmacy return (buf_ring_dequeue_sc(br)); 607191033Skmacy} 608186207Skmacy 609191033Skmacystatic __inline int 610191033Skmacydrbr_empty(struct ifnet *ifp, struct buf_ring *br) 611191033Skmacy{ 612191033Skmacy#ifdef ALTQ 613191033Skmacy if (ALTQ_IS_ENABLED(&ifp->if_snd)) 614191033Skmacy return (IFQ_DRV_IS_EMPTY(&ifp->if_snd)); 615191033Skmacy#endif 616191033Skmacy return (buf_ring_empty(br)); 617191033Skmacy} 618191033Skmacy#endif 61949459Sbrian/* 62049459Sbrian * 72 was chosen below because it is the size of a TCP/IP 62149459Sbrian * header (40) + the minimum mss (32). 62249459Sbrian */ 62349459Sbrian#define IF_MINMTU 72 62449459Sbrian#define IF_MAXMTU 65535 62549459Sbrian 62655205Speter#endif /* _KERNEL */ 62721259Swollman 62821259Swollman/* 62921259Swollman * The ifaddr structure contains information about one address 63021259Swollman * of an interface. They are maintained by the different address families, 63121259Swollman * are allocated and attached when an address is set, and are linked 63221259Swollman * together so all addresses for an interface can be located. 633128291Sluigi * 634128291Sluigi * NOTE: a 'struct ifaddr' is always at the beginning of a larger 635128291Sluigi * chunk of malloc'ed memory, where we store the three addresses 636128291Sluigi * (ifa_addr, ifa_dstaddr and ifa_netmask) referenced here. 63721259Swollman */ 63821259Swollmanstruct ifaddr { 63921259Swollman struct sockaddr *ifa_addr; /* address of interface */ 64021259Swollman struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ 64121259Swollman#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 64221259Swollman struct sockaddr *ifa_netmask; /* used to determine subnet */ 64367334Sjoe struct if_data if_data; /* not all members are meaningful */ 64421259Swollman struct ifnet *ifa_ifp; /* back-pointer to interface */ 64560938Sjake TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ 64621259Swollman void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ 64792725Salfred (int, struct rtentry *, struct rt_addrinfo *); 64821259Swollman u_short ifa_flags; /* mostly rt_flags for cloning */ 64947254Spb u_int ifa_refcnt; /* references to this structure */ 65021259Swollman int ifa_metric; /* cost of going out this interface */ 65128845Sjulian int (*ifa_claim_addr) /* check if an addr goes to this if */ 65292725Salfred (struct ifaddr *, struct sockaddr *); 653108033Shsu struct mtx ifa_mtx; 65421259Swollman}; 65521259Swollman#define IFA_ROUTE RTF_UP /* route installed */ 65621259Swollman 65753541Sshin/* for compatibility with other BSDs */ 65853541Sshin#define ifa_list ifa_link 65953541Sshin 660108033Shsu#define IFA_LOCK_INIT(ifa) \ 661108033Shsu mtx_init(&(ifa)->ifa_mtx, "ifaddr", NULL, MTX_DEF) 662108033Shsu#define IFA_LOCK(ifa) mtx_lock(&(ifa)->ifa_mtx) 663108033Shsu#define IFA_UNLOCK(ifa) mtx_unlock(&(ifa)->ifa_mtx) 664108033Shsu#define IFA_DESTROY(ifa) mtx_destroy(&(ifa)->ifa_mtx) 665108033Shsu 66621404Swollman/* 66752904Sshin * The prefix structure contains information about one prefix 66852904Sshin * of an interface. They are maintained by the different address families, 669108470Sschweikh * are allocated and attached when a prefix or an address is set, 67053541Sshin * and are linked together so all prefixes for an interface can be located. 67152904Sshin */ 67252904Sshinstruct ifprefix { 67352904Sshin struct sockaddr *ifpr_prefix; /* prefix of interface */ 67452904Sshin struct ifnet *ifpr_ifp; /* back-pointer to interface */ 67560938Sjake TAILQ_ENTRY(ifprefix) ifpr_list; /* queue macro glue */ 67652904Sshin u_char ifpr_plen; /* prefix length in bits */ 67752904Sshin u_char ifpr_type; /* protocol dependent prefix type */ 67852904Sshin}; 67952904Sshin 68052904Sshin/* 68121404Swollman * Multicast address structure. This is analogous to the ifaddr 68221404Swollman * structure except that it keeps track of multicast addresses. 68321404Swollman */ 68421404Swollmanstruct ifmultiaddr { 68572084Sphk TAILQ_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ 68621434Swollman struct sockaddr *ifma_addr; /* address this membership is for */ 68721434Swollman struct sockaddr *ifma_lladdr; /* link-layer translation, if any */ 68821434Swollman struct ifnet *ifma_ifp; /* back-pointer to interface */ 68921434Swollman u_int ifma_refcount; /* reference count */ 69021434Swollman void *ifma_protospec; /* protocol-specific state, if any */ 691167729Sbms struct ifmultiaddr *ifma_llifma; /* pointer to ifma for ifma_lladdr */ 69221404Swollman}; 69321404Swollman 69455205Speter#ifdef _KERNEL 695108036Shsu#define IFAFREE(ifa) \ 696108036Shsu do { \ 697108036Shsu IFA_LOCK(ifa); \ 698108036Shsu KASSERT((ifa)->ifa_refcnt > 0, \ 699108036Shsu ("ifa %p !(ifa_refcnt > 0)", ifa)); \ 700108036Shsu if (--(ifa)->ifa_refcnt == 0) { \ 701108036Shsu IFA_DESTROY(ifa); \ 702108036Shsu free(ifa, M_IFADDR); \ 703108036Shsu } else \ 704108036Shsu IFA_UNLOCK(ifa); \ 70546568Speter } while (0) 70621259Swollman 707108036Shsu#define IFAREF(ifa) \ 708108036Shsu do { \ 709108036Shsu IFA_LOCK(ifa); \ 710108036Shsu ++(ifa)->ifa_refcnt; \ 711108036Shsu IFA_UNLOCK(ifa); \ 712108033Shsu } while (0) 713108033Shsu 714186199Skmacyextern struct rwlock ifnet_lock; 715108298Shsu#define IFNET_LOCK_INIT() \ 716186199Skmacy rw_init_flags(&ifnet_lock, "ifnet", RW_RECURSE) 717186199Skmacy#define IFNET_WLOCK() rw_wlock(&ifnet_lock) 718186199Skmacy#define IFNET_WUNLOCK() rw_wunlock(&ifnet_lock) 719186199Skmacy#define IFNET_WLOCK_ASSERT() rw_assert(&ifnet_lock, RA_LOCKED) 720186199Skmacy#define IFNET_RLOCK() rw_rlock(&ifnet_lock) 721186199Skmacy#define IFNET_RUNLOCK() rw_runlock(&ifnet_lock) 722108172Shsu 72383130Sjlemonstruct ifindex_entry { 72487914Sjlemon struct ifnet *ife_ifnet; 725130585Sphk struct cdev *ife_dev; 72683130Sjlemon}; 72783130Sjlemon 728191367Srwatson/* 729191367Srwatson * Look up an ifnet given its index; the _ref variant also acquires a 730191367Srwatson * reference that must be freed using if_rele(). It is almost always a bug 731191367Srwatson * to call ifnet_byindex() instead if ifnet_byindex_ref(). 732191367Srwatson */ 733180042Srwatsonstruct ifnet *ifnet_byindex(u_short idx); 734191816Szecstruct ifnet *ifnet_byindex_locked(u_short idx); 735191367Srwatsonstruct ifnet *ifnet_byindex_ref(u_short idx); 736181892Skmacy 737128315Sluigi/* 738128315Sluigi * Given the index, ifaddr_byindex() returns the one and only 739128315Sluigi * link-level ifaddr for the interface. You are not supposed to use 740128315Sluigi * it to traverse the list of addresses associated to the interface. 741128315Sluigi */ 742180042Srwatsonstruct ifaddr *ifaddr_byindex(u_short idx); 743180042Srwatsonstruct cdev *ifdev_byindex(u_short idx); 74483130Sjlemon 745186048Sbz#ifdef VIMAGE_GLOBALS 74621259Swollmanextern struct ifnethead ifnet; 74771791Speterextern struct ifnet *loif; /* first loopback interface */ 74821259Swollmanextern int if_index; 749186048Sbz#endif 750186048Sbzextern int ifqmaxlen; 75121259Swollman 752159781Smlaierint if_addgroup(struct ifnet *, const char *); 753159781Smlaierint if_delgroup(struct ifnet *, const char *); 75492725Salfredint if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **); 75592725Salfredint if_allmulti(struct ifnet *, int); 756147256Sbrooksstruct ifnet* if_alloc(u_char); 75792725Salfredvoid if_attach(struct ifnet *); 758191418Srwatsonvoid if_dead(struct ifnet *); 759191816Szecvoid if_grow(void); 76092725Salfredint if_delmulti(struct ifnet *, struct sockaddr *); 761167729Sbmsvoid if_delmulti_ifma(struct ifmultiaddr *); 76292725Salfredvoid if_detach(struct ifnet *); 763192605Szecvoid if_vmove(struct ifnet *, struct vnet *); 764146620Speadarvoid if_purgeaddrs(struct ifnet *); 765177617Ssamvoid if_purgemaddrs(struct ifnet *); 76692725Salfredvoid if_down(struct ifnet *); 767167732Sbmsstruct ifmultiaddr * 768167732Sbms if_findmulti(struct ifnet *, struct sockaddr *); 769147256Sbrooksvoid if_free(struct ifnet *); 770147256Sbrooksvoid if_free_type(struct ifnet *, u_char); 771121816Sbrooksvoid if_initname(struct ifnet *, const char *, int); 772138542Ssamvoid if_link_state_change(struct ifnet *, int); 773103900Sbrooksint if_printf(struct ifnet *, const char *, ...) __printflike(2, 3); 774191161Skmacyvoid if_qflush(struct ifnet *); 775191367Srwatsonvoid if_ref(struct ifnet *); 776191367Srwatsonvoid if_rele(struct ifnet *); 77792725Salfredint if_setlladdr(struct ifnet *, const u_char *, int); 77892725Salfredvoid if_up(struct ifnet *); 77992725Salfred/*void ifinit(void);*/ /* declared in systm.h for main() */ 78092725Salfredint ifioctl(struct socket *, u_long, caddr_t, struct thread *); 78192725Salfredint ifpromisc(struct ifnet *, int); 78292725Salfredstruct ifnet *ifunit(const char *); 783191423Srwatsonstruct ifnet *ifunit_ref(const char *); 78421259Swollman 785185162Skmacyvoid ifq_attach(struct ifaltq *, struct ifnet *ifp); 786185162Skmacyvoid ifq_detach(struct ifaltq *); 787185162Skmacy 78892725Salfredstruct ifaddr *ifa_ifwithaddr(struct sockaddr *); 789162068Sandrestruct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); 79092725Salfredstruct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); 79192725Salfredstruct ifaddr *ifa_ifwithnet(struct sockaddr *); 79292725Salfredstruct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); 793178888Sjulianstruct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); 794178888Sjulian 79592725Salfredstruct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); 79621259Swollman 79792725Salfredint if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen); 79821434Swollman 799147256Sbrookstypedef void *if_com_alloc_t(u_char type, struct ifnet *ifp); 800147256Sbrookstypedef void if_com_free_t(void *com, u_char type); 801147256Sbrooksvoid if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f); 802147256Sbrooksvoid if_deregister_com_alloc(u_char type); 803147256Sbrooks 80484931Sfjoe#define IF_LLADDR(ifp) \ 805152315Sru LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr)) 80684931Sfjoe 80787902Sluigi#ifdef DEVICE_POLLING 808150789Sglebiusenum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS }; 80987902Sluigi 81092725Salfredtypedef void poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count); 81192725Salfredint ether_poll_register(poll_handler_t *h, struct ifnet *ifp); 81292725Salfredint ether_poll_deregister(struct ifnet *ifp); 81387902Sluigi#endif /* DEVICE_POLLING */ 81487902Sluigi 81555205Speter#endif /* _KERNEL */ 81621259Swollman 81721259Swollman#endif /* !_NET_IF_VAR_H_ */ 818