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