1 /* $NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $ */
4 * Copyright (c) 1993-96 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.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Mats O Jansson.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
34 static char rcsid
[]="$NetBSD: print.c,v 1.2 1997/03/25 03:07:30 thorpej Exp $";
37 #include <sys/types.h>
55 (void)fprintf(fd
, "%x:%x:%x:%x:%x:%x",
56 ap
[0],ap
[1],ap
[2],ap
[3],ap
[4],ap
[5]);
57 if (ap
[0] < 10) (void)fprintf(fd
, " ");
58 if (ap
[1] < 10) (void)fprintf(fd
, " ");
59 if (ap
[2] < 10) (void)fprintf(fd
, " ");
60 if (ap
[3] < 10) (void)fprintf(fd
, " ");
61 if (ap
[4] < 10) (void)fprintf(fd
, " ");
62 if (ap
[5] < 10) (void)fprintf(fd
, " ");
66 mopPrintBPTY(fd
, bpty
)
72 (void)fprintf(fd
, "System Processor");
75 (void)fprintf(fd
, "Communication Processor");
78 (void)fprintf(fd
, "Unknown");
84 mopPrintPGTY(fd
, pgty
)
89 case MOP_K_PGTY_SECLDR
:
90 (void)fprintf(fd
, "Secondary Loader");
92 case MOP_K_PGTY_TERLDR
:
93 (void)fprintf(fd
, "Tertiary Loader");
95 case MOP_K_PGTY_OPRSYS
:
96 (void)fprintf(fd
, "Operating System");
98 case MOP_K_PGTY_MGNTFL
:
99 (void)fprintf(fd
, "Management File");
102 (void)fprintf(fd
, "Unknown");
108 mopPrintOneline(fd
, pkt
, trans
)
114 u_char
*dst
, *src
, code
;
118 trans
= mopGetTrans(pkt
, trans
);
119 mopGetHeader(pkt
, &index
, &dst
, &src
, &proto
, &len
, trans
);
120 code
= mopGetChar(pkt
, &index
);
124 (void)fprintf(fd
, "MOP DL ");
127 (void)fprintf(fd
, "MOP RC ");
130 (void)fprintf(fd
, "MOP LP ");
133 switch((proto
% 256)*256 + (proto
/ 256)) {
135 (void)fprintf(fd
, "MOP DL ");
136 proto
= MOP_K_PROTO_DL
;
139 (void)fprintf(fd
, "MOP RC ");
140 proto
= MOP_K_PROTO_RC
;
143 (void)fprintf(fd
, "MOP LP ");
144 proto
= MOP_K_PROTO_LP
;
147 (void)fprintf(fd
, "MOP ?? ");
152 if (trans
== TRANS_8023
) {
153 (void)fprintf(fd
, "802.3 ");
156 mopPrintHWA(fd
, src
); (void)fprintf(fd
," > ");
157 mopPrintHWA(fd
, dst
);
159 (void)fprintf(fd
, " len %4d code %02x ",len
,code
);
161 (void)fprintf(fd
, " len %4d code %02x ",
162 (len
% 256)*256 + (len
/256), code
);
169 (void)fprintf(fd
, "MLT ");
172 (void)fprintf(fd
, "DCM ");
175 (void)fprintf(fd
, "MLD ");
178 (void)fprintf(fd
, "ASV ");
181 (void)fprintf(fd
, "RMD ");
184 (void)fprintf(fd
, "RPR ");
187 (void)fprintf(fd
, "RML ");
190 (void)fprintf(fd
, "RDS ");
193 (void)fprintf(fd
, "MDD ");
196 (void)fprintf(fd
, "PLT ");
199 (void)fprintf(fd
, "??? ");
206 (void)fprintf(fd
, "RID ");
209 (void)fprintf(fd
, "BOT ");
212 (void)fprintf(fd
, "SID ");
215 (void)fprintf(fd
, "RQC ");
218 (void)fprintf(fd
, "CNT ");
221 (void)fprintf(fd
, "RVC ");
224 (void)fprintf(fd
, "RLC ");
227 (void)fprintf(fd
, "CCP ");
230 (void)fprintf(fd
, "CRA ");
233 (void)fprintf(fd
, "??? ");
240 (void)fprintf(fd
, "ALD ");
243 (void)fprintf(fd
, "PLD ");
246 (void)fprintf(fd
, "??? ");
251 (void)fprintf(fd
, "??? ");
254 (void)fprintf(fd
, "\n");
258 mopPrintHeader(fd
, pkt
, trans
)
267 trans
= mopGetTrans(pkt
, trans
);
268 mopGetHeader(pkt
, &index
, &dst
, &src
, &proto
, &len
, trans
);
270 (void)fprintf(fd
,"\nDst : ");
271 mopPrintHWA(fd
, dst
);
272 if (mopCmpEAddr(dl_mcst
,dst
) == 0) {
273 (void)fprintf(fd
," MOP Dump/Load Multicast");
275 if (mopCmpEAddr(rc_mcst
,dst
) == 0) {
276 (void)fprintf(fd
," MOP Remote Console Multicast");
278 (void)fprintf(fd
,"\n");
280 (void)fprintf(fd
,"Src : ");
281 mopPrintHWA(fd
, src
);
282 (void)fprintf(fd
,"\n");
283 (void)fprintf(fd
,"Proto : %04x ",proto
);
288 (void)fprintf(fd
, "MOP Dump/Load (802.3)\n");
291 (void)fprintf(fd
, "MOP Dump/Load\n");
297 (void)fprintf(fd
, "MOP Remote Console (802.3)\n");
300 (void)fprintf(fd
, "MOP Remote Console\n");
306 (void)fprintf(fd
, "MOP Loopback (802.3)\n");
309 (void)fprintf(fd
, "MOP Loopback\n");
313 (void)fprintf(fd
, "\n");
318 (void)fprintf(fd
,"Length : %04x (%d)\n",len
,len
);
322 mopPrintMopHeader(fd
, pkt
, trans
)
332 trans
= mopGetTrans(pkt
, trans
);
333 mopGetHeader(pkt
, &index
, &dst
, &src
, &proto
, &len
, trans
);
335 code
= mopGetChar(pkt
, &index
);
337 (void)fprintf(fd
, "Code : %02x ",code
);
344 "Memory Load with transfer address\n");
347 (void)fprintf(fd
, "Dump Complete\n");
350 (void)fprintf(fd
, "Memory Load\n");
353 (void)fprintf(fd
, "Assistance volunteer\n");
356 (void)fprintf(fd
, "Request memory dump\n");
359 (void)fprintf(fd
, "Request program\n");
362 (void)fprintf(fd
, "Request memory load\n");
365 (void)fprintf(fd
, "Request Dump Service\n");
368 (void)fprintf(fd
, "Memory dump data\n");
372 "Parameter load with transfer addres\n");
375 (void)fprintf(fd
, "(unknown)\n");
382 (void)fprintf(fd
, "Request ID\n");
385 (void)fprintf(fd
, "Boot\n");
388 (void)fprintf(fd
, "System ID\n");
391 (void)fprintf(fd
, "Request Counters\n");
394 (void)fprintf(fd
, "Counters\n");
397 (void)fprintf(fd
, "Reserve Console\n");
400 (void)fprintf(fd
, "Release Console\n");
403 (void)fprintf(fd
, "Console Command and Poll\n");
407 "Console Response and Acknnowledge\n");
410 (void)fprintf(fd
, "(unknown)\n");
417 (void)fprintf(fd
, "Active loop data\n");
420 (void)fprintf(fd
, "Passive looped data\n");
423 (void)fprintf(fd
, "(unknown)\n");
428 (void)fprintf(fd
, "(unknown)\n");
434 mopPrintDevice(fd
, device
)
440 sname
= nmaGetShort((int) device
);
441 name
= nmaGetDevice((int) device
);
443 (void)fprintf(fd
, "%s '%s'",sname
,name
);
452 "%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d",
454 ap
[2],ap
[3],ap
[4],ap
[5],ap
[6],ap
[7],ap
[8],ap
[9]);
458 mopPrintInfo(fd
, pkt
, index
, moplen
, mopcode
, trans
)
460 u_char
*pkt
, mopcode
;
465 u_char ilen
,tmpc
,device
;
466 u_char uc1
,uc2
,uc3
,*ucp
;
473 moplen
= moplen
+ 16;
476 moplen
= moplen
+ 14;
480 itype
= mopGetShort(pkt
,index
);
482 while (*index
< (int)(moplen
+ 2)) {
483 ilen
= mopGetChar(pkt
,index
);
486 tmpc
= mopGetChar(pkt
,index
);
487 *index
= *index
+ tmpc
;
490 uc1
= mopGetChar(pkt
,index
);
491 uc2
= mopGetChar(pkt
,index
);
492 uc3
= mopGetChar(pkt
,index
);
493 (void)fprintf(fd
,"Maint Version: %d.%d.%d\n",
496 case MOP_K_INFO_MFCT
:
497 tmps
= mopGetShort(pkt
,index
);
498 (void)fprintf(fd
,"Maint Funcion: %04x ( ",tmps
);
499 if (tmps
& 1) (void)fprintf(fd
, "Loop ");
500 if (tmps
& 2) (void)fprintf(fd
, "Dump ");
501 if (tmps
& 4) (void)fprintf(fd
, "Pldr ");
502 if (tmps
& 8) (void)fprintf(fd
, "MLdr ");
503 if (tmps
& 16) (void)fprintf(fd
, "Boot ");
504 if (tmps
& 32) (void)fprintf(fd
, "CC ");
505 if (tmps
& 64) (void)fprintf(fd
, "DLC ");
506 if (tmps
& 128) (void)fprintf(fd
, "CCR ");
507 (void)fprintf(fd
, ")\n");
510 ucp
= pkt
+ *index
; *index
= *index
+ 6;
511 (void)fprintf(fd
,"Console User : ");
512 mopPrintHWA(fd
, ucp
);
513 (void)fprintf(fd
, "\n");
516 tmps
= mopGetShort(pkt
,index
);
517 (void)fprintf(fd
,"Reserv Timer : %04x (%d)\n",
521 tmps
= mopGetShort(pkt
,index
);
522 (void)fprintf(fd
,"Cons Cmd Size: %04x (%d)\n",
526 tmps
= mopGetShort(pkt
,index
);
527 (void)fprintf(fd
,"Cons Res Size: %04x (%d)\n",
531 ucp
= pkt
+ *index
; *index
= *index
+ 6;
532 (void)fprintf(fd
,"Hardware Addr: ");
533 mopPrintHWA(fd
, ucp
);
534 (void)fprintf(fd
, "\n");
536 case MOP_K_INFO_TIME
:
537 ucp
= pkt
+ *index
; *index
= *index
+ 10;
538 (void)fprintf(fd
,"System Time: ");
539 mopPrintTime(fd
, ucp
);
540 (void)fprintf(fd
,"\n");
542 case MOP_K_INFO_SOFD
:
543 device
= mopGetChar(pkt
,index
);
544 (void)fprintf(fd
,"Comm Device : %02x ",device
);
545 mopPrintDevice(fd
, device
);
546 (void)fprintf(fd
, "\n");
548 case MOP_K_INFO_SFID
:
549 tmpc
= mopGetChar(pkt
,index
);
550 (void)fprintf(fd
,"Software ID : %02x ",tmpc
);
552 (void)fprintf(fd
,"No software id");
555 (void)fprintf(fd
,"Maintenance system");
559 (void)fprintf(fd
,"Standard operating system");
563 (void)fprintf(fd
,"'");
564 for (i
= 0; i
< ((int) tmpc
); i
++) {
565 (void)fprintf(fd
,"%c",
566 mopGetChar(pkt
,index
));
568 (void)fprintf(fd
,"'");
570 (void)fprintf(fd
,"\n");
572 case MOP_K_INFO_PRTY
:
573 tmpc
= mopGetChar(pkt
,index
);
574 (void)fprintf(fd
,"System Proc : %02x ",tmpc
);
577 (void)fprintf(fd
, "PDP-11\n");
579 case MOP_K_PRTY_CMSV
:
581 "Communication Server\n");
584 (void)fprintf(fd
, "Professional\n");
587 (void)fprintf(fd
, "Scorpio\n");
590 (void)fprintf(fd
, "Amber\n");
593 (void)fprintf(fd
, "XLII Bridge\n");
596 (void)fprintf(fd
, "Unknown\n");
600 case MOP_K_INFO_DLTY
:
601 tmpc
= mopGetChar(pkt
,index
);
602 (void)fprintf(fd
,"Data Link Typ: %02x ",tmpc
);
605 (void)fprintf(fd
, "Ethernet\n");
607 case MOP_K_DLTY_DDCMP
:
608 (void)fprintf(fd
, "DDCMP\n");
610 case MOP_K_DLTY_LAPB
:
611 (void)fprintf(fd
, "LAPB (X.25)\n");
614 (void)fprintf(fd
, "Unknown\n");
618 case MOP_K_INFO_DLBSZ
:
619 tmps
= mopGetShort(pkt
,index
);
620 (void)fprintf(fd
,"DL Buff Size : %04x (%d)\n",
624 if (((device
= NMA_C_SOFD_LCS
) || /* DECserver 100 */
625 (device
= NMA_C_SOFD_DS2
) || /* DECserver 200 */
626 (device
= NMA_C_SOFD_DP2
) || /* DECserver 250 */
627 (device
= NMA_C_SOFD_DS3
)) && /* DECserver 300 */
628 ((itype
> 101) && (itype
< 107)))
633 *index
= *index
+ ilen
;
635 "ROM Sftwr Ver: %02x '",
637 for (i
= 0; i
< ilen
; i
++) {
638 (void)fprintf(fd
,"%c",ucp
[i
]);
640 (void)fprintf(fd
, "'\n");
644 *index
= *index
+ ilen
;
646 "Software Ver : %02x '",
648 for (i
= 0; i
< ilen
; i
++) {
649 (void)fprintf(fd
, "%c",ucp
[i
]);
651 (void)fprintf(fd
, "'\n");
654 tmps
= mopGetShort(pkt
,index
);
656 "DECnet Addr : %d.%d (%d)\n",
663 *index
= *index
+ ilen
;
665 "Node Name : %02x '",
667 for (i
= 0; i
< ilen
; i
++) {
668 (void)fprintf(fd
, "%c",ucp
[i
]);
670 (void)fprintf(fd
, "'\n");
674 *index
= *index
+ ilen
;
676 "Node Ident : %02x '",
678 for (i
= 0; i
< ilen
; i
++) {
679 (void)fprintf(fd
, "%c",ucp
[i
]);
681 (void)fprintf(fd
, "'\n");
685 ucp
= pkt
+ *index
; *index
= *index
+ ilen
;
686 (void)fprintf(fd
, "Info Type : %04x (%d)\n",
689 (void)fprintf(fd
, "Info Data : %02x ",
691 for (i
= 0; i
< ilen
; i
++) {
699 (void)fprintf(fd
, "%02x ",ucp
[i
]);
701 (void)fprintf(fd
, "\n");
704 itype
= mopGetShort(pkt
,index
);