1 /* $NetBSD: print.c,v 1.5 2009/10/20 00:51:13 snj 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.
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.
27 #include <sys/cdefs.h>
29 __RCSID("$NetBSD: print.c,v 1.5 2009/10/20 00:51:13 snj Exp $");
32 #include <sys/types.h>
46 mopPrintHWA(FILE *fd
, const u_char
*ap
)
48 (void)fprintf(fd
, "%x:%x:%x:%x:%x:%x",
49 ap
[0],ap
[1],ap
[2],ap
[3],ap
[4],ap
[5]);
50 if (ap
[0] < 10) (void)fprintf(fd
, " ");
51 if (ap
[1] < 10) (void)fprintf(fd
, " ");
52 if (ap
[2] < 10) (void)fprintf(fd
, " ");
53 if (ap
[3] < 10) (void)fprintf(fd
, " ");
54 if (ap
[4] < 10) (void)fprintf(fd
, " ");
55 if (ap
[5] < 10) (void)fprintf(fd
, " ");
59 mopPrintBPTY(FILE *fd
, u_char bpty
)
63 (void)fprintf(fd
, "System Processor");
66 (void)fprintf(fd
, "Communication Processor");
69 (void)fprintf(fd
, "Unknown");
75 mopPrintPGTY(FILE *fd
, u_char pgty
)
78 case MOP_K_PGTY_SECLDR
:
79 (void)fprintf(fd
, "Secondary Loader");
81 case MOP_K_PGTY_TERLDR
:
82 (void)fprintf(fd
, "Tertiary Loader");
84 case MOP_K_PGTY_OPRSYS
:
85 (void)fprintf(fd
, "Operating System");
87 case MOP_K_PGTY_MGNTFL
:
88 (void)fprintf(fd
, "Management File");
91 (void)fprintf(fd
, "Unknown");
97 mopPrintOneline(FILE *fd
, const u_char
*pkt
, int trans
)
100 const u_char
*dst
, *src
;
105 trans
= mopGetTrans(pkt
, trans
);
106 mopGetHeader(pkt
, &idx
, &dst
, &src
, &proto
, &len
, trans
);
107 code
= mopGetChar(pkt
, &idx
);
111 (void)fprintf(fd
, "MOP DL ");
114 (void)fprintf(fd
, "MOP RC ");
117 (void)fprintf(fd
, "MOP LP ");
120 switch((proto
% 256)*256 + (proto
/ 256)) {
122 (void)fprintf(fd
, "MOP DL ");
123 proto
= MOP_K_PROTO_DL
;
126 (void)fprintf(fd
, "MOP RC ");
127 proto
= MOP_K_PROTO_RC
;
130 (void)fprintf(fd
, "MOP LP ");
131 proto
= MOP_K_PROTO_LP
;
134 (void)fprintf(fd
, "MOP ?? ");
139 if (trans
== TRANS_8023
) {
140 (void)fprintf(fd
, "802.3 ");
143 mopPrintHWA(fd
, src
); (void)fprintf(fd
," > ");
144 mopPrintHWA(fd
, dst
);
146 (void)fprintf(fd
, " len %4d code %02x ",len
,code
);
148 (void)fprintf(fd
, " len %4d code %02x ",
149 (len
% 256)*256 + (len
/256), code
);
156 (void)fprintf(fd
, "MLT ");
159 (void)fprintf(fd
, "DCM ");
162 (void)fprintf(fd
, "MLD ");
165 (void)fprintf(fd
, "ASV ");
168 (void)fprintf(fd
, "RMD ");
171 (void)fprintf(fd
, "RPR ");
174 (void)fprintf(fd
, "RML ");
177 (void)fprintf(fd
, "RDS ");
180 (void)fprintf(fd
, "MDD ");
183 (void)fprintf(fd
, "PLT ");
186 (void)fprintf(fd
, "??? ");
193 (void)fprintf(fd
, "RID ");
196 (void)fprintf(fd
, "BOT ");
199 (void)fprintf(fd
, "SID ");
202 (void)fprintf(fd
, "RQC ");
205 (void)fprintf(fd
, "CNT ");
208 (void)fprintf(fd
, "RVC ");
211 (void)fprintf(fd
, "RLC ");
214 (void)fprintf(fd
, "CCP ");
217 (void)fprintf(fd
, "CRA ");
220 (void)fprintf(fd
, "??? ");
227 (void)fprintf(fd
, "ALD ");
230 (void)fprintf(fd
, "PLD ");
233 (void)fprintf(fd
, "??? ");
238 (void)fprintf(fd
, "??? ");
241 (void)fprintf(fd
, "\n");
245 mopPrintHeader(FILE *fd
, const u_char
*pkt
, int trans
)
247 const u_char
*dst
, *src
;
251 trans
= mopGetTrans(pkt
, trans
);
252 mopGetHeader(pkt
, &idx
, &dst
, &src
, &proto
, &len
, trans
);
254 (void)fprintf(fd
,"\nDst : ");
255 mopPrintHWA(fd
, dst
);
256 if (mopCmpEAddr(dl_mcst
,dst
) == 0) {
257 (void)fprintf(fd
," MOP Dump/Load Multicast");
259 if (mopCmpEAddr(rc_mcst
,dst
) == 0) {
260 (void)fprintf(fd
," MOP Remote Console Multicast");
262 (void)fprintf(fd
,"\n");
264 (void)fprintf(fd
,"Src : ");
265 mopPrintHWA(fd
, src
);
266 (void)fprintf(fd
,"\n");
267 (void)fprintf(fd
,"Proto : %04x ",proto
);
272 (void)fprintf(fd
, "MOP Dump/Load (802.3)\n");
275 (void)fprintf(fd
, "MOP Dump/Load\n");
281 (void)fprintf(fd
, "MOP Remote Console (802.3)\n");
284 (void)fprintf(fd
, "MOP Remote Console\n");
290 (void)fprintf(fd
, "MOP Loopback (802.3)\n");
293 (void)fprintf(fd
, "MOP Loopback\n");
297 (void)fprintf(fd
, "\n");
302 (void)fprintf(fd
,"Length : %04x (%d)\n",len
,len
);
306 mopPrintMopHeader(FILE *fd
, const u_char
*pkt
, int trans
)
308 const u_char
*dst
, *src
;
313 trans
= mopGetTrans(pkt
, trans
);
314 mopGetHeader(pkt
, &idx
, &dst
, &src
, &proto
, &len
, trans
);
316 code
= mopGetChar(pkt
, &idx
);
318 (void)fprintf(fd
, "Code : %02x ",code
);
325 "Memory Load with transfer address\n");
328 (void)fprintf(fd
, "Dump Complete\n");
331 (void)fprintf(fd
, "Memory Load\n");
334 (void)fprintf(fd
, "Assistance volunteer\n");
337 (void)fprintf(fd
, "Request memory dump\n");
340 (void)fprintf(fd
, "Request program\n");
343 (void)fprintf(fd
, "Request memory load\n");
346 (void)fprintf(fd
, "Request Dump Service\n");
349 (void)fprintf(fd
, "Memory dump data\n");
353 "Parameter load with transfer addres\n");
356 (void)fprintf(fd
, "(unknown)\n");
363 (void)fprintf(fd
, "Request ID\n");
366 (void)fprintf(fd
, "Boot\n");
369 (void)fprintf(fd
, "System ID\n");
372 (void)fprintf(fd
, "Request Counters\n");
375 (void)fprintf(fd
, "Counters\n");
378 (void)fprintf(fd
, "Reserve Console\n");
381 (void)fprintf(fd
, "Release Console\n");
384 (void)fprintf(fd
, "Console Command and Poll\n");
388 "Console Response and Acknnowledge\n");
391 (void)fprintf(fd
, "(unknown)\n");
398 (void)fprintf(fd
, "Active loop data\n");
401 (void)fprintf(fd
, "Passive looped data\n");
404 (void)fprintf(fd
, "(unknown)\n");
409 (void)fprintf(fd
, "(unknown)\n");
415 mopPrintDevice(FILE *fd
, u_char device
)
417 const char *sname
, *name
;
419 sname
= nmaGetShort((int) device
);
420 name
= nmaGetDevice((int) device
);
422 (void)fprintf(fd
, "%s '%s'",sname
,name
);
426 mopPrintTime(FILE *fd
, const u_char
*ap
)
429 "%04d-%02d-%02d %02d:%02d:%02d.%02d %d:%02d",
431 ap
[2],ap
[3],ap
[4],ap
[5],ap
[6],ap
[7],ap
[8],ap
[9]);
435 mopPrintInfo(FILE *fd
, const u_char
*pkt
, int *idx
,
436 u_short moplen
, u_char mopcode
, int trans
)
439 u_char ilen
,tmpc
,device
;
448 moplen
= moplen
+ 16;
451 moplen
= moplen
+ 14;
455 itype
= mopGetShort(pkt
,idx
);
457 while (*idx
< (int)(moplen
+ 2)) {
458 ilen
= mopGetChar(pkt
,idx
);
461 tmpc
= mopGetChar(pkt
,idx
);
465 uc1
= mopGetChar(pkt
,idx
);
466 uc2
= mopGetChar(pkt
,idx
);
467 uc3
= mopGetChar(pkt
,idx
);
468 (void)fprintf(fd
,"Maint Version: %d.%d.%d\n",
471 case MOP_K_INFO_MFCT
:
472 tmps
= mopGetShort(pkt
,idx
);
473 (void)fprintf(fd
,"Maint Funcion: %04x ( ",tmps
);
474 if (tmps
& 1) (void)fprintf(fd
, "Loop ");
475 if (tmps
& 2) (void)fprintf(fd
, "Dump ");
476 if (tmps
& 4) (void)fprintf(fd
, "Pldr ");
477 if (tmps
& 8) (void)fprintf(fd
, "MLdr ");
478 if (tmps
& 16) (void)fprintf(fd
, "Boot ");
479 if (tmps
& 32) (void)fprintf(fd
, "CC ");
480 if (tmps
& 64) (void)fprintf(fd
, "DLC ");
481 if (tmps
& 128) (void)fprintf(fd
, "CCR ");
482 (void)fprintf(fd
, ")\n");
485 ucp
= pkt
+ *idx
; *idx
= *idx
+ 6;
486 (void)fprintf(fd
,"Console User : ");
487 mopPrintHWA(fd
, ucp
);
488 (void)fprintf(fd
, "\n");
491 tmps
= mopGetShort(pkt
,idx
);
492 (void)fprintf(fd
,"Reserv Timer : %04x (%d)\n",
496 tmps
= mopGetShort(pkt
,idx
);
497 (void)fprintf(fd
,"Cons Cmd Size: %04x (%d)\n",
501 tmps
= mopGetShort(pkt
,idx
);
502 (void)fprintf(fd
,"Cons Res Size: %04x (%d)\n",
506 ucp
= pkt
+ *idx
; *idx
= *idx
+ 6;
507 (void)fprintf(fd
,"Hardware Addr: ");
508 mopPrintHWA(fd
, ucp
);
509 (void)fprintf(fd
, "\n");
511 case MOP_K_INFO_TIME
:
512 ucp
= pkt
+ *idx
; *idx
= *idx
+ 10;
513 (void)fprintf(fd
,"System Time: ");
514 mopPrintTime(fd
, ucp
);
515 (void)fprintf(fd
,"\n");
517 case MOP_K_INFO_SOFD
:
518 device
= mopGetChar(pkt
,idx
);
519 (void)fprintf(fd
,"Comm Device : %02x ",device
);
520 mopPrintDevice(fd
, device
);
521 (void)fprintf(fd
, "\n");
523 case MOP_K_INFO_SFID
:
524 tmpc
= mopGetChar(pkt
,idx
);
525 (void)fprintf(fd
,"Software ID : %02x ",tmpc
);
527 (void)fprintf(fd
,"No software id");
530 (void)fprintf(fd
,"Maintenance system");
534 (void)fprintf(fd
,"Standard operating system");
538 (void)fprintf(fd
,"'");
539 for (i
= 0; i
< ((int) tmpc
); i
++) {
540 (void)fprintf(fd
,"%c",
541 mopGetChar(pkt
,idx
));
543 (void)fprintf(fd
,"'");
545 (void)fprintf(fd
,"\n");
547 case MOP_K_INFO_PRTY
:
548 tmpc
= mopGetChar(pkt
,idx
);
549 (void)fprintf(fd
,"System Proc : %02x ",tmpc
);
552 (void)fprintf(fd
, "PDP-11\n");
554 case MOP_K_PRTY_CMSV
:
556 "Communication Server\n");
559 (void)fprintf(fd
, "Professional\n");
562 (void)fprintf(fd
, "Scorpio\n");
565 (void)fprintf(fd
, "Amber\n");
568 (void)fprintf(fd
, "XLII Bridge\n");
571 (void)fprintf(fd
, "Unknown\n");
575 case MOP_K_INFO_DLTY
:
576 tmpc
= mopGetChar(pkt
,idx
);
577 (void)fprintf(fd
,"Data Link Typ: %02x ",tmpc
);
580 (void)fprintf(fd
, "Ethernet\n");
582 case MOP_K_DLTY_DDCMP
:
583 (void)fprintf(fd
, "DDCMP\n");
585 case MOP_K_DLTY_LAPB
:
586 (void)fprintf(fd
, "LAPB (X.25)\n");
589 (void)fprintf(fd
, "Unknown\n");
593 case MOP_K_INFO_DLBSZ
:
594 tmps
= mopGetShort(pkt
,idx
);
595 (void)fprintf(fd
,"DL Buff Size : %04x (%d)\n",
599 if (((device
= NMA_C_SOFD_LCS
) || /* DECserver 100 */
600 (device
= NMA_C_SOFD_DS2
) || /* DECserver 200 */
601 (device
= NMA_C_SOFD_DP2
) || /* DECserver 250 */
602 (device
= NMA_C_SOFD_DS3
)) && /* DECserver 300 */
603 ((itype
> 101) && (itype
< 107)))
610 "ROM Sftwr Ver: %02x '",
612 for (i
= 0; i
< ilen
; i
++) {
613 (void)fprintf(fd
,"%c",ucp
[i
]);
615 (void)fprintf(fd
, "'\n");
621 "Software Ver : %02x '",
623 for (i
= 0; i
< ilen
; i
++) {
624 (void)fprintf(fd
, "%c",ucp
[i
]);
626 (void)fprintf(fd
, "'\n");
629 tmps
= mopGetShort(pkt
,idx
);
631 "DECnet Addr : %d.%d (%d)\n",
640 "Node Name : %02x '",
642 for (i
= 0; i
< ilen
; i
++) {
643 (void)fprintf(fd
, "%c",ucp
[i
]);
645 (void)fprintf(fd
, "'\n");
651 "Node Ident : %02x '",
653 for (i
= 0; i
< ilen
; i
++) {
654 (void)fprintf(fd
, "%c",ucp
[i
]);
656 (void)fprintf(fd
, "'\n");
660 ucp
= pkt
+ *idx
; *idx
= *idx
+ ilen
;
661 (void)fprintf(fd
, "Info Type : %04x (%d)\n",
664 (void)fprintf(fd
, "Info Data : %02x ",
666 for (i
= 0; i
< ilen
; i
++) {
674 (void)fprintf(fd
, "%02x ",ucp
[i
]);
676 (void)fprintf(fd
, "\n");
679 itype
= mopGetShort(pkt
,idx
);