|
|
1.1.1.2 root 1: /*
1.1 root 2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4: * All Rights Reserved.
1.1.1.2 root 5: *
1.1 root 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.
1.1.1.2 root 11: *
1.1 root 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.
1.1.1.2 root 15: *
1.1 root 16: * Carnegie Mellon requests users of this software to return to
1.1.1.2 root 17: *
1.1 root 18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
1.1.1.2 root 22: *
1.1 root 23: * any improvements or extensions that they make and grant Carnegie Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * Author: David B. Golub, Carnegie Mellon University
28: * Date: 3/89
29: *
30: * Status information for network interfaces.
31: */
32:
33: #ifndef _DEVICE_NET_STATUS_H_
34: #define _DEVICE_NET_STATUS_H_
35:
36: #include <device/device_types.h>
37: #include <mach/message.h>
38:
39: /*
40: * General interface status
41: */
42: struct net_status {
43: int min_packet_size; /* minimum size, including header */
44: int max_packet_size; /* maximum size, including header */
45: int header_format; /* format of network header */
46: int header_size; /* size of network header */
47: int address_size; /* size of network address */
48: int flags; /* interface status */
49: int mapped_size; /* if mappable, virtual mem needed */
50: };
51: #define NET_STATUS_COUNT (sizeof(struct net_status)/sizeof(int))
52: #define NET_STATUS (('n'<<16) + 1)
53:
54: /*
55: * Header formats, as given by RFC 826/1010 for ARP:
56: */
57: #define HDR_ETHERNET 1 /* Ethernet hardware address */
58: #define HDR_EXP_ETHERNET 2 /* 3Mhz experimental Ethernet
59: hardware address */
60: #define HDR_PRO_NET 4 /* Proteon ProNET Token Ring */
61: #define HDR_CHAOS 5 /* Chaosnet */
62: #define HDR_802 6 /* IEEE 802 networks */
63:
64:
65: /*
66: * A network address is an array of bytes. In order to return
67: * this in an array of (long) integers, it is returned in net order.
68: * Use 'ntohl' on each element of the array to retrieve the original
69: * ordering.
70: */
71: #define NET_ADDRESS (('n'<<16) + 2)
72:
73: #define NET_DSTADDR (('n'<<16) + 3)
74:
1.1.1.3 ! root 75: #define NET_FLAGS (('n'<<16) + 4)
1.1 root 76:
77: /*
78: * Input packet filter definition
79: */
80: #define NET_MAX_FILTER 128 /* was 64, bpf programs are big */
81: #define NET_FILTER_STACK_DEPTH 32
82:
83: /*
84: * We allow specification of up to NET_MAX_FILTER (short) words of a filter
85: * command list to be applied to incoming packets to determine if
86: * those packets should be given to a particular network input filter.
1.1.1.2 root 87: *
1.1 root 88: * Each network filter specifies the filter command list via net_add_filter.
89: * Each filter command list specifies a sequences of actions which leave a
90: * boolean value on the top of an internal stack. Each word of the
91: * command list specifies an action from the set {PUSHLIT, PUSHZERO,
92: * PUSHWORD+N} which respectively push the next word of the filter, zero,
93: * or word N of the incoming packet on the stack, and a binary operator
94: * from the set {EQ, LT, LE, GT, GE, AND, OR, XOR} which operates on the
95: * top two elements of the stack and replaces them with its result. The
96: * special action NOPUSH and the special operator NOP can be used to only
97: * perform the binary operation or to only push a value on the stack.
1.1.1.2 root 98: *
1.1 root 99: * If the final value of the filter operation is true, then the packet is
100: * accepted for the filter.
1.1.1.2 root 101: *
1.1.1.3 ! root 102: * The first filter_t object is a header which allows to set flags for the
! 103: * filter code. Main flags concern the direction of packets. This header is
! 104: * split in the same way NETF words are : the 6 MSB bits indicate the type
! 105: * of filter while the 10 LSB bits are the flags. For native NETF filters,
! 106: * clear the 6 MSB bits (which is why there is no dedicated macro).
1.1 root 107: */
108:
109: typedef unsigned short filter_t;
110: typedef filter_t *filter_array_t;
111:
112: #define CSPF_BYTES(n) ((n) * sizeof (filter_t))
113:
114: /* these must sum to 16! */
115: #define NETF_NBPA 10 /* # bits / argument */
116: #define NETF_NBPO 6 /* # bits / operator */
117:
118: #define NETF_ARG(word) ((word) & 0x3ff)
119: #define NETF_OP(word) (((word)>>NETF_NBPA)&0x3f)
120:
1.1.1.3 ! root 121: /* filter types */
! 122: #define NETF_TYPE_MASK (((1 << NETF_NBPO) - 1) << NETF_NBPA)
! 123: #define NETF_BPF (1 << NETF_NBPA)
! 124:
! 125: /* flags */
! 126: #define NETF_IN 0x1
! 127: #define NETF_OUT 0x2
! 128:
1.1 root 129: /* binary operators */
130: #define NETF_NOP (0<<NETF_NBPA)
131: #define NETF_EQ (1<<NETF_NBPA)
132: #define NETF_LT (2<<NETF_NBPA)
133: #define NETF_LE (3<<NETF_NBPA)
134: #define NETF_GT (4<<NETF_NBPA)
135: #define NETF_GE (5<<NETF_NBPA)
136: #define NETF_AND (6<<NETF_NBPA)
137: #define NETF_OR (7<<NETF_NBPA)
138: #define NETF_XOR (8<<NETF_NBPA)
139: #define NETF_COR (9<<NETF_NBPA)
140: #define NETF_CAND (10<<NETF_NBPA)
141: #define NETF_CNOR (11<<NETF_NBPA)
142: #define NETF_CNAND (12<<NETF_NBPA)
143: #define NETF_NEQ (13<<NETF_NBPA)
144: #define NETF_LSH (14<<NETF_NBPA)
145: #define NETF_RSH (15<<NETF_NBPA)
146: #define NETF_ADD (16<<NETF_NBPA)
147: #define NETF_SUB (17<<NETF_NBPA)
148:
149:
150: /* stack arguments */
151: #define NETF_NOPUSH 0 /* don`t push */
152: #define NETF_PUSHLIT 1 /* next word in filter */
153: #define NETF_PUSHZERO 2 /* 0 */
154: #define NETF_PUSHIND 14 /* word indexed by stack top */
155: #define NETF_PUSHHDRIND 15 /* header word indexed by stack top */
156: #define NETF_PUSHWORD 16 /* word 0 .. 944 in packet */
157: #define NETF_PUSHHDR 960 /* word 0 .. 31 in header */
158: #define NETF_PUSHSTK 992 /* word 0 .. 31 in stack */
159:
160: /* priorities */
161: #define NET_HI_PRI 100
162: #define NET_PRI_MAX 255
163:
164: /*
165: * BPF support.
166: */
167: #include <device/bpf.h>
168:
169: /*
170: * Net receive message format.
171: *
172: * The header and data are packaged separately, since some hardware
173: * supports variable-length headers. We prefix the packet with
174: * a packet_hdr structure so that the real data portion begins
175: * on a long-word boundary, and so that packet filters can address
176: * the type field and packet size uniformly.
177: */
178: #define NET_RCV_MAX 4095
179: #define NET_HDW_HDR_MAX 64
180:
181: #define NET_RCV_MSG_ID 2999 /* in device.defs reply range */
182:
183: struct packet_header {
184: unsigned short length;
185: unsigned short type; /* network order */
186: };
187:
188: struct net_rcv_msg {
189: mach_msg_header_t msg_hdr;
190: mach_msg_type_t header_type;
191: char header[NET_HDW_HDR_MAX];
192: mach_msg_type_t packet_type;
193: char packet[NET_RCV_MAX];
1.1.1.3 ! root 194: boolean_t sent;
1.1 root 195: };
196: typedef struct net_rcv_msg *net_rcv_msg_t;
197: #define net_rcv_msg_packet_count packet_type.msgt_number
198:
199:
200:
1.1.1.2 root 201: #endif /* _DEVICE_NET_STATUS_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.