]>
The Tcpdump Group git mirrors - tcpdump/blob - print-decnet.c
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"
49 static const char tstr
[] = "[|decnet]";
52 static int print_decnet_ctlmsg(const union routehdr
*, u_int
, u_int
);
53 static void print_t_info(int);
54 static int print_l1_routes(const char *, u_int
);
55 static int print_l2_routes(const char *, u_int
);
56 static void print_i_info(int);
57 static int print_elist(const char *, u_int
);
58 static int print_nsp(const u_char
*, u_int
);
59 static void print_reason(int);
61 static void pdata(u_char
*, int);
64 #ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
65 extern char *dnet_htoa(struct dn_naddr
*);
69 decnet_print(register const u_char
*ap
, register u_int length
,
70 register u_int caplen
)
72 register const union routehdr
*rhp
;
78 if (length
< sizeof(struct shorthdr
)) {
79 (void)printf("%s", tstr
);
83 TCHECK2(*ap
, sizeof(short));
84 pktlen
= EXTRACT_LE_16BITS(ap
);
85 if (pktlen
< sizeof(struct shorthdr
)) {
86 (void)printf("%s", tstr
);
89 if (pktlen
> length
) {
90 (void)printf("%s", tstr
);
95 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
96 TCHECK(rhp
->rh_short
.sh_flags
);
97 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
99 if (mflags
& RMF_PAD
) {
100 /* pad bytes of some sort in front of message */
101 u_int padlen
= mflags
& RMF_PADMASK
;
103 (void) printf("[pad:%d] ", padlen
);
104 if (length
< padlen
+ 2) {
105 (void)printf("%s", tstr
);
108 TCHECK2(ap
[sizeof(short)], padlen
);
112 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
113 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
116 if (mflags
& RMF_FVER
) {
117 (void) printf("future-version-decnet");
118 default_print(ap
, min(length
, caplen
));
122 /* is it a control message? */
123 if (mflags
& RMF_CTLMSG
) {
124 if (!print_decnet_ctlmsg(rhp
, length
, caplen
))
129 switch (mflags
& RMF_MASK
) {
131 if (length
< sizeof(struct longhdr
)) {
132 (void)printf("%s", tstr
);
135 TCHECK(rhp
->rh_long
);
137 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
139 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
140 hops
= EXTRACT_LE_8BITS(rhp
->rh_long
.lg_visits
);
141 nspp
= &(ap
[sizeof(short) + sizeof(struct longhdr
)]);
142 nsplen
= length
- sizeof(struct longhdr
);
145 TCHECK(rhp
->rh_short
);
146 dst
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_dst
);
147 src
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_src
);
148 hops
= (EXTRACT_LE_8BITS(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
149 nspp
= &(ap
[sizeof(short) + sizeof(struct shorthdr
)]);
150 nsplen
= length
- sizeof(struct shorthdr
);
153 (void) printf("unknown message flags under mask");
154 default_print((u_char
*)ap
, min(length
, caplen
));
158 (void)printf("%s > %s %d ",
159 dnaddr_string(src
), dnaddr_string(dst
), pktlen
);
161 if (mflags
& RMF_RQR
)
162 (void)printf("RQR ");
163 if (mflags
& RMF_RTS
)
164 (void)printf("RTS ");
167 (void)printf("%d hops ", hops
);
170 if (!print_nsp(nspp
, nsplen
))
175 (void)printf("%s", tstr
);
180 print_decnet_ctlmsg(register const union routehdr
*rhp
, u_int length
,
183 int mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
184 register union controlmsg
*cmp
= (union controlmsg
*)rhp
;
185 int src
, dst
, info
, blksize
, eco
, ueco
, hello
, other
, vers
;
186 etheraddr srcea
, rtea
;
188 char *rhpx
= (char *)rhp
;
191 switch (mflags
& RMF_CTLMASK
) {
193 (void)printf("init ");
194 if (length
< sizeof(struct initmsg
))
196 TCHECK(cmp
->cm_init
);
197 src
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_src
);
198 info
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_info
);
199 blksize
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_blksize
);
200 vers
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_vers
);
201 eco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_eco
);
202 ueco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_ueco
);
203 hello
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_hello
);
206 "src %sblksize %d vers %d eco %d ueco %d hello %d",
207 dnaddr_string(src
), blksize
, vers
, eco
, ueco
,
212 (void)printf("verification ");
213 if (length
< sizeof(struct verifmsg
))
216 src
= EXTRACT_LE_16BITS(cmp
->cm_ver
.ve_src
);
217 other
= EXTRACT_LE_8BITS(cmp
->cm_ver
.ve_fcnval
);
218 (void)printf("src %s fcnval %o", dnaddr_string(src
), other
);
222 (void)printf("test ");
223 if (length
< sizeof(struct testmsg
))
225 TCHECK(cmp
->cm_test
);
226 src
= EXTRACT_LE_16BITS(cmp
->cm_test
.te_src
);
227 other
= EXTRACT_LE_8BITS(cmp
->cm_test
.te_data
);
228 (void)printf("src %s data %o", dnaddr_string(src
), other
);
232 (void)printf("lev-1-routing ");
233 if (length
< sizeof(struct l1rout
))
235 TCHECK(cmp
->cm_l1rou
);
236 src
= EXTRACT_LE_16BITS(cmp
->cm_l1rou
.r1_src
);
237 (void)printf("src %s ", dnaddr_string(src
));
238 ret
= print_l1_routes(&(rhpx
[sizeof(struct l1rout
)]),
239 length
- sizeof(struct l1rout
));
242 (void)printf("lev-2-routing ");
243 if (length
< sizeof(struct l2rout
))
245 TCHECK(cmp
->cm_l2rout
);
246 src
= EXTRACT_LE_16BITS(cmp
->cm_l2rout
.r2_src
);
247 (void)printf("src %s ", dnaddr_string(src
));
248 ret
= print_l2_routes(&(rhpx
[sizeof(struct l2rout
)]),
249 length
- sizeof(struct l2rout
));
252 (void)printf("router-hello ");
253 if (length
< sizeof(struct rhellomsg
))
255 TCHECK(cmp
->cm_rhello
);
256 vers
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_vers
);
257 eco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_eco
);
258 ueco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_ueco
);
259 memcpy((char *)&srcea
, (char *)&(cmp
->cm_rhello
.rh_src
),
261 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
262 info
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_info
);
263 blksize
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_blksize
);
264 priority
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_priority
);
265 hello
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_hello
);
268 "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
269 vers
, eco
, ueco
, dnaddr_string(src
),
270 blksize
, priority
, hello
);
271 ret
= print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
272 length
- sizeof(struct rhellomsg
));
275 (void)printf("endnode-hello ");
276 if (length
< sizeof(struct ehellomsg
))
278 TCHECK(cmp
->cm_ehello
);
279 vers
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_vers
);
280 eco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_eco
);
281 ueco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_ueco
);
282 memcpy((char *)&srcea
, (char *)&(cmp
->cm_ehello
.eh_src
),
284 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
285 info
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_info
);
286 blksize
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_blksize
);
288 memcpy((char *)&rtea
, (char *)&(cmp
->cm_ehello
.eh_router
),
290 dst
= EXTRACT_LE_16BITS(rtea
.dne_remote
.dne_nodeaddr
);
291 hello
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_hello
);
292 other
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_data
);
295 "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
296 vers
, eco
, ueco
, dnaddr_string(src
),
297 blksize
, dnaddr_string(dst
), hello
, other
);
302 (void)printf("unknown control message");
303 default_print((u_char
*)rhp
, min(length
, caplen
));
314 print_t_info(int info
)
316 int ntype
= info
& 3;
318 case 0: (void)printf("reserved-ntype? "); break;
319 case TI_L2ROUT
: (void)printf("l2rout "); break;
320 case TI_L1ROUT
: (void)printf("l1rout "); break;
321 case TI_ENDNODE
: (void)printf("endnode "); break;
324 (void)printf("verif ");
326 (void)printf("blo ");
330 print_l1_routes(const char *rp
, u_int len
)
336 /* The last short is a checksum */
337 while (len
> (3 * sizeof(short))) {
338 TCHECK2(*rp
, 3 * sizeof(short));
339 count
= EXTRACT_LE_16BITS(rp
);
341 return (1); /* seems to be bogus from here on */
343 len
-= sizeof(short);
344 id
= EXTRACT_LE_16BITS(rp
);
346 len
-= sizeof(short);
347 info
= EXTRACT_LE_16BITS(rp
);
349 len
-= sizeof(short);
350 (void)printf("{ids %d-%d cost %d hops %d} ", id
, id
+ count
,
351 RI_COST(info
), RI_HOPS(info
));
360 print_l2_routes(const char *rp
, u_int len
)
366 /* The last short is a checksum */
367 while (len
> (3 * sizeof(short))) {
368 TCHECK2(*rp
, 3 * sizeof(short));
369 count
= EXTRACT_LE_16BITS(rp
);
371 return (1); /* seems to be bogus from here on */
373 len
-= sizeof(short);
374 area
= EXTRACT_LE_16BITS(rp
);
376 len
-= sizeof(short);
377 info
= EXTRACT_LE_16BITS(rp
);
379 len
-= sizeof(short);
380 (void)printf("{areas %d-%d cost %d hops %d} ", area
, area
+ count
,
381 RI_COST(info
), RI_HOPS(info
));
390 print_i_info(int info
)
392 int ntype
= info
& II_TYPEMASK
;
394 case 0: (void)printf("reserved-ntype? "); break;
395 case II_L2ROUT
: (void)printf("l2rout "); break;
396 case II_L1ROUT
: (void)printf("l1rout "); break;
397 case II_ENDNODE
: (void)printf("endnode "); break;
400 (void)printf("verif ");
401 if (info
& II_NOMCAST
)
402 (void)printf("nomcast ");
404 (void)printf("blo ");
408 print_elist(const char *elp _U_
, u_int len _U_
)
410 /* Not enough examples available for me to debug this */
415 print_nsp(const u_char
*nspp
, u_int nsplen
)
417 const struct nsphdr
*nsphp
= (struct nsphdr
*)nspp
;
420 if (nsplen
< sizeof(struct nsphdr
))
423 flags
= EXTRACT_LE_8BITS(nsphp
->nh_flags
);
424 dst
= EXTRACT_LE_16BITS(nsphp
->nh_dst
);
425 src
= EXTRACT_LE_16BITS(nsphp
->nh_src
);
427 switch (flags
& NSP_TYPEMASK
) {
429 switch (flags
& NSP_SUBMASK
) {
433 case MFS_BOM
+MFS_EOM
:
434 printf("data %d>%d ", src
, dst
);
436 struct seghdr
*shp
= (struct seghdr
*)nspp
;
441 u_int data_off
= sizeof(struct minseghdr
);
443 if (nsplen
< data_off
)
445 TCHECK(shp
->sh_seq
[0]);
446 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
447 if (ack
& SGQ_ACK
) { /* acknum field */
448 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
449 (void)printf("nak %d ", ack
& SGQ_MASK
);
451 (void)printf("ack %d ", ack
& SGQ_MASK
);
452 data_off
+= sizeof(short);
453 if (nsplen
< data_off
)
455 TCHECK(shp
->sh_seq
[1]);
456 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
457 if (ack
& SGQ_OACK
) { /* ackoth field */
458 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
459 (void)printf("onak %d ", ack
& SGQ_MASK
);
461 (void)printf("oack %d ", ack
& SGQ_MASK
);
462 data_off
+= sizeof(short);
463 if (nsplen
< data_off
)
465 TCHECK(shp
->sh_seq
[2]);
466 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
469 (void)printf("seg %d ", ack
& SGQ_MASK
);
471 if (nsplen
> data_off
) {
472 dp
= &(nspp
[data_off
]);
473 TCHECK2(*dp
, nsplen
- data_off
);
474 pdata(dp
, nsplen
- data_off
);
479 case MFS_ILS
+MFS_INT
:
482 struct seghdr
*shp
= (struct seghdr
*)nspp
;
487 u_int data_off
= sizeof(struct minseghdr
);
489 if (nsplen
< data_off
)
491 TCHECK(shp
->sh_seq
[0]);
492 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
493 if (ack
& SGQ_ACK
) { /* acknum field */
494 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
495 (void)printf("nak %d ", ack
& SGQ_MASK
);
497 (void)printf("ack %d ", ack
& SGQ_MASK
);
498 data_off
+= sizeof(short);
499 if (nsplen
< data_off
)
501 TCHECK(shp
->sh_seq
[1]);
502 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
503 if (ack
& SGQ_OACK
) { /* ackdat field */
504 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
505 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
507 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
508 data_off
+= sizeof(short);
509 if (nsplen
< data_off
)
511 TCHECK(shp
->sh_seq
[2]);
512 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
515 (void)printf("seg %d ", ack
& SGQ_MASK
);
517 if (nsplen
> data_off
) {
518 dp
= &(nspp
[data_off
]);
519 TCHECK2(*dp
, nsplen
- data_off
);
520 pdata(dp
, nsplen
- data_off
);
526 (void)printf("link-service %d>%d ", src
, dst
);
528 struct seghdr
*shp
= (struct seghdr
*)nspp
;
530 (struct lsmsg
*)&(nspp
[sizeof(struct seghdr
)]);
534 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
536 TCHECK(shp
->sh_seq
[0]);
537 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
538 if (ack
& SGQ_ACK
) { /* acknum field */
539 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
540 (void)printf("nak %d ", ack
& SGQ_MASK
);
542 (void)printf("ack %d ", ack
& SGQ_MASK
);
543 TCHECK(shp
->sh_seq
[1]);
544 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
545 if (ack
& SGQ_OACK
) { /* ackdat field */
546 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
547 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
549 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
550 TCHECK(shp
->sh_seq
[2]);
551 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
554 (void)printf("seg %d ", ack
& SGQ_MASK
);
556 lsflags
= EXTRACT_LE_8BITS(lsmp
->ls_lsflags
);
557 fcval
= EXTRACT_LE_8BITS(lsmp
->ls_fcval
);
558 switch (lsflags
& LSI_MASK
) {
560 (void)printf("dat seg count %d ", fcval
);
561 switch (lsflags
& LSM_MASK
) {
565 (void)printf("donotsend-data ");
568 (void)printf("send-data ");
571 (void)printf("reserved-fcmod? %x", lsflags
);
576 (void)printf("intr req count %d ", fcval
);
579 (void)printf("reserved-fcval-int? %x", lsflags
);
585 (void)printf("reserved-subtype? %x %d > %d", flags
, src
, dst
);
590 switch (flags
& NSP_SUBMASK
) {
592 (void)printf("data-ack %d>%d ", src
, dst
);
594 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
597 if (nsplen
< sizeof(struct ackmsg
))
600 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
601 if (ack
& SGQ_ACK
) { /* acknum field */
602 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
603 (void)printf("nak %d ", ack
& SGQ_MASK
);
605 (void)printf("ack %d ", ack
& SGQ_MASK
);
606 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
607 if (ack
& SGQ_OACK
) { /* ackoth field */
608 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
609 (void)printf("onak %d ", ack
& SGQ_MASK
);
611 (void)printf("oack %d ", ack
& SGQ_MASK
);
617 (void)printf("ils-ack %d>%d ", src
, dst
);
619 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
622 if (nsplen
< sizeof(struct ackmsg
))
625 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
626 if (ack
& SGQ_ACK
) { /* acknum field */
627 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
628 (void)printf("nak %d ", ack
& SGQ_MASK
);
630 (void)printf("ack %d ", ack
& SGQ_MASK
);
631 TCHECK(amp
->ak_acknum
[1]);
632 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
633 if (ack
& SGQ_OACK
) { /* ackdat field */
634 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
635 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
637 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
643 (void)printf("conn-ack %d", dst
);
646 (void)printf("reserved-acktype? %x %d > %d", flags
, src
, dst
);
651 switch (flags
& NSP_SUBMASK
) {
654 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
655 (void)printf("conn-initiate ");
657 (void)printf("retrans-conn-initiate ");
658 (void)printf("%d>%d ", src
, dst
);
660 struct cimsg
*cimp
= (struct cimsg
*)nspp
;
661 int services
, info
, segsize
;
666 if (nsplen
< sizeof(struct cimsg
))
669 services
= EXTRACT_LE_8BITS(cimp
->ci_services
);
670 info
= EXTRACT_LE_8BITS(cimp
->ci_info
);
671 segsize
= EXTRACT_LE_16BITS(cimp
->ci_segsize
);
673 switch (services
& COS_MASK
) {
677 (void)printf("seg ");
680 (void)printf("msg ");
683 (void)printf("crypt ");
686 switch (info
& COI_MASK
) {
688 (void)printf("ver 3.2 ");
691 (void)printf("ver 3.1 ");
694 (void)printf("ver 4.0 ");
697 (void)printf("ver 4.1 ");
700 (void)printf("segsize %d ", segsize
);
702 if (nsplen
> sizeof(struct cimsg
)) {
703 dp
= &(nspp
[sizeof(struct cimsg
)]);
704 TCHECK2(*dp
, nsplen
- sizeof(struct cimsg
));
705 pdata(dp
, nsplen
- sizeof(struct cimsg
));
711 (void)printf("conn-confirm %d>%d ", src
, dst
);
713 struct ccmsg
*ccmp
= (struct ccmsg
*)nspp
;
715 u_int segsize
, optlen
;
720 if (nsplen
< sizeof(struct ccmsg
))
723 services
= EXTRACT_LE_8BITS(ccmp
->cc_services
);
724 info
= EXTRACT_LE_8BITS(ccmp
->cc_info
);
725 segsize
= EXTRACT_LE_16BITS(ccmp
->cc_segsize
);
726 optlen
= EXTRACT_LE_8BITS(ccmp
->cc_optlen
);
728 switch (services
& COS_MASK
) {
732 (void)printf("seg ");
735 (void)printf("msg ");
738 (void)printf("crypt ");
741 switch (info
& COI_MASK
) {
743 (void)printf("ver 3.2 ");
746 (void)printf("ver 3.1 ");
749 (void)printf("ver 4.0 ");
752 (void)printf("ver 4.1 ");
755 (void)printf("segsize %d ", segsize
);
757 (void)printf("optlen %d ", optlen
);
759 if (optlen
> nsplen
- sizeof(struct ccmsg
))
761 dp
= &(nspp
[sizeof(struct ccmsg
)]);
762 TCHECK2(*dp
, optlen
);
769 (void)printf("disconn-initiate %d>%d ", src
, dst
);
771 struct dimsg
*dimp
= (struct dimsg
*)nspp
;
778 if (nsplen
< sizeof(struct dimsg
))
781 reason
= EXTRACT_LE_16BITS(dimp
->di_reason
);
782 optlen
= EXTRACT_LE_8BITS(dimp
->di_optlen
);
784 print_reason(reason
);
786 (void)printf("optlen %d ", optlen
);
788 if (optlen
> nsplen
- sizeof(struct dimsg
))
790 dp
= &(nspp
[sizeof(struct dimsg
)]);
791 TCHECK2(*dp
, optlen
);
798 (void)printf("disconn-confirm %d>%d ", src
, dst
);
800 struct dcmsg
*dcmp
= (struct dcmsg
*)nspp
;
804 reason
= EXTRACT_LE_16BITS(dcmp
->dc_reason
);
806 print_reason(reason
);
810 (void)printf("reserved-ctltype? %x %d > %d", flags
, src
, dst
);
815 (void)printf("reserved-type? %x %d > %d", flags
, src
, dst
);
824 static const struct tok reason2str
[] = {
825 { UC_OBJREJECT
, "object rejected connect" },
826 { UC_RESOURCES
, "insufficient resources" },
827 { UC_NOSUCHNODE
, "unrecognized node name" },
828 { DI_SHUT
, "node is shutting down" },
829 { UC_NOSUCHOBJ
, "unrecognized object" },
830 { UC_INVOBJFORMAT
, "invalid object name format" },
831 { UC_OBJTOOBUSY
, "object too busy" },
832 { DI_PROTOCOL
, "protocol error discovered" },
833 { DI_TPA
, "third party abort" },
834 { UC_USERABORT
, "user abort" },
835 { UC_INVNODEFORMAT
, "invalid node name format" },
836 { UC_LOCALSHUT
, "local node shutting down" },
837 { DI_LOCALRESRC
, "insufficient local resources" },
838 { DI_REMUSERRESRC
, "insufficient remote user resources" },
839 { UC_ACCESSREJECT
, "invalid access control information" },
840 { DI_BADACCNT
, "bad ACCOUNT information" },
841 { UC_NORESPONSE
, "no response from object" },
842 { UC_UNREACHABLE
, "node unreachable" },
843 { DC_NOLINK
, "no link terminate" },
844 { DC_COMPLETE
, "disconnect complete" },
845 { DI_BADIMAGE
, "bad image data in connect" },
846 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
851 print_reason(register int reason
)
853 printf("%s ", tok2str(reason2str
, "reason-%d", reason
));
857 dnnum_string(u_short dnaddr
)
861 int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
862 int node
= dnaddr
& NODEMASK
;
864 str
= (char *)malloc(siz
= sizeof("00.0000"));
866 error("dnnum_string: malloc");
867 snprintf(str
, siz
, "%d.%d", area
, node
);
872 dnname_string(u_short dnaddr
)
874 #ifdef HAVE_DNET_HTOA
877 dna
.a_len
= sizeof(short);
878 memcpy((char *)dna
.a_addr
, (char *)&dnaddr
, sizeof(short));
879 return (strdup(dnet_htoa(&dna
)));
881 return(dnnum_string(dnaddr
)); /* punt */
887 pdata(u_char
*dp
, u_int maxlen
)