]>
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.
22 /* \summary: DECnet printer */
24 * specification: Section 10.0 MESSAGES
25 * DECnet Digital Network Architecture
27 * Routing Layer Functional Specification
28 * Order No. AA-X435A-TK
29 * Version 2.0.0 December 1983
34 #include "netdissect-stdinc.h"
39 #define ND_LONGJMP_FROM_TCHECK
40 #include "netdissect.h"
42 #include "addrtoname.h"
46 typedef nd_uint8_t byte
; /* single byte field */
49 * the keyword 'byte' generates conflicts in Windows
51 typedef nd_uint8_t Byte
; /* single byte field */
54 typedef nd_uint16_t word
; /* 2 byte field */
55 typedef nd_uint32_t longword
; /* 4 bytes field */
58 * Definitions for DECNET Phase IV protocol headers
61 nd_mac48 dne_addr
; /* full Ethernet address */
63 nd_byte dne_hiord
[4]; /* DECnet HIORD prefix */
64 nd_byte dne_nodeaddr
[2]; /* DECnet node address */
66 } etheraddr
; /* Ethernet address */
68 #define HIORD 0x000400aa /* high 32-bits of address (swapped) */
70 #define AREAMASK 0176000 /* mask for area field */
71 #define AREASHIFT 10 /* bit-offset for area field */
72 #define NODEMASK 01777 /* mask for node address field */
75 * Define long and short header formats.
79 byte sh_flags
; /* route flags */
80 word sh_dst
; /* destination node address */
81 word sh_src
; /* source node address */
82 byte sh_visits
; /* visit count */
87 byte lg_flags
; /* route flags */
88 byte lg_darea
; /* destination area (reserved) */
89 byte lg_dsarea
; /* destination subarea (reserved) */
90 etheraddr lg_dst
; /* destination id */
91 byte lg_sarea
; /* source area (reserved) */
92 byte lg_ssarea
; /* source subarea (reserved) */
93 etheraddr lg_src
; /* source id */
94 byte lg_nextl2
; /* next level 2 router (reserved) */
95 byte lg_visits
; /* visit count */
96 byte lg_service
; /* service class (reserved) */
97 byte lg_pt
; /* protocol type (reserved) */
102 struct shorthdr rh_short
; /* short route header */
103 struct longhdr rh_long
; /* long route header */
107 * Define the values of various fields in the protocol messages.
109 * 1. Data packet formats.
111 #define RMF_MASK 7 /* mask for message type */
112 #define RMF_SHORT 2 /* short message format */
113 #define RMF_LONG 6 /* long message format */
115 #define RMF_RQR 010 /* request return to sender */
116 #define RMF_RTS 020 /* returning to sender */
117 #define RMF_IE 040 /* intra-ethernet packet */
119 #define RMF_FVER 0100 /* future version flag */
120 #define RMF_PAD 0200 /* pad field */
121 #define RMF_PADMASK 0177 /* pad field mask */
123 #define VIS_MASK 077 /* visit field mask */
126 * 2. Control packet formats.
128 #define RMF_CTLMASK 017 /* mask for message type */
129 #define RMF_CTLMSG 01 /* control message indicator */
130 #define RMF_INIT 01 /* initialization message */
131 #define RMF_VER 03 /* verification message */
132 #define RMF_TEST 05 /* hello and test message */
133 #define RMF_L1ROUT 07 /* level 1 routing message */
134 #define RMF_L2ROUT 011 /* level 2 routing message */
135 #define RMF_RHELLO 013 /* router hello message */
136 #define RMF_EHELLO 015 /* endnode hello message */
138 #define TI_L2ROUT 01 /* level 2 router */
139 #define TI_L1ROUT 02 /* level 1 router */
140 #define TI_ENDNODE 03 /* endnode */
141 #define TI_VERIF 04 /* verification required */
142 #define TI_BLOCK 010 /* blocking requested */
144 #define VE_VERS 2 /* version number (2) */
145 #define VE_ECO 0 /* ECO number */
146 #define VE_UECO 0 /* user ECO number (0) */
148 #define P3_VERS 1 /* phase III version number (1) */
149 #define P3_ECO 3 /* ECO number (3) */
150 #define P3_UECO 0 /* user ECO number (0) */
152 #define II_L2ROUT 01 /* level 2 router */
153 #define II_L1ROUT 02 /* level 1 router */
154 #define II_ENDNODE 03 /* endnode */
155 #define II_VERIF 04 /* verification required */
156 #define II_NOMCAST 040 /* no multicast traffic accepted */
157 #define II_BLOCK 0100 /* blocking requested */
158 #define II_TYPEMASK 03 /* mask for node type */
160 #define TESTDATA 0252 /* test data bytes */
161 #define TESTLEN 1 /* length of transmitted test data */
164 * Define control message formats.
166 struct initmsg
/* initialization message */
168 byte in_flags
; /* route flags */
169 word in_src
; /* source node address */
170 byte in_info
; /* routing layer information */
171 word in_blksize
; /* maximum data link block size */
172 byte in_vers
; /* version number */
173 byte in_eco
; /* ECO number */
174 byte in_ueco
; /* user ECO number */
175 word in_hello
; /* hello timer */
176 byte in_rsvd
; /* reserved image field */
179 struct verifmsg
/* verification message */
181 byte ve_flags
; /* route flags */
182 word ve_src
; /* source node address */
183 byte ve_fcnval
; /* function value image field */
186 struct testmsg
/* hello and test message */
188 byte te_flags
; /* route flags */
189 word te_src
; /* source node address */
190 byte te_data
; /* test data image field */
193 struct l1rout
/* level 1 routing message */
195 byte r1_flags
; /* route flags */
196 word r1_src
; /* source node address */
197 byte r1_rsvd
; /* reserved field */
200 struct l2rout
/* level 2 routing message */
202 byte r2_flags
; /* route flags */
203 word r2_src
; /* source node address */
204 byte r2_rsvd
; /* reserved field */
207 struct rhellomsg
/* router hello message */
209 byte rh_flags
; /* route flags */
210 byte rh_vers
; /* version number */
211 byte rh_eco
; /* ECO number */
212 byte rh_ueco
; /* user ECO number */
213 etheraddr rh_src
; /* source id */
214 byte rh_info
; /* routing layer information */
215 word rh_blksize
; /* maximum data link block size */
216 byte rh_priority
; /* router's priority */
217 byte rh_area
; /* reserved */
218 word rh_hello
; /* hello timer */
219 byte rh_mpd
; /* reserved */
222 struct ehellomsg
/* endnode hello message */
224 byte eh_flags
; /* route flags */
225 byte eh_vers
; /* version number */
226 byte eh_eco
; /* ECO number */
227 byte eh_ueco
; /* user ECO number */
228 etheraddr eh_src
; /* source id */
229 byte eh_info
; /* routing layer information */
230 word eh_blksize
; /* maximum data link block size */
231 byte eh_area
; /* area (reserved) */
232 byte eh_seed
[8]; /* verification seed */
233 etheraddr eh_router
; /* designated router */
234 word eh_hello
; /* hello timer */
235 byte eh_mpd
; /* (reserved) */
236 byte eh_data
; /* test data image field */
241 struct initmsg cm_init
; /* initialization message */
242 struct verifmsg cm_ver
; /* verification message */
243 struct testmsg cm_test
; /* hello and test message */
244 struct l1rout cm_l1rou
; /* level 1 routing message */
245 struct l2rout cm_l2rout
; /* level 2 routing message */
246 struct rhellomsg cm_rhello
; /* router hello message */
247 struct ehellomsg cm_ehello
; /* endnode hello message */
250 /* Macros for decoding routing-info fields */
251 #define RI_COST(x) ((x)&0777)
252 #define RI_HOPS(x) (((x)>>10)&037)
255 * NSP protocol fields and values.
258 #define NSP_TYPEMASK 014 /* mask to isolate type code */
259 #define NSP_SUBMASK 0160 /* mask to isolate subtype code */
260 #define NSP_SUBSHFT 4 /* shift to move subtype code */
262 #define MFT_DATA 0 /* data message */
263 #define MFT_ACK 04 /* acknowledgement message */
264 #define MFT_CTL 010 /* control message */
266 #define MFS_ILS 020 /* data or I/LS indicator */
267 #define MFS_BOM 040 /* beginning of message (data) */
268 #define MFS_MOM 0 /* middle of message (data) */
269 #define MFS_EOM 0100 /* end of message (data) */
270 #define MFS_INT 040 /* interrupt message */
272 #define MFS_DACK 0 /* data acknowledgement */
273 #define MFS_IACK 020 /* I/LS acknowledgement */
274 #define MFS_CACK 040 /* connect acknowledgement */
276 #define MFS_NOP 0 /* no operation */
277 #define MFS_CI 020 /* connect initiate */
278 #define MFS_CC 040 /* connect confirm */
279 #define MFS_DI 060 /* disconnect initiate */
280 #define MFS_DC 0100 /* disconnect confirm */
281 #define MFS_RCI 0140 /* retransmitted connect initiate */
283 #define SGQ_ACK 0100000 /* ack */
284 #define SGQ_NAK 0110000 /* negative ack */
285 #define SGQ_OACK 0120000 /* other channel ack */
286 #define SGQ_ONAK 0130000 /* other channel negative ack */
287 #define SGQ_MASK 07777 /* mask to isolate seq # */
288 #define SGQ_OTHER 020000 /* other channel qualifier */
289 #define SGQ_DELAY 010000 /* ack delay flag */
291 #define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
293 #define LSM_MASK 03 /* mask for modifier field */
294 #define LSM_NOCHANGE 0 /* no change */
295 #define LSM_DONOTSEND 1 /* do not send data */
296 #define LSM_SEND 2 /* send data */
298 #define LSI_MASK 014 /* mask for interpretation field */
299 #define LSI_DATA 0 /* data segment or message count */
300 #define LSI_INTR 4 /* interrupt request count */
301 #define LSI_INTM 0377 /* funny marker for int. message */
303 #define COS_MASK 014 /* mask for flow control field */
304 #define COS_NONE 0 /* no flow control */
305 #define COS_SEGMENT 04 /* segment flow control */
306 #define COS_MESSAGE 010 /* message flow control */
307 #define COS_DEFAULT 1 /* default value for field */
309 #define COI_MASK 3 /* mask for version field */
310 #define COI_32 0 /* version 3.2 */
311 #define COI_31 1 /* version 3.1 */
312 #define COI_40 2 /* version 4.0 */
313 #define COI_41 3 /* version 4.1 */
315 #define MNU_MASK 140 /* mask for session control version */
316 #define MNU_10 000 /* session V1.0 */
317 #define MNU_20 040 /* session V2.0 */
318 #define MNU_ACCESS 1 /* access control present */
319 #define MNU_USRDATA 2 /* user data field present */
320 #define MNU_INVKPROXY 4 /* invoke proxy field present */
321 #define MNU_UICPROXY 8 /* use uic-based proxy */
323 #define DC_NORESOURCES 1 /* no resource reason code */
324 #define DC_NOLINK 41 /* no link terminate reason code */
325 #define DC_COMPLETE 42 /* disconnect complete reason code */
327 #define DI_NOERROR 0 /* user disconnect */
328 #define DI_SHUT 3 /* node is shutting down */
329 #define DI_NOUSER 4 /* destination end user does not exist */
330 #define DI_INVDEST 5 /* invalid end user destination */
331 #define DI_REMRESRC 6 /* insufficient remote resources */
332 #define DI_TPA 8 /* third party abort */
333 #define DI_PROTOCOL 7 /* protocol error discovered */
334 #define DI_ABORT 9 /* user abort */
335 #define DI_LOCALRESRC 32 /* insufficient local resources */
336 #define DI_REMUSERRESRC 33 /* insufficient remote user resources */
337 #define DI_BADACCESS 34 /* bad access control information */
338 #define DI_BADACCNT 36 /* bad ACCOUNT information */
339 #define DI_CONNECTABORT 38 /* connect request cancelled */
340 #define DI_TIMEDOUT 38 /* remote node or user crashed */
341 #define DI_UNREACHABLE 39 /* local timers expired due to ... */
342 #define DI_BADIMAGE 43 /* bad image data in connect */
343 #define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
345 #define UC_OBJREJECT 0 /* object rejected connect */
346 #define UC_USERDISCONNECT 0 /* user disconnect */
347 #define UC_RESOURCES 1 /* insufficient resources (local or remote) */
348 #define UC_NOSUCHNODE 2 /* unrecognized node name */
349 #define UC_REMOTESHUT 3 /* remote node shutting down */
350 #define UC_NOSUCHOBJ 4 /* unrecognized object */
351 #define UC_INVOBJFORMAT 5 /* invalid object name format */
352 #define UC_OBJTOOBUSY 6 /* object too busy */
353 #define UC_NETWORKABORT 8 /* network abort */
354 #define UC_USERABORT 9 /* user abort */
355 #define UC_INVNODEFORMAT 10 /* invalid node name format */
356 #define UC_LOCALSHUT 11 /* local node shutting down */
357 #define UC_ACCESSREJECT 34 /* invalid access control information */
358 #define UC_NORESPONSE 38 /* no response from object */
359 #define UC_UNREACHABLE 39 /* node unreachable */
362 * NSP message formats.
364 struct nsphdr
/* general nsp header */
366 byte nh_flags
; /* message flags */
367 word nh_dst
; /* destination link address */
368 word nh_src
; /* source link address */
371 struct seghdr
/* data segment header */
373 byte sh_flags
; /* message flags */
374 word sh_dst
; /* destination link address */
375 word sh_src
; /* source link address */
376 word sh_seq
[3]; /* sequence numbers */
379 struct minseghdr
/* minimum data segment header */
381 byte ms_flags
; /* message flags */
382 word ms_dst
; /* destination link address */
383 word ms_src
; /* source link address */
384 word ms_seq
; /* sequence number */
387 struct lsmsg
/* link service message (after hdr) */
389 byte ls_lsflags
; /* link service flags */
390 byte ls_fcval
; /* flow control value */
393 struct ackmsg
/* acknowledgement message */
395 byte ak_flags
; /* message flags */
396 word ak_dst
; /* destination link address */
397 word ak_src
; /* source link address */
398 word ak_acknum
[2]; /* acknowledgement numbers */
401 struct minackmsg
/* minimum acknowledgement message */
403 byte mk_flags
; /* message flags */
404 word mk_dst
; /* destination link address */
405 word mk_src
; /* source link address */
406 word mk_acknum
; /* acknowledgement number */
409 struct ciackmsg
/* connect acknowledgement message */
411 byte ck_flags
; /* message flags */
412 word ck_dst
; /* destination link address */
415 struct cimsg
/* connect initiate message */
417 byte ci_flags
; /* message flags */
418 word ci_dst
; /* destination link address (0) */
419 word ci_src
; /* source link address */
420 byte ci_services
; /* requested services */
421 byte ci_info
; /* information */
422 word ci_segsize
; /* maximum segment size */
425 struct ccmsg
/* connect confirm message */
427 byte cc_flags
; /* message flags */
428 word cc_dst
; /* destination link address */
429 word cc_src
; /* source link address */
430 byte cc_services
; /* requested services */
431 byte cc_info
; /* information */
432 word cc_segsize
; /* maximum segment size */
433 byte cc_optlen
; /* optional data length */
436 struct cnmsg
/* generic connect message */
438 byte cn_flags
; /* message flags */
439 word cn_dst
; /* destination link address */
440 word cn_src
; /* source link address */
441 byte cn_services
; /* requested services */
442 byte cn_info
; /* information */
443 word cn_segsize
; /* maximum segment size */
446 struct dimsg
/* disconnect initiate message */
448 byte di_flags
; /* message flags */
449 word di_dst
; /* destination link address */
450 word di_src
; /* source link address */
451 word di_reason
; /* reason code */
452 byte di_optlen
; /* optional data length */
455 struct dcmsg
/* disconnect confirm message */
457 byte dc_flags
; /* message flags */
458 word dc_dst
; /* destination link address */
459 word dc_src
; /* source link address */
460 word dc_reason
; /* reason code */
464 static int print_decnet_ctlmsg(netdissect_options
*, const union routehdr
*, u_int
, u_int
);
465 static void print_t_info(netdissect_options
*, u_int
);
466 static void print_l1_routes(netdissect_options
*, const u_char
*, u_int
);
467 static void print_l2_routes(netdissect_options
*, const u_char
*, u_int
);
468 static void print_i_info(netdissect_options
*, u_int
);
469 static void print_elist(const u_char
*, u_int
);
470 static int print_nsp(netdissect_options
*, const u_char
*, u_int
);
471 static void print_reason(netdissect_options
*, u_int
);
474 decnet_print(netdissect_options
*ndo
,
475 const u_char
*ap
, u_int length
,
478 const union routehdr
*rhp
;
482 u_int nsplen
, pktlen
;
485 ndo
->ndo_protocol
= "decnet";
486 if (length
< sizeof(struct shorthdr
)) {
487 ND_PRINT(" (length %u < %zu)", length
, sizeof(struct shorthdr
));
492 * This length does not seem to be in any specification, but it is present
493 * in the test case packet capture, which is consistent with the Wireshark
496 pktlen
= GET_LE_U_2(ap
);
497 if (pktlen
< sizeof(struct shorthdr
)) {
498 ND_PRINT(" (pktlen %u < %zu)", pktlen
, sizeof(struct shorthdr
));
501 if (pktlen
> length
) {
502 ND_PRINT(" (pktlen %u > %u)", pktlen
, length
);
507 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
508 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
510 if (mflags
& RMF_PAD
) {
511 /* pad bytes of some sort in front of message */
512 u_int padlen
= mflags
& RMF_PADMASK
;
514 ND_PRINT("[pad:%u] ", padlen
);
515 if (length
< padlen
+ 2) {
516 ND_PRINT(" (length %u < %u)", length
, padlen
+ 2);
519 ND_TCHECK_LEN(ap
+ sizeof(short), padlen
);
523 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
524 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
527 if (mflags
& RMF_FVER
) {
528 ND_PRINT("future-version-decnet");
529 ND_DEFAULTPRINT(ap
, ND_MIN(length
, caplen
));
533 /* is it a control message? */
534 if (mflags
& RMF_CTLMSG
) {
535 if (!print_decnet_ctlmsg(ndo
, rhp
, length
, caplen
))
540 switch (mflags
& RMF_MASK
) {
542 if (length
< sizeof(struct longhdr
)) {
543 ND_PRINT(" (length %u < %zu)", length
, sizeof(struct longhdr
));
546 ND_TCHECK_SIZE(&rhp
->rh_long
);
548 GET_LE_U_2(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
550 GET_LE_U_2(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
551 hops
= GET_U_1(rhp
->rh_long
.lg_visits
);
552 nspp
= ap
+ sizeof(short) + sizeof(struct longhdr
);
553 nsplen
= length
- sizeof(struct longhdr
);
556 dst
= GET_LE_U_2(rhp
->rh_short
.sh_dst
);
557 src
= GET_LE_U_2(rhp
->rh_short
.sh_src
);
558 hops
= (GET_U_1(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
559 nspp
= ap
+ sizeof(short) + sizeof(struct shorthdr
);
560 nsplen
= length
- sizeof(struct shorthdr
);
563 ND_PRINT("unknown message flags under mask");
564 ND_DEFAULTPRINT((const u_char
*)ap
, ND_MIN(length
, caplen
));
568 ND_PRINT("%s > %s %u ",
569 dnaddr_string(ndo
, src
), dnaddr_string(ndo
, dst
), pktlen
);
570 if (ndo
->ndo_vflag
) {
571 if (mflags
& RMF_RQR
)
573 if (mflags
& RMF_RTS
)
577 ND_PRINT("%u hops ", hops
);
580 if (!print_nsp(ndo
, nspp
, nsplen
))
585 nd_print_invalid(ndo
);
589 print_decnet_ctlmsg(netdissect_options
*ndo
,
590 const union routehdr
*rhp
, u_int length
,
593 /* Our caller has already checked for mflags */
594 u_int mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
595 const union controlmsg
*cmp
= (const union controlmsg
*)rhp
;
597 u_int info
, blksize
, eco
, ueco
, hello
, other
, vers
;
599 const u_char
*rhpx
= (const u_char
*)rhp
;
601 switch (mflags
& RMF_CTLMASK
) {
604 if (length
< sizeof(struct initmsg
))
606 ND_TCHECK_SIZE(&cmp
->cm_init
);
607 src
= GET_LE_U_2(cmp
->cm_init
.in_src
);
608 info
= GET_U_1(cmp
->cm_init
.in_info
);
609 blksize
= GET_LE_U_2(cmp
->cm_init
.in_blksize
);
610 vers
= GET_U_1(cmp
->cm_init
.in_vers
);
611 eco
= GET_U_1(cmp
->cm_init
.in_eco
);
612 ueco
= GET_U_1(cmp
->cm_init
.in_ueco
);
613 hello
= GET_LE_U_2(cmp
->cm_init
.in_hello
);
614 print_t_info(ndo
, info
);
615 ND_PRINT("src %sblksize %u vers %u eco %u ueco %u hello %u",
616 dnaddr_string(ndo
, src
), blksize
, vers
, eco
, ueco
,
620 ND_PRINT("verification ");
621 if (length
< sizeof(struct verifmsg
))
623 src
= GET_LE_U_2(cmp
->cm_ver
.ve_src
);
624 other
= GET_U_1(cmp
->cm_ver
.ve_fcnval
);
625 ND_PRINT("src %s fcnval %o", dnaddr_string(ndo
, src
), other
);
629 if (length
< sizeof(struct testmsg
))
631 src
= GET_LE_U_2(cmp
->cm_test
.te_src
);
632 other
= GET_U_1(cmp
->cm_test
.te_data
);
633 ND_PRINT("src %s data %o", dnaddr_string(ndo
, src
), other
);
636 ND_PRINT("lev-1-routing ");
637 if (length
< sizeof(struct l1rout
))
639 ND_TCHECK_SIZE(&cmp
->cm_l1rou
);
640 src
= GET_LE_U_2(cmp
->cm_l1rou
.r1_src
);
641 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
642 print_l1_routes(ndo
, &(rhpx
[sizeof(struct l1rout
)]),
643 length
- sizeof(struct l1rout
));
646 ND_PRINT("lev-2-routing ");
647 if (length
< sizeof(struct l2rout
))
649 ND_TCHECK_SIZE(&cmp
->cm_l2rout
);
650 src
= GET_LE_U_2(cmp
->cm_l2rout
.r2_src
);
651 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
652 print_l2_routes(ndo
, &(rhpx
[sizeof(struct l2rout
)]),
653 length
- sizeof(struct l2rout
));
656 ND_PRINT("router-hello ");
657 if (length
< sizeof(struct rhellomsg
))
659 ND_TCHECK_SIZE(&cmp
->cm_rhello
);
660 vers
= GET_U_1(cmp
->cm_rhello
.rh_vers
);
661 eco
= GET_U_1(cmp
->cm_rhello
.rh_eco
);
662 ueco
= GET_U_1(cmp
->cm_rhello
.rh_ueco
);
664 GET_LE_U_2(cmp
->cm_rhello
.rh_src
.dne_remote
.dne_nodeaddr
);
665 info
= GET_U_1(cmp
->cm_rhello
.rh_info
);
666 blksize
= GET_LE_U_2(cmp
->cm_rhello
.rh_blksize
);
667 priority
= GET_U_1(cmp
->cm_rhello
.rh_priority
);
668 hello
= GET_LE_U_2(cmp
->cm_rhello
.rh_hello
);
669 print_i_info(ndo
, info
);
670 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u pri %u hello %u",
671 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
672 blksize
, priority
, hello
);
673 print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
674 length
- sizeof(struct rhellomsg
));
677 ND_PRINT("endnode-hello ");
678 if (length
< sizeof(struct ehellomsg
))
680 vers
= GET_U_1(cmp
->cm_ehello
.eh_vers
);
681 eco
= GET_U_1(cmp
->cm_ehello
.eh_eco
);
682 ueco
= GET_U_1(cmp
->cm_ehello
.eh_ueco
);
684 GET_LE_U_2(cmp
->cm_ehello
.eh_src
.dne_remote
.dne_nodeaddr
);
685 info
= GET_U_1(cmp
->cm_ehello
.eh_info
);
686 blksize
= GET_LE_U_2(cmp
->cm_ehello
.eh_blksize
);
689 GET_LE_U_2(cmp
->cm_ehello
.eh_router
.dne_remote
.dne_nodeaddr
);
690 hello
= GET_LE_U_2(cmp
->cm_ehello
.eh_hello
);
691 other
= GET_U_1(cmp
->cm_ehello
.eh_data
);
692 print_i_info(ndo
, info
);
693 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u rtr %s hello %u data %o",
694 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
695 blksize
, dnaddr_string(ndo
, dst
), hello
, other
);
699 ND_PRINT("unknown control message");
700 ND_DEFAULTPRINT((const u_char
*)rhp
, ND_MIN(length
, caplen
));
710 print_t_info(netdissect_options
*ndo
,
713 u_int ntype
= info
& 3;
715 case 0: ND_PRINT("reserved-ntype? "); break;
716 case TI_L2ROUT
: ND_PRINT("l2rout "); break;
717 case TI_L1ROUT
: ND_PRINT("l1rout "); break;
718 case TI_ENDNODE
: ND_PRINT("endnode "); break;
727 print_l1_routes(netdissect_options
*ndo
,
728 const u_char
*rp
, u_int len
)
734 /* The last short is a checksum */
735 while (len
> (3 * sizeof(short))) {
736 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
737 count
= GET_LE_U_2(rp
);
739 return; /* seems to be bogus from here on */
741 len
-= sizeof(short);
744 len
-= sizeof(short);
745 info
= GET_LE_U_2(rp
);
747 len
-= sizeof(short);
748 ND_PRINT("{ids %u-%u cost %u hops %u} ", id
, id
+ count
,
749 RI_COST(info
), RI_HOPS(info
));
754 print_l2_routes(netdissect_options
*ndo
,
755 const u_char
*rp
, u_int len
)
761 /* The last short is a checksum */
762 while (len
> (3 * sizeof(short))) {
763 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
764 count
= GET_LE_U_2(rp
);
766 return; /* seems to be bogus from here on */
768 len
-= sizeof(short);
769 area
= GET_LE_U_2(rp
);
771 len
-= sizeof(short);
772 info
= GET_LE_U_2(rp
);
774 len
-= sizeof(short);
775 ND_PRINT("{areas %u-%u cost %u hops %u} ", area
, area
+ count
,
776 RI_COST(info
), RI_HOPS(info
));
781 print_i_info(netdissect_options
*ndo
,
784 u_int ntype
= info
& II_TYPEMASK
;
786 case 0: ND_PRINT("reserved-ntype? "); break;
787 case II_L2ROUT
: ND_PRINT("l2rout "); break;
788 case II_L1ROUT
: ND_PRINT("l1rout "); break;
789 case II_ENDNODE
: ND_PRINT("endnode "); break;
793 if (info
& II_NOMCAST
)
794 ND_PRINT("nomcast ");
800 print_elist(const u_char
*elp _U_
, u_int len _U_
)
802 /* Not enough examples available for me to debug this */
806 print_nsp(netdissect_options
*ndo
,
807 const u_char
*nspp
, u_int nsplen
)
809 const struct nsphdr
*nsphp
= (const struct nsphdr
*)nspp
;
810 u_int dst
, src
, flags
;
812 if (nsplen
< sizeof(struct nsphdr
)) {
813 ND_PRINT(" (nsplen %u < %zu)", nsplen
, sizeof(struct nsphdr
));
816 flags
= GET_U_1(nsphp
->nh_flags
);
817 dst
= GET_LE_U_2(nsphp
->nh_dst
);
818 src
= GET_LE_U_2(nsphp
->nh_src
);
820 switch (flags
& NSP_TYPEMASK
) {
822 switch (flags
& NSP_SUBMASK
) {
826 case MFS_BOM
+MFS_EOM
:
827 ND_PRINT("data %u>%u ", src
, dst
);
829 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
831 u_int data_off
= sizeof(struct minseghdr
);
833 if (nsplen
< data_off
)
835 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
836 if (ack
& SGQ_ACK
) { /* acknum field */
837 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
838 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
840 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
841 data_off
+= sizeof(short);
842 if (nsplen
< data_off
)
844 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
845 if (ack
& SGQ_OACK
) { /* ackoth field */
846 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
847 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
849 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
850 data_off
+= sizeof(short);
851 if (nsplen
< data_off
)
853 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
856 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
859 case MFS_ILS
+MFS_INT
:
862 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
864 u_int data_off
= sizeof(struct minseghdr
);
866 if (nsplen
< data_off
)
868 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
869 if (ack
& SGQ_ACK
) { /* acknum field */
870 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
871 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
873 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
874 data_off
+= sizeof(short);
875 if (nsplen
< data_off
)
877 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
878 if (ack
& SGQ_OACK
) { /* ackdat field */
879 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
880 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
882 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
883 data_off
+= sizeof(short);
884 if (nsplen
< data_off
)
886 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
889 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
893 ND_PRINT("link-service %u>%u ", src
, dst
);
895 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
896 const struct lsmsg
*lsmp
=
897 (const struct lsmsg
*)(nspp
+ sizeof(struct seghdr
));
899 u_int lsflags
, fcval
;
901 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
903 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
904 if (ack
& SGQ_ACK
) { /* acknum field */
905 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
906 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
908 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
909 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
910 if (ack
& SGQ_OACK
) { /* ackdat field */
911 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
912 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
914 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
915 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
918 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
919 lsflags
= GET_U_1(lsmp
->ls_lsflags
);
920 fcval
= GET_U_1(lsmp
->ls_fcval
);
921 switch (lsflags
& LSI_MASK
) {
923 ND_PRINT("dat seg count %u ", fcval
);
924 switch (lsflags
& LSM_MASK
) {
928 ND_PRINT("donotsend-data ");
931 ND_PRINT("send-data ");
934 ND_PRINT("reserved-fcmod? %x", lsflags
);
939 ND_PRINT("intr req count %u ", fcval
);
942 ND_PRINT("reserved-fcval-int? %x", lsflags
);
948 ND_PRINT("reserved-subtype? %x %u > %u", flags
, src
, dst
);
953 switch (flags
& NSP_SUBMASK
) {
955 ND_PRINT("data-ack %u>%u ", src
, dst
);
957 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
960 if (nsplen
< sizeof(struct ackmsg
))
963 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
964 if (ack
& SGQ_ACK
) { /* acknum field */
965 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
966 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
968 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
969 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
970 if (ack
& SGQ_OACK
) { /* ackoth field */
971 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
972 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
974 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
980 ND_PRINT("ils-ack %u>%u ", src
, dst
);
982 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
985 if (nsplen
< sizeof(struct ackmsg
))
988 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
989 if (ack
& SGQ_ACK
) { /* acknum field */
990 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
991 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
993 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
994 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
995 if (ack
& SGQ_OACK
) { /* ackdat field */
996 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
997 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
999 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
1005 ND_PRINT("conn-ack %u", dst
);
1008 ND_PRINT("reserved-acktype? %x %u > %u", flags
, src
, dst
);
1013 switch (flags
& NSP_SUBMASK
) {
1016 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
1017 ND_PRINT("conn-initiate ");
1019 ND_PRINT("retrans-conn-initiate ");
1020 ND_PRINT("%u>%u ", src
, dst
);
1022 const struct cimsg
*cimp
= (const struct cimsg
*)nspp
;
1023 u_int services
, info
, segsize
;
1025 if (nsplen
< sizeof(struct cimsg
))
1027 services
= GET_U_1(cimp
->ci_services
);
1028 info
= GET_U_1(cimp
->ci_info
);
1029 segsize
= GET_LE_U_2(cimp
->ci_segsize
);
1031 switch (services
& COS_MASK
) {
1041 switch (info
& COI_MASK
) {
1043 ND_PRINT("ver 3.2 ");
1046 ND_PRINT("ver 3.1 ");
1049 ND_PRINT("ver 4.0 ");
1052 ND_PRINT("ver 4.1 ");
1055 ND_PRINT("segsize %u ", segsize
);
1059 ND_PRINT("conn-confirm %u>%u ", src
, dst
);
1061 const struct ccmsg
*ccmp
= (const struct ccmsg
*)nspp
;
1062 u_int services
, info
;
1063 u_int segsize
, optlen
;
1065 if (nsplen
< sizeof(struct ccmsg
))
1067 services
= GET_U_1(ccmp
->cc_services
);
1068 info
= GET_U_1(ccmp
->cc_info
);
1069 segsize
= GET_LE_U_2(ccmp
->cc_segsize
);
1070 optlen
= GET_U_1(ccmp
->cc_optlen
);
1072 switch (services
& COS_MASK
) {
1082 switch (info
& COI_MASK
) {
1084 ND_PRINT("ver 3.2 ");
1087 ND_PRINT("ver 3.1 ");
1090 ND_PRINT("ver 4.0 ");
1093 ND_PRINT("ver 4.1 ");
1096 ND_PRINT("segsize %u ", segsize
);
1098 ND_PRINT("optlen %u ", optlen
);
1103 ND_PRINT("disconn-initiate %u>%u ", src
, dst
);
1105 const struct dimsg
*dimp
= (const struct dimsg
*)nspp
;
1109 if (nsplen
< sizeof(struct dimsg
))
1111 reason
= GET_LE_U_2(dimp
->di_reason
);
1112 optlen
= GET_U_1(dimp
->di_optlen
);
1114 print_reason(ndo
, reason
);
1116 ND_PRINT("optlen %u ", optlen
);
1121 ND_PRINT("disconn-confirm %u>%u ", src
, dst
);
1123 const struct dcmsg
*dcmp
= (const struct dcmsg
*)nspp
;
1126 reason
= GET_LE_U_2(dcmp
->dc_reason
);
1128 print_reason(ndo
, reason
);
1132 ND_PRINT("reserved-ctltype? %x %u > %u", flags
, src
, dst
);
1137 ND_PRINT("reserved-type? %x %u > %u", flags
, src
, dst
);
1146 static const struct tok reason2str
[] = {
1147 { UC_OBJREJECT
, "object rejected connect" },
1148 { UC_RESOURCES
, "insufficient resources" },
1149 { UC_NOSUCHNODE
, "unrecognized node name" },
1150 { DI_SHUT
, "node is shutting down" },
1151 { UC_NOSUCHOBJ
, "unrecognized object" },
1152 { UC_INVOBJFORMAT
, "invalid object name format" },
1153 { UC_OBJTOOBUSY
, "object too busy" },
1154 { DI_PROTOCOL
, "protocol error discovered" },
1155 { DI_TPA
, "third party abort" },
1156 { UC_USERABORT
, "user abort" },
1157 { UC_INVNODEFORMAT
, "invalid node name format" },
1158 { UC_LOCALSHUT
, "local node shutting down" },
1159 { DI_LOCALRESRC
, "insufficient local resources" },
1160 { DI_REMUSERRESRC
, "insufficient remote user resources" },
1161 { UC_ACCESSREJECT
, "invalid access control information" },
1162 { DI_BADACCNT
, "bad ACCOUNT information" },
1163 { UC_NORESPONSE
, "no response from object" },
1164 { UC_UNREACHABLE
, "node unreachable" },
1165 { DC_NOLINK
, "no link terminate" },
1166 { DC_COMPLETE
, "disconnect complete" },
1167 { DI_BADIMAGE
, "bad image data in connect" },
1168 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
1173 print_reason(netdissect_options
*ndo
,
1176 ND_PRINT("%s ", tok2str(reason2str
, "reason-%u", reason
));
1180 dnnum_string(netdissect_options
*ndo
, u_short dnaddr
)
1184 u_int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
1185 u_int node
= dnaddr
& NODEMASK
;
1187 /* malloc() return used by the 'dnaddrtable' hash table: do not free() */
1188 str
= (char *)malloc(siz
= sizeof("00.0000"));
1190 (*ndo
->ndo_error
)(ndo
, S_ERR_ND_MEM_ALLOC
, "%s: malloc", __func__
);
1191 snprintf(str
, siz
, "%u.%u", area
, node
);