Back to index

lightning-sunbird  0.9+nobinonly
if.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1982, 1986, 1989, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * [3 Deleted as of 22Jul99, see
00014  *     ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00015  *        for details]
00016  * 4. Neither the name of the University nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  *     @(#)if.h      8.1 (Berkeley) 6/10/93
00033  */
00034 
00035 /* Adapted for GUSI by Matthias Neeracher <neeri@iis.ee.ethz.ch> */
00036 
00037 /*
00038  * Structures defining a network interface, providing a packet
00039  * transport mechanism (ala level 0 of the PUP protocols).
00040  *
00041  * Each interface accepts output datagrams of a specified maximum
00042  * length, and provides higher level routines with input datagrams
00043  * received from its medium.
00044  *
00045  * Output occurs when the routine if_output is called, with three parameters:
00046  *     (*ifp->if_output)(ifp, m, dst, rt)
00047  * Here m is the mbuf chain to be sent and dst is the destination address.
00048  * The output routine encapsulates the supplied datagram if necessary,
00049  * and then transmits it on its medium.
00050  *
00051  * On input, each interface unwraps the data received by it, and either
00052  * places it on the input queue of a internetwork datagram routine
00053  * and posts the associated software interrupt, or passes the datagram to a raw
00054  * packet input routine.
00055  *
00056  * Routines exist for locating interfaces by their addresses
00057  * or for locating a interface on a certain network, as well as more general
00058  * routing and gateway routines maintaining information used to locate
00059  * interfaces.  These routines live in the files if.c and route.c
00060  */
00061 
00062 #define       IFF_UP        0x1           /* interface is up */
00063 #define       IFF_BROADCAST 0x2           /* broadcast address valid */
00064 #define       IFF_DEBUG     0x4           /* turn on debugging */
00065 #define       IFF_LOOPBACK  0x8           /* is a loopback net */
00066 #define       IFF_POINTOPOINT      0x10          /* interface is point-to-point link */
00067 #define       IFF_NOTRAILERS       0x20          /* avoid use of trailers */
00068 #define       IFF_RUNNING   0x40          /* resources allocated */
00069 #define       IFF_NOARP     0x80          /* no address resolution protocol */
00070 #define       IFF_PROMISC   0x100         /* receive all packets */
00071 #define       IFF_ALLMULTI  0x200         /* receive all multicast packets */
00072 #define       IFF_OACTIVE   0x400         /* transmission in progress */
00073 #define       IFF_SIMPLEX   0x800         /* can't hear own transmissions */
00074 #define       IFF_LINK0     0x1000        /* per link layer defined bit */
00075 #define       IFF_LINK1     0x2000        /* per link layer defined bit */
00076 #define       IFF_LINK2     0x4000        /* per link layer defined bit */
00077 #define       IFF_MULTICAST 0x8000        /* supports multicast */
00078 
00079 /* flags set internally only: */
00080 #define       IFF_CANTCHANGE \
00081        (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
00082            IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
00083 
00084 /*
00085  * Interface request structure used for socket
00086  * ioctl's.  All interface ioctl's must have parameter
00087  * definitions which begin with ifr_name.  The
00088  * remainder may be interface specific.
00089  */
00090 struct ifreq {
00091 #define       IFNAMSIZ      16
00092        char   ifr_name[IFNAMSIZ];         /* if name, e.g. "en0" */
00093        union {
00094               struct sockaddr ifru_addr;
00095               struct sockaddr ifru_dstaddr;
00096               struct sockaddr ifru_broadaddr;
00097               short  ifru_flags;
00098               int    ifru_metric;
00099               caddr_t       ifru_data;
00100        } ifr_ifru;
00101 #define       ifr_addr      ifr_ifru.ifru_addr   /* address */
00102 #define       ifr_dstaddr   ifr_ifru.ifru_dstaddr       /* other end of p-to-p link */
00103 #define       ifr_broadaddr ifr_ifru.ifru_broadaddr     /* broadcast address */
00104 #define       ifr_flags     ifr_ifru.ifru_flags  /* flags */
00105 #define       ifr_metric    ifr_ifru.ifru_metric /* metric */
00106 #define       ifr_data      ifr_ifru.ifru_data   /* for use by interface */
00107 };
00108 
00109 struct ifaliasreq {
00110        char   ifra_name[IFNAMSIZ];        /* if name, e.g. "en0" */
00111        struct sockaddr ifra_addr;
00112        struct sockaddr ifra_broadaddr;
00113        struct sockaddr ifra_mask;
00114 };
00115 
00116 /*
00117  * Structure used in SIOCGIFCONF request.
00118  * Used to retrieve interface configuration
00119  * for machine (useful for programs which
00120  * must know all networks accessible).
00121  */
00122 struct ifconf {
00123        int    ifc_len;             /* size of associated buffer */
00124        union {
00125               caddr_t       ifcu_buf;
00126               struct ifreq *ifcu_req;
00127        } ifc_ifcu;
00128 #define       ifc_buf       ifc_ifcu.ifcu_buf    /* buffer address */
00129 #define       ifc_req       ifc_ifcu.ifcu_req    /* array of structures returned */
00130 };
00131