1 |
|
|
/* $OpenBSD: rc.c,v 1.9 2017/07/29 07:18:03 florian 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 |
|
|
* |
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. |
25 |
|
|
*/ |
26 |
|
|
|
27 |
|
|
#include "os.h" |
28 |
|
|
#include "common/get.h" |
29 |
|
|
#include "common/print.h" |
30 |
|
|
#include "common/mopdef.h" |
31 |
|
|
|
32 |
|
|
void |
33 |
|
|
mopDumpRC(FILE *fd, u_char *pkt, int trans) |
34 |
|
|
{ |
35 |
|
|
int i, idx = 0; |
36 |
|
|
long tmpl; |
37 |
|
|
u_char tmpc, code, control; |
38 |
|
|
u_short len, tmps, moplen; |
39 |
|
|
|
40 |
|
|
len = mopGetLength(pkt, trans); |
41 |
|
|
|
42 |
|
|
switch (trans) { |
43 |
|
|
case TRANS_8023: |
44 |
|
|
idx = 22; |
45 |
|
|
moplen = len - 8; |
46 |
|
|
break; |
47 |
|
|
default: |
48 |
|
|
idx = 16; |
49 |
|
|
moplen = len; |
50 |
|
|
} |
51 |
|
|
code = mopGetChar(pkt, &idx); |
52 |
|
|
|
53 |
|
|
switch (code) { |
54 |
|
|
case MOP_K_CODE_RID: |
55 |
|
|
|
56 |
|
|
tmpc = mopGetChar(pkt, &idx); |
57 |
|
|
fprintf(fd, "Reserved : %02x\n", tmpc); |
58 |
|
|
|
59 |
|
|
tmps = mopGetShort(pkt, &idx); |
60 |
|
|
fprintf(fd, "Receipt Nbr : %04x\n", tmps); |
61 |
|
|
|
62 |
|
|
break; |
63 |
|
|
case MOP_K_CODE_BOT: |
64 |
|
|
|
65 |
|
|
if (moplen == 5) { |
66 |
|
|
tmps = mopGetShort(pkt, &idx); |
67 |
|
|
fprintf(fd, "Verification : %04x\n", tmps); |
68 |
|
|
} else { |
69 |
|
|
|
70 |
|
|
tmpl = mopGetLong(pkt, &idx); |
71 |
|
|
fprintf(fd, "Verification : %08lx\n", tmpl); |
72 |
|
|
|
73 |
|
|
tmpc = mopGetChar(pkt, &idx); /* Processor */ |
74 |
|
|
fprintf(fd, "Processor : %02x ", tmpc); |
75 |
|
|
mopPrintBPTY(fd, tmpc); fprintf(fd, "\n"); |
76 |
|
|
|
77 |
|
|
control = mopGetChar(pkt, &idx); /* Control */ |
78 |
|
|
fprintf(fd, "Control : %02x ", control); |
79 |
|
|
if ((control & (1<<MOP_K_BOT_CNTL_SERVER))) |
80 |
|
|
fprintf(fd, "Bootserver Requesting system "); |
81 |
|
|
else |
82 |
|
|
fprintf(fd, "Bootserver System default "); |
83 |
|
|
if ((control & (1<<MOP_K_BOT_CNTL_DEVICE))) |
84 |
|
|
fprintf(fd, "Bootdevice Specified device"); |
85 |
|
|
else |
86 |
|
|
fprintf(fd, "Bootdevice System default"); |
87 |
|
|
fprintf(fd, "\n"); |
88 |
|
|
|
89 |
|
|
if ((control & (1<<MOP_K_BOT_CNTL_DEVICE))) { |
90 |
|
|
tmpc = mopGetChar(pkt, &idx);/* Device ID */ |
91 |
|
|
fprintf(fd, "Device ID : %02x '", tmpc); |
92 |
|
|
for (i = 0; i < ((int) tmpc); i++) |
93 |
|
|
fprintf(fd, "%c", |
94 |
|
|
mopGetChar(pkt, &idx)); |
95 |
|
|
fprintf(fd, "'\n"); |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
tmpc = mopGetChar(pkt, &idx); /* Software ID */ |
99 |
|
|
fprintf(fd, "Software ID : %02x ", tmpc); |
100 |
|
|
if (tmpc == 0) |
101 |
|
|
fprintf(fd, "No software id"); |
102 |
|
|
if (tmpc == 254) { |
103 |
|
|
fprintf(fd, "Maintenance system"); |
104 |
|
|
tmpc = 0; |
105 |
|
|
} |
106 |
|
|
if (tmpc == 255) { |
107 |
|
|
fprintf(fd, "Standard operating system"); |
108 |
|
|
tmpc = 0; |
109 |
|
|
} |
110 |
|
|
if (tmpc > 0) { |
111 |
|
|
fprintf(fd, "'"); |
112 |
|
|
for (i = 0; i < ((int) tmpc); i++) |
113 |
|
|
fprintf(fd, "%c", |
114 |
|
|
mopGetChar(pkt, &idx)); |
115 |
|
|
fprintf(fd, "'"); |
116 |
|
|
} |
117 |
|
|
fprintf(fd, "'\n"); |
118 |
|
|
|
119 |
|
|
} |
120 |
|
|
break; |
121 |
|
|
case MOP_K_CODE_SID: |
122 |
|
|
|
123 |
|
|
tmpc = mopGetChar(pkt, &idx); /* Reserved */ |
124 |
|
|
fprintf(fd, "Reserved : %02x\n", tmpc); |
125 |
|
|
|
126 |
|
|
tmps = mopGetShort(pkt, &idx); /* Receipt # */ |
127 |
|
|
fprintf(fd, "Receipt Nbr : %04x\n", tmpc); |
128 |
|
|
|
129 |
|
|
mopPrintInfo(fd, pkt, &idx, moplen, code, trans); |
130 |
|
|
|
131 |
|
|
break; |
132 |
|
|
case MOP_K_CODE_RQC: |
133 |
|
|
|
134 |
|
|
tmps = mopGetShort(pkt, &idx); |
135 |
|
|
fprintf(fd, "Receipt Nbr : %04x\n", tmps); |
136 |
|
|
|
137 |
|
|
break; |
138 |
|
|
case MOP_K_CODE_CNT: |
139 |
|
|
|
140 |
|
|
tmps = mopGetShort(pkt, &idx); |
141 |
|
|
fprintf(fd, "Receipt Nbr : %04x %d\n", tmps, tmps); |
142 |
|
|
|
143 |
|
|
tmps = mopGetShort(pkt, &idx); |
144 |
|
|
fprintf(fd, "Last Zeroed : %04x %d\n", tmps, tmps); |
145 |
|
|
|
146 |
|
|
tmpl = mopGetLong(pkt, &idx); |
147 |
|
|
fprintf(fd, "Bytes rec : %08lx %ld\n", tmpl, tmpl); |
148 |
|
|
|
149 |
|
|
tmpl = mopGetLong(pkt, &idx); |
150 |
|
|
fprintf(fd, "Bytes snd : %08lx %ld\n", tmpl, tmpl); |
151 |
|
|
|
152 |
|
|
tmpl = mopGetLong(pkt, &idx); |
153 |
|
|
fprintf(fd, "Frames rec : %08lx %ld\n", tmpl, tmpl); |
154 |
|
|
|
155 |
|
|
tmpl = mopGetLong(pkt, &idx); |
156 |
|
|
fprintf(fd, "Frames snd : %08lx %ld\n", tmpl, tmpl); |
157 |
|
|
|
158 |
|
|
tmpl = mopGetLong(pkt, &idx); |
159 |
|
|
fprintf(fd, "Mcst Bytes re: %08lx %ld\n", tmpl, tmpl); |
160 |
|
|
|
161 |
|
|
tmpl = mopGetLong(pkt, &idx); |
162 |
|
|
fprintf(fd, "Mcst Frame re: %08lx %ld\n", tmpl, tmpl); |
163 |
|
|
|
164 |
|
|
tmpl = mopGetLong(pkt, &idx); |
165 |
|
|
fprintf(fd, "Frame snd, def: %08lx %ld\n", tmpl, tmpl); |
166 |
|
|
|
167 |
|
|
tmpl = mopGetLong(pkt, &idx); |
168 |
|
|
fprintf(fd, "Frame snd, col: %08lx %ld\n", tmpl, tmpl); |
169 |
|
|
|
170 |
|
|
tmpl = mopGetLong(pkt, &idx); |
171 |
|
|
fprintf(fd, "Frame snd, mcl: %08lx %ld\n", tmpl, tmpl); |
172 |
|
|
|
173 |
|
|
tmps = mopGetShort(pkt, &idx); |
174 |
|
|
fprintf(fd, "Snd failure : %04x %d\n", tmps, tmps); |
175 |
|
|
|
176 |
|
|
tmps = mopGetShort(pkt, &idx); |
177 |
|
|
fprintf(fd, "Snd fail reas: %04x ", tmps); |
178 |
|
|
if (tmps & 1) |
179 |
|
|
fprintf(fd, "Excess col "); |
180 |
|
|
if (tmps & 2) |
181 |
|
|
fprintf(fd, "Carrier chk fail "); |
182 |
|
|
if (tmps & 4) |
183 |
|
|
fprintf(fd, "Short circ "); |
184 |
|
|
if (tmps & 8) |
185 |
|
|
fprintf(fd, "Open circ "); |
186 |
|
|
if (tmps & 16) |
187 |
|
|
fprintf(fd, "Frm to long "); |
188 |
|
|
if (tmps & 32) |
189 |
|
|
fprintf(fd, "Rem fail to defer "); |
190 |
|
|
fprintf(fd, "\n"); |
191 |
|
|
|
192 |
|
|
tmps = mopGetShort(pkt, &idx); |
193 |
|
|
fprintf(fd, "Rec failure : %04x %d\n", tmps, tmps); |
194 |
|
|
|
195 |
|
|
tmps = mopGetShort(pkt, &idx); |
196 |
|
|
fprintf(fd, "Rec fail reas: %04x ", tmps); |
197 |
|
|
if (tmps & 1) |
198 |
|
|
fprintf(fd, "Block chk err "); |
199 |
|
|
if (tmps & 2) |
200 |
|
|
fprintf(fd, "Framing err "); |
201 |
|
|
if (tmps & 4) |
202 |
|
|
fprintf(fd, "Frm to long "); |
203 |
|
|
fprintf(fd, "\n"); |
204 |
|
|
|
205 |
|
|
tmps = mopGetShort(pkt, &idx); |
206 |
|
|
fprintf(fd, "Unrec frm dst: %04x %d\n", tmps, tmps); |
207 |
|
|
|
208 |
|
|
tmps = mopGetShort(pkt, &idx); |
209 |
|
|
fprintf(fd, "Data overrun : %04x %d\n", tmps, tmps); |
210 |
|
|
|
211 |
|
|
tmps = mopGetShort(pkt, &idx); |
212 |
|
|
fprintf(fd, "Sys Buf Unava: %04x %d\n", tmps, tmps); |
213 |
|
|
|
214 |
|
|
tmps = mopGetShort(pkt, &idx); |
215 |
|
|
fprintf(fd, "Usr Buf Unava: %04x %d\n", tmps, tmps); |
216 |
|
|
|
217 |
|
|
break; |
218 |
|
|
case MOP_K_CODE_RVC: |
219 |
|
|
|
220 |
|
|
tmpl = mopGetLong(pkt, &idx); |
221 |
|
|
fprintf(fd, "Verification : %08lx\n", tmpl); |
222 |
|
|
|
223 |
|
|
break; |
224 |
|
|
case MOP_K_CODE_RLC: |
225 |
|
|
|
226 |
|
|
/* Empty message */ |
227 |
|
|
|
228 |
|
|
break; |
229 |
|
|
case MOP_K_CODE_CCP: |
230 |
|
|
tmpc = mopGetChar(pkt, &idx); |
231 |
|
|
fprintf(fd, "Control Flags: %02x Message %d ", tmpc, tmpc & 1); |
232 |
|
|
if (tmpc & 2) |
233 |
|
|
fprintf(fd, "Break"); |
234 |
|
|
fprintf(fd, "\n"); |
235 |
|
|
|
236 |
|
|
if (moplen > 2) { |
237 |
|
|
for (i = 0; i < (moplen - 2); i++) { |
238 |
|
|
if ((i % 16) == 0) { |
239 |
|
|
if ((i / 16) == 0) |
240 |
|
|
fprintf(fd, |
241 |
|
|
"Image Data : %04x ", |
242 |
|
|
moplen-2); |
243 |
|
|
else |
244 |
|
|
fprintf(fd, |
245 |
|
|
" "); |
246 |
|
|
} |
247 |
|
|
fprintf(fd, "%02x ", mopGetChar(pkt, &idx)); |
248 |
|
|
if ((i % 16) == 15) |
249 |
|
|
fprintf(fd, "\n"); |
250 |
|
|
} |
251 |
|
|
if ((i % 16) != 15) |
252 |
|
|
fprintf(fd, "\n"); |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
break; |
256 |
|
|
case MOP_K_CODE_CRA: |
257 |
|
|
|
258 |
|
|
tmpc = mopGetChar(pkt, &idx); |
259 |
|
|
fprintf(fd, "Control Flags: %02x Message %d ", tmpc, tmpc & 1); |
260 |
|
|
if (tmpc & 2) |
261 |
|
|
fprintf(fd, "Cmd Data Lost "); |
262 |
|
|
if (tmpc & 4) |
263 |
|
|
fprintf(fd, "Resp Data Lost "); |
264 |
|
|
fprintf(fd, "\n"); |
265 |
|
|
|
266 |
|
|
if (moplen > 2) { |
267 |
|
|
for (i = 0; i < (moplen - 2); i++) { |
268 |
|
|
if ((i % 16) == 0) { |
269 |
|
|
if ((i / 16) == 0) |
270 |
|
|
fprintf(fd, |
271 |
|
|
"Image Data : %04x ", |
272 |
|
|
moplen-2); |
273 |
|
|
else |
274 |
|
|
fprintf(fd, |
275 |
|
|
" "); |
276 |
|
|
} |
277 |
|
|
fprintf(fd, "%02x ", mopGetChar(pkt, &idx)); |
278 |
|
|
if ((i % 16) == 15) |
279 |
|
|
fprintf(fd, "\n"); |
280 |
|
|
} |
281 |
|
|
if ((i % 16) != 15) |
282 |
|
|
fprintf(fd, "\n"); |
283 |
|
|
} |
284 |
|
|
|
285 |
|
|
break; |
286 |
|
|
default: |
287 |
|
|
break; |
288 |
|
|
} |
289 |
|
|
} |