Annotation of OSKit-Mach/device/if_hdr.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  *
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  *
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  *
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  *
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  *
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     Taken from (bsd)net/if.h.  Modified for MACH kernel.
        !            28:  */
        !            29: /*
        !            30:  * Copyright (c) 1982, 1986 Regents of the University of California.
        !            31:  * All rights reserved.
        !            32:  *
        !            33:  * Redistribution and use in source and binary forms, with or without
        !            34:  * modification, are permitted provided that the following conditions
        !            35:  * are met:
        !            36:  * 1. Redistributions of source code must retain the above copyright
        !            37:  *    notice, this list of conditions and the following disclaimer.
        !            38:  * 2. Redistributions in binary form must reproduce the above copyright
        !            39:  *    notice, this list of conditions and the following disclaimer in the
        !            40:  *    documentation and/or other materials provided with the distribution.
        !            41:  * 4. The name of the Laboratory may not be used to endorse or promote
        !            42:  *    products derived from this software without specific prior written
        !            43:  *    permission.
        !            44:  *
        !            45:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            46:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            47:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            48:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            49:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            50:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            51:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            52:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            53:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            54:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            55:  * SUCH DAMAGE.
        !            56:  *
        !            57:  *     @(#)if.h        7.3 (Berkeley) 6/27/88
        !            58:  */
        !            59: 
        !            60: #ifndef        _IF_HDR_
        !            61: #define        _IF_HDR_
        !            62: 
        !            63: #include <kern/lock.h>
        !            64: #include <kern/queue.h>
        !            65: 
        !            66: /*
        !            67:  * Queue for network output and filter input.
        !            68:  */
        !            69: struct ifqueue {
        !            70:        queue_head_t    ifq_head;       /* queue of io_req_t */
        !            71:        int             ifq_len;        /* length of queue */
        !            72:        int             ifq_maxlen;     /* maximum length of queue */
        !            73:        int             ifq_drops;      /* number of packets dropped
        !            74:                                           because queue full */
        !            75:        decl_simple_lock_data(,
        !            76:                        ifq_lock)       /* lock for queue and counters */
        !            77: };
        !            78: 
        !            79: /*
        !            80:  * Header for network interface drivers.
        !            81:  */
        !            82: struct ifnet {
        !            83: #if 0
        !            84:        short   if_unit;                /* unit number */
        !            85:        short   if_flags;               /* up/down, broadcast, etc. */
        !            86:        short   if_timer;               /* time until if_watchdog called */
        !            87:        short   if_mtu;                 /* maximum transmission unit */
        !            88:        short   if_header_size;         /* length of header */
        !            89:        short   if_header_format;       /* format of hardware header */
        !            90:        short   if_address_size;        /* length of hardware address */
        !            91:        short   if_alloc_size;          /* size of read buffer to allocate */
        !            92:        char    *if_address;            /* pointer to hardware address */
        !            93:        struct ifqueue if_snd;          /* output queue */
        !            94: #endif
        !            95:        queue_head_t if_rcv_port_list;  /* input filter list */
        !            96:        decl_simple_lock_data(,
        !            97:                if_rcv_port_list_lock)  /* lock for filter list */
        !            98: /* statistics */
        !            99:        int     if_ipackets;            /* packets received */
        !           100:        int     if_ierrors;             /* input errors */
        !           101:        int     if_opackets;            /* packets sent */
        !           102:        int     if_oerrors;             /* output errors */
        !           103:        int     if_collisions;          /* collisions on csma interfaces */
        !           104:        int     if_rcvdrops;            /* packets received but dropped */
        !           105: };
        !           106: 
        !           107: #define        IFF_UP          0x0001          /* interface is up */
        !           108: #define        IFF_BROADCAST   0x0002          /* interface can broadcast */
        !           109: #define        IFF_DEBUG       0x0004          /* turn on debugging */
        !           110: #define        IFF_LOOPBACK    0x0008          /* is a loopback net */
        !           111: #define        IFF_POINTOPOINT 0x0010          /* point-to-point link */
        !           112: #define        IFF_RUNNING     0x0040          /* resources allocated */
        !           113: #define        IFF_NOARP       0x0080          /* no address resolution protocol */
        !           114: #define        IFF_PROMISC     0x0100          /* receive all packets */
        !           115: #define        IFF_ALLMULTI    0x0200          /* receive all multicast packets */
        !           116: #define        IFF_BRIDGE      0x0100          /* support token ring routing field */
        !           117: #define        IFF_SNAP        0x0200          /* support extended sap header */
        !           118: 
        !           119: /* internal flags only: */
        !           120: #define        IFF_CANTCHANGE  (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
        !           121: 
        !           122: /*
        !           123:  * Output queues (ifp->if_snd)
        !           124:  * have queues of messages stored on ifqueue structures.  Entries
        !           125:  * are added to and deleted from these structures by these macros, which
        !           126:  * should be called with ipl raised to splimp().
        !           127:  * XXX locking XXX
        !           128:  */
        !           129: 
        !           130: #define        IF_QFULL(ifq)           ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
        !           131: #define        IF_DROP(ifq)            ((ifq)->ifq_drops++)
        !           132: #define        IF_ENQUEUE(ifq, ior) { \
        !           133:        simple_lock(&(ifq)->ifq_lock); \
        !           134:        enqueue_tail(&(ifq)->ifq_head, (queue_entry_t)ior); \
        !           135:        (ifq)->ifq_len++; \
        !           136:        simple_unlock(&(ifq)->ifq_lock); \
        !           137: }
        !           138: #define        IF_PREPEND(ifq, ior) { \
        !           139:        simple_lock(&(ifq)->ifq_lock); \
        !           140:        enqueue_head(&(ifq)->ifq_head, (queue_entry_t)ior); \
        !           141:        (ifq)->ifq_len++; \
        !           142:        simple_unlock(&(ifq)->ifq_lock); \
        !           143: }
        !           144: 
        !           145: #define        IF_DEQUEUE(ifq, ior) { \
        !           146:        simple_lock(&(ifq)->ifq_lock); \
        !           147:        if (((ior) = (io_req_t)dequeue_head(&(ifq)->ifq_head)) != 0) \
        !           148:            (ifq)->ifq_len--; \
        !           149:        simple_unlock(&(ifq)->ifq_lock); \
        !           150: }
        !           151: 
        !           152: #define        IFQ_MAXLEN      50
        !           153: 
        !           154: #define        IFQ_INIT(ifq) { \
        !           155:        queue_init(&(ifq)->ifq_head); \
        !           156:        simple_lock_init(&(ifq)->ifq_lock); \
        !           157:        (ifq)->ifq_len = 0; \
        !           158:        (ifq)->ifq_maxlen = IFQ_MAXLEN; \
        !           159:        (ifq)->ifq_drops = 0; \
        !           160: }
        !           161: 
        !           162: #define        IFNET_SLOWHZ    1               /* granularity is 1 second */
        !           163: 
        !           164: #endif /* _IF_HDR_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.