if.h revision 1.45 1 /* $NetBSD: if.h,v 1.45 2000/03/06 18:55:10 kleink Exp $ */
2
3 /*-
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by William Studnemund and Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Copyright (c) 1982, 1986, 1989, 1993
41 * The Regents of the University of California. All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by the University of
54 * California, Berkeley and its contributors.
55 * 4. Neither the name of the University nor the names of its contributors
56 * may be used to endorse or promote products derived from this software
57 * without specific prior written permission.
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * @(#)if.h 8.3 (Berkeley) 2/9/95
72 */
73
74 #ifndef _NET_IF_H_
75 #define _NET_IF_H_
76
77 #if !defined(_XOPEN_SOURCE)
78
79 #include <sys/queue.h>
80
81 /*
82 * Structures defining a network interface, providing a packet
83 * transport mechanism (ala level 0 of the PUP protocols).
84 *
85 * Each interface accepts output datagrams of a specified maximum
86 * length, and provides higher level routines with input datagrams
87 * received from its medium.
88 *
89 * Output occurs when the routine if_output is called, with four parameters:
90 * (*ifp->if_output)(ifp, m, dst, rt)
91 * Here m is the mbuf chain to be sent and dst is the destination address.
92 * The output routine encapsulates the supplied datagram if necessary,
93 * and then transmits it on its medium.
94 *
95 * On input, each interface unwraps the data received by it, and either
96 * places it on the input queue of a internetwork datagram routine
97 * and posts the associated software interrupt, or passes the datagram to a raw
98 * packet input routine.
99 *
100 * Routines exist for locating interfaces by their addresses
101 * or for locating a interface on a certain network, as well as more general
102 * routing and gateway routines maintaining information used to locate
103 * interfaces. These routines live in the files if.c and route.c
104 */
105 /* XXX fast fix for SNMP, going away soon */
106 #include <sys/time.h>
107
108 #if defined(_KERNEL) && !defined(_LKM)
109 #include "opt_compat_netbsd.h"
110 #endif
111
112 struct mbuf;
113 struct proc;
114 struct rtentry;
115 struct socket;
116 struct ether_header;
117
118 /*
119 * Structure defining statistics and other data kept regarding a network
120 * interface.
121 */
122 struct if_data {
123 /* generic interface information */
124 u_char ifi_type; /* ethernet, tokenring, etc. */
125 u_char ifi_addrlen; /* media address length */
126 u_char ifi_hdrlen; /* media header length */
127 u_quad_t ifi_mtu; /* maximum transmission unit */
128 u_quad_t ifi_metric; /* routing metric (external only) */
129 u_quad_t ifi_baudrate; /* linespeed */
130 /* volatile statistics */
131 u_quad_t ifi_ipackets; /* packets received on interface */
132 u_quad_t ifi_ierrors; /* input errors on interface */
133 u_quad_t ifi_opackets; /* packets sent on interface */
134 u_quad_t ifi_oerrors; /* output errors on interface */
135 u_quad_t ifi_collisions; /* collisions on csma interfaces */
136 u_quad_t ifi_ibytes; /* total number of octets received */
137 u_quad_t ifi_obytes; /* total number of octets sent */
138 u_quad_t ifi_imcasts; /* packets received via multicast */
139 u_quad_t ifi_omcasts; /* packets sent via multicast */
140 u_quad_t ifi_iqdrops; /* dropped on input, this interface */
141 u_quad_t ifi_noproto; /* destined for unsupported protocol */
142 struct timeval ifi_lastchange; /* last updated */
143 };
144
145 #if defined(_KERNEL) && defined(COMPAT_14)
146 /* Pre-1.5 if_data struct */
147 struct if_data14 {
148 /* generic interface information */
149 u_char ifi_type; /* ethernet, tokenring, etc. */
150 u_char ifi_addrlen; /* media address length */
151 u_char ifi_hdrlen; /* media header length */
152 u_long ifi_mtu; /* maximum transmission unit */
153 u_long ifi_metric; /* routing metric (external only) */
154 u_long ifi_baudrate; /* linespeed */
155 /* volatile statistics */
156 u_long ifi_ipackets; /* packets received on interface */
157 u_long ifi_ierrors; /* input errors on interface */
158 u_long ifi_opackets; /* packets sent on interface */
159 u_long ifi_oerrors; /* output errors on interface */
160 u_long ifi_collisions; /* collisions on csma interfaces */
161 u_long ifi_ibytes; /* total number of octets received */
162 u_long ifi_obytes; /* total number of octets sent */
163 u_long ifi_imcasts; /* packets received via multicast */
164 u_long ifi_omcasts; /* packets sent via multicast */
165 u_long ifi_iqdrops; /* dropped on input, this interface */
166 u_long ifi_noproto; /* destined for unsupported protocol */
167 struct timeval ifi_lastchange; /* last updated */
168 };
169 #endif /* _KERNEL && COMPAT_14 */
170
171 /*
172 * Structure defining a queue for a network interface.
173 *
174 * (Would like to call this struct ``if'', but C isn't PL/1.)
175 */
176 TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */
177
178 /*
179 * Length of interface external name, including terminating '\0'.
180 * Note: this is the same size as a generic device's external name.
181 */
182 #define IFNAMSIZ 16
183 #define IF_NAMESIZE IFNAMSIZ
184
185 struct ifnet { /* and the entries */
186 void *if_softc; /* lower-level data for this if */
187 TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */
188 TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
189 char if_xname[IFNAMSIZ]; /* external name (name + unit) */
190 int if_pcount; /* number of promiscuous listeners */
191 caddr_t if_bpf; /* packet filter structure */
192 u_short if_index; /* numeric abbreviation for this if */
193 short if_timer; /* time 'til if_watchdog called */
194 short if_flags; /* up/down, broadcast, etc. */
195 short if__pad1; /* be nice to m68k ports */
196 struct if_data if_data; /* statistics and other data about if */
197 /*
198 * Procedure handles. If you add more of these, don't forget the
199 * corresponding NULL stub in if.c.
200 */
201 int (*if_output) /* output routine (enqueue) */
202 __P((struct ifnet *, struct mbuf *, struct sockaddr *,
203 struct rtentry *));
204 void (*if_input) /* input routine (from h/w driver) */
205 __P((struct ifnet *, struct mbuf *));
206 void (*if_start) /* initiate output routine */
207 __P((struct ifnet *));
208 int (*if_ioctl) /* ioctl routine */
209 __P((struct ifnet *, u_long, caddr_t));
210 int (*if_reset) /* XXX bus reset routine */
211 __P((struct ifnet *));
212 void (*if_watchdog) /* timer routine */
213 __P((struct ifnet *));
214 void (*if_drain) /* routine to release resources */
215 __P((struct ifnet *));
216 struct ifqueue {
217 struct mbuf *ifq_head;
218 struct mbuf *ifq_tail;
219 int ifq_len;
220 int ifq_maxlen;
221 int ifq_drops;
222 } if_snd; /* output queue */
223 struct sockaddr_dl *if_sadl; /* pointer to our sockaddr_dl */
224 u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
225 struct ifprefix *if_prefixlist; /* linked list of prefixes per if */
226 };
227 #define if_mtu if_data.ifi_mtu
228 #define if_type if_data.ifi_type
229 #define if_addrlen if_data.ifi_addrlen
230 #define if_hdrlen if_data.ifi_hdrlen
231 #define if_metric if_data.ifi_metric
232 #define if_baudrate if_data.ifi_baudrate
233 #define if_ipackets if_data.ifi_ipackets
234 #define if_ierrors if_data.ifi_ierrors
235 #define if_opackets if_data.ifi_opackets
236 #define if_oerrors if_data.ifi_oerrors
237 #define if_collisions if_data.ifi_collisions
238 #define if_ibytes if_data.ifi_ibytes
239 #define if_obytes if_data.ifi_obytes
240 #define if_imcasts if_data.ifi_imcasts
241 #define if_omcasts if_data.ifi_omcasts
242 #define if_iqdrops if_data.ifi_iqdrops
243 #define if_noproto if_data.ifi_noproto
244 #define if_lastchange if_data.ifi_lastchange
245
246 #define IFF_UP 0x1 /* interface is up */
247 #define IFF_BROADCAST 0x2 /* broadcast address valid */
248 #define IFF_DEBUG 0x4 /* turn on debugging */
249 #define IFF_LOOPBACK 0x8 /* is a loopback net */
250 #define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
251 #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
252 #define IFF_RUNNING 0x40 /* resources allocated */
253 #define IFF_NOARP 0x80 /* no address resolution protocol */
254 #define IFF_PROMISC 0x100 /* receive all packets */
255 #define IFF_ALLMULTI 0x200 /* receive all multicast packets */
256 #define IFF_OACTIVE 0x400 /* transmission in progress */
257 #define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
258 #define IFF_LINK0 0x1000 /* per link layer defined bit */
259 #define IFF_LINK1 0x2000 /* per link layer defined bit */
260 #define IFF_LINK2 0x4000 /* per link layer defined bit */
261 #define IFF_MULTICAST 0x8000 /* supports multicast */
262
263 /* flags set internally only: */
264 #define IFF_CANTCHANGE \
265 (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
266 IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
267
268 /*
269 * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
270 * input routines have queues of messages stored on ifqueue structures
271 * (defined above). Entries are added to and deleted from these structures
272 * by these macros, which should be called with ipl raised to splimp().
273 */
274 #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
275 #define IF_DROP(ifq) ((ifq)->ifq_drops++)
276 #define IF_ENQUEUE(ifq, m) { \
277 (m)->m_nextpkt = 0; \
278 if ((ifq)->ifq_tail == 0) \
279 (ifq)->ifq_head = m; \
280 else \
281 (ifq)->ifq_tail->m_nextpkt = m; \
282 (ifq)->ifq_tail = m; \
283 (ifq)->ifq_len++; \
284 }
285 #define IF_PREPEND(ifq, m) { \
286 (m)->m_nextpkt = (ifq)->ifq_head; \
287 if ((ifq)->ifq_tail == 0) \
288 (ifq)->ifq_tail = (m); \
289 (ifq)->ifq_head = (m); \
290 (ifq)->ifq_len++; \
291 }
292 #define IF_DEQUEUE(ifq, m) { \
293 (m) = (ifq)->ifq_head; \
294 if (m) { \
295 if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
296 (ifq)->ifq_tail = 0; \
297 (m)->m_nextpkt = 0; \
298 (ifq)->ifq_len--; \
299 } \
300 }
301
302 #define IFQ_MAXLEN 50
303 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
304
305 /*
306 * Structure defining statistics and other data kept regarding an address
307 * on a network interface.
308 */
309 struct ifaddr_data {
310 int64_t ifad_inbytes;
311 int64_t ifad_outbytes;
312 };
313
314 /*
315 * The ifaddr structure contains information about one address
316 * of an interface. They are maintained by the different address families,
317 * are allocated and attached when an address is set, and are linked
318 * together so all addresses for an interface can be located.
319 */
320 struct ifaddr {
321 struct sockaddr *ifa_addr; /* address of interface */
322 struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
323 #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
324 struct sockaddr *ifa_netmask; /* used to determine subnet */
325 struct ifnet *ifa_ifp; /* back-pointer to interface */
326 TAILQ_ENTRY(ifaddr) ifa_list; /* list of addresses for interface */
327 struct ifaddr_data ifa_data; /* statistics on the address */
328 void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
329 __P((int, struct rtentry *, struct sockaddr *));
330 u_int ifa_flags; /* mostly rt_flags for cloning */
331 int ifa_refcnt; /* count of references */
332 int ifa_metric; /* cost of going out this interface */
333 };
334 #define IFA_ROUTE RTF_UP /* route installed */
335
336 /*
337 * The prefix structure contains information about one prefix
338 * of an interface. They are maintained by the different address families,
339 * are allocated and attached when an prefix or an address is set,
340 * and are linked together so all prfefixes for an interface can be located.
341 */
342 struct ifprefix {
343 struct sockaddr *ifpr_prefix; /* prefix of interface */
344 struct ifnet *ifpr_ifp; /* back-pointer to interface */
345 struct ifprefix *ifpr_next;
346 u_char ifpr_plen; /* prefix length in bits */
347 u_char ifpr_type; /* protocol dependent prefix type */
348 };
349
350 /*
351 * Message format for use in obtaining information about interfaces
352 * from sysctl and the routing socket.
353 */
354 struct if_msghdr {
355 u_short ifm_msglen; /* to skip over non-understood messages */
356 u_char ifm_version; /* future binary compatability */
357 u_char ifm_type; /* message type */
358 int ifm_addrs; /* like rtm_addrs */
359 int ifm_flags; /* value of if_flags */
360 u_short ifm_index; /* index for associated ifp */
361 struct if_data ifm_data;/* statistics and other data about if */
362 };
363
364 #if defined(_KERNEL) && defined(COMPAT_14)
365 /* pre-1.5 if_msghdr (ifm_data changed) */
366 struct if_msghdr14 {
367 u_short ifm_msglen; /* to skip over non-understood messages */
368 u_char ifm_version; /* future binary compatability */
369 u_char ifm_type; /* message type */
370 int ifm_addrs; /* like rtm_addrs */
371 int ifm_flags; /* value of if_flags */
372 u_short ifm_index; /* index for associated ifp */
373 struct if_data14 ifm_data; /* statistics and other data about if */
374 };
375 #endif /* _KERNEL && COMPAT_14 */
376
377 /*
378 * Message format for use in obtaining information about interface addresses
379 * from sysctl and the routing socket.
380 */
381 struct ifa_msghdr {
382 u_short ifam_msglen; /* to skip over non-understood messages */
383 u_char ifam_version; /* future binary compatability */
384 u_char ifam_type; /* message type */
385 int ifam_addrs; /* like rtm_addrs */
386 int ifam_flags; /* value of ifa_flags */
387 u_short ifam_index; /* index for associated ifp */
388 int ifam_metric; /* value of ifa_metric */
389 };
390
391 /*
392 * Interface request structure used for socket
393 * ioctl's. All interface ioctl's must have parameter
394 * definitions which begin with ifr_name. The
395 * remainder may be interface specific.
396 */
397 struct ifreq {
398 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
399 union {
400 struct sockaddr ifru_addr;
401 struct sockaddr ifru_dstaddr;
402 struct sockaddr ifru_broadaddr;
403 short ifru_flags;
404 int ifru_metric;
405 int ifru_mtu;
406 u_int ifru_value;
407 caddr_t ifru_data;
408 } ifr_ifru;
409 #define ifr_addr ifr_ifru.ifru_addr /* address */
410 #define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
411 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
412 #define ifr_flags ifr_ifru.ifru_flags /* flags */
413 #define ifr_metric ifr_ifru.ifru_metric /* metric */
414 #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
415 #define ifr_value ifr_ifru.ifru_value /* generic value */
416 #define ifr_media ifr_ifru.ifru_metric /* media options (overload) */
417 #define ifr_data ifr_ifru.ifru_data /* for use by interface */
418 };
419
420 struct ifaliasreq {
421 char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
422 struct sockaddr ifra_addr;
423 struct sockaddr ifra_dstaddr;
424 #define ifra_broadaddr ifra_dstaddr
425 struct sockaddr ifra_mask;
426 };
427
428 struct ifmediareq {
429 char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
430 int ifm_current; /* current media options */
431 int ifm_mask; /* don't care mask */
432 int ifm_status; /* media status */
433 int ifm_active; /* active options */
434 int ifm_count; /* # entries in ifm_ulist
435 array */
436 int *ifm_ulist; /* media words */
437 };
438
439
440 struct ifdrv {
441 char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */
442 unsigned long ifd_cmd;
443 size_t ifd_len;
444 void *ifd_data;
445 };
446
447 /*
448 * Structure used in SIOCGIFCONF request.
449 * Used to retrieve interface configuration
450 * for machine (useful for programs which
451 * must know all networks accessible).
452 */
453 struct ifconf {
454 int ifc_len; /* size of associated buffer */
455 union {
456 caddr_t ifcu_buf;
457 struct ifreq *ifcu_req;
458 } ifc_ifcu;
459 #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
460 #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
461 };
462
463 /*
464 * Structure for SIOC[AGD]LIFADDR
465 */
466 struct if_laddrreq {
467 char iflr_name[IFNAMSIZ];
468 unsigned int flags;
469 #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */
470 unsigned int prefixlen; /* in/out */
471 struct sockaddr_storage addr; /* in/out */
472 struct sockaddr_storage dstaddr; /* out */
473 };
474
475 #include <net/if_arp.h>
476
477 #endif /* !_XOPEN_SOURCE */
478
479 #ifdef _KERNEL
480 #ifdef IFAREF_DEBUG
481 #define IFAREF(ifa) \
482 do { \
483 printf("IFAREF: %s:%d %p -> %d\n", __FILE__, __LINE__, \
484 (ifa), ++(ifa)->ifa_refcnt); \
485 } while (0)
486
487 #define IFAFREE(ifa) \
488 do { \
489 if ((ifa)->ifa_refcnt <= 0) \
490 panic("%s:%d: %p ifa_refcnt <= 0", __FILE__, \
491 __LINE__, (ifa)); \
492 printf("IFAFREE: %s:%d %p -> %d\n", __FILE__, __LINE__, \
493 (ifa), --(ifa)->ifa_refcnt); \
494 if ((ifa)->ifa_refcnt == 0) \
495 ifafree(ifa); \
496 } while (0)
497 #else
498 #define IFAREF(ifa) (ifa)->ifa_refcnt++
499
500 #ifdef DIAGNOSTIC
501 #define IFAFREE(ifa) \
502 do { \
503 if ((ifa)->ifa_refcnt <= 0) \
504 panic("%s:%d: %p ifa_refcnt <= 0", __FILE__, \
505 __LINE__, (ifa)); \
506 if (--(ifa)->ifa_refcnt == 0) \
507 ifafree(ifa); \
508 } while (0)
509 #else
510 #define IFAFREE(ifa) \
511 do { \
512 if (--(ifa)->ifa_refcnt == 0) \
513 ifafree(ifa); \
514 } while (0)
515 #endif /* DIAGNOSTIC */
516 #endif /* IFAREF_DEBUG */
517
518 struct ifnet_head ifnet;
519 struct ifnet **ifindex2ifnet;
520 #if 0
521 struct ifnet loif[];
522 #endif
523 int if_index;
524
525 void ether_ifattach __P((struct ifnet *, const u_int8_t *));
526 void ether_ifdetach __P((struct ifnet *));
527 char *ether_sprintf __P((const u_char *));
528
529 void if_attach __P((struct ifnet *));
530 void if_deactivate __P((struct ifnet *));
531 void if_detach __P((struct ifnet *));
532 void if_down __P((struct ifnet *));
533 void if_qflush __P((struct ifqueue *));
534 void if_slowtimo __P((void *));
535 void if_up __P((struct ifnet *));
536 int ifconf __P((u_long, caddr_t));
537 void ifinit __P((void));
538 int ifioctl __P((struct socket *, u_long, caddr_t, struct proc *));
539 int ifpromisc __P((struct ifnet *, int));
540 struct ifnet *ifunit __P((const char *));
541 struct ifnet *if_withname __P((struct sockaddr *));
542
543 struct ifaddr *ifa_ifwithaddr __P((struct sockaddr *));
544 struct ifaddr *ifa_ifwithaf __P((int));
545 struct ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *));
546 struct ifaddr *ifa_ifwithnet __P((struct sockaddr *));
547 struct ifaddr *ifa_ifwithladdr __P((struct sockaddr *));
548 struct ifaddr *ifa_ifwithroute __P((int, struct sockaddr *,
549 struct sockaddr *));
550 struct ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));
551 void ifafree __P((struct ifaddr *));
552 void link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
553
554 int loioctl __P((struct ifnet *, u_long, caddr_t));
555 void loopattach __P((int));
556 int looutput __P((struct ifnet *,
557 struct mbuf *, struct sockaddr *, struct rtentry *));
558 void lortrequest __P((int, struct rtentry *, struct sockaddr *));
559
560 /*
561 * These are exported because they're an easy way to tell if
562 * an interface is going away without having to burn a flag.
563 */
564 int if_nulloutput __P((struct ifnet *, struct mbuf *,
565 struct sockaddr *, struct rtentry *));
566 void if_nullinput __P((struct ifnet *, struct mbuf *));
567 void if_nullstart __P((struct ifnet *));
568 int if_nullioctl __P((struct ifnet *, u_long, caddr_t));
569 int if_nullreset __P((struct ifnet *));
570 void if_nullwatchdog __P((struct ifnet *));
571 void if_nulldrain __P((struct ifnet *));
572 #else
573 struct if_nameindex {
574 unsigned int if_index; /* 1, 2, ... */
575 char *if_name; /* null terminated name: "le0", ... */
576 };
577
578 #include <sys/cdefs.h>
579 __BEGIN_DECLS
580 unsigned int if_nametoindex __P((const char *));
581 char * if_indextoname __P((unsigned int, char *));
582 struct if_nameindex * if_nameindex __P((void));
583 void if_freenameindex __P((struct if_nameindex *));
584 __END_DECLS
585 #endif /* _KERNEL */
586 #endif /* !_NET_IF_H_ */
587