Commit | Line | Data |
---|---|---|
dec69c36 GW |
1 | /* |
2 | * Copyright (c) 1988 University of Utah. | |
3 | * Copyright (c) 1990 The Regents of the University of California. | |
4 | * All rights reserved. | |
5 | * | |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * the Systems Programming Group of the University of Utah Computer | |
8 | * Science Department. | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | |
18 | * 3. All advertising materials mentioning features or use of this software | |
19 | * must display the following acknowledgement: | |
20 | * This product includes software developed by the University of | |
21 | * California, Berkeley and its contributors. | |
22 | * 4. Neither the name of the University nor the names of its contributors | |
23 | * may be used to endorse or promote products derived from this software | |
24 | * without specific prior written permission. | |
25 | * | |
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
36 | * SUCH DAMAGE. | |
37 | * | |
38 | * from: Utah $Hdr: rmp_var.h 1.3 89/06/07$ | |
39 | * | |
40 | * @(#)rmp_var.h 7.1 (Berkeley) 5/8/90 | |
41 | */ | |
42 | ||
43 | #ifndef _NETRMP_RMP_VAR_H_ | |
44 | #define _NETRMP_RMP_VAR_H_ 1 | |
45 | ||
46 | /* | |
47 | * WARNING: rmp_packet is defined assuming alignment on 16-bit boundaries. | |
48 | * Data will be contiguous on HP's (MC68000), but there may be holes if | |
49 | * this is used elsewhere (e.g. VAXen). Or, in other words: | |
50 | * | |
51 | * if (sizeof(struct rmp_packet) != 1504) error("AlignmentProblem"); | |
52 | */ | |
53 | ||
54 | /* | |
55 | * Possible values for "rmp_type" fields. | |
56 | */ | |
57 | ||
58 | #define RMP_BOOT_REQ 1 /* boot request packet */ | |
59 | #define RMP_BOOT_REPL 129 /* boot reply packet */ | |
60 | #define RMP_READ_REQ 2 /* read request packet */ | |
61 | #define RMP_READ_REPL 130 /* read reply packet */ | |
62 | #define RMP_BOOT_DONE 3 /* boot complete packet */ | |
63 | ||
64 | /* | |
65 | * Useful constants. | |
66 | */ | |
67 | ||
68 | #define RMP_VERSION 2 /* protocol version */ | |
69 | #define RMP_TIMEOUT 600 /* timeout connection after ten minutes */ | |
70 | #define RMP_PROBESID 0xffff /* session ID for probes */ | |
71 | #define RMP_HOSTLEN 13 /* max length of server's name */ | |
72 | ||
73 | /* | |
74 | * RMP error codes | |
75 | */ | |
76 | ||
77 | #define RMP_E_OKAY 0 | |
78 | #define RMP_E_EOF 2 /* read reply: returned end of file */ | |
79 | #define RMP_E_ABORT 3 /* abort operation */ | |
80 | #define RMP_E_BUSY 4 /* boot reply: server busy */ | |
81 | #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */ | |
82 | #define RMP_E_NOFILE 16 /* boot reply: file does not exist */ | |
83 | #define RMP_E_OPENFILE 17 /* boot reply: file open failed */ | |
84 | #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */ | |
85 | #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */ | |
86 | #define RMP_E_BADSID 25 /* read reply: bad session ID */ | |
87 | #define RMP_E_BADPACKET 27 /* Bad packet detected */ | |
88 | ||
89 | /* | |
90 | * Assorted field sizes. | |
91 | */ | |
92 | ||
93 | #define RMPADDRLEN 6 /* size of ethernet address */ | |
94 | #define RMPLENGTHLEN 2 /* size of ethernet length field (802.3) */ | |
95 | #define RMPMACHLEN 20 /* length of machine type field */ | |
96 | ||
97 | /* | |
98 | * RMPDATALEN is the maximum number of data octets that can be stuffed | |
99 | * into an RMP packet. This excludes the 802.2 LLC w/HP extensions. | |
100 | */ | |
101 | ||
102 | #define RMPDATALEN (RMP_MAX_PACKET - (2*RMPADDRLEN + RMPLENGTHLEN + \ | |
103 | sizeof(struct hp_llc)) ) | |
104 | ||
105 | /* | |
106 | * Define sizes of packets we send. Boot and Read replies are variable | |
107 | * in length depending on the length of `s'. | |
108 | * | |
109 | * Also, define how much space `restofpkt' can take up for outgoing | |
110 | * Boot and Read replies. Boot Request packets are effectively | |
111 | * limited to 255 bytes due to the preceding 1-byte length field. | |
112 | */ | |
113 | ||
114 | #define RMPBOOTSIZE(s) (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \ | |
115 | sizeof(struct rmp_boot_repl) + s - \ | |
116 | sizeof(restofpkt)) | |
117 | #define RMPREADSIZE(s) (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \ | |
118 | sizeof(struct rmp_read_repl) + s - \ | |
119 | sizeof(restofpkt) - sizeof(u_char)) | |
120 | #define RMPDONESIZE (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \ | |
121 | sizeof(struct rmp_boot_done)) | |
122 | #define RMPBOOTDATA 255 | |
123 | #define RMPREADDATA (RMPDATALEN - \ | |
124 | (2*sizeof(u_char)+sizeof(u_short)+sizeof(u_long))) | |
125 | ||
126 | ||
127 | /* | |
128 | * This protocol defines some field sizes as "rest of ethernet packet". | |
129 | * There is no easy way to specify this in C, so we use a one character | |
130 | * field to denote it, and index past it to the end of the packet. | |
131 | */ | |
132 | ||
133 | typedef char restofpkt; | |
134 | ||
135 | /* | |
136 | * Packet structures. | |
137 | */ | |
138 | ||
139 | struct rmp_raw { | |
140 | u_char rmp_type; /* packet type */ | |
141 | u_char rmp_rawdata[RMPDATALEN-1]; | |
142 | }; | |
143 | ||
144 | struct rmp_boot_req { /* boot request */ | |
145 | u_char rmp_type; /* packet type (RMP_BOOT_REQ) */ | |
146 | u_char rmp_retcode; /* return code (0) */ | |
147 | u_long rmp_seqno; /* sequence number (real time clock) */ | |
148 | u_short rmp_session; /* session id (normally 0) */ | |
149 | u_short rmp_version; /* protocol version (RMP_VERSION) */ | |
150 | char rmp_machtype[RMPMACHLEN]; /* machine type */ | |
151 | u_char rmp_flnmsize; /* length of rmp_flnm */ | |
152 | restofpkt rmp_flnm; /* name of file to be read */ | |
153 | }; | |
154 | ||
155 | struct rmp_boot_repl { /* boot reply */ | |
156 | u_char rmp_type; /* packet type (RMP_BOOT_REPL) */ | |
157 | u_char rmp_retcode; /* return code (normally 0) */ | |
158 | u_long rmp_seqno; /* sequence number (from boot req) */ | |
159 | u_short rmp_session; /* session id (generated) */ | |
160 | u_short rmp_version; /* protocol version (RMP_VERSION) */ | |
161 | u_char rmp_flnmsize; /* length of rmp_flnm */ | |
162 | restofpkt rmp_flnm; /* name of file (from boot req) */ | |
163 | }; | |
164 | ||
165 | struct rmp_read_req { /* read request */ | |
166 | u_char rmp_type; /* packet type (RMP_READ_REQ) */ | |
167 | u_char rmp_retcode; /* return code (0) */ | |
168 | u_long rmp_offset; /* file relative byte offset */ | |
169 | u_short rmp_session; /* session id (from boot repl) */ | |
170 | u_short rmp_size; /* max no of bytes to send */ | |
171 | }; | |
172 | ||
173 | struct rmp_read_repl { /* read reply */ | |
174 | u_char rmp_type; /* packet type (RMP_READ_REPL) */ | |
175 | u_char rmp_retcode; /* return code (normally 0) */ | |
176 | u_long rmp_offset; /* byte offset (from read req) */ | |
177 | u_short rmp_session; /* session id (from read req) */ | |
178 | restofpkt rmp_data; /* data (max size from read req) */ | |
179 | u_char rmp_unused; /* padding to 16-bit boundary */ | |
180 | }; | |
181 | ||
182 | struct rmp_boot_done { /* boot complete */ | |
183 | u_char rmp_type; /* packet type (RMP_BOOT_DONE) */ | |
184 | u_char rmp_retcode; /* return code (0) */ | |
185 | u_long rmp_unused; /* not used (0) */ | |
186 | u_short rmp_session; /* session id (from read repl) */ | |
187 | }; | |
188 | ||
189 | struct rmp_packet { | |
190 | struct ifnet *ifp; /* ptr to intf packet arrived on */ | |
191 | struct hp_llc hp_llc; | |
192 | union { | |
193 | struct rmp_boot_req rmp_brq; /* boot request */ | |
194 | struct rmp_boot_repl rmp_brpl; /* boot reply */ | |
195 | struct rmp_read_req rmp_rrq; /* read request */ | |
196 | struct rmp_read_repl rmp_rrpl; /* read reply */ | |
197 | struct rmp_boot_done rmp_done; /* boot complete */ | |
198 | struct rmp_raw rmp_raw; /* raw data */ | |
199 | } rmp_proto; | |
200 | }; | |
201 | ||
202 | /* | |
203 | * Make life easier... | |
204 | */ | |
205 | ||
206 | #define r_type rmp_proto.rmp_raw.rmp_type | |
207 | #define r_data rmp_proto.rmp_raw.rmp_data | |
208 | #define r_brq rmp_proto.rmp_brq | |
209 | #define r_brpl rmp_proto.rmp_brpl | |
210 | #define r_rrq rmp_proto.rmp_rrq | |
211 | #define r_rrpl rmp_proto.rmp_rrpl | |
212 | #define r_done rmp_proto.rmp_done | |
213 | ||
214 | /* | |
215 | * RMP socket address: just family & destination addr. | |
216 | */ | |
217 | ||
218 | struct sockaddr_rmp { | |
219 | short srmp_family; /* address family (AF_RMP) */ | |
220 | u_char srmp_dhost[RMPADDRLEN]; /* ethernet destination addr */ | |
221 | }; | |
222 | ||
223 | #endif /* _NETRMP_RMP_VAR_H_ */ |