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: net_status.h,v $
29 * Revision 2.9 93/08/10 15:11:09 mrt
30 * Bumped up max size of filter programs since bpf programs are big.
31 * [93/07/06 cmaeda]
32 *
33 * Added BPF support.
34 * [93/02/08 yuhara]
35 *
36 * Revision 2.8 92/02/25 15:34:48 elf
37 * Add support for ux, NET_DSTADDR, to say whether it is ok
38 * to establish a point to point for this interface.
39 * [92/02/21 rvb]
40 *
41 * Revision 2.7 92/01/03 20:04:18 dbg
42 * Add: NETF_PUSHHDR, NETF_PUSHSTK, NETF_PUSHIND, NETF_PUSHHDRIND.
43 * [91/12/23 dbg]
44 *
45 * Revision 2.6 91/05/14 16:00:25 mrt
46 * Correcting copyright
47 *
48 * Revision 2.5 91/02/05 17:10:08 mrt
49 * Changed to new Mach copyright
50 * [91/01/31 17:30:26 mrt]
51 *
52 * Revision 2.4 90/09/09 23:20:05 rpd
53 * Added mapped_size info for mapped interfaces.
54 * [90/08/30 17:41:27 af]
55 *
56 * Revision 2.3 90/08/27 21:55:30 dbg
57 * Allow more low-priority filters. Fix from Dan Julin.
58 * [90/08/27 dbg]
59 *
60 * Revision 2.2 90/06/02 14:48:24 rpd
61 * Converted to new IPC.
62 * [90/03/26 21:58:55 rpd]
63 *
64 * Revision 2.1 89/08/03 15:29:01 rwd
65 * Created.
66 *
67 * 14-Mar-89 David Golub (dbg) at Carnegie-Mellon University
68 * Created.
69 *
70 */
71 /*
72 * Author: David B. Golub, Carnegie Mellon University
73 * Date: 3/89
74 *
75 * Status information for network interfaces.
76 */
77
78 #ifndef _DEVICE_NET_STATUS_H_
79 #define _DEVICE_NET_STATUS_H_
80
81 #include <device/device_types.h>
82 #include <mach/message.h>
83
84 /*
85 * General interface status
86 */
87 struct net_status {
88 int min_packet_size; /* minimum size, including header */
89 int max_packet_size; /* maximum size, including header */
90 int header_format; /* format of network header */
91 int header_size; /* size of network header */
92 int address_size; /* size of network address */
93 int flags; /* interface status */
94 int mapped_size; /* if mappable, virtual mem needed */
95 };
96 #define NET_STATUS_COUNT (sizeof(struct net_status)/sizeof(int))
97 #define NET_STATUS (('n'<<16) + 1)
98
99 /*
100 * Header formats, as given by RFC 826/1010 for ARP:
101 */
102 #define HDR_ETHERNET 1 /* Ethernet hardware address */
103 #define HDR_EXP_ETHERNET 2 /* 3Mhz experimental Ethernet
104 hardware address */
105 #define HDR_PRO_NET 4 /* Proteon ProNET Token Ring */
106 #define HDR_CHAOS 5 /* Chaosnet */
107 #define HDR_802 6 /* IEEE 802 networks */
108
109
110 /*
111 * A network address is an array of bytes. In order to return
112 * this in an array of (long) integers, it is returned in net order.
113 * Use 'ntohl' on each element of the array to retrieve the original
114 * ordering.
115 */
116 #define NET_ADDRESS (('n'<<16) + 2)
117
118 #define NET_DSTADDR (('n'<<16) + 3)
119
120
121 /*
122 * Input packet filter definition
123 */
124 #define NET_MAX_FILTER 128 /* was 64, bpf programs are big */
125 #define NET_FILTER_STACK_DEPTH 32
126
127 /*
128 * We allow specification of up to NET_MAX_FILTER (short) words of a filter
129 * command list to be applied to incoming packets to determine if
130 * those packets should be given to a particular network input filter.
131 *
132 * Each network filter specifies the filter command list via net_add_filter.
133 * Each filter command list specifies a sequences of actions which leave a
134 * boolean value on the top of an internal stack. Each word of the
135 * command list specifies an action from the set {PUSHLIT, PUSHZERO,
136 * PUSHWORD+N} which respectively push the next word of the filter, zero,
137 * or word N of the incoming packet on the stack, and a binary operator
138 * from the set {EQ, LT, LE, GT, GE, AND, OR, XOR} which operates on the
139 * top two elements of the stack and replaces them with its result. The
140 * special action NOPUSH and the special operator NOP can be used to only
141 * perform the binary operation or to only push a value on the stack.
142 *
143 * If the final value of the filter operation is true, then the packet is
144 * accepted for the filter.
145 *
146 */
147
148 typedef unsigned short filter_t;
149 typedef filter_t *filter_array_t;
150
151 #define CSPF_BYTES(n) ((n) * sizeof (filter_t))
152
153 /* these must sum to 16! */
154 #define NETF_NBPA 10 /* # bits / argument */
155 #define NETF_NBPO 6 /* # bits / operator */
156
157 #define NETF_ARG(word) ((word) & 0x3ff)
158 #define NETF_OP(word) (((word)>>NETF_NBPA)&0x3f)
159
160 /* binary operators */
161 #define NETF_NOP (0<<NETF_NBPA)
162 #define NETF_EQ (1<<NETF_NBPA)
163 #define NETF_LT (2<<NETF_NBPA)
164 #define NETF_LE (3<<NETF_NBPA)
165 #define NETF_GT (4<<NETF_NBPA)
166 #define NETF_GE (5<<NETF_NBPA)
167 #define NETF_AND (6<<NETF_NBPA)
168 #define NETF_OR (7<<NETF_NBPA)
169 #define NETF_XOR (8<<NETF_NBPA)
170 #define NETF_COR (9<<NETF_NBPA)
171 #define NETF_CAND (10<<NETF_NBPA)
172 #define NETF_CNOR (11<<NETF_NBPA)
173 #define NETF_CNAND (12<<NETF_NBPA)
174 #define NETF_NEQ (13<<NETF_NBPA)
175 #define NETF_LSH (14<<NETF_NBPA)
176 #define NETF_RSH (15<<NETF_NBPA)
177 #define NETF_ADD (16<<NETF_NBPA)
178 #define NETF_SUB (17<<NETF_NBPA)
179 #define NETF_BPF (((1 << NETF_NBPO) - 1) << NETF_NBPA)
180
181
182 /* stack arguments */
183 #define NETF_NOPUSH 0 /* don`t push */
184 #define NETF_PUSHLIT 1 /* next word in filter */
185 #define NETF_PUSHZERO 2 /* 0 */
186 #define NETF_PUSHIND 14 /* word indexed by stack top */
187 #define NETF_PUSHHDRIND 15 /* header word indexed by stack top */
188 #define NETF_PUSHWORD 16 /* word 0 .. 944 in packet */
189 #define NETF_PUSHHDR 960 /* word 0 .. 31 in header */
190 #define NETF_PUSHSTK 992 /* word 0 .. 31 in stack */
191
192 /* priorities */
193 #define NET_HI_PRI 100
194 #define NET_PRI_MAX 255
195
196 /*
197 * BPF support.
198 */
199 #include <device/bpf.h>
200
201 /*
202 * Net receive message format.
203 *
204 * The header and data are packaged separately, since some hardware
205 * supports variable-length headers. We prefix the packet with
206 * a packet_hdr structure so that the real data portion begins
207 * on a long-word boundary, and so that packet filters can address
208 * the type field and packet size uniformly.
209 */
210 #define NET_RCV_MAX 4095
211 #define NET_HDW_HDR_MAX 64
212
213 #define NET_RCV_MSG_ID 2999 /* in device.defs reply range */
214
215 struct packet_header {
216 unsigned short length;
217 unsigned short type; /* network order */
218 };
219
220 struct net_rcv_msg {
221 mach_msg_header_t msg_hdr;
222 mach_msg_type_t header_type;
223 char header[NET_HDW_HDR_MAX];
224 mach_msg_type_t packet_type;
225 char packet[NET_RCV_MAX];
226 };
227 typedef struct net_rcv_msg *net_rcv_msg_t;
228 #define net_rcv_msg_packet_count packet_type.msgt_number
229
230
231
232 #endif _DEVICE_NET_STATUS_H_
Cache object: d63cd77feb7eebc08edfc468507113ab
|