|
|
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: *
1.1.1.3 ! root 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.
1.1 root 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: short if_unit; /* unit number */
84: short if_flags; /* up/down, broadcast, etc. */
85: short if_timer; /* time until if_watchdog called */
86: short if_mtu; /* maximum transmission unit */
87: short if_header_size; /* length of header */
88: short if_header_format; /* format of hardware header */
89: short if_address_size; /* length of hardware address */
90: short if_alloc_size; /* size of read buffer to allocate */
91: char *if_address; /* pointer to hardware address */
92: struct ifqueue if_snd; /* output queue */
93: queue_head_t if_rcv_port_list; /* input filter list */
1.1.1.3 ! root 94: queue_head_t if_snd_port_list; /* output filter list */
! 95: decl_simple_lock_data(,
! 96: if_rcv_port_list_lock) /* lock for input filter list */
1.1 root 97: decl_simple_lock_data(,
1.1.1.3 ! root 98: if_snd_port_list_lock) /* lock for output filter list */
1.1 root 99: /* statistics */
100: int if_ipackets; /* packets received */
101: int if_ierrors; /* input errors */
102: int if_opackets; /* packets sent */
103: int if_oerrors; /* output errors */
104: int if_collisions; /* collisions on csma interfaces */
105: int if_rcvdrops; /* packets received but dropped */
106: };
107:
108: #define IFF_UP 0x0001 /* interface is up */
109: #define IFF_BROADCAST 0x0002 /* interface can broadcast */
110: #define IFF_DEBUG 0x0004 /* turn on debugging */
111: #define IFF_LOOPBACK 0x0008 /* is a loopback net */
112: #define IFF_POINTOPOINT 0x0010 /* point-to-point link */
113: #define IFF_RUNNING 0x0040 /* resources allocated */
114: #define IFF_NOARP 0x0080 /* no address resolution protocol */
115: #define IFF_PROMISC 0x0100 /* receive all packets */
116: #define IFF_ALLMULTI 0x0200 /* receive all multicast packets */
117: #define IFF_BRIDGE 0x0100 /* support token ring routing field */
118: #define IFF_SNAP 0x0200 /* support extended sap header */
119:
120: /* internal flags only: */
121: #define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
122:
123: /*
124: * Output queues (ifp->if_snd)
125: * have queues of messages stored on ifqueue structures. Entries
126: * are added to and deleted from these structures by these macros, which
127: * should be called with ipl raised to splimp().
128: * XXX locking XXX
129: */
130:
131: #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
132: #define IF_DROP(ifq) ((ifq)->ifq_drops++)
133: #define IF_ENQUEUE(ifq, ior) { \
134: simple_lock(&(ifq)->ifq_lock); \
135: enqueue_tail(&(ifq)->ifq_head, (queue_entry_t)ior); \
136: (ifq)->ifq_len++; \
137: simple_unlock(&(ifq)->ifq_lock); \
138: }
139: #define IF_PREPEND(ifq, ior) { \
140: simple_lock(&(ifq)->ifq_lock); \
141: enqueue_head(&(ifq)->ifq_head, (queue_entry_t)ior); \
142: (ifq)->ifq_len++; \
143: simple_unlock(&(ifq)->ifq_lock); \
144: }
145:
146: #define IF_DEQUEUE(ifq, ior) { \
147: simple_lock(&(ifq)->ifq_lock); \
148: if (((ior) = (io_req_t)dequeue_head(&(ifq)->ifq_head)) != 0) \
149: (ifq)->ifq_len--; \
150: simple_unlock(&(ifq)->ifq_lock); \
151: }
152:
153: #define IFQ_MAXLEN 50
154:
155: #define IFQ_INIT(ifq) { \
156: queue_init(&(ifq)->ifq_head); \
157: simple_lock_init(&(ifq)->ifq_lock); \
158: (ifq)->ifq_len = 0; \
159: (ifq)->ifq_maxlen = IFQ_MAXLEN; \
160: (ifq)->ifq_drops = 0; \
161: }
162:
163: #define IFNET_SLOWHZ 1 /* granularity is 1 second */
164:
1.1.1.2 root 165: #endif /* _IF_HDR_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.