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