1 /* $NetBSD: rc.c,v 1.5 2009/10/20 00:51:13 snj Exp $ */
4 * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
29 __RCSID("$NetBSD: rc.c,v 1.5 2009/10/20 00:51:13 snj Exp $");
39 mopDumpRC(FILE *fd
, const u_char
*pkt
, int trans
)
43 u_char tmpc
,code
,control
;
44 u_short len
,tmps
,moplen
;
46 len
= mopGetLength(pkt
, trans
);
57 code
= mopGetChar(pkt
,&idx
);
62 tmpc
= mopGetChar(pkt
,&idx
);
63 (void)fprintf(fd
,"Reserved : %02x\n",tmpc
);
65 tmps
= mopGetShort(pkt
,&idx
);
66 (void)fprintf(fd
,"Receipt Nbr : %04x\n",tmps
);
72 tmps
= mopGetShort(pkt
,&idx
);
73 (void)fprintf(fd
,"Verification : %04x\n",tmps
);
76 tmpl
= mopGetLong(pkt
,&idx
);
77 (void)fprintf(fd
,"Verification : %08x\n",tmpl
);
79 tmpc
= mopGetChar(pkt
,&idx
); /* Processor */
80 (void)fprintf(fd
,"Processor : %02x ",tmpc
);
81 mopPrintBPTY(fd
, tmpc
); (void)fprintf(fd
, "\n");
83 control
= mopGetChar(pkt
,&idx
); /* Control */
84 (void)fprintf(fd
,"Control : %02x ",control
);
85 if ((control
& (1>>MOP_K_BOT_CNTL_SERVER
))) {
87 "Bootserver Requesting system ");
90 "Bootserver System default ");
92 if ((control
& (1>>MOP_K_BOT_CNTL_DEVICE
))) {
94 "Bootdevice Specified device");
97 "Bootdevice System default");
99 (void)fprintf(fd
,"\n");
101 if ((control
& (1>>MOP_K_BOT_CNTL_DEVICE
))) {
102 tmpc
= mopGetChar(pkt
,&idx
);/* Device ID */
104 "Device ID : %02x '",tmpc
);
105 for (i
= 0; i
< ((int) tmpc
); i
++) {
106 (void)fprintf(fd
,"%c",
107 mopGetChar(pkt
,&idx
));
109 (void)fprintf(fd
,"'\n");
112 tmpc
= mopGetChar(pkt
,&idx
); /* Software ID */
113 (void)fprintf(fd
,"Software ID : %02x ",tmpc
);
115 (void)fprintf(fd
,"No software id");
118 (void)fprintf(fd
,"Maintenance system");
122 (void)fprintf(fd
,"Standard operating system");
126 (void)fprintf(fd
,"'");
127 for (i
= 0; i
< ((int) tmpc
); i
++) {
128 (void)fprintf(fd
,"%c",
129 mopGetChar(pkt
,&idx
));
131 (void)fprintf(fd
,"'");
133 (void)fprintf(fd
,"'\n");
139 tmpc
= mopGetChar(pkt
,&idx
); /* Reserved */
140 (void)fprintf(fd
, "Reserved : %02x\n",tmpc
);
142 tmps
= mopGetShort(pkt
,&idx
); /* Receipt # */
143 (void)fprintf(fd
, "Receipt Nbr : %04x\n",tmpc
);
145 mopPrintInfo(fd
, pkt
, &idx
, moplen
, code
, trans
);
150 tmps
= mopGetShort(pkt
,&idx
);
151 (void)fprintf(fd
,"Receipt Nbr : %04x\n",tmps
);
156 tmps
= mopGetShort(pkt
,&idx
);
157 (void)fprintf(fd
,"Receipt Nbr : %04x %d\n",tmps
,tmps
);
159 tmps
= mopGetShort(pkt
,&idx
);
160 (void)fprintf(fd
,"Last Zeroed : %04x %d\n",tmps
,tmps
);
162 tmpl
= mopGetLong(pkt
,&idx
);
163 (void)fprintf(fd
,"Bytes rec : %08x %d\n",tmpl
,tmpl
);
165 tmpl
= mopGetLong(pkt
,&idx
);
166 (void)fprintf(fd
,"Bytes snd : %08x %d\n",tmpl
,tmpl
);
168 tmpl
= mopGetLong(pkt
,&idx
);
169 (void)fprintf(fd
,"Frames rec : %08x %d\n",tmpl
,tmpl
);
171 tmpl
= mopGetLong(pkt
,&idx
);
172 (void)fprintf(fd
,"Frames snd : %08x %d\n",tmpl
,tmpl
);
174 tmpl
= mopGetLong(pkt
,&idx
);
175 (void)fprintf(fd
,"Mcst Bytes re: %08x %d\n",tmpl
,tmpl
);
177 tmpl
= mopGetLong(pkt
,&idx
);
178 (void)fprintf(fd
,"Mcst Frame re: %08x %d\n",tmpl
,tmpl
);
180 tmpl
= mopGetLong(pkt
,&idx
);
181 (void)fprintf(fd
,"Frame snd,def: %08x %d\n",tmpl
,tmpl
);
183 tmpl
= mopGetLong(pkt
,&idx
);
184 (void)fprintf(fd
,"Frame snd,col: %08x %d\n",tmpl
,tmpl
);
186 tmpl
= mopGetLong(pkt
,&idx
);
187 (void)fprintf(fd
,"Frame snd,mcl: %08x %d\n",tmpl
,tmpl
);
189 tmps
= mopGetShort(pkt
,&idx
);
190 (void)fprintf(fd
,"Snd failure : %04x %d\n",tmps
,tmps
);
192 tmps
= mopGetShort(pkt
,&idx
);
193 (void)fprintf(fd
,"Snd fail reas: %04x ",tmps
);
194 if ((tmps
& 1)) (void)fprintf(fd
,"Excess col ");
195 if ((tmps
& 2)) (void)fprintf(fd
,"Carrier chk fail ");
196 if ((tmps
& 4)) (void)fprintf(fd
,"Short circ ");
197 if ((tmps
& 8)) (void)fprintf(fd
,"Open circ ");
198 if ((tmps
& 16)) (void)fprintf(fd
,"Frm to long ");
199 if ((tmps
& 32)) (void)fprintf(fd
,"Rem fail to defer ");
200 (void)fprintf(fd
,"\n");
202 tmps
= mopGetShort(pkt
,&idx
);
203 (void)fprintf(fd
,"Rec failure : %04x %d\n",tmps
,tmps
);
205 tmps
= mopGetShort(pkt
,&idx
);
206 (void)fprintf(fd
,"Rec fail reas: %04x ",tmps
);
207 if ((tmps
& 1)) (void)fprintf(fd
,"Block chk err ");
208 if ((tmps
& 2)) (void)fprintf(fd
,"Framing err ");
209 if ((tmps
& 4)) (void)fprintf(fd
,"Frm to long ");
210 (void)fprintf(fd
,"\n");
212 tmps
= mopGetShort(pkt
,&idx
);
213 (void)fprintf(fd
,"Unrec frm dst: %04x %d\n",tmps
,tmps
);
215 tmps
= mopGetShort(pkt
,&idx
);
216 (void)fprintf(fd
,"Data overrun : %04x %d\n",tmps
,tmps
);
218 tmps
= mopGetShort(pkt
,&idx
);
219 (void)fprintf(fd
,"Sys Buf Unava: %04x %d\n",tmps
,tmps
);
221 tmps
= mopGetShort(pkt
,&idx
);
222 (void)fprintf(fd
,"Usr Buf Unava: %04x %d\n",tmps
,tmps
);
227 tmpl
= mopGetLong(pkt
,&idx
);
228 (void)fprintf(fd
,"Verification : %08x\n",tmpl
);
238 tmpc
= mopGetChar(pkt
,&idx
);
240 "Control Flags: %02x Message %d ",tmpc
,tmpc
& 1);
242 (void)fprintf(fd
,"Break");
243 (void)fprintf(fd
,"\n");
247 for (i
= 0; i
< (moplen
- 2); i
++) {
251 "Image Data : %04x ",
258 (void)fprintf(fd
,"%02x ",
259 mopGetChar(pkt
,&idx
));
261 (void)fprintf(fd
,"\n");
264 (void)fprintf(fd
,"\n");
266 idx
= idx
+ moplen
- 2;
273 tmpc
= mopGetChar(pkt
,&idx
);
275 "Control Flags: %02x Message %d ",tmpc
,tmpc
& 1);
277 (void)fprintf(fd
,"Cmd Data Lost ");
279 (void)fprintf(fd
,"Resp Data Lost ");
280 (void)fprintf(fd
,"\n");
284 for (i
= 0; i
< (moplen
- 2); i
++) {
288 "Image Data : %04x ",
295 (void)fprintf(fd
,"%02x ",
296 mopGetChar(pkt
,&idx
));
298 (void)fprintf(fd
,"\n");
301 (void)fprintf(fd
,"\n");
303 idx
= idx
+ moplen
- 2;