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