rc.c revision 1.2
1/*	$NetBSD: rc.c,v 1.2 1997/03/25 03:07:35 thorpej Exp $	*/
2
3/*
4 * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 *    must display the following acknowledgement:
16 *	This product includes software developed by Mats O Jansson.
17 * 4. The name of the author may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef LINT
33static char rcsid[] = "$NetBSD: rc.c,v 1.2 1997/03/25 03:07:35 thorpej Exp $";
34#endif
35
36#include "os.h"
37#include "common/get.h"
38#include "common/print.h"
39#include "common/mopdef.h"
40
41void
42mopDumpRC(fd, pkt, trans)
43	FILE	*fd;
44	u_char 	*pkt;
45	int	 trans;
46{
47	int	i,index = 0;
48	long	tmpl;
49	u_char	tmpc,code,control;
50	u_short	len,tmps,moplen;
51
52	len = mopGetLength(pkt, trans);
53
54	switch (trans) {
55	case TRANS_8023:
56		index = 22;
57		moplen = len - 8;
58		break;
59	default:
60		index = 16;
61		moplen = len;
62	}
63	code = mopGetChar(pkt,&index);
64
65	switch (code) {
66	case MOP_K_CODE_RID:
67
68		tmpc = mopGetChar(pkt,&index);
69		(void)fprintf(fd,"Reserved     :   %02x\n",tmpc);
70
71		tmps = mopGetShort(pkt,&index);
72		(void)fprintf(fd,"Receipt Nbr  : %04x\n",tmps);
73
74		break;
75	case MOP_K_CODE_BOT:
76
77		if ((moplen == 5)) {
78			tmps = mopGetShort(pkt,&index);
79			(void)fprintf(fd,"Verification : %04x\n",tmps);
80		} else {
81
82			tmpl = mopGetLong(pkt,&index);
83			(void)fprintf(fd,"Verification : %08x\n",tmpl);
84
85			tmpc = mopGetChar(pkt,&index);	/* Processor */
86			(void)fprintf(fd,"Processor    :   %02x ",tmpc);
87			mopPrintBPTY(fd, tmpc);  (void)fprintf(fd, "\n");
88
89			control = mopGetChar(pkt,&index);	/* Control */
90			(void)fprintf(fd,"Control    :   %02x ",control);
91			if ((control & (1>>MOP_K_BOT_CNTL_SERVER))) {
92				(void)fprintf(fd,
93					      "Bootserver Requesting system ");
94			} else {
95				(void)fprintf(fd,
96					      "Bootserver System default ");
97			}
98			if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
99				(void)fprintf(fd,
100					      "Bootdevice Specified device");
101			} else {
102				(void)fprintf(fd,
103					      "Bootdevice System default");
104			}
105			(void)fprintf(fd,"\n");
106
107			if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
108				tmpc = mopGetChar(pkt,&index);/* Device ID */
109				(void)fprintf(fd,
110					      "Device ID    :   %02x '",tmpc);
111				for (i = 0; i < ((int) tmpc); i++) {
112				  (void)fprintf(fd,"%c",
113						mopGetChar(pkt,&index));
114				}
115				(void)fprintf(fd,"'\n");
116			}
117
118			tmpc = mopGetChar(pkt,&index);      /* Software ID */
119			(void)fprintf(fd,"Software ID  :   %02x ",tmpc);
120			if ((tmpc == 0)) {
121				(void)fprintf(fd,"No software id");
122			}
123			if ((tmpc == 254)) {
124				(void)fprintf(fd,"Maintenance system");
125				tmpc = 0;
126			}
127			if ((tmpc == 255)) {
128				(void)fprintf(fd,"Standard operating system");
129				tmpc = 0;
130			}
131			if ((tmpc > 0)) {
132				(void)fprintf(fd,"'");
133				for (i = 0; i < ((int) tmpc); i++) {
134					(void)fprintf(fd,"%c",
135						     mopGetChar(pkt,&index));
136				}
137				(void)fprintf(fd,"'");
138			}
139			(void)fprintf(fd,"'\n");
140
141		}
142		break;
143	case MOP_K_CODE_SID:
144
145		tmpc = mopGetChar(pkt,&index);		/* Reserved */
146		(void)fprintf(fd, "Reserved     :   %02x\n",tmpc);
147
148		tmps = mopGetShort(pkt,&index);		/* Receipt # */
149		(void)fprintf(fd, "Receipt Nbr  : %04x\n",tmpc);
150
151		mopPrintInfo(fd, pkt, &index, moplen, code, trans);
152
153		break;
154	case MOP_K_CODE_RQC:
155
156		tmps = mopGetShort(pkt,&index);
157		(void)fprintf(fd,"Receipt Nbr  : %04x\n",tmps);
158
159		break;
160	case MOP_K_CODE_CNT:
161
162		tmps = mopGetShort(pkt,&index);
163		(void)fprintf(fd,"Receipt Nbr  : %04x %d\n",tmps,tmps);
164
165		tmps = mopGetShort(pkt,&index);
166		(void)fprintf(fd,"Last Zeroed  : %04x %d\n",tmps,tmps);
167
168		tmpl = mopGetLong(pkt,&index);
169		(void)fprintf(fd,"Bytes rec    : %08x %d\n",tmpl,tmpl);
170
171		tmpl = mopGetLong(pkt,&index);
172		(void)fprintf(fd,"Bytes snd    : %08x %d\n",tmpl,tmpl);
173
174		tmpl = mopGetLong(pkt,&index);
175		(void)fprintf(fd,"Frames rec   : %08x %d\n",tmpl,tmpl);
176
177		tmpl = mopGetLong(pkt,&index);
178		(void)fprintf(fd,"Frames snd   : %08x %d\n",tmpl,tmpl);
179
180		tmpl = mopGetLong(pkt,&index);
181		(void)fprintf(fd,"Mcst Bytes re: %08x %d\n",tmpl,tmpl);
182
183		tmpl = mopGetLong(pkt,&index);
184		(void)fprintf(fd,"Mcst Frame re: %08x %d\n",tmpl,tmpl);
185
186		tmpl = mopGetLong(pkt,&index);
187		(void)fprintf(fd,"Frame snd,def: %08x %d\n",tmpl,tmpl);
188
189		tmpl = mopGetLong(pkt,&index);
190		(void)fprintf(fd,"Frame snd,col: %08x %d\n",tmpl,tmpl);
191
192		tmpl = mopGetLong(pkt,&index);
193		(void)fprintf(fd,"Frame snd,mcl: %08x %d\n",tmpl,tmpl);
194
195		tmps = mopGetShort(pkt,&index);
196		(void)fprintf(fd,"Snd failure  : %04x %d\n",tmps,tmps);
197
198		tmps = mopGetShort(pkt,&index);
199		(void)fprintf(fd,"Snd fail reas: %04x ",tmps);
200		if ((tmps &  1)) (void)fprintf(fd,"Excess col  ");
201		if ((tmps &  2)) (void)fprintf(fd,"Carrier chk fail  ");
202		if ((tmps &  4)) (void)fprintf(fd,"Short circ  ");
203		if ((tmps &  8)) (void)fprintf(fd,"Open circ  ");
204		if ((tmps & 16)) (void)fprintf(fd,"Frm to long  ");
205		if ((tmps & 32)) (void)fprintf(fd,"Rem fail to defer  ");
206		(void)fprintf(fd,"\n");
207
208		tmps = mopGetShort(pkt,&index);
209		(void)fprintf(fd,"Rec failure  : %04x %d\n",tmps,tmps);
210
211		tmps = mopGetShort(pkt,&index);
212		(void)fprintf(fd,"Rec fail reas: %04x ",tmps);
213		if ((tmps &  1)) (void)fprintf(fd,"Block chk err  ");
214		if ((tmps &  2)) (void)fprintf(fd,"Framing err  ");
215		if ((tmps &  4)) (void)fprintf(fd,"Frm to long  ");
216		(void)fprintf(fd,"\n");
217
218		tmps = mopGetShort(pkt,&index);
219		(void)fprintf(fd,"Unrec frm dst: %04x %d\n",tmps,tmps);
220
221		tmps = mopGetShort(pkt,&index);
222		(void)fprintf(fd,"Data overrun : %04x %d\n",tmps,tmps);
223
224		tmps = mopGetShort(pkt,&index);
225		(void)fprintf(fd,"Sys Buf Unava: %04x %d\n",tmps,tmps);
226
227		tmps = mopGetShort(pkt,&index);
228		(void)fprintf(fd,"Usr Buf Unava: %04x %d\n",tmps,tmps);
229
230		break;
231	case MOP_K_CODE_RVC:
232
233		tmpl = mopGetLong(pkt,&index);
234		(void)fprintf(fd,"Verification : %08x\n",tmpl);
235
236		break;
237	case MOP_K_CODE_RLC:
238
239		/* Empty message */
240
241		break;
242	case MOP_K_CODE_CCP:
243
244		tmpc = mopGetChar(pkt,&index);
245		(void)fprintf(fd,
246			      "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
247		if ((tmpc & 2))
248			(void)fprintf(fd,"Break");
249		(void)fprintf(fd,"\n");
250
251		if (moplen > 2) {
252#ifndef SHORT_PRINT
253			for (i = 0; i < (moplen - 2); i++) {
254		  		if ((i % 16) == 0) {
255					if ((i / 16) == 0) {
256						(void)fprintf(fd,
257							"Image Data   : %04x ",
258							      moplen-2);
259					} else {
260						(void)fprintf(fd,
261						       "                    ");
262				        }
263				}
264				(void)fprintf(fd,"%02x ",
265					      mopGetChar(pkt,&index));
266				if ((i % 16) == 15)
267					(void)fprintf(fd,"\n");
268			}
269			if ((i % 16) != 15)
270				(void)fprintf(fd,"\n");
271#else
272			index = index + moplen - 2;
273#endif
274		}
275
276		break;
277	case MOP_K_CODE_CRA:
278
279		tmpc = mopGetChar(pkt,&index);
280		(void)fprintf(fd,
281			      "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
282		if ((tmpc & 2))
283			(void)fprintf(fd,"Cmd Data Lost ");
284		if ((tmpc & 4))
285			(void)fprintf(fd,"Resp Data Lost ");
286		(void)fprintf(fd,"\n");
287
288		if (moplen > 2) {
289#ifndef SHORT_PRINT
290			for (i = 0; i < (moplen - 2); i++) {
291				if ((i % 16) == 0) {
292					if ((i / 16) == 0) {
293						(void)fprintf(fd,
294							"Image Data   : %04x ",
295							      moplen-2);
296					} else {
297						(void)fprintf(fd,
298						       "                    ");
299					}
300				}
301				(void)fprintf(fd,"%02x ",
302					      mopGetChar(pkt,&index));
303				if ((i % 16) == 15)
304					(void)fprintf(fd,"\n");
305			}
306			if ((i % 16) != 15)
307				(void)fprintf(fd,"\n");
308#else
309			index = index + moplen - 2;
310#endif
311		}
312
313		break;
314	default:
315		break;
316	}
317}
318
319