FreeBSD/Linux Kernel Cross Reference
sys/device/if_hdr.h
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 Software.Distribution@CS.CMU.EDU
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 * HISTORY
28 * $Log: if_hdr.h,v $
29 * Revision 2.5 91/05/14 15:48:37 mrt
30 * Correcting copyright
31 *
32 * Revision 2.4 91/02/05 17:09:44 mrt
33 * Changed to new Mach copyright
34 * [91/01/31 17:29:39 mrt]
35 *
36 * Revision 2.3 90/09/09 14:31:33 rpd
37 * Use decl_simple_lock_data.
38 * [90/08/30 rpd]
39 *
40 * Revision 2.2 90/01/11 11:42:08 dbg
41 * Add locking.
42 * [89/11/27 dbg]
43 *
44 * Revision 2.1 89/08/03 15:28:52 rwd
45 * Created.
46 *
47 * 13-Mar-89 David Golub (dbg) at Carnegie-Mellon University
48 * Added packet filter.
49 *
50 * 3-Mar-89 David Golub (dbg) at Carnegie-Mellon University
51 * Created.
52 */
53 /*
54 * Taken from (bsd)net/if.h. Modified for MACH kernel.
55 */
56 /*
57 * Copyright (c) 1982, 1986 Regents of the University of California.
58 * All rights reserved.
59 *
60 * Redistribution and use in source and binary forms are permitted
61 * provided that the above copyright notice and this paragraph are
62 * duplicated in all such forms and that any documentation,
63 * advertising materials, and other materials related to such
64 * distribution and use acknowledge that the software was developed
65 * by the University of California, Berkeley. The name of the
66 * University may not be used to endorse or promote products derived
67 * from this software without specific prior written permission.
68 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
69 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
70 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
71 *
72 * @(#)if.h 7.3 (Berkeley) 6/27/88
73 */
74
75 #ifndef _IF_HDR_
76 #define _IF_HDR_
77
78 #include <kern/lock.h>
79 #include <kern/queue.h>
80
81 /*
82 * Queue for network output and filter input.
83 */
84 struct ifqueue {
85 queue_head_t ifq_head; /* queue of io_req_t */
86 int ifq_len; /* length of queue */
87 int ifq_maxlen; /* maximum length of queue */
88 int ifq_drops; /* number of packets dropped
89 because queue full */
90 decl_simple_lock_data(,
91 ifq_lock) /* lock for queue and counters */
92 };
93
94 /*
95 * Header for network interface drivers.
96 */
97 struct ifnet {
98 short if_unit; /* unit number */
99 short if_flags; /* up/down, broadcast, etc. */
100 short if_timer; /* time until if_watchdog called */
101 short if_mtu; /* maximum transmission unit */
102 short if_header_size; /* length of header */
103 short if_header_format; /* format of hardware header */
104 short if_address_size; /* length of hardware address */
105 short if_alloc_size; /* size of read buffer to allocate */
106 char *if_address; /* pointer to hardware address */
107 struct ifqueue if_snd; /* output queue */
108 queue_head_t if_rcv_port_list; /* input filter list */
109 decl_simple_lock_data(,
110 if_rcv_port_list_lock) /* lock for filter list */
111 /* statistics */
112 int if_ipackets; /* packets received */
113 int if_ierrors; /* input errors */
114 int if_opackets; /* packets sent */
115 int if_oerrors; /* output errors */
116 int if_collisions; /* collisions on csma interfaces */
117 int if_rcvdrops; /* packets received but dropped */
118 };
119
120 #define IFF_UP 0x0001 /* interface is up */
121 #define IFF_BROADCAST 0x0002 /* interface can broadcast */
122 #define IFF_DEBUG 0x0004 /* turn on debugging */
123 #define IFF_LOOPBACK 0x0008 /* is a loopback net */
124 #define IFF_POINTOPOINT 0x0010 /* point-to-point link */
125 #define IFF_RUNNING 0x0040 /* resources allocated */
126 #define IFF_NOARP 0x0080 /* no address resolution protocol */
127 #define IFF_PROMISC 0x0100 /* receive all packets */
128 #define IFF_ALLMULTI 0x0200 /* receive all multicast packets */
129 #define IFF_BRIDGE 0x0100 /* support token ring routing field */
130 #define IFF_SNAP 0x0200 /* support extended sap header */
131
132 /* internal flags only: */
133 #define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
134
135 /*
136 * Output queues (ifp->if_snd)
137 * have queues of messages stored on ifqueue structures. Entries
138 * are added to and deleted from these structures by these macros, which
139 * should be called with ipl raised to splimp().
140 * XXX locking XXX
141 */
142
143 #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
144 #define IF_DROP(ifq) ((ifq)->ifq_drops++)
145 #define IF_ENQUEUE(ifq, ior) { \
146 simple_lock(&(ifq)->ifq_lock); \
147 enqueue_tail(&(ifq)->ifq_head, (queue_entry_t)ior); \
148 (ifq)->ifq_len++; \
149 simple_unlock(&(ifq)->ifq_lock); \
150 }
151 #define IF_PREPEND(ifq, ior) { \
152 simple_lock(&(ifq)->ifq_lock); \
153 enqueue_head(&(ifq)->ifq_head, (queue_entry_t)ior); \
154 (ifq)->ifq_len++; \
155 simple_unlock(&(ifq)->ifq_lock); \
156 }
157
158 #define IF_DEQUEUE(ifq, ior) { \
159 simple_lock(&(ifq)->ifq_lock); \
160 if (((ior) = (io_req_t)dequeue_head(&(ifq)->ifq_head)) != 0) \
161 (ifq)->ifq_len--; \
162 simple_unlock(&(ifq)->ifq_lock); \
163 }
164
165 #define IFQ_MAXLEN 50
166
167 #define IFQ_INIT(ifq) { \
168 queue_init(&(ifq)->ifq_head); \
169 simple_lock_init(&(ifq)->ifq_lock); \
170 (ifq)->ifq_len = 0; \
171 (ifq)->ifq_maxlen = IFQ_MAXLEN; \
172 (ifq)->ifq_drops = 0; \
173 }
174
175 #define IFNET_SLOWHZ 1 /* granularity is 1 second */
176
177 #endif _IF_HDR_
Cache object: fb891af2d9254f9a87d3a3db568b18b6
|