|
|
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 are permitted
34: * provided that the above copyright notice and this paragraph are
35: * duplicated in all such forms and that any documentation,
36: * advertising materials, and other materials related to such
37: * distribution and use acknowledge that the software was developed
38: * by the University of California, Berkeley. The name of the
39: * University may not be used to endorse or promote products derived
40: * from this software without specific prior written permission.
41: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
42: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
43: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
44: *
45: * @(#)if.h 7.3 (Berkeley) 6/27/88
46: */
47:
48: #ifndef _IF_HDR_
49: #define _IF_HDR_
50:
51: #include <kern/lock.h>
52: #include <kern/queue.h>
53:
54: /*
55: * Queue for network output and filter input.
56: */
57: struct ifqueue {
58: queue_head_t ifq_head; /* queue of io_req_t */
59: int ifq_len; /* length of queue */
60: int ifq_maxlen; /* maximum length of queue */
61: int ifq_drops; /* number of packets dropped
62: because queue full */
63: decl_simple_lock_data(,
64: ifq_lock) /* lock for queue and counters */
65: };
66:
67: /*
68: * Header for network interface drivers.
69: */
70: struct ifnet {
71: short if_unit; /* unit number */
72: short if_flags; /* up/down, broadcast, etc. */
73: short if_timer; /* time until if_watchdog called */
74: short if_mtu; /* maximum transmission unit */
75: short if_header_size; /* length of header */
76: short if_header_format; /* format of hardware header */
77: short if_address_size; /* length of hardware address */
78: short if_alloc_size; /* size of read buffer to allocate */
79: char *if_address; /* pointer to hardware address */
80: struct ifqueue if_snd; /* output queue */
81: queue_head_t if_rcv_port_list; /* input filter list */
82: decl_simple_lock_data(,
83: if_rcv_port_list_lock) /* lock for filter list */
84: /* statistics */
85: int if_ipackets; /* packets received */
86: int if_ierrors; /* input errors */
87: int if_opackets; /* packets sent */
88: int if_oerrors; /* output errors */
89: int if_collisions; /* collisions on csma interfaces */
90: int if_rcvdrops; /* packets received but dropped */
91: };
92:
93: #define IFF_UP 0x0001 /* interface is up */
94: #define IFF_BROADCAST 0x0002 /* interface can broadcast */
95: #define IFF_DEBUG 0x0004 /* turn on debugging */
96: #define IFF_LOOPBACK 0x0008 /* is a loopback net */
97: #define IFF_POINTOPOINT 0x0010 /* point-to-point link */
98: #define IFF_RUNNING 0x0040 /* resources allocated */
99: #define IFF_NOARP 0x0080 /* no address resolution protocol */
100: #define IFF_PROMISC 0x0100 /* receive all packets */
101: #define IFF_ALLMULTI 0x0200 /* receive all multicast packets */
102: #define IFF_BRIDGE 0x0100 /* support token ring routing field */
103: #define IFF_SNAP 0x0200 /* support extended sap header */
104:
105: /* internal flags only: */
106: #define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
107:
108: /*
109: * Output queues (ifp->if_snd)
110: * have queues of messages stored on ifqueue structures. Entries
111: * are added to and deleted from these structures by these macros, which
112: * should be called with ipl raised to splimp().
113: * XXX locking XXX
114: */
115:
116: #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
117: #define IF_DROP(ifq) ((ifq)->ifq_drops++)
118: #define IF_ENQUEUE(ifq, ior) { \
119: simple_lock(&(ifq)->ifq_lock); \
120: enqueue_tail(&(ifq)->ifq_head, (queue_entry_t)ior); \
121: (ifq)->ifq_len++; \
122: simple_unlock(&(ifq)->ifq_lock); \
123: }
124: #define IF_PREPEND(ifq, ior) { \
125: simple_lock(&(ifq)->ifq_lock); \
126: enqueue_head(&(ifq)->ifq_head, (queue_entry_t)ior); \
127: (ifq)->ifq_len++; \
128: simple_unlock(&(ifq)->ifq_lock); \
129: }
130:
131: #define IF_DEQUEUE(ifq, ior) { \
132: simple_lock(&(ifq)->ifq_lock); \
133: if (((ior) = (io_req_t)dequeue_head(&(ifq)->ifq_head)) != 0) \
134: (ifq)->ifq_len--; \
135: simple_unlock(&(ifq)->ifq_lock); \
136: }
137:
138: #define IFQ_MAXLEN 50
139:
140: #define IFQ_INIT(ifq) { \
141: queue_init(&(ifq)->ifq_head); \
142: simple_lock_init(&(ifq)->ifq_lock); \
143: (ifq)->ifq_len = 0; \
144: (ifq)->ifq_maxlen = IFQ_MAXLEN; \
145: (ifq)->ifq_drops = 0; \
146: }
147:
148: #define IFNET_SLOWHZ 1 /* granularity is 1 second */
149:
150: #endif _IF_HDR_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.