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