2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1982, 1986, 1989, 1993
25 * The Regents of the University of California. All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgement:
37 * This product includes software developed by the University of
38 * California, Berkeley and its contributors.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
56 * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.7 2001/07/24 19:10:18 brooks Exp $
59 #ifndef _NET_IF_VAR_H_
60 #define _NET_IF_VAR_H_
62 #include <sys/appleapiopts.h>
63 #include <sys/types.h>
65 #include <sys/queue.h> /* get TAILQ macros */
67 #include <kern/locks.h>
68 #endif /* KERNEL_PRIVATE */
71 #include <net/kpi_interface.h>
75 #define APPLE_IF_FAM_LOOPBACK 1
76 #define APPLE_IF_FAM_ETHERNET 2
77 #define APPLE_IF_FAM_SLIP 3
78 #define APPLE_IF_FAM_TUN 4
79 #define APPLE_IF_FAM_VLAN 5
80 #define APPLE_IF_FAM_PPP 6
81 #define APPLE_IF_FAM_PVC 7
82 #define APPLE_IF_FAM_DISC 8
83 #define APPLE_IF_FAM_MDECAP 9
84 #define APPLE_IF_FAM_GIF 10
85 #define APPLE_IF_FAM_FAITH 11
86 #define APPLE_IF_FAM_STF 12
87 #define APPLE_IF_FAM_FIREWIRE 13
88 #define APPLE_IF_FAM_BOND 14
92 * 72 was chosen below because it is the size of a TCP/IP
93 * header (40) + the minimum mss (32).
96 #define IF_MAXMTU 65535
99 * Structures defining a network interface, providing a packet
100 * transport mechanism (ala level 0 of the PUP protocols).
102 * Each interface accepts output datagrams of a specified maximum
103 * length, and provides higher level routines with input datagrams
104 * received from its medium.
106 * Output occurs when the routine if_output is called, with three parameters:
107 * (*ifp->if_output)(ifp, m, dst, rt)
108 * Here m is the mbuf chain to be sent and dst is the destination address.
109 * The output routine encapsulates the supplied datagram if necessary,
110 * and then transmits it on its medium.
112 * On input, each interface unwraps the data received by it, and either
113 * places it on the input queue of a internetwork datagram routine
114 * and posts the associated software interrupt, or passes the datagram to a raw
115 * packet input routine.
117 * Routines exist for locating interfaces by their addresses
118 * or for locating a interface on a certain network, as well as more general
119 * routing and gateway routines maintaining information used to locate
120 * interfaces. These routines live in the files if.c and route.c
125 /* This belongs up in socket.h or socketvar.h, depending on how far the
129 struct net_event_data
{
130 unsigned long if_family
;
131 unsigned long if_unit
;
132 char if_name
[IFNAMSIZ
];
136 * Structure describing information about an interface
137 * which may be of interest to management entities.
140 /* generic interface information */
141 unsigned char ifi_type
; /* ethernet, tokenring, etc */
143 unsigned char ifi_typelen
; /* Length of frame type id */
145 unsigned char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
146 unsigned char ifi_addrlen
; /* media address length */
147 unsigned char ifi_hdrlen
; /* media header length */
148 unsigned char ifi_recvquota
; /* polling quota for receive intrs */
149 unsigned char ifi_xmitquota
; /* polling quota for xmit intrs */
150 unsigned char ifi_unused1
; /* for future use */
151 unsigned long ifi_mtu
; /* maximum transmission unit */
152 unsigned long ifi_metric
; /* routing metric (external only) */
153 unsigned long ifi_baudrate
; /* linespeed */
154 /* volatile statistics */
155 unsigned long ifi_ipackets
; /* packets received on interface */
156 unsigned long ifi_ierrors
; /* input errors on interface */
157 unsigned long ifi_opackets
; /* packets sent on interface */
158 unsigned long ifi_oerrors
; /* output errors on interface */
159 unsigned long ifi_collisions
; /* collisions on csma interfaces */
160 unsigned long ifi_ibytes
; /* total number of octets received */
161 unsigned long ifi_obytes
; /* total number of octets sent */
162 unsigned long ifi_imcasts
; /* packets received via multicast */
163 unsigned long ifi_omcasts
; /* packets sent via multicast */
164 unsigned long ifi_iqdrops
; /* dropped on input, this interface */
165 unsigned long ifi_noproto
; /* destined for unsupported protocol */
166 unsigned long ifi_recvtiming
; /* usec spent receiving when timing */
167 unsigned long ifi_xmittiming
; /* usec spent xmitting when timing */
168 struct timeval ifi_lastchange
; /* time of last administrative change */
169 unsigned long ifi_unused2
; /* used to be the default_proto */
170 unsigned long ifi_hwassist
; /* HW offload capabilities */
171 unsigned long ifi_reserved1
; /* for future use */
172 unsigned long ifi_reserved2
; /* for future use */
176 * Structure describing information about an interface
177 * which may be of interest to management entities.
180 /* generic interface information */
181 u_char ifi_type
; /* ethernet, tokenring, etc */
183 u_char ifi_typelen
; /* Length of frame type id */
185 u_char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
186 u_char ifi_addrlen
; /* media address length */
187 u_char ifi_hdrlen
; /* media header length */
188 u_char ifi_recvquota
; /* polling quota for receive intrs */
189 u_char ifi_xmitquota
; /* polling quota for xmit intrs */
190 u_char ifi_unused1
; /* for future use */
191 u_long ifi_mtu
; /* maximum transmission unit */
192 u_long ifi_metric
; /* routing metric (external only) */
193 u_int64_t ifi_baudrate
; /* linespeed */
194 /* volatile statistics */
195 u_int64_t ifi_ipackets
; /* packets received on interface */
196 u_int64_t ifi_ierrors
; /* input errors on interface */
197 u_int64_t ifi_opackets
; /* packets sent on interface */
198 u_int64_t ifi_oerrors
; /* output errors on interface */
199 u_int64_t ifi_collisions
; /* collisions on csma interfaces */
200 u_int64_t ifi_ibytes
; /* total number of octets received */
201 u_int64_t ifi_obytes
; /* total number of octets sent */
202 u_int64_t ifi_imcasts
; /* packets received via multicast */
203 u_int64_t ifi_omcasts
; /* packets sent via multicast */
204 u_int64_t ifi_iqdrops
; /* dropped on input, this interface */
205 u_int64_t ifi_noproto
; /* destined for unsupported protocol */
206 u_long ifi_recvtiming
; /* usec spent receiving when timing */
207 u_long ifi_xmittiming
; /* usec spent xmitting when timing */
208 struct timeval ifi_lastchange
; /* time of last administrative change */
213 * Internal storage of if_data. This is bound to change. Various places in the
214 * stack will translate this data structure in to the externally visible
215 * if_data structure above.
217 struct if_data_internal
{
218 /* generic interface information */
219 u_char ifi_type
; /* ethernet, tokenring, etc */
220 u_char ifi_typelen
; /* Length of frame type id */
221 u_char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
222 u_char ifi_addrlen
; /* media address length */
223 u_char ifi_hdrlen
; /* media header length */
224 u_char ifi_recvquota
; /* polling quota for receive intrs */
225 u_char ifi_xmitquota
; /* polling quota for xmit intrs */
226 u_char ifi_unused1
; /* for future use */
227 u_long ifi_mtu
; /* maximum transmission unit */
228 u_long ifi_metric
; /* routing metric (external only) */
229 u_long ifi_baudrate
; /* linespeed */
230 /* volatile statistics */
231 u_int64_t ifi_ipackets
; /* packets received on interface */
232 u_int64_t ifi_ierrors
; /* input errors on interface */
233 u_int64_t ifi_opackets
; /* packets sent on interface */
234 u_int64_t ifi_oerrors
; /* output errors on interface */
235 u_int64_t ifi_collisions
; /* collisions on csma interfaces */
236 u_int64_t ifi_ibytes
; /* total number of octets received */
237 u_int64_t ifi_obytes
; /* total number of octets sent */
238 u_int64_t ifi_imcasts
; /* packets received via multicast */
239 u_int64_t ifi_omcasts
; /* packets sent via multicast */
240 u_int64_t ifi_iqdrops
; /* dropped on input, this interface */
241 u_int64_t ifi_noproto
; /* destined for unsupported protocol */
242 u_long ifi_recvtiming
; /* usec spent receiving when timing */
243 u_long ifi_xmittiming
; /* usec spent xmitting when timing */
244 #define IF_LASTCHANGEUPTIME 1 /* lastchange: 1-uptime 0-calendar time */
245 struct timeval ifi_lastchange
; /* time of last administrative change */
246 u_long ifi_hwassist
; /* HW offload capabilities */
249 #define if_mtu if_data.ifi_mtu
250 #define if_type if_data.ifi_type
251 #define if_typelen if_data.ifi_typelen
252 #define if_physical if_data.ifi_physical
253 #define if_addrlen if_data.ifi_addrlen
254 #define if_hdrlen if_data.ifi_hdrlen
255 #define if_metric if_data.ifi_metric
256 #define if_baudrate if_data.ifi_baudrate
257 #define if_hwassist if_data.ifi_hwassist
258 #define if_ipackets if_data.ifi_ipackets
259 #define if_ierrors if_data.ifi_ierrors
260 #define if_opackets if_data.ifi_opackets
261 #define if_oerrors if_data.ifi_oerrors
262 #define if_collisions if_data.ifi_collisions
263 #define if_ibytes if_data.ifi_ibytes
264 #define if_obytes if_data.ifi_obytes
265 #define if_imcasts if_data.ifi_imcasts
266 #define if_omcasts if_data.ifi_omcasts
267 #define if_iqdrops if_data.ifi_iqdrops
268 #define if_noproto if_data.ifi_noproto
269 #define if_lastchange if_data.ifi_lastchange
270 #define if_recvquota if_data.ifi_recvquota
271 #define if_xmitquota if_data.ifi_xmitquota
272 #define if_iflags if_data.ifi_iflags
276 TAILQ_HEAD(ifnethead
, ifnet
); /* we use TAILQs so that the order of */
277 TAILQ_HEAD(ifaddrhead
, ifaddr
); /* instantiation is preserved in the list */
278 TAILQ_HEAD(ifprefixhead
, ifprefix
);
279 LIST_HEAD(ifmultihead
, ifmultiaddr
);
281 TAILQ_HEAD(tailq_head
, tqdummy
);
284 * Forward structure declarations for function prototypes [sic].
293 TAILQ_HEAD(ifnet_filter_head
, ifnet_filter
);
294 TAILQ_HEAD(ddesc_head_name
, dlil_demux_desc
);
296 /* bottom 16 bits reserved for hardware checksum */
297 #define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP */
298 #define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP */
299 #define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP */
300 #define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments */
301 #define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation */
302 #define IF_HWASSIST_CSUM_TCP_SUM16 0x1000 /* simple TCP Sum16 computation */
303 #define IF_HWASSIST_CSUM_MASK 0xffff
304 #define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK)
307 #define IF_HWASSIST_VLAN_TAGGING 0x10000 /* supports VLAN tagging */
308 #define IF_HWASSIST_VLAN_MTU 0x20000 /* supports VLAN MTU-sized packet (for software VLAN) */
310 #define IFNET_RW_LOCK 1
313 * Structure defining a queue for a network interface.
323 struct ddesc_head_str
;
324 struct proto_hash_entry
;
328 * Structure defining a network interface.
330 * (Would like to call this struct ``if'', but C isn't PL/1.)
333 void *if_softc
; /* pointer to driver state */
334 const char *if_name
; /* name, e.g. ``en'' or ``lo'' */
335 TAILQ_ENTRY(ifnet
) if_link
; /* all struct ifnets are chained */
336 struct ifaddrhead if_addrhead
; /* linked list of addresses per if */
338 #ifdef __KPI_INTERFACE__
339 ifnet_check_multi if_check_multi
;
341 void* if_check_multi
;
342 #endif __KPI_INTERFACE__
343 int if_pcount
; /* number of promiscuous listeners */
344 struct bpf_if
*if_bpf
; /* packet filter structure */
345 u_short if_index
; /* numeric abbreviation for this if */
346 short if_unit
; /* sub-unit for lower level driver */
347 short if_timer
; /* time 'til if_watchdog called */
348 short if_flags
; /* up/down, broadcast, etc. */
349 int if_ipending
; /* interrupts pending */
350 void *if_linkmib
; /* link-type-specific MIB data */
351 size_t if_linkmiblen
; /* length of above data */
352 struct if_data_internal if_data
;
355 #ifdef BSD_KERNEL_PRIVATE
361 #ifdef __KPI_INTERFACE__
362 ifnet_output_func if_output
;
363 ifnet_ioctl_func if_ioctl
;
364 ifnet_set_bpf_tap if_set_bpf_tap
;
365 ifnet_detached_func if_free
;
366 ifnet_demux_func if_demux
;
367 ifnet_event_func if_event
;
368 ifnet_framer_func if_framer
;
369 ifnet_family_t if_family
; /* ulong assigned by Apple */
373 void* if_set_bpf_tap
;
378 u_long if_family
; /* ulong assigned by Apple */
381 struct ifnet_filter_head if_flt_head
;
383 /* End DLIL specific */
385 u_long if_delayed_detach
; /* need to perform delayed detach */
386 void *if_private
; /* private to interface */
387 long if_eflags
; /* autoaddr, autoaddr done, etc. */
389 struct ifmultihead if_multiaddrs
; /* multicast addresses configured */
390 int if_amcount
; /* number of all-multicast requests */
391 /* procedure handles */
392 #ifdef __KPI_INTERFACE__
394 int (*original
)(struct ifnet
*ifp
, u_long protocol_family
,
395 struct ddesc_head_str
*demux_desc_head
);
396 ifnet_add_proto_func kpi
;
398 ifnet_del_proto_func if_del_proto
;
399 #else __KPI_INTERFACE__
402 #endif __KPI_INTERFACE__
403 struct proto_hash_entry
*if_proto_hash
;
404 void *if_kpi_storage
;
406 void *unused_was_init
;
407 void *unused_was_resolvemulti
;
409 struct ifqueue if_snd
;
412 u_long family_cookie
;
413 struct ifprefixhead if_prefixhead
; /* list of prefixes per if */
415 #ifdef _KERN_LOCKS_H_
417 lck_rw_t
*if_lock
; /* Lock to protect this interface */
419 lck_mtx_t
*if_lock
; /* Lock to protect this interface */
426 struct ifprefixhead if_prefixhead
; /* list of prefixes per if */
427 #endif /* __APPLE__ */
437 #define if_add_proto if_add_proto_u.original
440 /* for compatibility with other BSDs */
441 #define if_addrlist if_addrhead
442 #define if_list if_link
448 #ifdef KERNEL_PRIVATE
450 * Structure describing a `cloning' interface.
453 LIST_ENTRY(if_clone
) ifc_list
; /* on list of cloners */
454 const char *ifc_name
; /* name of device, e.g. `vlan' */
455 size_t ifc_namelen
; /* length of name */
456 int ifc_minifs
; /* minimum number of interfaces */
457 int ifc_maxunit
; /* maximum unit number */
458 unsigned char *ifc_units
; /* bitmap to handle units */
459 int ifc_bmlen
; /* bitmap length */
461 int (*ifc_create
)(struct if_clone
*, int);
462 void (*ifc_destroy
)(struct ifnet
*);
465 #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit) \
466 { { 0, 0 }, name, sizeof(name) - 1, minifs, maxunit, NULL, 0, create, destroy }
469 * Bit values in if_ipending
471 #define IFI_RECV 1 /* I want to receive */
472 #define IFI_XMIT 2 /* I want to transmit */
475 * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
476 * are queues of messages stored on ifqueue structures
477 * (defined above). Entries are added to and deleted from these structures
478 * by these macros, which should be called with ipl raised to splimp().
480 #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
481 #define IF_DROP(ifq) ((ifq)->ifq_drops++)
482 #define IF_ENQUEUE(ifq, m) { \
483 (m)->m_nextpkt = 0; \
484 if ((ifq)->ifq_tail == 0) \
485 (ifq)->ifq_head = m; \
487 ((struct mbuf*)(ifq)->ifq_tail)->m_nextpkt = m; \
488 (ifq)->ifq_tail = m; \
491 #define IF_PREPEND(ifq, m) { \
492 (m)->m_nextpkt = (ifq)->ifq_head; \
493 if ((ifq)->ifq_tail == 0) \
494 (ifq)->ifq_tail = (m); \
495 (ifq)->ifq_head = (m); \
498 #define IF_DEQUEUE(ifq, m) { \
499 (m) = (ifq)->ifq_head; \
501 if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
502 (ifq)->ifq_tail = 0; \
503 (m)->m_nextpkt = 0; \
508 #define IF_ENQ_DROP(ifq, m) if_enq_drop(ifq, m)
510 #if defined(__GNUC__) && defined(MT_HEADER)
512 if_queue_drop(struct ifqueue
*ifq
, __unused
struct mbuf
*m
)
519 if_enq_drop(struct ifqueue
*ifq
, struct mbuf
*m
)
522 !if_queue_drop(ifq
, m
))
530 int if_enq_drop(struct ifqueue
*, struct mbuf
*);
533 #endif defined(__GNUC__) && defined(MT_HEADER)
535 #endif /* KERNEL_PRIVATE */
540 * The ifaddr structure contains information about one address
541 * of an interface. They are maintained by the different address families,
542 * are allocated and attached when an address is set, and are linked
543 * together so all addresses for an interface can be located.
546 struct sockaddr
*ifa_addr
; /* address of interface */
547 struct sockaddr
*ifa_dstaddr
; /* other end of p-to-p link */
548 #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
549 struct sockaddr
*ifa_netmask
; /* used to determine subnet */
550 struct ifnet
*ifa_ifp
; /* back-pointer to interface */
551 TAILQ_ENTRY(ifaddr
) ifa_link
; /* queue macro glue */
552 void (*ifa_rtrequest
) /* check or clean routes (+ or -)'d */
553 (int, struct rtentry
*, struct sockaddr
*);
554 u_short ifa_flags
; /* mostly rt_flags for cloning */
555 int ifa_refcnt
;/* 32bit ref count, use ifaref, ifafree */
556 int ifa_metric
; /* cost of going out this interface */
558 struct rtentry
*ifa_rt
; /* XXXX for ROUTETOIF ????? */
560 int (*ifa_claim_addr
) /* check if an addr goes to this if */
561 (struct ifaddr
*, const struct sockaddr
*);
562 u_long ifa_debug
; /* debug flags */
564 #define IFA_ROUTE RTF_UP /* route installed (0x1) */
565 #define IFA_CLONING RTF_CLONING /* (0x100) */
566 #define IFA_ATTACHED 0x1 /* ifa_debug: IFA is attached to an interface */
570 #ifdef KERNEL_PRIVATE
572 * The prefix structure contains information about one prefix
573 * of an interface. They are maintained by the different address families,
574 * are allocated and attached when an prefix or an address is set,
575 * and are linked together so all prefixes for an interface can be located.
578 struct sockaddr
*ifpr_prefix
; /* prefix of interface */
579 struct ifnet
*ifpr_ifp
; /* back-pointer to interface */
580 TAILQ_ENTRY(ifprefix
) ifpr_list
; /* queue macro glue */
581 u_char ifpr_plen
; /* prefix length in bits */
582 u_char ifpr_type
; /* protocol dependent prefix type */
584 #endif /* KERNEL_PRIVATE */
587 typedef void (*ifma_protospec_free_func
)(void* ifma_protospec
);
590 * Multicast address structure. This is analogous to the ifaddr
591 * structure except that it keeps track of multicast addresses.
592 * Also, the reference count here is a count of requests for this
593 * address, not a count of pointers to this structure.
596 LIST_ENTRY(ifmultiaddr
) ifma_link
; /* queue macro glue */
597 struct sockaddr
*ifma_addr
; /* address this membership is for */
598 struct ifmultiaddr
*ifma_ll
; /* link-layer translation, if any */
599 struct ifnet
*ifma_ifp
; /* back-pointer to interface */
600 u_int ifma_usecount
; /* use count, protected by ifp's lock */
601 void *ifma_protospec
; /* protocol-specific state, if any */
602 int32_t ifma_refcount
; /* reference count, atomically protected */
603 ifma_protospec_free_func ifma_free
; /* function called to free ifma_protospec */
607 #ifdef KERNEL_PRIVATE
608 #define IFAREF(ifa) ifaref(ifa)
609 #define IFAFREE(ifa) ifafree(ifa)
612 * To preserve kmem compatibility, we define
613 * ifnet_head to ifnet. This should be temp.
615 #define ifnet_head ifnet
616 extern struct ifnethead ifnet_head
;
617 extern struct ifnet
**ifindex2ifnet
;
618 extern int ifqmaxlen
;
619 extern struct ifnet loif
[];
621 extern struct ifaddr
**ifnet_addrs
;
622 extern struct ifnet
*lo_ifp
;
624 int if_addmulti(struct ifnet
*, const struct sockaddr
*, struct ifmultiaddr
**);
625 int if_allmulti(struct ifnet
*, int);
626 void if_attach(struct ifnet
*);
627 int if_delmultiaddr(struct ifmultiaddr
*ifma
, int locked
);
628 int if_delmulti(struct ifnet
*, const struct sockaddr
*);
629 void if_down(struct ifnet
*);
630 void if_route(struct ifnet
*, int flag
, int fam
);
631 void if_unroute(struct ifnet
*, int flag
, int fam
);
632 void if_up(struct ifnet
*);
633 void if_updown(struct ifnet
*ifp
, int up
);
634 /*void ifinit(void));*/ /* declared in systm.h for main( */
635 int ifioctl(struct socket
*, u_long
, caddr_t
, struct proc
*);
636 int ifioctllocked(struct socket
*, u_long
, caddr_t
, struct proc
*);
637 struct ifnet
*ifunit(const char *);
638 struct ifnet
*if_withname(struct sockaddr
*);
640 void if_clone_attach(struct if_clone
*);
641 void if_clone_detach(struct if_clone
*);
643 void ifnet_lock_assert(struct ifnet
*ifp
, int what
);
644 void ifnet_lock_shared(struct ifnet
*ifp
);
645 void ifnet_lock_exclusive(struct ifnet
*ifp
);
646 void ifnet_lock_done(struct ifnet
*ifp
);
648 void ifnet_head_lock_shared(void);
649 void ifnet_head_lock_exclusive(void);
650 void ifnet_head_done(void);
652 void if_attach_ifa(struct ifnet
* ifp
, struct ifaddr
*ifa
);
653 void if_detach_ifa(struct ifnet
* ifp
, struct ifaddr
*ifa
);
655 void ifma_reference(struct ifmultiaddr
*ifma
);
656 void ifma_release(struct ifmultiaddr
*ifma
);
658 struct ifaddr
*ifa_ifwithaddr(const struct sockaddr
*);
659 struct ifaddr
*ifa_ifwithdstaddr(const struct sockaddr
*);
660 struct ifaddr
*ifa_ifwithnet(const struct sockaddr
*);
661 struct ifaddr
*ifa_ifwithroute(int, const struct sockaddr
*, const struct sockaddr
*);
662 struct ifaddr
*ifaof_ifpforaddr(const struct sockaddr
*, struct ifnet
*);
663 void ifafree(struct ifaddr
*);
664 void ifaref(struct ifaddr
*);
666 struct ifmultiaddr
*ifmaof_ifpforaddr(const struct sockaddr
*, struct ifnet
*);
668 #ifdef BSD_KERNEL_PRIVATE
669 void if_data_internal_to_if_data(const struct if_data_internal
*if_data_int
,
670 struct if_data
*if_data
);
671 void if_data_internal_to_if_data64(const struct if_data_internal
*if_data_int
,
672 struct if_data64
*if_data64
);
673 #endif /* BSD_KERNEL_PRIVATE */
674 #endif /* KERNEL_PRIVATE */
675 #endif /* !_NET_IF_VAR_H_ */