2 * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 static const char rcsid
[] _U_
=
24 "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
36 #ifdef HAVE_NETDNET_DNETDB_H
37 #include <netdnet/dnetdb.h>
46 #include "interface.h"
47 #include "addrtoname.h"
50 static int print_decnet_ctlmsg(const union routehdr
*, u_int
, u_int
);
51 static void print_t_info(int);
52 static int print_l1_routes(const char *, u_int
);
53 static int print_l2_routes(const char *, u_int
);
54 static void print_i_info(int);
55 static int print_elist(const char *, u_int
);
56 static int print_nsp(const u_char
*, u_int
);
57 static void print_reason(int);
59 static void pdata(u_char
*, int);
62 #ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
63 extern char *dnet_htoa(struct dn_naddr
*);
67 decnet_print(register const u_char
*ap
, register u_int length
,
68 register u_int caplen
)
70 register const union routehdr
*rhp
;
76 if (length
< sizeof(struct shorthdr
)) {
77 (void)printf("[|decnet]");
81 TCHECK2(*ap
, sizeof(short));
82 pktlen
= EXTRACT_LE_16BITS(ap
);
83 if (pktlen
< sizeof(struct shorthdr
)) {
84 (void)printf("[|decnet]");
87 if (pktlen
> length
) {
88 (void)printf("[|decnet]");
93 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
94 TCHECK(rhp
->rh_short
.sh_flags
);
95 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
97 if (mflags
& RMF_PAD
) {
98 /* pad bytes of some sort in front of message */
99 u_int padlen
= mflags
& RMF_PADMASK
;
101 (void) printf("[pad:%d] ", padlen
);
102 if (length
< padlen
+ 2) {
103 (void)printf("[|decnet]");
106 TCHECK2(ap
[sizeof(short)], padlen
);
110 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
111 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
114 if (mflags
& RMF_FVER
) {
115 (void) printf("future-version-decnet");
116 default_print(ap
, min(length
, caplen
));
120 /* is it a control message? */
121 if (mflags
& RMF_CTLMSG
) {
122 if (!print_decnet_ctlmsg(rhp
, length
, caplen
))
127 switch (mflags
& RMF_MASK
) {
129 if (length
< sizeof(struct longhdr
)) {
130 (void)printf("[|decnet]");
133 TCHECK(rhp
->rh_long
);
135 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
137 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
138 hops
= EXTRACT_LE_8BITS(rhp
->rh_long
.lg_visits
);
139 nspp
= &(ap
[sizeof(short) + sizeof(struct longhdr
)]);
140 nsplen
= length
- sizeof(struct longhdr
);
143 TCHECK(rhp
->rh_short
);
144 dst
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_dst
);
145 src
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_src
);
146 hops
= (EXTRACT_LE_8BITS(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
147 nspp
= &(ap
[sizeof(short) + sizeof(struct shorthdr
)]);
148 nsplen
= length
- sizeof(struct shorthdr
);
151 (void) printf("unknown message flags under mask");
152 default_print((u_char
*)ap
, min(length
, caplen
));
156 (void)printf("%s > %s %d ",
157 dnaddr_string(src
), dnaddr_string(dst
), pktlen
);
159 if (mflags
& RMF_RQR
)
160 (void)printf("RQR ");
161 if (mflags
& RMF_RTS
)
162 (void)printf("RTS ");
165 (void)printf("%d hops ", hops
);
168 if (!print_nsp(nspp
, nsplen
))
173 (void)printf("[|decnet]");
178 print_decnet_ctlmsg(register const union routehdr
*rhp
, u_int length
,
181 int mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
182 register union controlmsg
*cmp
= (union controlmsg
*)rhp
;
183 int src
, dst
, info
, blksize
, eco
, ueco
, hello
, other
, vers
;
184 etheraddr srcea
, rtea
;
186 char *rhpx
= (char *)rhp
;
189 switch (mflags
& RMF_CTLMASK
) {
191 (void)printf("init ");
192 if (length
< sizeof(struct initmsg
))
194 TCHECK(cmp
->cm_init
);
195 src
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_src
);
196 info
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_info
);
197 blksize
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_blksize
);
198 vers
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_vers
);
199 eco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_eco
);
200 ueco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_ueco
);
201 hello
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_hello
);
204 "src %sblksize %d vers %d eco %d ueco %d hello %d",
205 dnaddr_string(src
), blksize
, vers
, eco
, ueco
,
210 (void)printf("verification ");
211 if (length
< sizeof(struct verifmsg
))
214 src
= EXTRACT_LE_16BITS(cmp
->cm_ver
.ve_src
);
215 other
= EXTRACT_LE_8BITS(cmp
->cm_ver
.ve_fcnval
);
216 (void)printf("src %s fcnval %o", dnaddr_string(src
), other
);
220 (void)printf("test ");
221 if (length
< sizeof(struct testmsg
))
223 TCHECK(cmp
->cm_test
);
224 src
= EXTRACT_LE_16BITS(cmp
->cm_test
.te_src
);
225 other
= EXTRACT_LE_8BITS(cmp
->cm_test
.te_data
);
226 (void)printf("src %s data %o", dnaddr_string(src
), other
);
230 (void)printf("lev-1-routing ");
231 if (length
< sizeof(struct l1rout
))
233 TCHECK(cmp
->cm_l1rou
);
234 src
= EXTRACT_LE_16BITS(cmp
->cm_l1rou
.r1_src
);
235 (void)printf("src %s ", dnaddr_string(src
));
236 ret
= print_l1_routes(&(rhpx
[sizeof(struct l1rout
)]),
237 length
- sizeof(struct l1rout
));
240 (void)printf("lev-2-routing ");
241 if (length
< sizeof(struct l2rout
))
243 TCHECK(cmp
->cm_l2rout
);
244 src
= EXTRACT_LE_16BITS(cmp
->cm_l2rout
.r2_src
);
245 (void)printf("src %s ", dnaddr_string(src
));
246 ret
= print_l2_routes(&(rhpx
[sizeof(struct l2rout
)]),
247 length
- sizeof(struct l2rout
));
250 (void)printf("router-hello ");
251 if (length
< sizeof(struct rhellomsg
))
253 TCHECK(cmp
->cm_rhello
);
254 vers
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_vers
);
255 eco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_eco
);
256 ueco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_ueco
);
257 memcpy((char *)&srcea
, (char *)&(cmp
->cm_rhello
.rh_src
),
259 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
260 info
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_info
);
261 blksize
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_blksize
);
262 priority
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_priority
);
263 hello
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_hello
);
266 "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
267 vers
, eco
, ueco
, dnaddr_string(src
),
268 blksize
, priority
, hello
);
269 ret
= print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
270 length
- sizeof(struct rhellomsg
));
273 (void)printf("endnode-hello ");
274 if (length
< sizeof(struct ehellomsg
))
276 TCHECK(cmp
->cm_ehello
);
277 vers
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_vers
);
278 eco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_eco
);
279 ueco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_ueco
);
280 memcpy((char *)&srcea
, (char *)&(cmp
->cm_ehello
.eh_src
),
282 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
283 info
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_info
);
284 blksize
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_blksize
);
286 memcpy((char *)&rtea
, (char *)&(cmp
->cm_ehello
.eh_router
),
288 dst
= EXTRACT_LE_16BITS(rtea
.dne_remote
.dne_nodeaddr
);
289 hello
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_hello
);
290 other
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_data
);
293 "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
294 vers
, eco
, ueco
, dnaddr_string(src
),
295 blksize
, dnaddr_string(dst
), hello
, other
);
300 (void)printf("unknown control message");
301 default_print((u_char
*)rhp
, min(length
, caplen
));
312 print_t_info(int info
)
314 int ntype
= info
& 3;
316 case 0: (void)printf("reserved-ntype? "); break;
317 case TI_L2ROUT
: (void)printf("l2rout "); break;
318 case TI_L1ROUT
: (void)printf("l1rout "); break;
319 case TI_ENDNODE
: (void)printf("endnode "); break;
322 (void)printf("verif ");
324 (void)printf("blo ");
328 print_l1_routes(const char *rp
, u_int len
)
334 /* The last short is a checksum */
335 while (len
> (3 * sizeof(short))) {
336 TCHECK2(*rp
, 3 * sizeof(short));
337 count
= EXTRACT_LE_16BITS(rp
);
339 return (1); /* seems to be bogus from here on */
341 len
-= sizeof(short);
342 id
= EXTRACT_LE_16BITS(rp
);
344 len
-= sizeof(short);
345 info
= EXTRACT_LE_16BITS(rp
);
347 len
-= sizeof(short);
348 (void)printf("{ids %d-%d cost %d hops %d} ", id
, id
+ count
,
349 RI_COST(info
), RI_HOPS(info
));
358 print_l2_routes(const char *rp
, u_int len
)
364 /* The last short is a checksum */
365 while (len
> (3 * sizeof(short))) {
366 TCHECK2(*rp
, 3 * sizeof(short));
367 count
= EXTRACT_LE_16BITS(rp
);
369 return (1); /* seems to be bogus from here on */
371 len
-= sizeof(short);
372 area
= EXTRACT_LE_16BITS(rp
);
374 len
-= sizeof(short);
375 info
= EXTRACT_LE_16BITS(rp
);
377 len
-= sizeof(short);
378 (void)printf("{areas %d-%d cost %d hops %d} ", area
, area
+ count
,
379 RI_COST(info
), RI_HOPS(info
));
388 print_i_info(int info
)
390 int ntype
= info
& II_TYPEMASK
;
392 case 0: (void)printf("reserved-ntype? "); break;
393 case II_L2ROUT
: (void)printf("l2rout "); break;
394 case II_L1ROUT
: (void)printf("l1rout "); break;
395 case II_ENDNODE
: (void)printf("endnode "); break;
398 (void)printf("verif ");
399 if (info
& II_NOMCAST
)
400 (void)printf("nomcast ");
402 (void)printf("blo ");
406 print_elist(const char *elp _U_
, u_int len _U_
)
408 /* Not enough examples available for me to debug this */
413 print_nsp(const u_char
*nspp
, u_int nsplen
)
415 const struct nsphdr
*nsphp
= (struct nsphdr
*)nspp
;
418 if (nsplen
< sizeof(struct nsphdr
))
421 flags
= EXTRACT_LE_8BITS(nsphp
->nh_flags
);
422 dst
= EXTRACT_LE_16BITS(nsphp
->nh_dst
);
423 src
= EXTRACT_LE_16BITS(nsphp
->nh_src
);
425 switch (flags
& NSP_TYPEMASK
) {
427 switch (flags
& NSP_SUBMASK
) {
431 case MFS_BOM
+MFS_EOM
:
432 printf("data %d>%d ", src
, dst
);
434 struct seghdr
*shp
= (struct seghdr
*)nspp
;
439 u_int data_off
= sizeof(struct minseghdr
);
441 if (nsplen
< data_off
)
443 TCHECK(shp
->sh_seq
[0]);
444 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
445 if (ack
& SGQ_ACK
) { /* acknum field */
446 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
447 (void)printf("nak %d ", ack
& SGQ_MASK
);
449 (void)printf("ack %d ", ack
& SGQ_MASK
);
450 data_off
+= sizeof(short);
451 if (nsplen
< data_off
)
453 TCHECK(shp
->sh_seq
[1]);
454 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
455 if (ack
& SGQ_OACK
) { /* ackoth field */
456 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
457 (void)printf("onak %d ", ack
& SGQ_MASK
);
459 (void)printf("oack %d ", ack
& SGQ_MASK
);
460 data_off
+= sizeof(short);
461 if (nsplen
< data_off
)
463 TCHECK(shp
->sh_seq
[2]);
464 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
467 (void)printf("seg %d ", ack
& SGQ_MASK
);
469 if (nsplen
> data_off
) {
470 dp
= &(nspp
[data_off
]);
471 TCHECK2(*dp
, nsplen
- data_off
);
472 pdata(dp
, nsplen
- data_off
);
477 case MFS_ILS
+MFS_INT
:
480 struct seghdr
*shp
= (struct seghdr
*)nspp
;
485 u_int data_off
= sizeof(struct minseghdr
);
487 if (nsplen
< data_off
)
489 TCHECK(shp
->sh_seq
[0]);
490 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
491 if (ack
& SGQ_ACK
) { /* acknum field */
492 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
493 (void)printf("nak %d ", ack
& SGQ_MASK
);
495 (void)printf("ack %d ", ack
& SGQ_MASK
);
496 data_off
+= sizeof(short);
497 if (nsplen
< data_off
)
499 TCHECK(shp
->sh_seq
[1]);
500 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
501 if (ack
& SGQ_OACK
) { /* ackdat field */
502 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
503 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
505 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
506 data_off
+= sizeof(short);
507 if (nsplen
< data_off
)
509 TCHECK(shp
->sh_seq
[2]);
510 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
513 (void)printf("seg %d ", ack
& SGQ_MASK
);
515 if (nsplen
> data_off
) {
516 dp
= &(nspp
[data_off
]);
517 TCHECK2(*dp
, nsplen
- data_off
);
518 pdata(dp
, nsplen
- data_off
);
524 (void)printf("link-service %d>%d ", src
, dst
);
526 struct seghdr
*shp
= (struct seghdr
*)nspp
;
528 (struct lsmsg
*)&(nspp
[sizeof(struct seghdr
)]);
532 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
534 TCHECK(shp
->sh_seq
[0]);
535 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
536 if (ack
& SGQ_ACK
) { /* acknum field */
537 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
538 (void)printf("nak %d ", ack
& SGQ_MASK
);
540 (void)printf("ack %d ", ack
& SGQ_MASK
);
541 TCHECK(shp
->sh_seq
[1]);
542 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
543 if (ack
& SGQ_OACK
) { /* ackdat field */
544 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
545 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
547 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
548 TCHECK(shp
->sh_seq
[2]);
549 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
552 (void)printf("seg %d ", ack
& SGQ_MASK
);
554 lsflags
= EXTRACT_LE_8BITS(lsmp
->ls_lsflags
);
555 fcval
= EXTRACT_LE_8BITS(lsmp
->ls_fcval
);
556 switch (lsflags
& LSI_MASK
) {
558 (void)printf("dat seg count %d ", fcval
);
559 switch (lsflags
& LSM_MASK
) {
563 (void)printf("donotsend-data ");
566 (void)printf("send-data ");
569 (void)printf("reserved-fcmod? %x", lsflags
);
574 (void)printf("intr req count %d ", fcval
);
577 (void)printf("reserved-fcval-int? %x", lsflags
);
583 (void)printf("reserved-subtype? %x %d > %d", flags
, src
, dst
);
588 switch (flags
& NSP_SUBMASK
) {
590 (void)printf("data-ack %d>%d ", src
, dst
);
592 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
595 if (nsplen
< sizeof(struct ackmsg
))
598 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
599 if (ack
& SGQ_ACK
) { /* acknum field */
600 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
601 (void)printf("nak %d ", ack
& SGQ_MASK
);
603 (void)printf("ack %d ", ack
& SGQ_MASK
);
604 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
605 if (ack
& SGQ_OACK
) { /* ackoth field */
606 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
607 (void)printf("onak %d ", ack
& SGQ_MASK
);
609 (void)printf("oack %d ", ack
& SGQ_MASK
);
615 (void)printf("ils-ack %d>%d ", src
, dst
);
617 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
620 if (nsplen
< sizeof(struct ackmsg
))
623 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
624 if (ack
& SGQ_ACK
) { /* acknum field */
625 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
626 (void)printf("nak %d ", ack
& SGQ_MASK
);
628 (void)printf("ack %d ", ack
& SGQ_MASK
);
629 TCHECK(amp
->ak_acknum
[1]);
630 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
631 if (ack
& SGQ_OACK
) { /* ackdat field */
632 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
633 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
635 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
641 (void)printf("conn-ack %d", dst
);
644 (void)printf("reserved-acktype? %x %d > %d", flags
, src
, dst
);
649 switch (flags
& NSP_SUBMASK
) {
652 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
653 (void)printf("conn-initiate ");
655 (void)printf("retrans-conn-initiate ");
656 (void)printf("%d>%d ", src
, dst
);
658 struct cimsg
*cimp
= (struct cimsg
*)nspp
;
659 int services
, info
, segsize
;
664 if (nsplen
< sizeof(struct cimsg
))
667 services
= EXTRACT_LE_8BITS(cimp
->ci_services
);
668 info
= EXTRACT_LE_8BITS(cimp
->ci_info
);
669 segsize
= EXTRACT_LE_16BITS(cimp
->ci_segsize
);
671 switch (services
& COS_MASK
) {
675 (void)printf("seg ");
678 (void)printf("msg ");
681 (void)printf("crypt ");
684 switch (info
& COI_MASK
) {
686 (void)printf("ver 3.2 ");
689 (void)printf("ver 3.1 ");
692 (void)printf("ver 4.0 ");
695 (void)printf("ver 4.1 ");
698 (void)printf("segsize %d ", segsize
);
700 if (nsplen
> sizeof(struct cimsg
)) {
701 dp
= &(nspp
[sizeof(struct cimsg
)]);
702 TCHECK2(*dp
, nsplen
- sizeof(struct cimsg
));
703 pdata(dp
, nsplen
- sizeof(struct cimsg
));
709 (void)printf("conn-confirm %d>%d ", src
, dst
);
711 struct ccmsg
*ccmp
= (struct ccmsg
*)nspp
;
713 u_int segsize
, optlen
;
718 if (nsplen
< sizeof(struct ccmsg
))
721 services
= EXTRACT_LE_8BITS(ccmp
->cc_services
);
722 info
= EXTRACT_LE_8BITS(ccmp
->cc_info
);
723 segsize
= EXTRACT_LE_16BITS(ccmp
->cc_segsize
);
724 optlen
= EXTRACT_LE_8BITS(ccmp
->cc_optlen
);
726 switch (services
& COS_MASK
) {
730 (void)printf("seg ");
733 (void)printf("msg ");
736 (void)printf("crypt ");
739 switch (info
& COI_MASK
) {
741 (void)printf("ver 3.2 ");
744 (void)printf("ver 3.1 ");
747 (void)printf("ver 4.0 ");
750 (void)printf("ver 4.1 ");
753 (void)printf("segsize %d ", segsize
);
755 (void)printf("optlen %d ", optlen
);
757 if (optlen
> nsplen
- sizeof(struct ccmsg
))
759 dp
= &(nspp
[sizeof(struct ccmsg
)]);
760 TCHECK2(*dp
, optlen
);
767 (void)printf("disconn-initiate %d>%d ", src
, dst
);
769 struct dimsg
*dimp
= (struct dimsg
*)nspp
;
776 if (nsplen
< sizeof(struct dimsg
))
779 reason
= EXTRACT_LE_16BITS(dimp
->di_reason
);
780 optlen
= EXTRACT_LE_8BITS(dimp
->di_optlen
);
782 print_reason(reason
);
784 (void)printf("optlen %d ", optlen
);
786 if (optlen
> nsplen
- sizeof(struct dimsg
))
788 dp
= &(nspp
[sizeof(struct dimsg
)]);
789 TCHECK2(*dp
, optlen
);
796 (void)printf("disconn-confirm %d>%d ", src
, dst
);
798 struct dcmsg
*dcmp
= (struct dcmsg
*)nspp
;
802 reason
= EXTRACT_LE_16BITS(dcmp
->dc_reason
);
804 print_reason(reason
);
808 (void)printf("reserved-ctltype? %x %d > %d", flags
, src
, dst
);
813 (void)printf("reserved-type? %x %d > %d", flags
, src
, dst
);
822 static struct tok reason2str
[] = {
823 { UC_OBJREJECT
, "object rejected connect" },
824 { UC_RESOURCES
, "insufficient resources" },
825 { UC_NOSUCHNODE
, "unrecognized node name" },
826 { DI_SHUT
, "node is shutting down" },
827 { UC_NOSUCHOBJ
, "unrecognized object" },
828 { UC_INVOBJFORMAT
, "invalid object name format" },
829 { UC_OBJTOOBUSY
, "object too busy" },
830 { DI_PROTOCOL
, "protocol error discovered" },
831 { DI_TPA
, "third party abort" },
832 { UC_USERABORT
, "user abort" },
833 { UC_INVNODEFORMAT
, "invalid node name format" },
834 { UC_LOCALSHUT
, "local node shutting down" },
835 { DI_LOCALRESRC
, "insufficient local resources" },
836 { DI_REMUSERRESRC
, "insufficient remote user resources" },
837 { UC_ACCESSREJECT
, "invalid access control information" },
838 { DI_BADACCNT
, "bad ACCOUNT information" },
839 { UC_NORESPONSE
, "no response from object" },
840 { UC_UNREACHABLE
, "node unreachable" },
841 { DC_NOLINK
, "no link terminate" },
842 { DC_COMPLETE
, "disconnect complete" },
843 { DI_BADIMAGE
, "bad image data in connect" },
844 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
849 print_reason(register int reason
)
851 printf("%s ", tok2str(reason2str
, "reason-%d", reason
));
855 dnnum_string(u_short dnaddr
)
859 int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
860 int node
= dnaddr
& NODEMASK
;
862 str
= (char *)malloc(siz
= sizeof("00.0000"));
864 error("dnnum_string: malloc");
865 snprintf(str
, siz
, "%d.%d", area
, node
);
870 dnname_string(u_short dnaddr
)
872 #ifdef HAVE_DNET_HTOA
875 dna
.a_len
= sizeof(short);
876 memcpy((char *)dna
.a_addr
, (char *)&dnaddr
, sizeof(short));
877 return (strdup(dnet_htoa(&dna
)));
879 return(dnnum_string(dnaddr
)); /* punt */
885 pdata(u_char
*dp
, u_int maxlen
)