1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
/* $NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Mats O Jansson.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char rcsid[]="$NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $";
#endif
#include <sys/types.h>
#include <stdio.h>
#include "os.h"
#include "cmp.h"
#include "get.h"
#include "mopdef.h"
#include "nma.h"
#include "nmadef.h"
#include "print.h"
#define SHORT_PRINT
void
mopPrintHWA(fd, ap)
FILE *fd;
u_char *ap;
{
(void)fprintf(fd, "%x:%x:%x:%x:%x:%x",
ap[0],ap[1],ap[2],ap[3],ap[4],ap[5]);
if (ap[0] < 10) (void)fprintf(fd, " ");
if (ap[1] < 10) (void)fprintf(fd, " ");
if (ap[2] < 10) (void)fprintf(fd, " ");
if (ap[3] < 10) (void)fprintf(fd, " ");
if (ap[4] < 10) (void)fprintf(fd, " ");
if (ap[5] < 10) (void)fprintf(fd, " ");
}
void
mopPrintBPTY(fd, bpty)
FILE *fd;
u_char bpty;
{
switch(bpty) {
case MOP_K_BPTY_SYS:
(void)fprintf(fd, "System Processor");
break;
case MOP_K_BPTY_COM:
(void)fprintf(fd, "Communication Processor");
break;
default:
(void)fprintf(fd, "Unknown");
break;
};
};
void
mopPrintPGTY(fd, pgty)
FILE *fd;
u_char pgty;
{
switch(pgty) {
case MOP_K_PGTY_SECLDR:
(void)fprintf(fd, "Secondary Loader");
break;
case MOP_K_PGTY_TERLDR:
(void)fprintf(fd, "Tertiary Loader");
break;
case MOP_K_PGTY_OPRSYS:
(void)fprintf(fd, "Operating System");
break;
case MOP_K_PGTY_MGNTFL:
(void)fprintf(fd, "Management File");
break;
default:
(void)fprintf(fd, "Unknown");
break;
};
}
void
mopPrintOneline(fd, pkt, trans)
FILE *fd;
u_char *pkt;
int trans;
{
int index = 0;
u_char *dst, *src, code;
u_short proto;
int len;
trans = mopGetTrans(pkt, trans);
mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans);
code = mopGetChar(pkt, &index);
switch (proto) {
case MOP_K_PROTO_DL:
(void)fprintf(fd, "MOP DL ");
break;
case MOP_K_PROTO_RC:
(void)fprintf(fd, "MOP RC ");
break;
case MOP_K_PROTO_LP:
(void)fprintf(fd, "MOP LP ");
break;
default:
switch((proto % 256)*256 + (proto / 256)) {
case MOP_K_PROTO_DL:
(void)fprintf(fd, "MOP DL ");
proto = MOP_K_PROTO_DL;
break;
case MOP_K_PROTO_RC:
(void)fprintf(fd, "MOP RC ");
proto = MOP_K_PROTO_RC;
break;
case MOP_K_PROTO_LP:
(void)fprintf(fd, "MOP LP ");
proto = MOP_K_PROTO_LP;
break;
default:
(void)fprintf(fd, "MOP ?? ");
break;
}
}
if (trans == TRANS_8023) {
(void)fprintf(fd, "802.3 ");
}
mopPrintHWA(fd, src); (void)fprintf(fd," > ");
mopPrintHWA(fd, dst);
if (len < 1600) {
(void)fprintf(fd, " len %4d code %02x ",len,code);
} else {
(void)fprintf(fd, " len %4d code %02x ",
(len % 256)*256 + (len /256), code);
}
switch (proto) {
case MOP_K_PROTO_DL:
switch (code) {
case MOP_K_CODE_MLT:
(void)fprintf(fd, "MLT ");
break;
case MOP_K_CODE_DCM:
(void)fprintf(fd, "DCM ");
break;
case MOP_K_CODE_MLD:
(void)fprintf(fd, "MLD ");
break;
case MOP_K_CODE_ASV:
(void)fprintf(fd, "ASV ");
break;
case MOP_K_CODE_RMD:
(void)fprintf(fd, "RMD ");
break;
case MOP_K_CODE_RPR:
(void)fprintf(fd, "RPR ");
break;
case MOP_K_CODE_RML:
(void)fprintf(fd, "RML ");
break;
case MOP_K_CODE_RDS:
(void)fprintf(fd, "RDS ");
break;
case MOP_K_CODE_MDD:
(void)fprintf(fd, "MDD ");
break;
case MOP_K_CODE_PLT:
(void)fprintf(fd, "PLT ");
break;
default:
(void)fprintf(fd, "??? ");
break;
}
break;
case MOP_K_PROTO_RC:
switch (code) {
case MOP_K_CODE_RID:
(void)fprintf(fd, "RID ");
break;
case MOP_K_CODE_BOT:
(void)fprintf(fd, "BOT ");
break;
case MOP_K_CODE_SID:
(void)fprintf(fd, "SID ");
break;
case MOP_K_CODE_RQC:
(void)fprintf(fd, "RQC ");
break;
case MOP_K_CODE_CNT:
(void)fprintf(fd, "CNT ");
break;
case MOP_K_CODE_RVC:
(void)fprintf(fd, "RVC ");
break;
case MOP_K_CODE_RLC:
(void)fprintf(fd, "RLC ");
break;
case MOP_K_CODE_CCP:
(void)fprintf(fd, "CCP ");
break;
case MOP_K_CODE_CRA:
(void)fprintf(fd, "CRA ");
break;
default:
(void)fprintf(fd, "??? ");
break;
}
break;
case MOP_K_PROTO_LP:
switch (code) {
case MOP_K_CODE_ALD:
(void)fprintf(fd, "ALD ");
break;
case MOP_K_CODE_PLD:
(void)fprintf(fd, "PLD ");
break;
default:
(void)fprintf(fd, "??? ");
break;
}
break;
default:
(void)fprintf(fd, "??? ");
break;
}
(void)fprintf(fd, "\n");
}
void
mopPrintHeader(fd, pkt, trans)
FILE *fd;
u_char *pkt;
int trans;
{
u_char *dst, *src;
u_short proto;
int len, index = 0;
trans = mopGetTrans(pkt, trans);
mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans);
(void)fprintf(fd,"\nDst : ");
mopPrintHWA(fd, dst);
if (mopCmpEAddr(dl_mcst,dst) == 0) {
(void)fprintf(fd," MOP Dump/Load Multicast");
};
if (mopCmpEAddr(rc_mcst,dst) == 0) {
(void)fprintf(fd," MOP Remote Console Multicast");
};
(void)fprintf(fd,"\n");
(void)fprintf(fd,"Src : ");
mopPrintHWA(fd, src);
(void)fprintf(fd,"\n");
(void)fprintf(fd,"Proto : %04x ",proto);
switch (proto) {
case MOP_K_PROTO_DL:
switch (trans) {
case TRANS_8023:
(void)fprintf(fd, "MOP Dump/Load (802.3)\n");
break;
default:
(void)fprintf(fd, "MOP Dump/Load\n");
}
break;
case MOP_K_PROTO_RC:
switch (trans) {
case TRANS_8023:
(void)fprintf(fd, "MOP Remote Console (802.3)\n");
break;
default:
(void)fprintf(fd, "MOP Remote Console\n");
}
break;
case MOP_K_PROTO_LP:
switch (trans) {
case TRANS_8023:
(void)fprintf(fd, "MOP Loopback (802.3)\n");
break;
default:
(void)fprintf(fd, "MOP Loopback\n");
}
break;
default:
(void)fprintf(fd, "\n");
break;
}
(void)fprintf(fd,"Length : %04x (%d)\n",len,len);
}
void
mopPrintMopHeader(fd, pkt, trans)
FILE *fd;
u_char *pkt;
int trans;
{
u_char *dst, *src;
u_short proto;
int len, index = 0;
u_char code;
trans = mopGetTrans(pkt, trans);
mopGetHeader(pkt, &index, &dst, &src, &proto, &len, trans);
code = mopGetChar(pkt, &index);
(void)fprintf(fd, "Code : %02x ",code);
switch (proto) {
case MOP_K_PROTO_DL:
switch (code) {
case MOP_K_CODE_MLT:
(void)fprintf(fd,
"Memory Load with transfer address\n");
break;
case MOP_K_CODE_DCM:
(void)fprintf(fd, "Dump Complete\n");
break;
case MOP_K_CODE_MLD:
(void)fprintf(fd, "Memory Load\n");
break;
case MOP_K_CODE_ASV:
(void)fprintf(fd, "Assistance volunteer\n");
break;
case MOP_K_CODE_RMD:
(void)fprintf(fd, "Request memory dump\n");
break;
case MOP_K_CODE_RPR:
(void)fprintf(fd, "Request program\n");
break;
case MOP_K_CODE_RML:
(void)fprintf(fd, "Request memory load\n");
break;
case MOP_K_CODE_RDS:
(void)fprintf(fd, "Request Dump Service\n");
break;
case MOP_K_CODE_MDD:
(void)fprintf(fd, "Memory dump data\n");
break;
case MOP_K_CODE_PLT:
(void)fprintf(fd,
"Parameter load with transfer addres\n");
break;
default:
(void)fprintf(fd, "(unknown)\n");
break;
}
break;
case MOP_K_PROTO_RC:
switch (code) {
case MOP_K_CODE_RID:
(void)fprintf(fd, "Request ID\n");
break;
case MOP_K_CODE_BOT:
(void)fprintf(fd, "Boot\n");
break;
case MOP_K_CODE_SID:
(void)fprintf(fd, "System ID\n");
break;
case MOP_K_CODE_RQC:
(void)fprintf(fd, "Request Counters\n");
break;
case MOP_K_CODE_CNT:
(void)fprintf(fd, "Counters\n");
break;
case MOP_K_CODE_RVC:
(void)fprintf(fd, "Reserve Console\n");
break;
case MOP_K_CODE_RLC:
(void)fprintf(fd, "Release Console\n");
break;
case MOP_K_CODE_CCP:
(void)fprintf(fd, "Console Command and Poll\n");
break;
case MOP_K_CODE_CRA:
(void)fprintf(fd,
"Console Response and Acknnowledge\n");
break;
default:
(void)fprintf(fd, "(unknown)\n");
break;
}
break;
case MOP_K_PROTO_LP:
switch (code) {
case MOP_K_CODE_ALD:
(void)fprintf(fd, "Active loop data\n");
break;
case MOP_K_CODE_PLD:
(void)fprintf(fd, "Passive looped data\n");
break;
default:
(void)fprintf(fd, "(unknown)\n");
break;
}
break;
default:
(void)fprintf(fd, "(unknown)\n");
break;
}
}
void
mopPrintDevice(fd, device)
FILE *fd;
u_char device;
{
char *sname, *name;
sname = nmaGetShort((int) device);
name = nmaGetDevice((int) device);
(void)fprintf(fd, "%s '%s'",sname,name);
}
void
mopPrintTime(fd, ap)
FILE *fd;
u_char *ap;
{
(void)fprintf(fd,
"%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d",
ap[0]*100 + ap[1],
ap[2],ap[3],ap[4],ap[5],ap[6],ap[7],ap[8],ap[9]);
}
void
mopPrintInfo(fd, pkt, index, moplen, mopcode, trans)
FILE *fd;
u_char *pkt, mopcode;
int *index, trans;
u_short moplen;
{
u_short itype,tmps;
u_char ilen ,tmpc,device;
u_char uc1,uc2,uc3,*ucp;
int i;
device = 0;
switch(trans) {
case TRANS_ETHER:
moplen = moplen + 16;
break;
case TRANS_8023:
moplen = moplen + 14;
break;
}
itype = mopGetShort(pkt,index);
while (*index < (int)(moplen + 2)) {
ilen = mopGetChar(pkt,index);
switch (itype) {
case 0:
tmpc = mopGetChar(pkt,index);
*index = *index + tmpc;
break;
case MOP_K_INFO_VER:
uc1 = mopGetChar(pkt,index);
uc2 = mopGetChar(pkt,index);
uc3 = mopGetChar(pkt,index);
(void)fprintf(fd,"Maint Version: %d.%d.%d\n",
uc1,uc2,uc3);
break;
case MOP_K_INFO_MFCT:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,"Maint Funcion: %04x ( ",tmps);
if (tmps & 1) (void)fprintf(fd, "Loop ");
if (tmps & 2) (void)fprintf(fd, "Dump ");
if (tmps & 4) (void)fprintf(fd, "Pldr ");
if (tmps & 8) (void)fprintf(fd, "MLdr ");
if (tmps & 16) (void)fprintf(fd, "Boot ");
if (tmps & 32) (void)fprintf(fd, "CC ");
if (tmps & 64) (void)fprintf(fd, "DLC ");
if (tmps & 128) (void)fprintf(fd, "CCR ");
(void)fprintf(fd, ")\n");
break;
case MOP_K_INFO_CNU:
ucp = pkt + *index; *index = *index + 6;
(void)fprintf(fd,"Console User : ");
mopPrintHWA(fd, ucp);
(void)fprintf(fd, "\n");
break;
case MOP_K_INFO_RTM:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,"Reserv Timer : %04x (%d)\n",
tmps,tmps);
break;
case MOP_K_INFO_CSZ:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,"Cons Cmd Size: %04x (%d)\n",
tmps,tmps);
break;
case MOP_K_INFO_RSZ:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,"Cons Res Size: %04x (%d)\n",
tmps,tmps);
break;
case MOP_K_INFO_HWA:
ucp = pkt + *index; *index = *index + 6;
(void)fprintf(fd,"Hardware Addr: ");
mopPrintHWA(fd, ucp);
(void)fprintf(fd, "\n");
break;
case MOP_K_INFO_TIME:
ucp = pkt + *index; *index = *index + 10;
(void)fprintf(fd,"System Time: ");
mopPrintTime(fd, ucp);
(void)fprintf(fd,"\n");
break;
case MOP_K_INFO_SOFD:
device = mopGetChar(pkt,index);
(void)fprintf(fd,"Comm Device : %02x ",device);
mopPrintDevice(fd, device);
(void)fprintf(fd, "\n");
break;
case MOP_K_INFO_SFID:
tmpc = mopGetChar(pkt,index);
(void)fprintf(fd,"Software ID : %02x ",tmpc);
if ((tmpc == 0)) {
(void)fprintf(fd,"No software id");
}
if ((tmpc == 254)) {
(void)fprintf(fd,"Maintenance system");
tmpc = 0;
}
if ((tmpc == 255)) {
(void)fprintf(fd,"Standard operating system");
tmpc = 0;
}
if ((tmpc > 0)) {
(void)fprintf(fd,"'");
for (i = 0; i < ((int) tmpc); i++) {
(void)fprintf(fd,"%c",
mopGetChar(pkt,index));
}
(void)fprintf(fd,"'");
}
(void)fprintf(fd,"\n");
break;
case MOP_K_INFO_PRTY:
tmpc = mopGetChar(pkt,index);
(void)fprintf(fd,"System Proc : %02x ",tmpc);
switch (tmpc) {
case MOP_K_PRTY_11:
(void)fprintf(fd, "PDP-11\n");
break;
case MOP_K_PRTY_CMSV:
(void)fprintf(fd,
"Communication Server\n");
break;
case MOP_K_PRTY_PRO:
(void)fprintf(fd, "Professional\n");
break;
case MOP_K_PRTY_SCO:
(void)fprintf(fd, "Scorpio\n");
break;
case MOP_K_PRTY_AMB:
(void)fprintf(fd, "Amber\n");
break;
case MOP_K_PRTY_BRI:
(void)fprintf(fd, "XLII Bridge\n");
break;
default:
(void)fprintf(fd, "Unknown\n");
break;
};
break;
case MOP_K_INFO_DLTY:
tmpc = mopGetChar(pkt,index);
(void)fprintf(fd,"Data Link Typ: %02x ",tmpc);
switch (tmpc) {
case MOP_K_DLTY_NI:
(void)fprintf(fd, "Ethernet\n");
break;
case MOP_K_DLTY_DDCMP:
(void)fprintf(fd, "DDCMP\n");
break;
case MOP_K_DLTY_LAPB:
(void)fprintf(fd, "LAPB (X.25)\n");
break;
default:
(void)fprintf(fd, "Unknown\n");
break;
};
break;
case MOP_K_INFO_DLBSZ:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,"DL Buff Size : %04x (%d)\n",
tmps,tmps);
break;
default:
if (((device = NMA_C_SOFD_LCS) || /* DECserver 100 */
(device = NMA_C_SOFD_DS2) || /* DECserver 200 */
(device = NMA_C_SOFD_DP2) || /* DECserver 250 */
(device = NMA_C_SOFD_DS3)) && /* DECserver 300 */
((itype > 101) && (itype < 107)))
{
switch (itype) {
case 102:
ucp = pkt + *index;
*index = *index + ilen;
(void)fprintf(fd,
"ROM Sftwr Ver: %02x '",
ilen);
for (i = 0; i < ilen; i++) {
(void)fprintf(fd,"%c",ucp[i]);
}
(void)fprintf(fd, "'\n");
break;
case 103:
ucp = pkt + *index;
*index = *index + ilen;
(void)fprintf(fd,
"Software Ver : %02x '",
ilen);
for (i = 0; i < ilen; i++) {
(void)fprintf(fd, "%c",ucp[i]);
}
(void)fprintf(fd, "'\n");
break;
case 104:
tmps = mopGetShort(pkt,index);
(void)fprintf(fd,
"DECnet Addr : %d.%d (%d)\n",
tmps / 1024,
tmps % 1024,
tmps);
break;
case 105:
ucp = pkt + *index;
*index = *index + ilen;
(void)fprintf(fd,
"Node Name : %02x '",
ilen);
for (i = 0; i < ilen; i++) {
(void)fprintf(fd, "%c",ucp[i]);
}
(void)fprintf(fd, "'\n");
break;
case 106:
ucp = pkt + *index;
*index = *index + ilen;
(void)fprintf(fd,
"Node Ident : %02x '",
ilen);
for (i = 0; i < ilen; i++) {
(void)fprintf(fd, "%c",ucp[i]);
}
(void)fprintf(fd, "'\n");
break;
};
} else {
ucp = pkt + *index; *index = *index + ilen;
(void)fprintf(fd, "Info Type : %04x (%d)\n",
itype,
itype);
(void)fprintf(fd, "Info Data : %02x ",
ilen);
for (i = 0; i < ilen; i++) {
if ((i % 16) == 0) {
if ((i / 16) == 0) {
} else {
(void)fprintf(fd,
"\n ");
};
};
(void)fprintf(fd, "%02x ",ucp[i]);
}
(void)fprintf(fd, "\n");
};
}
itype = mopGetShort(pkt,index);
}
}
|