]>
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.
26 #include <tcpdump-stdinc.h>
31 #ifdef HAVE_NETDNET_DNETDB_H
32 #include <netdnet/dnetdb.h>
40 #include "interface.h"
41 #include "addrtoname.h"
43 static const char tstr
[] = "[|decnet]";
46 typedef u_int8_t byte
[1]; /* single byte field */
49 * the keyword 'byte' generates conflicts in Windows
51 typedef unsigned char Byte
[1]; /* single byte field */
54 typedef u_int8_t word
[2]; /* 2 byte field */
55 typedef u_int8_t longword
[4]; /* 4 bytes field */
58 * Definitions for DECNET Phase IV protocol headers
61 u_int8_t dne_addr
[6]; /* full ethernet address */
63 u_int8_t dne_hiord
[4]; /* DECnet HIORD prefix */
64 u_int8_t dne_nodeaddr
[2]; /* DECnet node address */
68 typedef union etheraddress etheraddr
; /* Ethernet address */
70 #define HIORD 0x000400aa /* high 32-bits of address (swapped) */
72 #define AREAMASK 0176000 /* mask for area field */
73 #define AREASHIFT 10 /* bit-offset for area field */
74 #define NODEMASK 01777 /* mask for node address field */
76 #define DN_MAXADDL 20 /* max size of DECnet address */
78 u_int16_t a_len
; /* length of address */
79 u_int8_t a_addr
[DN_MAXADDL
]; /* address as bytes */
83 * Define long and short header formats.
87 byte sh_flags
; /* route flags */
88 word sh_dst
; /* destination node address */
89 word sh_src
; /* source node address */
90 byte sh_visits
; /* visit count */
95 byte lg_flags
; /* route flags */
96 byte lg_darea
; /* destination area (reserved) */
97 byte lg_dsarea
; /* destination subarea (reserved) */
98 etheraddr lg_dst
; /* destination id */
99 byte lg_sarea
; /* source area (reserved) */
100 byte lg_ssarea
; /* source subarea (reserved) */
101 etheraddr lg_src
; /* source id */
102 byte lg_nextl2
; /* next level 2 router (reserved) */
103 byte lg_visits
; /* visit count */
104 byte lg_service
; /* service class (reserved) */
105 byte lg_pt
; /* protocol type (reserved) */
110 struct shorthdr rh_short
; /* short route header */
111 struct longhdr rh_long
; /* long route header */
115 * Define the values of various fields in the protocol messages.
117 * 1. Data packet formats.
119 #define RMF_MASK 7 /* mask for message type */
120 #define RMF_SHORT 2 /* short message format */
121 #define RMF_LONG 6 /* long message format */
123 #define RMF_RQR 010 /* request return to sender */
124 #define RMF_RTS 020 /* returning to sender */
125 #define RMF_IE 040 /* intra-ethernet packet */
127 #define RMF_FVER 0100 /* future version flag */
128 #define RMF_PAD 0200 /* pad field */
129 #define RMF_PADMASK 0177 /* pad field mask */
131 #define VIS_MASK 077 /* visit field mask */
134 * 2. Control packet formats.
136 #define RMF_CTLMASK 017 /* mask for message type */
137 #define RMF_CTLMSG 01 /* control message indicator */
138 #define RMF_INIT 01 /* initialization message */
139 #define RMF_VER 03 /* verification message */
140 #define RMF_TEST 05 /* hello and test message */
141 #define RMF_L1ROUT 07 /* level 1 routing message */
142 #define RMF_L2ROUT 011 /* level 2 routing message */
143 #define RMF_RHELLO 013 /* router hello message */
144 #define RMF_EHELLO 015 /* endnode hello message */
146 #define TI_L2ROUT 01 /* level 2 router */
147 #define TI_L1ROUT 02 /* level 1 router */
148 #define TI_ENDNODE 03 /* endnode */
149 #define TI_VERIF 04 /* verification required */
150 #define TI_BLOCK 010 /* blocking requested */
152 #define VE_VERS 2 /* version number (2) */
153 #define VE_ECO 0 /* ECO number */
154 #define VE_UECO 0 /* user ECO number (0) */
156 #define P3_VERS 1 /* phase III version number (1) */
157 #define P3_ECO 3 /* ECO number (3) */
158 #define P3_UECO 0 /* user ECO number (0) */
160 #define II_L2ROUT 01 /* level 2 router */
161 #define II_L1ROUT 02 /* level 1 router */
162 #define II_ENDNODE 03 /* endnode */
163 #define II_VERIF 04 /* verification required */
164 #define II_NOMCAST 040 /* no multicast traffic accepted */
165 #define II_BLOCK 0100 /* blocking requested */
166 #define II_TYPEMASK 03 /* mask for node type */
168 #define TESTDATA 0252 /* test data bytes */
169 #define TESTLEN 1 /* length of transmitted test data */
172 * Define control message formats.
174 struct initmsgIII
/* phase III initialization message */
176 byte inIII_flags
; /* route flags */
177 word inIII_src
; /* source node address */
178 byte inIII_info
; /* routing layer information */
179 word inIII_blksize
; /* maximum data link block size */
180 byte inIII_vers
; /* version number */
181 byte inIII_eco
; /* ECO number */
182 byte inIII_ueco
; /* user ECO number */
183 byte inIII_rsvd
; /* reserved image field */
186 struct initmsg
/* initialization message */
188 byte in_flags
; /* route flags */
189 word in_src
; /* source node address */
190 byte in_info
; /* routing layer information */
191 word in_blksize
; /* maximum data link block size */
192 byte in_vers
; /* version number */
193 byte in_eco
; /* ECO number */
194 byte in_ueco
; /* user ECO number */
195 word in_hello
; /* hello timer */
196 byte in_rsvd
; /* reserved image field */
199 struct verifmsg
/* verification message */
201 byte ve_flags
; /* route flags */
202 word ve_src
; /* source node address */
203 byte ve_fcnval
; /* function value image field */
206 struct testmsg
/* hello and test message */
208 byte te_flags
; /* route flags */
209 word te_src
; /* source node address */
210 byte te_data
; /* test data image field */
213 struct l1rout
/* level 1 routing message */
215 byte r1_flags
; /* route flags */
216 word r1_src
; /* source node address */
217 byte r1_rsvd
; /* reserved field */
220 struct l2rout
/* level 2 routing message */
222 byte r2_flags
; /* route flags */
223 word r2_src
; /* source node address */
224 byte r2_rsvd
; /* reserved field */
227 struct rhellomsg
/* router hello message */
229 byte rh_flags
; /* route flags */
230 byte rh_vers
; /* version number */
231 byte rh_eco
; /* ECO number */
232 byte rh_ueco
; /* user ECO number */
233 etheraddr rh_src
; /* source id */
234 byte rh_info
; /* routing layer information */
235 word rh_blksize
; /* maximum data link block size */
236 byte rh_priority
; /* router's priority */
237 byte rh_area
; /* reserved */
238 word rh_hello
; /* hello timer */
239 byte rh_mpd
; /* reserved */
242 struct ehellomsg
/* endnode hello message */
244 byte eh_flags
; /* route flags */
245 byte eh_vers
; /* version number */
246 byte eh_eco
; /* ECO number */
247 byte eh_ueco
; /* user ECO number */
248 etheraddr eh_src
; /* source id */
249 byte eh_info
; /* routing layer information */
250 word eh_blksize
; /* maximum data link block size */
251 byte eh_area
; /* area (reserved) */
252 byte eh_seed
[8]; /* verification seed */
253 etheraddr eh_router
; /* designated router */
254 word eh_hello
; /* hello timer */
255 byte eh_mpd
; /* (reserved) */
256 byte eh_data
; /* test data image field */
261 struct initmsg cm_init
; /* initialization message */
262 struct verifmsg cm_ver
; /* verification message */
263 struct testmsg cm_test
; /* hello and test message */
264 struct l1rout cm_l1rou
; /* level 1 routing message */
265 struct l2rout cm_l2rout
; /* level 2 routing message */
266 struct rhellomsg cm_rhello
; /* router hello message */
267 struct ehellomsg cm_ehello
; /* endnode hello message */
270 /* Macros for decoding routing-info fields */
271 #define RI_COST(x) ((x)&0777)
272 #define RI_HOPS(x) (((x)>>10)&037)
275 * NSP protocol fields and values.
278 #define NSP_TYPEMASK 014 /* mask to isolate type code */
279 #define NSP_SUBMASK 0160 /* mask to isolate subtype code */
280 #define NSP_SUBSHFT 4 /* shift to move subtype code */
282 #define MFT_DATA 0 /* data message */
283 #define MFT_ACK 04 /* acknowledgement message */
284 #define MFT_CTL 010 /* control message */
286 #define MFS_ILS 020 /* data or I/LS indicator */
287 #define MFS_BOM 040 /* beginning of message (data) */
288 #define MFS_MOM 0 /* middle of message (data) */
289 #define MFS_EOM 0100 /* end of message (data) */
290 #define MFS_INT 040 /* interrupt message */
292 #define MFS_DACK 0 /* data acknowledgement */
293 #define MFS_IACK 020 /* I/LS acknowledgement */
294 #define MFS_CACK 040 /* connect acknowledgement */
296 #define MFS_NOP 0 /* no operation */
297 #define MFS_CI 020 /* connect initiate */
298 #define MFS_CC 040 /* connect confirm */
299 #define MFS_DI 060 /* disconnect initiate */
300 #define MFS_DC 0100 /* disconnect confirm */
301 #define MFS_RCI 0140 /* retransmitted connect initiate */
303 #define SGQ_ACK 0100000 /* ack */
304 #define SGQ_NAK 0110000 /* negative ack */
305 #define SGQ_OACK 0120000 /* other channel ack */
306 #define SGQ_ONAK 0130000 /* other channel negative ack */
307 #define SGQ_MASK 07777 /* mask to isolate seq # */
308 #define SGQ_OTHER 020000 /* other channel qualifier */
309 #define SGQ_DELAY 010000 /* ack delay flag */
311 #define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
313 #define LSM_MASK 03 /* mask for modifier field */
314 #define LSM_NOCHANGE 0 /* no change */
315 #define LSM_DONOTSEND 1 /* do not send data */
316 #define LSM_SEND 2 /* send data */
318 #define LSI_MASK 014 /* mask for interpretation field */
319 #define LSI_DATA 0 /* data segment or message count */
320 #define LSI_INTR 4 /* interrupt request count */
321 #define LSI_INTM 0377 /* funny marker for int. message */
323 #define COS_MASK 014 /* mask for flow control field */
324 #define COS_NONE 0 /* no flow control */
325 #define COS_SEGMENT 04 /* segment flow control */
326 #define COS_MESSAGE 010 /* message flow control */
327 #define COS_CRYPTSER 020 /* cryptographic services requested */
328 #define COS_DEFAULT 1 /* default value for field */
330 #define COI_MASK 3 /* mask for version field */
331 #define COI_32 0 /* version 3.2 */
332 #define COI_31 1 /* version 3.1 */
333 #define COI_40 2 /* version 4.0 */
334 #define COI_41 3 /* version 4.1 */
336 #define MNU_MASK 140 /* mask for session control version */
337 #define MNU_10 000 /* session V1.0 */
338 #define MNU_20 040 /* session V2.0 */
339 #define MNU_ACCESS 1 /* access control present */
340 #define MNU_USRDATA 2 /* user data field present */
341 #define MNU_INVKPROXY 4 /* invoke proxy field present */
342 #define MNU_UICPROXY 8 /* use uic-based proxy */
344 #define DC_NORESOURCES 1 /* no resource reason code */
345 #define DC_NOLINK 41 /* no link terminate reason code */
346 #define DC_COMPLETE 42 /* disconnect complete reason code */
348 #define DI_NOERROR 0 /* user disconnect */
349 #define DI_SHUT 3 /* node is shutting down */
350 #define DI_NOUSER 4 /* destination end user does not exist */
351 #define DI_INVDEST 5 /* invalid end user destination */
352 #define DI_REMRESRC 6 /* insufficient remote resources */
353 #define DI_TPA 8 /* third party abort */
354 #define DI_PROTOCOL 7 /* protocol error discovered */
355 #define DI_ABORT 9 /* user abort */
356 #define DI_LOCALRESRC 32 /* insufficient local resources */
357 #define DI_REMUSERRESRC 33 /* insufficient remote user resources */
358 #define DI_BADACCESS 34 /* bad access control information */
359 #define DI_BADACCNT 36 /* bad ACCOUNT information */
360 #define DI_CONNECTABORT 38 /* connect request cancelled */
361 #define DI_TIMEDOUT 38 /* remote node or user crashed */
362 #define DI_UNREACHABLE 39 /* local timers expired due to ... */
363 #define DI_BADIMAGE 43 /* bad image data in connect */
364 #define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
366 #define UC_OBJREJECT 0 /* object rejected connect */
367 #define UC_USERDISCONNECT 0 /* user disconnect */
368 #define UC_RESOURCES 1 /* insufficient resources (local or remote) */
369 #define UC_NOSUCHNODE 2 /* unrecognized node name */
370 #define UC_REMOTESHUT 3 /* remote node shutting down */
371 #define UC_NOSUCHOBJ 4 /* unrecognized object */
372 #define UC_INVOBJFORMAT 5 /* invalid object name format */
373 #define UC_OBJTOOBUSY 6 /* object too busy */
374 #define UC_NETWORKABORT 8 /* network abort */
375 #define UC_USERABORT 9 /* user abort */
376 #define UC_INVNODEFORMAT 10 /* invalid node name format */
377 #define UC_LOCALSHUT 11 /* local node shutting down */
378 #define UC_ACCESSREJECT 34 /* invalid access control information */
379 #define UC_NORESPONSE 38 /* no response from object */
380 #define UC_UNREACHABLE 39 /* node unreachable */
383 * NSP message formats.
385 struct nsphdr
/* general nsp header */
387 byte nh_flags
; /* message flags */
388 word nh_dst
; /* destination link address */
389 word nh_src
; /* source link address */
392 struct seghdr
/* data segment header */
394 byte sh_flags
; /* message flags */
395 word sh_dst
; /* destination link address */
396 word sh_src
; /* source link address */
397 word sh_seq
[3]; /* sequence numbers */
400 struct minseghdr
/* minimum data segment header */
402 byte ms_flags
; /* message flags */
403 word ms_dst
; /* destination link address */
404 word ms_src
; /* source link address */
405 word ms_seq
; /* sequence number */
408 struct lsmsg
/* link service message (after hdr) */
410 byte ls_lsflags
; /* link service flags */
411 byte ls_fcval
; /* flow control value */
414 struct ackmsg
/* acknowledgement message */
416 byte ak_flags
; /* message flags */
417 word ak_dst
; /* destination link address */
418 word ak_src
; /* source link address */
419 word ak_acknum
[2]; /* acknowledgement numbers */
422 struct minackmsg
/* minimum acknowledgement message */
424 byte mk_flags
; /* message flags */
425 word mk_dst
; /* destination link address */
426 word mk_src
; /* source link address */
427 word mk_acknum
; /* acknowledgement number */
430 struct ciackmsg
/* connect acknowledgement message */
432 byte ck_flags
; /* message flags */
433 word ck_dst
; /* destination link address */
436 struct cimsg
/* connect initiate message */
438 byte ci_flags
; /* message flags */
439 word ci_dst
; /* destination link address (0) */
440 word ci_src
; /* source link address */
441 byte ci_services
; /* requested services */
442 byte ci_info
; /* information */
443 word ci_segsize
; /* maximum segment size */
446 struct ccmsg
/* connect confirm message */
448 byte cc_flags
; /* message flags */
449 word cc_dst
; /* destination link address */
450 word cc_src
; /* source link address */
451 byte cc_services
; /* requested services */
452 byte cc_info
; /* information */
453 word cc_segsize
; /* maximum segment size */
454 byte cc_optlen
; /* optional data length */
457 struct cnmsg
/* generic connect message */
459 byte cn_flags
; /* message flags */
460 word cn_dst
; /* destination link address */
461 word cn_src
; /* source link address */
462 byte cn_services
; /* requested services */
463 byte cn_info
; /* information */
464 word cn_segsize
; /* maximum segment size */
467 struct dimsg
/* disconnect initiate message */
469 byte di_flags
; /* message flags */
470 word di_dst
; /* destination link address */
471 word di_src
; /* source link address */
472 word di_reason
; /* reason code */
473 byte di_optlen
; /* optional data length */
476 struct dcmsg
/* disconnect confirm message */
478 byte dc_flags
; /* message flags */
479 word dc_dst
; /* destination link address */
480 word dc_src
; /* source link address */
481 word dc_reason
; /* reason code */
485 static int print_decnet_ctlmsg(const union routehdr
*, u_int
, u_int
);
486 static void print_t_info(int);
487 static int print_l1_routes(const char *, u_int
);
488 static int print_l2_routes(const char *, u_int
);
489 static void print_i_info(int);
490 static int print_elist(const char *, u_int
);
491 static int print_nsp(const u_char
*, u_int
);
492 static void print_reason(int);
494 static void pdata(u_char
*, int);
497 #ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
498 extern char *dnet_htoa(struct dn_naddr
*);
502 decnet_print(register const u_char
*ap
, register u_int length
,
503 register u_int caplen
)
505 register const union routehdr
*rhp
;
508 u_int nsplen
, pktlen
;
511 if (length
< sizeof(struct shorthdr
)) {
512 (void)printf("%s", tstr
);
516 TCHECK2(*ap
, sizeof(short));
517 pktlen
= EXTRACT_LE_16BITS(ap
);
518 if (pktlen
< sizeof(struct shorthdr
)) {
519 (void)printf("%s", tstr
);
522 if (pktlen
> length
) {
523 (void)printf("%s", tstr
);
528 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
529 TCHECK(rhp
->rh_short
.sh_flags
);
530 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
532 if (mflags
& RMF_PAD
) {
533 /* pad bytes of some sort in front of message */
534 u_int padlen
= mflags
& RMF_PADMASK
;
536 (void) printf("[pad:%d] ", padlen
);
537 if (length
< padlen
+ 2) {
538 (void)printf("%s", tstr
);
541 TCHECK2(ap
[sizeof(short)], padlen
);
545 rhp
= (const union routehdr
*)&(ap
[sizeof(short)]);
546 mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
549 if (mflags
& RMF_FVER
) {
550 (void) printf("future-version-decnet");
551 default_print(ap
, min(length
, caplen
));
555 /* is it a control message? */
556 if (mflags
& RMF_CTLMSG
) {
557 if (!print_decnet_ctlmsg(rhp
, length
, caplen
))
562 switch (mflags
& RMF_MASK
) {
564 if (length
< sizeof(struct longhdr
)) {
565 (void)printf("%s", tstr
);
568 TCHECK(rhp
->rh_long
);
570 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
572 EXTRACT_LE_16BITS(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
573 hops
= EXTRACT_LE_8BITS(rhp
->rh_long
.lg_visits
);
574 nspp
= &(ap
[sizeof(short) + sizeof(struct longhdr
)]);
575 nsplen
= length
- sizeof(struct longhdr
);
578 TCHECK(rhp
->rh_short
);
579 dst
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_dst
);
580 src
= EXTRACT_LE_16BITS(rhp
->rh_short
.sh_src
);
581 hops
= (EXTRACT_LE_8BITS(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
582 nspp
= &(ap
[sizeof(short) + sizeof(struct shorthdr
)]);
583 nsplen
= length
- sizeof(struct shorthdr
);
586 (void) printf("unknown message flags under mask");
587 default_print((u_char
*)ap
, min(length
, caplen
));
591 (void)printf("%s > %s %d ",
592 dnaddr_string(src
), dnaddr_string(dst
), pktlen
);
594 if (mflags
& RMF_RQR
)
595 (void)printf("RQR ");
596 if (mflags
& RMF_RTS
)
597 (void)printf("RTS ");
600 (void)printf("%d hops ", hops
);
603 if (!print_nsp(nspp
, nsplen
))
608 (void)printf("%s", tstr
);
613 print_decnet_ctlmsg(register const union routehdr
*rhp
, u_int length
,
616 int mflags
= EXTRACT_LE_8BITS(rhp
->rh_short
.sh_flags
);
617 register union controlmsg
*cmp
= (union controlmsg
*)rhp
;
618 int src
, dst
, info
, blksize
, eco
, ueco
, hello
, other
, vers
;
619 etheraddr srcea
, rtea
;
621 char *rhpx
= (char *)rhp
;
624 switch (mflags
& RMF_CTLMASK
) {
626 (void)printf("init ");
627 if (length
< sizeof(struct initmsg
))
629 TCHECK(cmp
->cm_init
);
630 src
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_src
);
631 info
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_info
);
632 blksize
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_blksize
);
633 vers
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_vers
);
634 eco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_eco
);
635 ueco
= EXTRACT_LE_8BITS(cmp
->cm_init
.in_ueco
);
636 hello
= EXTRACT_LE_16BITS(cmp
->cm_init
.in_hello
);
639 "src %sblksize %d vers %d eco %d ueco %d hello %d",
640 dnaddr_string(src
), blksize
, vers
, eco
, ueco
,
645 (void)printf("verification ");
646 if (length
< sizeof(struct verifmsg
))
649 src
= EXTRACT_LE_16BITS(cmp
->cm_ver
.ve_src
);
650 other
= EXTRACT_LE_8BITS(cmp
->cm_ver
.ve_fcnval
);
651 (void)printf("src %s fcnval %o", dnaddr_string(src
), other
);
655 (void)printf("test ");
656 if (length
< sizeof(struct testmsg
))
658 TCHECK(cmp
->cm_test
);
659 src
= EXTRACT_LE_16BITS(cmp
->cm_test
.te_src
);
660 other
= EXTRACT_LE_8BITS(cmp
->cm_test
.te_data
);
661 (void)printf("src %s data %o", dnaddr_string(src
), other
);
665 (void)printf("lev-1-routing ");
666 if (length
< sizeof(struct l1rout
))
668 TCHECK(cmp
->cm_l1rou
);
669 src
= EXTRACT_LE_16BITS(cmp
->cm_l1rou
.r1_src
);
670 (void)printf("src %s ", dnaddr_string(src
));
671 ret
= print_l1_routes(&(rhpx
[sizeof(struct l1rout
)]),
672 length
- sizeof(struct l1rout
));
675 (void)printf("lev-2-routing ");
676 if (length
< sizeof(struct l2rout
))
678 TCHECK(cmp
->cm_l2rout
);
679 src
= EXTRACT_LE_16BITS(cmp
->cm_l2rout
.r2_src
);
680 (void)printf("src %s ", dnaddr_string(src
));
681 ret
= print_l2_routes(&(rhpx
[sizeof(struct l2rout
)]),
682 length
- sizeof(struct l2rout
));
685 (void)printf("router-hello ");
686 if (length
< sizeof(struct rhellomsg
))
688 TCHECK(cmp
->cm_rhello
);
689 vers
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_vers
);
690 eco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_eco
);
691 ueco
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_ueco
);
692 memcpy((char *)&srcea
, (char *)&(cmp
->cm_rhello
.rh_src
),
694 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
695 info
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_info
);
696 blksize
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_blksize
);
697 priority
= EXTRACT_LE_8BITS(cmp
->cm_rhello
.rh_priority
);
698 hello
= EXTRACT_LE_16BITS(cmp
->cm_rhello
.rh_hello
);
701 "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
702 vers
, eco
, ueco
, dnaddr_string(src
),
703 blksize
, priority
, hello
);
704 ret
= print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
705 length
- sizeof(struct rhellomsg
));
708 (void)printf("endnode-hello ");
709 if (length
< sizeof(struct ehellomsg
))
711 TCHECK(cmp
->cm_ehello
);
712 vers
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_vers
);
713 eco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_eco
);
714 ueco
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_ueco
);
715 memcpy((char *)&srcea
, (char *)&(cmp
->cm_ehello
.eh_src
),
717 src
= EXTRACT_LE_16BITS(srcea
.dne_remote
.dne_nodeaddr
);
718 info
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_info
);
719 blksize
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_blksize
);
721 memcpy((char *)&rtea
, (char *)&(cmp
->cm_ehello
.eh_router
),
723 dst
= EXTRACT_LE_16BITS(rtea
.dne_remote
.dne_nodeaddr
);
724 hello
= EXTRACT_LE_16BITS(cmp
->cm_ehello
.eh_hello
);
725 other
= EXTRACT_LE_8BITS(cmp
->cm_ehello
.eh_data
);
728 "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
729 vers
, eco
, ueco
, dnaddr_string(src
),
730 blksize
, dnaddr_string(dst
), hello
, other
);
735 (void)printf("unknown control message");
736 default_print((u_char
*)rhp
, min(length
, caplen
));
747 print_t_info(int info
)
749 int ntype
= info
& 3;
751 case 0: (void)printf("reserved-ntype? "); break;
752 case TI_L2ROUT
: (void)printf("l2rout "); break;
753 case TI_L1ROUT
: (void)printf("l1rout "); break;
754 case TI_ENDNODE
: (void)printf("endnode "); break;
757 (void)printf("verif ");
759 (void)printf("blo ");
763 print_l1_routes(const char *rp
, u_int len
)
769 /* The last short is a checksum */
770 while (len
> (3 * sizeof(short))) {
771 TCHECK2(*rp
, 3 * sizeof(short));
772 count
= EXTRACT_LE_16BITS(rp
);
774 return (1); /* seems to be bogus from here on */
776 len
-= sizeof(short);
777 id
= EXTRACT_LE_16BITS(rp
);
779 len
-= sizeof(short);
780 info
= EXTRACT_LE_16BITS(rp
);
782 len
-= sizeof(short);
783 (void)printf("{ids %d-%d cost %d hops %d} ", id
, id
+ count
,
784 RI_COST(info
), RI_HOPS(info
));
793 print_l2_routes(const char *rp
, u_int len
)
799 /* The last short is a checksum */
800 while (len
> (3 * sizeof(short))) {
801 TCHECK2(*rp
, 3 * sizeof(short));
802 count
= EXTRACT_LE_16BITS(rp
);
804 return (1); /* seems to be bogus from here on */
806 len
-= sizeof(short);
807 area
= EXTRACT_LE_16BITS(rp
);
809 len
-= sizeof(short);
810 info
= EXTRACT_LE_16BITS(rp
);
812 len
-= sizeof(short);
813 (void)printf("{areas %d-%d cost %d hops %d} ", area
, area
+ count
,
814 RI_COST(info
), RI_HOPS(info
));
823 print_i_info(int info
)
825 int ntype
= info
& II_TYPEMASK
;
827 case 0: (void)printf("reserved-ntype? "); break;
828 case II_L2ROUT
: (void)printf("l2rout "); break;
829 case II_L1ROUT
: (void)printf("l1rout "); break;
830 case II_ENDNODE
: (void)printf("endnode "); break;
833 (void)printf("verif ");
834 if (info
& II_NOMCAST
)
835 (void)printf("nomcast ");
837 (void)printf("blo ");
841 print_elist(const char *elp _U_
, u_int len _U_
)
843 /* Not enough examples available for me to debug this */
848 print_nsp(const u_char
*nspp
, u_int nsplen
)
850 const struct nsphdr
*nsphp
= (struct nsphdr
*)nspp
;
853 if (nsplen
< sizeof(struct nsphdr
))
856 flags
= EXTRACT_LE_8BITS(nsphp
->nh_flags
);
857 dst
= EXTRACT_LE_16BITS(nsphp
->nh_dst
);
858 src
= EXTRACT_LE_16BITS(nsphp
->nh_src
);
860 switch (flags
& NSP_TYPEMASK
) {
862 switch (flags
& NSP_SUBMASK
) {
866 case MFS_BOM
+MFS_EOM
:
867 printf("data %d>%d ", src
, dst
);
869 struct seghdr
*shp
= (struct seghdr
*)nspp
;
874 u_int data_off
= sizeof(struct minseghdr
);
876 if (nsplen
< data_off
)
878 TCHECK(shp
->sh_seq
[0]);
879 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
880 if (ack
& SGQ_ACK
) { /* acknum field */
881 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
882 (void)printf("nak %d ", ack
& SGQ_MASK
);
884 (void)printf("ack %d ", ack
& SGQ_MASK
);
885 data_off
+= sizeof(short);
886 if (nsplen
< data_off
)
888 TCHECK(shp
->sh_seq
[1]);
889 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
890 if (ack
& SGQ_OACK
) { /* ackoth field */
891 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
892 (void)printf("onak %d ", ack
& SGQ_MASK
);
894 (void)printf("oack %d ", ack
& SGQ_MASK
);
895 data_off
+= sizeof(short);
896 if (nsplen
< data_off
)
898 TCHECK(shp
->sh_seq
[2]);
899 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
902 (void)printf("seg %d ", ack
& SGQ_MASK
);
904 if (nsplen
> data_off
) {
905 dp
= &(nspp
[data_off
]);
906 TCHECK2(*dp
, nsplen
- data_off
);
907 pdata(dp
, nsplen
- data_off
);
912 case MFS_ILS
+MFS_INT
:
915 struct seghdr
*shp
= (struct seghdr
*)nspp
;
920 u_int data_off
= sizeof(struct minseghdr
);
922 if (nsplen
< data_off
)
924 TCHECK(shp
->sh_seq
[0]);
925 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
926 if (ack
& SGQ_ACK
) { /* acknum field */
927 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
928 (void)printf("nak %d ", ack
& SGQ_MASK
);
930 (void)printf("ack %d ", ack
& SGQ_MASK
);
931 data_off
+= sizeof(short);
932 if (nsplen
< data_off
)
934 TCHECK(shp
->sh_seq
[1]);
935 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
936 if (ack
& SGQ_OACK
) { /* ackdat field */
937 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
938 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
940 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
941 data_off
+= sizeof(short);
942 if (nsplen
< data_off
)
944 TCHECK(shp
->sh_seq
[2]);
945 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
948 (void)printf("seg %d ", ack
& SGQ_MASK
);
950 if (nsplen
> data_off
) {
951 dp
= &(nspp
[data_off
]);
952 TCHECK2(*dp
, nsplen
- data_off
);
953 pdata(dp
, nsplen
- data_off
);
959 (void)printf("link-service %d>%d ", src
, dst
);
961 struct seghdr
*shp
= (struct seghdr
*)nspp
;
963 (struct lsmsg
*)&(nspp
[sizeof(struct seghdr
)]);
967 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
969 TCHECK(shp
->sh_seq
[0]);
970 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[0]);
971 if (ack
& SGQ_ACK
) { /* acknum field */
972 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
973 (void)printf("nak %d ", ack
& SGQ_MASK
);
975 (void)printf("ack %d ", ack
& SGQ_MASK
);
976 TCHECK(shp
->sh_seq
[1]);
977 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[1]);
978 if (ack
& SGQ_OACK
) { /* ackdat field */
979 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
980 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
982 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
983 TCHECK(shp
->sh_seq
[2]);
984 ack
= EXTRACT_LE_16BITS(shp
->sh_seq
[2]);
987 (void)printf("seg %d ", ack
& SGQ_MASK
);
989 lsflags
= EXTRACT_LE_8BITS(lsmp
->ls_lsflags
);
990 fcval
= EXTRACT_LE_8BITS(lsmp
->ls_fcval
);
991 switch (lsflags
& LSI_MASK
) {
993 (void)printf("dat seg count %d ", fcval
);
994 switch (lsflags
& LSM_MASK
) {
998 (void)printf("donotsend-data ");
1001 (void)printf("send-data ");
1004 (void)printf("reserved-fcmod? %x", lsflags
);
1009 (void)printf("intr req count %d ", fcval
);
1012 (void)printf("reserved-fcval-int? %x", lsflags
);
1018 (void)printf("reserved-subtype? %x %d > %d", flags
, src
, dst
);
1023 switch (flags
& NSP_SUBMASK
) {
1025 (void)printf("data-ack %d>%d ", src
, dst
);
1027 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
1030 if (nsplen
< sizeof(struct ackmsg
))
1033 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
1034 if (ack
& SGQ_ACK
) { /* acknum field */
1035 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
1036 (void)printf("nak %d ", ack
& SGQ_MASK
);
1038 (void)printf("ack %d ", ack
& SGQ_MASK
);
1039 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
1040 if (ack
& SGQ_OACK
) { /* ackoth field */
1041 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
1042 (void)printf("onak %d ", ack
& SGQ_MASK
);
1044 (void)printf("oack %d ", ack
& SGQ_MASK
);
1050 (void)printf("ils-ack %d>%d ", src
, dst
);
1052 struct ackmsg
*amp
= (struct ackmsg
*)nspp
;
1055 if (nsplen
< sizeof(struct ackmsg
))
1058 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[0]);
1059 if (ack
& SGQ_ACK
) { /* acknum field */
1060 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
1061 (void)printf("nak %d ", ack
& SGQ_MASK
);
1063 (void)printf("ack %d ", ack
& SGQ_MASK
);
1064 TCHECK(amp
->ak_acknum
[1]);
1065 ack
= EXTRACT_LE_16BITS(amp
->ak_acknum
[1]);
1066 if (ack
& SGQ_OACK
) { /* ackdat field */
1067 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
1068 (void)printf("nakdat %d ", ack
& SGQ_MASK
);
1070 (void)printf("ackdat %d ", ack
& SGQ_MASK
);
1076 (void)printf("conn-ack %d", dst
);
1079 (void)printf("reserved-acktype? %x %d > %d", flags
, src
, dst
);
1084 switch (flags
& NSP_SUBMASK
) {
1087 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
1088 (void)printf("conn-initiate ");
1090 (void)printf("retrans-conn-initiate ");
1091 (void)printf("%d>%d ", src
, dst
);
1093 struct cimsg
*cimp
= (struct cimsg
*)nspp
;
1094 int services
, info
, segsize
;
1095 #ifdef PRINT_NSPDATA
1099 if (nsplen
< sizeof(struct cimsg
))
1102 services
= EXTRACT_LE_8BITS(cimp
->ci_services
);
1103 info
= EXTRACT_LE_8BITS(cimp
->ci_info
);
1104 segsize
= EXTRACT_LE_16BITS(cimp
->ci_segsize
);
1106 switch (services
& COS_MASK
) {
1110 (void)printf("seg ");
1113 (void)printf("msg ");
1116 (void)printf("crypt ");
1119 switch (info
& COI_MASK
) {
1121 (void)printf("ver 3.2 ");
1124 (void)printf("ver 3.1 ");
1127 (void)printf("ver 4.0 ");
1130 (void)printf("ver 4.1 ");
1133 (void)printf("segsize %d ", segsize
);
1134 #ifdef PRINT_NSPDATA
1135 if (nsplen
> sizeof(struct cimsg
)) {
1136 dp
= &(nspp
[sizeof(struct cimsg
)]);
1137 TCHECK2(*dp
, nsplen
- sizeof(struct cimsg
));
1138 pdata(dp
, nsplen
- sizeof(struct cimsg
));
1144 (void)printf("conn-confirm %d>%d ", src
, dst
);
1146 struct ccmsg
*ccmp
= (struct ccmsg
*)nspp
;
1148 u_int segsize
, optlen
;
1149 #ifdef PRINT_NSPDATA
1153 if (nsplen
< sizeof(struct ccmsg
))
1156 services
= EXTRACT_LE_8BITS(ccmp
->cc_services
);
1157 info
= EXTRACT_LE_8BITS(ccmp
->cc_info
);
1158 segsize
= EXTRACT_LE_16BITS(ccmp
->cc_segsize
);
1159 optlen
= EXTRACT_LE_8BITS(ccmp
->cc_optlen
);
1161 switch (services
& COS_MASK
) {
1165 (void)printf("seg ");
1168 (void)printf("msg ");
1171 (void)printf("crypt ");
1174 switch (info
& COI_MASK
) {
1176 (void)printf("ver 3.2 ");
1179 (void)printf("ver 3.1 ");
1182 (void)printf("ver 4.0 ");
1185 (void)printf("ver 4.1 ");
1188 (void)printf("segsize %d ", segsize
);
1190 (void)printf("optlen %d ", optlen
);
1191 #ifdef PRINT_NSPDATA
1192 if (optlen
> nsplen
- sizeof(struct ccmsg
))
1194 dp
= &(nspp
[sizeof(struct ccmsg
)]);
1195 TCHECK2(*dp
, optlen
);
1202 (void)printf("disconn-initiate %d>%d ", src
, dst
);
1204 struct dimsg
*dimp
= (struct dimsg
*)nspp
;
1207 #ifdef PRINT_NSPDATA
1211 if (nsplen
< sizeof(struct dimsg
))
1214 reason
= EXTRACT_LE_16BITS(dimp
->di_reason
);
1215 optlen
= EXTRACT_LE_8BITS(dimp
->di_optlen
);
1217 print_reason(reason
);
1219 (void)printf("optlen %d ", optlen
);
1220 #ifdef PRINT_NSPDATA
1221 if (optlen
> nsplen
- sizeof(struct dimsg
))
1223 dp
= &(nspp
[sizeof(struct dimsg
)]);
1224 TCHECK2(*dp
, optlen
);
1231 (void)printf("disconn-confirm %d>%d ", src
, dst
);
1233 struct dcmsg
*dcmp
= (struct dcmsg
*)nspp
;
1237 reason
= EXTRACT_LE_16BITS(dcmp
->dc_reason
);
1239 print_reason(reason
);
1243 (void)printf("reserved-ctltype? %x %d > %d", flags
, src
, dst
);
1248 (void)printf("reserved-type? %x %d > %d", flags
, src
, dst
);
1257 static const struct tok reason2str
[] = {
1258 { UC_OBJREJECT
, "object rejected connect" },
1259 { UC_RESOURCES
, "insufficient resources" },
1260 { UC_NOSUCHNODE
, "unrecognized node name" },
1261 { DI_SHUT
, "node is shutting down" },
1262 { UC_NOSUCHOBJ
, "unrecognized object" },
1263 { UC_INVOBJFORMAT
, "invalid object name format" },
1264 { UC_OBJTOOBUSY
, "object too busy" },
1265 { DI_PROTOCOL
, "protocol error discovered" },
1266 { DI_TPA
, "third party abort" },
1267 { UC_USERABORT
, "user abort" },
1268 { UC_INVNODEFORMAT
, "invalid node name format" },
1269 { UC_LOCALSHUT
, "local node shutting down" },
1270 { DI_LOCALRESRC
, "insufficient local resources" },
1271 { DI_REMUSERRESRC
, "insufficient remote user resources" },
1272 { UC_ACCESSREJECT
, "invalid access control information" },
1273 { DI_BADACCNT
, "bad ACCOUNT information" },
1274 { UC_NORESPONSE
, "no response from object" },
1275 { UC_UNREACHABLE
, "node unreachable" },
1276 { DC_NOLINK
, "no link terminate" },
1277 { DC_COMPLETE
, "disconnect complete" },
1278 { DI_BADIMAGE
, "bad image data in connect" },
1279 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
1284 print_reason(register int reason
)
1286 printf("%s ", tok2str(reason2str
, "reason-%d", reason
));
1290 dnnum_string(u_short dnaddr
)
1294 int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
1295 int node
= dnaddr
& NODEMASK
;
1297 str
= (char *)malloc(siz
= sizeof("00.0000"));
1299 error("dnnum_string: malloc");
1300 snprintf(str
, siz
, "%d.%d", area
, node
);
1305 dnname_string(u_short dnaddr
)
1307 #ifdef HAVE_DNET_HTOA
1308 struct dn_naddr dna
;
1310 dna
.a_len
= sizeof(short);
1311 memcpy((char *)dna
.a_addr
, (char *)&dnaddr
, sizeof(short));
1312 return (strdup(dnet_htoa(&dna
)));
1314 return(dnnum_string(dnaddr
)); /* punt */
1318 #ifdef PRINT_NSPDATA
1320 pdata(u_char
*dp
, u_int maxlen
)
1327 safeputchar(gndo
, c
);