|
|
1.1 root 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: /*
44: * WARNING: rmp_packet is defined assuming alignment on 16-bit boundaries.
45: * Data will be contiguous on HP's (MC68000), but there may be holes if
46: * this is used elsewhere (e.g. VAXen). Or, in other words:
47: *
48: * if (sizeof(struct rmp_packet) != 1504) error("AlignmentProblem");
49: */
50:
51: /*
52: * Possible values for "rmp_type" fields.
53: */
54:
55: #define RMP_BOOT_REQ 1 /* boot request packet */
56: #define RMP_BOOT_REPL 129 /* boot reply packet */
57: #define RMP_READ_REQ 2 /* read request packet */
58: #define RMP_READ_REPL 130 /* read reply packet */
59: #define RMP_BOOT_DONE 3 /* boot complete packet */
60:
61: /*
62: * Useful constants.
63: */
64:
65: #define RMP_VERSION 2 /* protocol version */
66: #define RMP_TIMEOUT 600 /* timeout connection after ten minutes */
67: #define RMP_PROBESID 0xffff /* session ID for probes */
68: #define RMP_HOSTLEN 13 /* max length of server's name */
69:
70: /*
71: * RMP error codes
72: */
73:
74: #define RMP_E_OKAY 0
75: #define RMP_E_EOF 2 /* read reply: returned end of file */
76: #define RMP_E_ABORT 3 /* abort operation */
77: #define RMP_E_BUSY 4 /* boot reply: server busy */
78: #define RMP_E_TIMEOUT 5 /* lengthen time out (not implemented) */
79: #define RMP_E_NOFILE 16 /* boot reply: file does not exist */
80: #define RMP_E_OPENFILE 17 /* boot reply: file open failed */
81: #define RMP_E_NODFLT 18 /* boot reply: default file does not exist */
82: #define RMP_E_OPENDFLT 19 /* boot reply: default file open failed */
83: #define RMP_E_BADSID 25 /* read reply: bad session ID */
84: #define RMP_E_BADPACKET 27 /* Bad packet detected */
85:
86: /*
87: * Assorted field sizes.
88: */
89:
90: #define RMPADDRLEN 6 /* size of ethernet address */
91: #define RMPLENGTHLEN 2 /* size of ethernet length field (802.3) */
92: #define RMPMACHLEN 20 /* length of machine type field */
93:
94: /*
95: * RMPDATALEN is the maximum number of data octets that can be stuffed
96: * into an RMP packet. This excludes the 802.2 LLC w/HP extensions.
97: */
98:
99: #define RMPDATALEN (RMP_MAX_PACKET - (2*RMPADDRLEN + RMPLENGTHLEN + \
100: sizeof(struct hp_llc)) )
101:
102: /*
103: * Define sizes of packets we send. Boot and Read replies are variable
104: * in length depending on the length of `s'.
105: *
106: * Also, define how much space `restofpkt' can take up for outgoing
107: * Boot and Read replies. Boot Request packets are effectively
108: * limited to 255 bytes due to the preceding 1-byte length field.
109: */
110:
111: #define RMPBOOTSIZE(s) (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \
112: sizeof(struct rmp_boot_repl) + s - \
113: sizeof(restofpkt))
114: #define RMPREADSIZE(s) (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \
115: sizeof(struct rmp_read_repl) + s - \
116: sizeof(restofpkt) - sizeof(u_char))
117: #define RMPDONESIZE (sizeof(struct hp_llc) + sizeof(struct ifnet *) + \
118: sizeof(struct rmp_boot_done))
119: #define RMPBOOTDATA 255
120: #define RMPREADDATA (RMPDATALEN - \
121: (2*sizeof(u_char)+sizeof(u_short)+sizeof(u_long)))
122:
123:
124: /*
125: * This protocol defines some field sizes as "rest of ethernet packet".
126: * There is no easy way to specify this in C, so we use a one character
127: * field to denote it, and index past it to the end of the packet.
128: */
129:
130: typedef char restofpkt;
131:
132: /*
133: * Packet structures.
134: */
135:
136: struct rmp_raw {
137: u_char rmp_type; /* packet type */
138: u_char rmp_rawdata[RMPDATALEN-1];
139: };
140:
141: struct rmp_boot_req { /* boot request */
142: u_char rmp_type; /* packet type (RMP_BOOT_REQ) */
143: u_char rmp_retcode; /* return code (0) */
144: u_long rmp_seqno; /* sequence number (real time clock) */
145: u_short rmp_session; /* session id (normally 0) */
146: u_short rmp_version; /* protocol version (RMP_VERSION) */
147: char rmp_machtype[RMPMACHLEN]; /* machine type */
148: u_char rmp_flnmsize; /* length of rmp_flnm */
149: restofpkt rmp_flnm; /* name of file to be read */
150: };
151:
152: struct rmp_boot_repl { /* boot reply */
153: u_char rmp_type; /* packet type (RMP_BOOT_REPL) */
154: u_char rmp_retcode; /* return code (normally 0) */
155: u_long rmp_seqno; /* sequence number (from boot req) */
156: u_short rmp_session; /* session id (generated) */
157: u_short rmp_version; /* protocol version (RMP_VERSION) */
158: u_char rmp_flnmsize; /* length of rmp_flnm */
159: restofpkt rmp_flnm; /* name of file (from boot req) */
160: };
161:
162: struct rmp_read_req { /* read request */
163: u_char rmp_type; /* packet type (RMP_READ_REQ) */
164: u_char rmp_retcode; /* return code (0) */
165: u_long rmp_offset; /* file relative byte offset */
166: u_short rmp_session; /* session id (from boot repl) */
167: u_short rmp_size; /* max no of bytes to send */
168: };
169:
170: struct rmp_read_repl { /* read reply */
171: u_char rmp_type; /* packet type (RMP_READ_REPL) */
172: u_char rmp_retcode; /* return code (normally 0) */
173: u_long rmp_offset; /* byte offset (from read req) */
174: u_short rmp_session; /* session id (from read req) */
175: restofpkt rmp_data; /* data (max size from read req) */
176: u_char rmp_unused; /* padding to 16-bit boundary */
177: };
178:
179: struct rmp_boot_done { /* boot complete */
180: u_char rmp_type; /* packet type (RMP_BOOT_DONE) */
181: u_char rmp_retcode; /* return code (0) */
182: u_long rmp_unused; /* not used (0) */
183: u_short rmp_session; /* session id (from read repl) */
184: };
185:
186: struct rmp_packet {
187: struct ifnet *ifp; /* ptr to intf packet arrived on */
188: struct hp_llc hp_llc;
189: union {
190: struct rmp_boot_req rmp_brq; /* boot request */
191: struct rmp_boot_repl rmp_brpl; /* boot reply */
192: struct rmp_read_req rmp_rrq; /* read request */
193: struct rmp_read_repl rmp_rrpl; /* read reply */
194: struct rmp_boot_done rmp_done; /* boot complete */
195: struct rmp_raw rmp_raw; /* raw data */
196: } rmp_proto;
197: };
198:
199: /*
200: * Make life easier...
201: */
202:
203: #define r_type rmp_proto.rmp_raw.rmp_type
204: #define r_data rmp_proto.rmp_raw.rmp_data
205: #define r_brq rmp_proto.rmp_brq
206: #define r_brpl rmp_proto.rmp_brpl
207: #define r_rrq rmp_proto.rmp_rrq
208: #define r_rrpl rmp_proto.rmp_rrpl
209: #define r_done rmp_proto.rmp_done
210:
211: /*
212: * RMP socket address: just family & destination addr.
213: */
214:
215: struct sockaddr_rmp {
216: short srmp_family; /* address family (AF_RMP) */
217: u_char srmp_dhost[RMPADDRLEN]; /* ethernet destination addr */
218: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.