]>
Commit | Line | Data |
---|---|---|
b7080c8e A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights | |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.0 (the 'License'). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
13 | * | |
14 | * The Original Code and all software distributed under the License are | |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License." | |
21 | * | |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | /* | |
25 | * Copyright (c) 1988, 1992 The University of Utah and the Center | |
26 | * for Software Science (CSS). | |
27 | * Copyright (c) 1992, 1993 | |
28 | * The Regents of the University of California. All rights reserved. | |
29 | * | |
30 | * This code is derived from software contributed to Berkeley by | |
31 | * the Center for Software Science of the University of Utah Computer | |
32 | * Science Department. CSS requests users of this software to return | |
33 | * to css-dist@cs.utah.edu any improvements that they make and grant | |
34 | * CSS redistribution rights. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)rmp_var.h 8.1 (Berkeley) 6/4/93 | |
65 | * | |
66 | * Utah $Hdr: rmp_var.h 3.1 92/07/06$ | |
67 | * Author: Jeff Forys, University of Utah CSS | |
68 | */ | |
69 | ||
70 | /* | |
71 | * Possible values for "rmp_type" fields. | |
72 | */ | |
73 | ||
74 | #define RMP_BOOT_REQ 1 /* boot request packet */ | |
75 | #define RMP_BOOT_REPL 129 /* boot reply packet */ | |
76 | #define RMP_READ_REQ 2 /* read request packet */ | |
77 | #define RMP_READ_REPL 130 /* read reply packet */ | |
78 | #define RMP_BOOT_DONE 3 /* boot complete packet */ | |
79 | ||
80 | /* | |
81 | * Useful constants. | |
82 | */ | |
83 | ||
84 | #define RMP_VERSION 2 /* protocol version */ | |
85 | #define RMP_TIMEOUT 600 /* timeout connection after ten minutes */ | |
86 | #define RMP_PROBESID 0xffff /* session ID for probes */ | |
87 | #define RMP_HOSTLEN 13 /* max length of server's name */ | |
88 | #define RMP_MACHLEN 20 /* length of machine type field */ | |
89 | ||
90 | /* | |
91 | * RMP error codes | |
92 | */ | |
93 | ||
94 | #define RMP_E_OKAY 0 | |
95 | #define RMP_E_EOF 2 /* read reply: returned end of file */ | |
96 | #define RMP_E_ABORT 3 /* abort operation */ | |
97 | #define RMP_E_BUSY 4 /* boot reply: server busy */ | |
98 | #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */ | |
99 | #define RMP_E_NOFILE 16 /* boot reply: file does not exist */ | |
100 | #define RMP_E_OPENFILE 17 /* boot reply: file open failed */ | |
101 | #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */ | |
102 | #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */ | |
103 | #define RMP_E_BADSID 25 /* read reply: bad session ID */ | |
104 | #define RMP_E_BADPACKET 27 /* Bad packet detected */ | |
105 | ||
106 | /* | |
107 | * RMPDATALEN is the maximum number of data octets that can be stuffed | |
108 | * into an RMP packet. This excludes the 802.2 LLC w/HP extensions. | |
109 | */ | |
110 | #define RMPDATALEN (RMP_MAX_PACKET - (sizeof(struct hp_hdr) + \ | |
111 | sizeof(struct hp_llc))) | |
112 | ||
113 | /* | |
114 | * Define sizes of packets we send. Boot and Read replies are variable | |
115 | * in length depending on the length of `s'. | |
116 | * | |
117 | * Also, define how much space `restofpkt' can take up for outgoing | |
118 | * Boot and Read replies. Boot Request packets are effectively | |
119 | * limited to 255 bytes due to the preceding 1-byte length field. | |
120 | */ | |
121 | ||
122 | #define RMPBOOTSIZE(s) (sizeof(struct hp_hdr) + sizeof(struct hp_llc) + \ | |
123 | sizeof(struct rmp_boot_repl) + s - sizeof(restofpkt)) | |
124 | #define RMPREADSIZE(s) (sizeof(struct hp_hdr) + sizeof(struct hp_llc) + \ | |
125 | sizeof(struct rmp_read_repl) + s - sizeof(restofpkt) \ | |
126 | - sizeof(u_char)) | |
127 | #define RMPDONESIZE (sizeof(struct hp_hdr) + sizeof(struct hp_llc) + \ | |
128 | sizeof(struct rmp_boot_done)) | |
129 | #define RMPBOOTDATA 255 | |
130 | #define RMPREADDATA (RMPDATALEN - \ | |
131 | (2*sizeof(u_char)+sizeof(u_short)+sizeof(u_word))) | |
132 | ||
133 | /* | |
134 | * This protocol defines some field sizes as "rest of ethernet packet". | |
135 | * There is no easy way to specify this in C, so we use a one character | |
136 | * field to denote it, and index past it to the end of the packet. | |
137 | */ | |
138 | ||
139 | typedef char restofpkt; | |
140 | ||
141 | /* | |
142 | * Due to the RMP packet layout, we'll run into alignment problems | |
143 | * on machines that cant access words on half-word boundaries. If | |
144 | * you know that your machine does not suffer from this problem, | |
145 | * add it to the hp300 #define below. | |
146 | * | |
147 | * The following macros are used to deal with this problem: | |
148 | * WORDZE(w) Return True if u_word `w' is zero, False otherwise. | |
149 | * ZEROWORD(w) Set u_word `w' to zero. | |
150 | * COPYWORD(w1,w2) Copy u_word `w1' to `w2'. | |
151 | * GETWORD(w,i) Copy u_word `w' into int `i'. | |
152 | * PUTWORD(i,w) Copy int `i' into u_word `w'. | |
153 | * | |
154 | * N.B. We do not support little endian alignment-challenged machines. | |
155 | */ | |
156 | #if defined(vax) || defined(tahoe) || defined(hp300) | |
157 | ||
158 | typedef u_int u_word; | |
159 | ||
160 | #define WORDZE(w) ((w) == 0) | |
161 | #define ZEROWORD(w) (w) = 0 | |
162 | #define COPYWORD(w1,w2) (w2) = (w1) | |
163 | #define GETWORD(w, i) (i) = (w) | |
164 | #define PUTWORD(i, w) (w) = (i) | |
165 | ||
166 | #else | |
167 | ||
168 | #define _WORD_HIGHPART 0 /* XXX: assume Big Endian for now */ | |
169 | #define _WORD_LOWPART 1 | |
170 | ||
171 | typedef struct _uword { u_short val[2]; } u_word; | |
172 | ||
173 | #define WORDZE(w) \ | |
174 | ((w.val[_WORD_HIGHPART] == 0) && (w.val[_WORD_LOWPART] == 0)) | |
175 | #define ZEROWORD(w) \ | |
176 | (w).val[_WORD_HIGHPART] = (w).val[_WORD_LOWPART] = 0 | |
177 | #define COPYWORD(w1, w2) \ | |
178 | { (w2).val[_WORD_HIGHPART] = (w1).val[_WORD_HIGHPART]; \ | |
179 | (w2).val[_WORD_LOWPART] = (w1).val[_WORD_LOWPART]; \ | |
180 | } | |
181 | #define GETWORD(w, i) \ | |
182 | (i) = (((u_int)(w).val[_WORD_HIGHPART]) << 16) | (w).val[_WORD_LOWPART] | |
183 | #define PUTWORD(i, w) \ | |
184 | { (w).val[_WORD_HIGHPART] = (u_short) (((i) >> 16) & 0xffff); \ | |
185 | (w).val[_WORD_LOWPART] = (u_short) (i & 0xffff); \ | |
186 | } | |
187 | ||
188 | #endif | |
189 | ||
190 | /* | |
191 | * Packet structures. | |
192 | */ | |
193 | ||
194 | struct rmp_raw { /* generic RMP packet */ | |
195 | u_char rmp_type; /* packet type */ | |
196 | u_char rmp_rawdata[RMPDATALEN-1]; | |
197 | }; | |
198 | ||
199 | struct rmp_boot_req { /* boot request */ | |
200 | u_char rmp_type; /* packet type (RMP_BOOT_REQ) */ | |
201 | u_char rmp_retcode; /* return code (0) */ | |
202 | u_word rmp_seqno; /* sequence number (real time clock) */ | |
203 | u_short rmp_session; /* session id (normally 0) */ | |
204 | u_short rmp_version; /* protocol version (RMP_VERSION) */ | |
205 | char rmp_machtype[RMP_MACHLEN]; /* machine type */ | |
206 | u_char rmp_flnmsize; /* length of rmp_flnm */ | |
207 | restofpkt rmp_flnm; /* name of file to be read */ | |
208 | }; | |
209 | ||
210 | struct rmp_boot_repl { /* boot reply */ | |
211 | u_char rmp_type; /* packet type (RMP_BOOT_REPL) */ | |
212 | u_char rmp_retcode; /* return code (normally 0) */ | |
213 | u_word rmp_seqno; /* sequence number (from boot req) */ | |
214 | u_short rmp_session; /* session id (generated) */ | |
215 | u_short rmp_version; /* protocol version (RMP_VERSION) */ | |
216 | u_char rmp_flnmsize; /* length of rmp_flnm */ | |
217 | restofpkt rmp_flnm; /* name of file (from boot req) */ | |
218 | }; | |
219 | ||
220 | struct rmp_read_req { /* read request */ | |
221 | u_char rmp_type; /* packet type (RMP_READ_REQ) */ | |
222 | u_char rmp_retcode; /* return code (0) */ | |
223 | u_word rmp_offset; /* file relative byte offset */ | |
224 | u_short rmp_session; /* session id (from boot repl) */ | |
225 | u_short rmp_size; /* max no of bytes to send */ | |
226 | }; | |
227 | ||
228 | struct rmp_read_repl { /* read reply */ | |
229 | u_char rmp_type; /* packet type (RMP_READ_REPL) */ | |
230 | u_char rmp_retcode; /* return code (normally 0) */ | |
231 | u_word rmp_offset; /* byte offset (from read req) */ | |
232 | u_short rmp_session; /* session id (from read req) */ | |
233 | restofpkt rmp_data; /* data (max size from read req) */ | |
234 | u_char rmp_unused; /* padding to 16-bit boundary */ | |
235 | }; | |
236 | ||
237 | struct rmp_boot_done { /* boot complete */ | |
238 | u_char rmp_type; /* packet type (RMP_BOOT_DONE) */ | |
239 | u_char rmp_retcode; /* return code (0) */ | |
240 | u_word rmp_unused; /* not used (0) */ | |
241 | u_short rmp_session; /* session id (from read repl) */ | |
242 | }; | |
243 | ||
244 | struct rmp_packet { | |
245 | struct hp_hdr hp_hdr; | |
246 | struct hp_llc hp_llc; | |
247 | union { | |
248 | struct rmp_boot_req rmp_brq; /* boot request */ | |
249 | struct rmp_boot_repl rmp_brpl; /* boot reply */ | |
250 | struct rmp_read_req rmp_rrq; /* read request */ | |
251 | struct rmp_read_repl rmp_rrpl; /* read reply */ | |
252 | struct rmp_boot_done rmp_done; /* boot complete */ | |
253 | struct rmp_raw rmp_raw; /* raw data */ | |
254 | } rmp_proto; | |
255 | }; | |
256 | ||
257 | /* | |
258 | * Make life easier... | |
259 | */ | |
260 | ||
261 | #define r_type rmp_proto.rmp_raw.rmp_type | |
262 | #define r_data rmp_proto.rmp_raw.rmp_data | |
263 | #define r_brq rmp_proto.rmp_brq | |
264 | #define r_brpl rmp_proto.rmp_brpl | |
265 | #define r_rrq rmp_proto.rmp_rrq | |
266 | #define r_rrpl rmp_proto.rmp_rrpl | |
267 | #define r_done rmp_proto.rmp_done |