]>
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 */
28 #include "netdissect-stdinc.h"
34 #include "netdissect.h"
36 #include "addrtoname.h"
40 typedef nd_uint8_t byte
; /* single byte field */
43 * the keyword 'byte' generates conflicts in Windows
45 typedef nd_uint8_t Byte
; /* single byte field */
48 typedef nd_uint16_t word
; /* 2 byte field */
49 typedef nd_uint32_t longword
; /* 4 bytes field */
52 * Definitions for DECNET Phase IV protocol headers
55 nd_byte dne_addr
[MAC_ADDR_LEN
]; /* full Ethernet address */
57 nd_byte dne_hiord
[4]; /* DECnet HIORD prefix */
58 nd_byte dne_nodeaddr
[2]; /* DECnet node address */
60 } etheraddr
; /* Ethernet address */
62 #define HIORD 0x000400aa /* high 32-bits of address (swapped) */
64 #define AREAMASK 0176000 /* mask for area field */
65 #define AREASHIFT 10 /* bit-offset for area field */
66 #define NODEMASK 01777 /* mask for node address field */
69 * Define long and short header formats.
73 byte sh_flags
; /* route flags */
74 word sh_dst
; /* destination node address */
75 word sh_src
; /* source node address */
76 byte sh_visits
; /* visit count */
81 byte lg_flags
; /* route flags */
82 byte lg_darea
; /* destination area (reserved) */
83 byte lg_dsarea
; /* destination subarea (reserved) */
84 etheraddr lg_dst
; /* destination id */
85 byte lg_sarea
; /* source area (reserved) */
86 byte lg_ssarea
; /* source subarea (reserved) */
87 etheraddr lg_src
; /* source id */
88 byte lg_nextl2
; /* next level 2 router (reserved) */
89 byte lg_visits
; /* visit count */
90 byte lg_service
; /* service class (reserved) */
91 byte lg_pt
; /* protocol type (reserved) */
96 struct shorthdr rh_short
; /* short route header */
97 struct longhdr rh_long
; /* long route header */
101 * Define the values of various fields in the protocol messages.
103 * 1. Data packet formats.
105 #define RMF_MASK 7 /* mask for message type */
106 #define RMF_SHORT 2 /* short message format */
107 #define RMF_LONG 6 /* long message format */
109 #define RMF_RQR 010 /* request return to sender */
110 #define RMF_RTS 020 /* returning to sender */
111 #define RMF_IE 040 /* intra-ethernet packet */
113 #define RMF_FVER 0100 /* future version flag */
114 #define RMF_PAD 0200 /* pad field */
115 #define RMF_PADMASK 0177 /* pad field mask */
117 #define VIS_MASK 077 /* visit field mask */
120 * 2. Control packet formats.
122 #define RMF_CTLMASK 017 /* mask for message type */
123 #define RMF_CTLMSG 01 /* control message indicator */
124 #define RMF_INIT 01 /* initialization message */
125 #define RMF_VER 03 /* verification message */
126 #define RMF_TEST 05 /* hello and test message */
127 #define RMF_L1ROUT 07 /* level 1 routing message */
128 #define RMF_L2ROUT 011 /* level 2 routing message */
129 #define RMF_RHELLO 013 /* router hello message */
130 #define RMF_EHELLO 015 /* endnode hello message */
132 #define TI_L2ROUT 01 /* level 2 router */
133 #define TI_L1ROUT 02 /* level 1 router */
134 #define TI_ENDNODE 03 /* endnode */
135 #define TI_VERIF 04 /* verification required */
136 #define TI_BLOCK 010 /* blocking requested */
138 #define VE_VERS 2 /* version number (2) */
139 #define VE_ECO 0 /* ECO number */
140 #define VE_UECO 0 /* user ECO number (0) */
142 #define P3_VERS 1 /* phase III version number (1) */
143 #define P3_ECO 3 /* ECO number (3) */
144 #define P3_UECO 0 /* user ECO number (0) */
146 #define II_L2ROUT 01 /* level 2 router */
147 #define II_L1ROUT 02 /* level 1 router */
148 #define II_ENDNODE 03 /* endnode */
149 #define II_VERIF 04 /* verification required */
150 #define II_NOMCAST 040 /* no multicast traffic accepted */
151 #define II_BLOCK 0100 /* blocking requested */
152 #define II_TYPEMASK 03 /* mask for node type */
154 #define TESTDATA 0252 /* test data bytes */
155 #define TESTLEN 1 /* length of transmitted test data */
158 * Define control message formats.
160 struct initmsgIII
/* phase III initialization message */
162 byte inIII_flags
; /* route flags */
163 word inIII_src
; /* source node address */
164 byte inIII_info
; /* routing layer information */
165 word inIII_blksize
; /* maximum data link block size */
166 byte inIII_vers
; /* version number */
167 byte inIII_eco
; /* ECO number */
168 byte inIII_ueco
; /* user ECO number */
169 byte inIII_rsvd
; /* reserved image field */
172 struct initmsg
/* initialization message */
174 byte in_flags
; /* route flags */
175 word in_src
; /* source node address */
176 byte in_info
; /* routing layer information */
177 word in_blksize
; /* maximum data link block size */
178 byte in_vers
; /* version number */
179 byte in_eco
; /* ECO number */
180 byte in_ueco
; /* user ECO number */
181 word in_hello
; /* hello timer */
182 byte in_rsvd
; /* reserved image field */
185 struct verifmsg
/* verification message */
187 byte ve_flags
; /* route flags */
188 word ve_src
; /* source node address */
189 byte ve_fcnval
; /* function value image field */
192 struct testmsg
/* hello and test message */
194 byte te_flags
; /* route flags */
195 word te_src
; /* source node address */
196 byte te_data
; /* test data image field */
199 struct l1rout
/* level 1 routing message */
201 byte r1_flags
; /* route flags */
202 word r1_src
; /* source node address */
203 byte r1_rsvd
; /* reserved field */
206 struct l2rout
/* level 2 routing message */
208 byte r2_flags
; /* route flags */
209 word r2_src
; /* source node address */
210 byte r2_rsvd
; /* reserved field */
213 struct rhellomsg
/* router hello message */
215 byte rh_flags
; /* route flags */
216 byte rh_vers
; /* version number */
217 byte rh_eco
; /* ECO number */
218 byte rh_ueco
; /* user ECO number */
219 etheraddr rh_src
; /* source id */
220 byte rh_info
; /* routing layer information */
221 word rh_blksize
; /* maximum data link block size */
222 byte rh_priority
; /* router's priority */
223 byte rh_area
; /* reserved */
224 word rh_hello
; /* hello timer */
225 byte rh_mpd
; /* reserved */
228 struct ehellomsg
/* endnode hello message */
230 byte eh_flags
; /* route flags */
231 byte eh_vers
; /* version number */
232 byte eh_eco
; /* ECO number */
233 byte eh_ueco
; /* user ECO number */
234 etheraddr eh_src
; /* source id */
235 byte eh_info
; /* routing layer information */
236 word eh_blksize
; /* maximum data link block size */
237 byte eh_area
; /* area (reserved) */
238 byte eh_seed
[8]; /* verification seed */
239 etheraddr eh_router
; /* designated router */
240 word eh_hello
; /* hello timer */
241 byte eh_mpd
; /* (reserved) */
242 byte eh_data
; /* test data image field */
247 struct initmsg cm_init
; /* initialization message */
248 struct verifmsg cm_ver
; /* verification message */
249 struct testmsg cm_test
; /* hello and test message */
250 struct l1rout cm_l1rou
; /* level 1 routing message */
251 struct l2rout cm_l2rout
; /* level 2 routing message */
252 struct rhellomsg cm_rhello
; /* router hello message */
253 struct ehellomsg cm_ehello
; /* endnode hello message */
256 /* Macros for decoding routing-info fields */
257 #define RI_COST(x) ((x)&0777)
258 #define RI_HOPS(x) (((x)>>10)&037)
261 * NSP protocol fields and values.
264 #define NSP_TYPEMASK 014 /* mask to isolate type code */
265 #define NSP_SUBMASK 0160 /* mask to isolate subtype code */
266 #define NSP_SUBSHFT 4 /* shift to move subtype code */
268 #define MFT_DATA 0 /* data message */
269 #define MFT_ACK 04 /* acknowledgement message */
270 #define MFT_CTL 010 /* control message */
272 #define MFS_ILS 020 /* data or I/LS indicator */
273 #define MFS_BOM 040 /* beginning of message (data) */
274 #define MFS_MOM 0 /* middle of message (data) */
275 #define MFS_EOM 0100 /* end of message (data) */
276 #define MFS_INT 040 /* interrupt message */
278 #define MFS_DACK 0 /* data acknowledgement */
279 #define MFS_IACK 020 /* I/LS acknowledgement */
280 #define MFS_CACK 040 /* connect acknowledgement */
282 #define MFS_NOP 0 /* no operation */
283 #define MFS_CI 020 /* connect initiate */
284 #define MFS_CC 040 /* connect confirm */
285 #define MFS_DI 060 /* disconnect initiate */
286 #define MFS_DC 0100 /* disconnect confirm */
287 #define MFS_RCI 0140 /* retransmitted connect initiate */
289 #define SGQ_ACK 0100000 /* ack */
290 #define SGQ_NAK 0110000 /* negative ack */
291 #define SGQ_OACK 0120000 /* other channel ack */
292 #define SGQ_ONAK 0130000 /* other channel negative ack */
293 #define SGQ_MASK 07777 /* mask to isolate seq # */
294 #define SGQ_OTHER 020000 /* other channel qualifier */
295 #define SGQ_DELAY 010000 /* ack delay flag */
297 #define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
299 #define LSM_MASK 03 /* mask for modifier field */
300 #define LSM_NOCHANGE 0 /* no change */
301 #define LSM_DONOTSEND 1 /* do not send data */
302 #define LSM_SEND 2 /* send data */
304 #define LSI_MASK 014 /* mask for interpretation field */
305 #define LSI_DATA 0 /* data segment or message count */
306 #define LSI_INTR 4 /* interrupt request count */
307 #define LSI_INTM 0377 /* funny marker for int. message */
309 #define COS_MASK 014 /* mask for flow control field */
310 #define COS_NONE 0 /* no flow control */
311 #define COS_SEGMENT 04 /* segment flow control */
312 #define COS_MESSAGE 010 /* message flow control */
313 #define COS_DEFAULT 1 /* default value for field */
315 #define COI_MASK 3 /* mask for version field */
316 #define COI_32 0 /* version 3.2 */
317 #define COI_31 1 /* version 3.1 */
318 #define COI_40 2 /* version 4.0 */
319 #define COI_41 3 /* version 4.1 */
321 #define MNU_MASK 140 /* mask for session control version */
322 #define MNU_10 000 /* session V1.0 */
323 #define MNU_20 040 /* session V2.0 */
324 #define MNU_ACCESS 1 /* access control present */
325 #define MNU_USRDATA 2 /* user data field present */
326 #define MNU_INVKPROXY 4 /* invoke proxy field present */
327 #define MNU_UICPROXY 8 /* use uic-based proxy */
329 #define DC_NORESOURCES 1 /* no resource reason code */
330 #define DC_NOLINK 41 /* no link terminate reason code */
331 #define DC_COMPLETE 42 /* disconnect complete reason code */
333 #define DI_NOERROR 0 /* user disconnect */
334 #define DI_SHUT 3 /* node is shutting down */
335 #define DI_NOUSER 4 /* destination end user does not exist */
336 #define DI_INVDEST 5 /* invalid end user destination */
337 #define DI_REMRESRC 6 /* insufficient remote resources */
338 #define DI_TPA 8 /* third party abort */
339 #define DI_PROTOCOL 7 /* protocol error discovered */
340 #define DI_ABORT 9 /* user abort */
341 #define DI_LOCALRESRC 32 /* insufficient local resources */
342 #define DI_REMUSERRESRC 33 /* insufficient remote user resources */
343 #define DI_BADACCESS 34 /* bad access control information */
344 #define DI_BADACCNT 36 /* bad ACCOUNT information */
345 #define DI_CONNECTABORT 38 /* connect request cancelled */
346 #define DI_TIMEDOUT 38 /* remote node or user crashed */
347 #define DI_UNREACHABLE 39 /* local timers expired due to ... */
348 #define DI_BADIMAGE 43 /* bad image data in connect */
349 #define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
351 #define UC_OBJREJECT 0 /* object rejected connect */
352 #define UC_USERDISCONNECT 0 /* user disconnect */
353 #define UC_RESOURCES 1 /* insufficient resources (local or remote) */
354 #define UC_NOSUCHNODE 2 /* unrecognized node name */
355 #define UC_REMOTESHUT 3 /* remote node shutting down */
356 #define UC_NOSUCHOBJ 4 /* unrecognized object */
357 #define UC_INVOBJFORMAT 5 /* invalid object name format */
358 #define UC_OBJTOOBUSY 6 /* object too busy */
359 #define UC_NETWORKABORT 8 /* network abort */
360 #define UC_USERABORT 9 /* user abort */
361 #define UC_INVNODEFORMAT 10 /* invalid node name format */
362 #define UC_LOCALSHUT 11 /* local node shutting down */
363 #define UC_ACCESSREJECT 34 /* invalid access control information */
364 #define UC_NORESPONSE 38 /* no response from object */
365 #define UC_UNREACHABLE 39 /* node unreachable */
368 * NSP message formats.
370 struct nsphdr
/* general nsp header */
372 byte nh_flags
; /* message flags */
373 word nh_dst
; /* destination link address */
374 word nh_src
; /* source link address */
377 struct seghdr
/* data segment header */
379 byte sh_flags
; /* message flags */
380 word sh_dst
; /* destination link address */
381 word sh_src
; /* source link address */
382 word sh_seq
[3]; /* sequence numbers */
385 struct minseghdr
/* minimum data segment header */
387 byte ms_flags
; /* message flags */
388 word ms_dst
; /* destination link address */
389 word ms_src
; /* source link address */
390 word ms_seq
; /* sequence number */
393 struct lsmsg
/* link service message (after hdr) */
395 byte ls_lsflags
; /* link service flags */
396 byte ls_fcval
; /* flow control value */
399 struct ackmsg
/* acknowledgement message */
401 byte ak_flags
; /* message flags */
402 word ak_dst
; /* destination link address */
403 word ak_src
; /* source link address */
404 word ak_acknum
[2]; /* acknowledgement numbers */
407 struct minackmsg
/* minimum acknowledgement message */
409 byte mk_flags
; /* message flags */
410 word mk_dst
; /* destination link address */
411 word mk_src
; /* source link address */
412 word mk_acknum
; /* acknowledgement number */
415 struct ciackmsg
/* connect acknowledgement message */
417 byte ck_flags
; /* message flags */
418 word ck_dst
; /* destination link address */
421 struct cimsg
/* connect initiate message */
423 byte ci_flags
; /* message flags */
424 word ci_dst
; /* destination link address (0) */
425 word ci_src
; /* source link address */
426 byte ci_services
; /* requested services */
427 byte ci_info
; /* information */
428 word ci_segsize
; /* maximum segment size */
431 struct ccmsg
/* connect confirm message */
433 byte cc_flags
; /* message flags */
434 word cc_dst
; /* destination link address */
435 word cc_src
; /* source link address */
436 byte cc_services
; /* requested services */
437 byte cc_info
; /* information */
438 word cc_segsize
; /* maximum segment size */
439 byte cc_optlen
; /* optional data length */
442 struct cnmsg
/* generic connect message */
444 byte cn_flags
; /* message flags */
445 word cn_dst
; /* destination link address */
446 word cn_src
; /* source link address */
447 byte cn_services
; /* requested services */
448 byte cn_info
; /* information */
449 word cn_segsize
; /* maximum segment size */
452 struct dimsg
/* disconnect initiate message */
454 byte di_flags
; /* message flags */
455 word di_dst
; /* destination link address */
456 word di_src
; /* source link address */
457 word di_reason
; /* reason code */
458 byte di_optlen
; /* optional data length */
461 struct dcmsg
/* disconnect confirm message */
463 byte dc_flags
; /* message flags */
464 word dc_dst
; /* destination link address */
465 word dc_src
; /* source link address */
466 word dc_reason
; /* reason code */
470 static int print_decnet_ctlmsg(netdissect_options
*, const union routehdr
*, u_int
, u_int
);
471 static void print_t_info(netdissect_options
*, u_int
);
472 static int print_l1_routes(netdissect_options
*, const u_char
*, u_int
);
473 static int print_l2_routes(netdissect_options
*, const u_char
*, u_int
);
474 static void print_i_info(netdissect_options
*, u_int
);
475 static int print_elist(const u_char
*, u_int
);
476 static int print_nsp(netdissect_options
*, const u_char
*, u_int
);
477 static void print_reason(netdissect_options
*, u_int
);
480 decnet_print(netdissect_options
*ndo
,
481 const u_char
*ap
, u_int length
,
484 const union routehdr
*rhp
;
488 u_int nsplen
, pktlen
;
491 ndo
->ndo_protocol
= "decnet";
492 if (length
< sizeof(struct shorthdr
)) {
497 pktlen
= GET_LE_U_2(ap
);
498 if (pktlen
< sizeof(struct shorthdr
)) {
502 if (pktlen
> length
) {
508 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
509 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
511 if (mflags
& RMF_PAD
) {
512 /* pad bytes of some sort in front of message */
513 u_int padlen
= mflags
& RMF_PADMASK
;
515 ND_PRINT("[pad:%u] ", padlen
);
516 if (length
< padlen
+ 2) {
520 ND_TCHECK_LEN(ap
+ sizeof(short), padlen
);
524 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
525 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
528 if (mflags
& RMF_FVER
) {
529 ND_PRINT("future-version-decnet");
530 ND_DEFAULTPRINT(ap
, ND_MIN(length
, caplen
));
534 /* is it a control message? */
535 if (mflags
& RMF_CTLMSG
) {
536 if (!print_decnet_ctlmsg(ndo
, rhp
, length
, caplen
))
541 switch (mflags
& RMF_MASK
) {
543 if (length
< sizeof(struct longhdr
)) {
547 ND_TCHECK_SIZE(&rhp
->rh_long
);
549 GET_LE_U_2(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
551 GET_LE_U_2(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
552 hops
= GET_U_1(rhp
->rh_long
.lg_visits
);
553 nspp
= ap
+ sizeof(short) + sizeof(struct longhdr
);
554 nsplen
= length
- sizeof(struct longhdr
);
557 ND_TCHECK_SIZE(&rhp
->rh_short
);
558 dst
= GET_LE_U_2(rhp
->rh_short
.sh_dst
);
559 src
= GET_LE_U_2(rhp
->rh_short
.sh_src
);
560 hops
= (GET_U_1(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
561 nspp
= ap
+ sizeof(short) + sizeof(struct shorthdr
);
562 nsplen
= length
- sizeof(struct shorthdr
);
565 ND_PRINT("unknown message flags under mask");
566 ND_DEFAULTPRINT((const u_char
*)ap
, ND_MIN(length
, caplen
));
570 ND_PRINT("%s > %s %u ",
571 dnaddr_string(ndo
, src
), dnaddr_string(ndo
, dst
), pktlen
);
572 if (ndo
->ndo_vflag
) {
573 if (mflags
& RMF_RQR
)
575 if (mflags
& RMF_RTS
)
579 ND_PRINT("%u hops ", hops
);
582 if (!print_nsp(ndo
, nspp
, nsplen
))
591 print_decnet_ctlmsg(netdissect_options
*ndo
,
592 const union routehdr
*rhp
, u_int length
,
595 /* Our caller has already checked for mflags */
596 u_int mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
597 const union controlmsg
*cmp
= (const union controlmsg
*)rhp
;
599 u_int info
, blksize
, eco
, ueco
, hello
, other
, vers
;
601 const u_char
*rhpx
= (const u_char
*)rhp
;
604 switch (mflags
& RMF_CTLMASK
) {
607 if (length
< sizeof(struct initmsg
))
609 ND_TCHECK_SIZE(&cmp
->cm_init
);
610 src
= GET_LE_U_2(cmp
->cm_init
.in_src
);
611 info
= GET_U_1(cmp
->cm_init
.in_info
);
612 blksize
= GET_LE_U_2(cmp
->cm_init
.in_blksize
);
613 vers
= GET_U_1(cmp
->cm_init
.in_vers
);
614 eco
= GET_U_1(cmp
->cm_init
.in_eco
);
615 ueco
= GET_U_1(cmp
->cm_init
.in_ueco
);
616 hello
= GET_LE_U_2(cmp
->cm_init
.in_hello
);
617 print_t_info(ndo
, info
);
618 ND_PRINT("src %sblksize %u vers %u eco %u ueco %u hello %u",
619 dnaddr_string(ndo
, src
), blksize
, vers
, eco
, ueco
,
624 ND_PRINT("verification ");
625 if (length
< sizeof(struct verifmsg
))
627 ND_TCHECK_SIZE(&cmp
->cm_ver
);
628 src
= GET_LE_U_2(cmp
->cm_ver
.ve_src
);
629 other
= GET_U_1(cmp
->cm_ver
.ve_fcnval
);
630 ND_PRINT("src %s fcnval %o", dnaddr_string(ndo
, src
), other
);
635 if (length
< sizeof(struct testmsg
))
637 ND_TCHECK_SIZE(&cmp
->cm_test
);
638 src
= GET_LE_U_2(cmp
->cm_test
.te_src
);
639 other
= GET_U_1(cmp
->cm_test
.te_data
);
640 ND_PRINT("src %s data %o", dnaddr_string(ndo
, src
), other
);
644 ND_PRINT("lev-1-routing ");
645 if (length
< sizeof(struct l1rout
))
647 ND_TCHECK_SIZE(&cmp
->cm_l1rou
);
648 src
= GET_LE_U_2(cmp
->cm_l1rou
.r1_src
);
649 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
650 ret
= print_l1_routes(ndo
, &(rhpx
[sizeof(struct l1rout
)]),
651 length
- sizeof(struct l1rout
));
654 ND_PRINT("lev-2-routing ");
655 if (length
< sizeof(struct l2rout
))
657 ND_TCHECK_SIZE(&cmp
->cm_l2rout
);
658 src
= GET_LE_U_2(cmp
->cm_l2rout
.r2_src
);
659 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
660 ret
= print_l2_routes(ndo
, &(rhpx
[sizeof(struct l2rout
)]),
661 length
- sizeof(struct l2rout
));
664 ND_PRINT("router-hello ");
665 if (length
< sizeof(struct rhellomsg
))
667 ND_TCHECK_SIZE(&cmp
->cm_rhello
);
668 vers
= GET_U_1(cmp
->cm_rhello
.rh_vers
);
669 eco
= GET_U_1(cmp
->cm_rhello
.rh_eco
);
670 ueco
= GET_U_1(cmp
->cm_rhello
.rh_ueco
);
672 GET_LE_U_2(cmp
->cm_rhello
.rh_src
.dne_remote
.dne_nodeaddr
);
673 info
= GET_U_1(cmp
->cm_rhello
.rh_info
);
674 blksize
= GET_LE_U_2(cmp
->cm_rhello
.rh_blksize
);
675 priority
= GET_U_1(cmp
->cm_rhello
.rh_priority
);
676 hello
= GET_LE_U_2(cmp
->cm_rhello
.rh_hello
);
677 print_i_info(ndo
, info
);
678 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u pri %u hello %u",
679 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
680 blksize
, priority
, hello
);
681 ret
= print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
682 length
- sizeof(struct rhellomsg
));
685 ND_PRINT("endnode-hello ");
686 if (length
< sizeof(struct ehellomsg
))
688 ND_TCHECK_SIZE(&cmp
->cm_ehello
);
689 vers
= GET_U_1(cmp
->cm_ehello
.eh_vers
);
690 eco
= GET_U_1(cmp
->cm_ehello
.eh_eco
);
691 ueco
= GET_U_1(cmp
->cm_ehello
.eh_ueco
);
693 GET_LE_U_2(cmp
->cm_ehello
.eh_src
.dne_remote
.dne_nodeaddr
);
694 info
= GET_U_1(cmp
->cm_ehello
.eh_info
);
695 blksize
= GET_LE_U_2(cmp
->cm_ehello
.eh_blksize
);
698 GET_LE_U_2(cmp
->cm_ehello
.eh_router
.dne_remote
.dne_nodeaddr
);
699 hello
= GET_LE_U_2(cmp
->cm_ehello
.eh_hello
);
700 other
= GET_U_1(cmp
->cm_ehello
.eh_data
);
701 print_i_info(ndo
, info
);
702 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u rtr %s hello %u data %o",
703 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
704 blksize
, dnaddr_string(ndo
, dst
), hello
, other
);
709 ND_PRINT("unknown control message");
710 ND_DEFAULTPRINT((const u_char
*)rhp
, ND_MIN(length
, caplen
));
721 print_t_info(netdissect_options
*ndo
,
724 u_int ntype
= info
& 3;
726 case 0: ND_PRINT("reserved-ntype? "); break;
727 case TI_L2ROUT
: ND_PRINT("l2rout "); break;
728 case TI_L1ROUT
: ND_PRINT("l1rout "); break;
729 case TI_ENDNODE
: ND_PRINT("endnode "); break;
738 print_l1_routes(netdissect_options
*ndo
,
739 const u_char
*rp
, u_int len
)
745 /* The last short is a checksum */
746 while (len
> (3 * sizeof(short))) {
747 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
748 count
= GET_LE_U_2(rp
);
750 return (1); /* seems to be bogus from here on */
752 len
-= sizeof(short);
755 len
-= sizeof(short);
756 info
= GET_LE_U_2(rp
);
758 len
-= sizeof(short);
759 ND_PRINT("{ids %u-%u cost %u hops %u} ", id
, id
+ count
,
760 RI_COST(info
), RI_HOPS(info
));
769 print_l2_routes(netdissect_options
*ndo
,
770 const u_char
*rp
, u_int len
)
776 /* The last short is a checksum */
777 while (len
> (3 * sizeof(short))) {
778 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
779 count
= GET_LE_U_2(rp
);
781 return (1); /* seems to be bogus from here on */
783 len
-= sizeof(short);
784 area
= GET_LE_U_2(rp
);
786 len
-= sizeof(short);
787 info
= GET_LE_U_2(rp
);
789 len
-= sizeof(short);
790 ND_PRINT("{areas %u-%u cost %u hops %u} ", area
, area
+ count
,
791 RI_COST(info
), RI_HOPS(info
));
800 print_i_info(netdissect_options
*ndo
,
803 u_int ntype
= info
& II_TYPEMASK
;
805 case 0: ND_PRINT("reserved-ntype? "); break;
806 case II_L2ROUT
: ND_PRINT("l2rout "); break;
807 case II_L1ROUT
: ND_PRINT("l1rout "); break;
808 case II_ENDNODE
: ND_PRINT("endnode "); break;
812 if (info
& II_NOMCAST
)
813 ND_PRINT("nomcast ");
819 print_elist(const u_char
*elp _U_
, u_int len _U_
)
821 /* Not enough examples available for me to debug this */
826 print_nsp(netdissect_options
*ndo
,
827 const u_char
*nspp
, u_int nsplen
)
829 const struct nsphdr
*nsphp
= (const struct nsphdr
*)nspp
;
830 u_int dst
, src
, flags
;
832 if (nsplen
< sizeof(struct nsphdr
))
834 ND_TCHECK_SIZE(nsphp
);
835 flags
= GET_U_1(nsphp
->nh_flags
);
836 dst
= GET_LE_U_2(nsphp
->nh_dst
);
837 src
= GET_LE_U_2(nsphp
->nh_src
);
839 switch (flags
& NSP_TYPEMASK
) {
841 switch (flags
& NSP_SUBMASK
) {
845 case MFS_BOM
+MFS_EOM
:
846 ND_PRINT("data %u>%u ", src
, dst
);
848 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
850 u_int data_off
= sizeof(struct minseghdr
);
852 if (nsplen
< data_off
)
854 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
855 if (ack
& SGQ_ACK
) { /* acknum field */
856 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
857 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
859 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
860 data_off
+= sizeof(short);
861 if (nsplen
< data_off
)
863 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
864 if (ack
& SGQ_OACK
) { /* ackoth field */
865 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
866 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
868 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
869 data_off
+= sizeof(short);
870 if (nsplen
< data_off
)
872 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
875 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
878 case MFS_ILS
+MFS_INT
:
881 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
883 u_int data_off
= sizeof(struct minseghdr
);
885 if (nsplen
< data_off
)
887 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
888 if (ack
& SGQ_ACK
) { /* acknum field */
889 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
890 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
892 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
893 data_off
+= sizeof(short);
894 if (nsplen
< data_off
)
896 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
897 if (ack
& SGQ_OACK
) { /* ackdat field */
898 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
899 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
901 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
902 data_off
+= sizeof(short);
903 if (nsplen
< data_off
)
905 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
908 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
912 ND_PRINT("link-service %u>%u ", src
, dst
);
914 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
915 const struct lsmsg
*lsmp
=
916 (const struct lsmsg
*)(nspp
+ sizeof(struct seghdr
));
918 u_int lsflags
, fcval
;
920 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
922 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
923 if (ack
& SGQ_ACK
) { /* acknum field */
924 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
925 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
927 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
928 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
929 if (ack
& SGQ_OACK
) { /* ackdat field */
930 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
931 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
933 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
934 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
937 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
938 ND_TCHECK_SIZE(lsmp
);
939 lsflags
= GET_U_1(lsmp
->ls_lsflags
);
940 fcval
= GET_U_1(lsmp
->ls_fcval
);
941 switch (lsflags
& LSI_MASK
) {
943 ND_PRINT("dat seg count %u ", fcval
);
944 switch (lsflags
& LSM_MASK
) {
948 ND_PRINT("donotsend-data ");
951 ND_PRINT("send-data ");
954 ND_PRINT("reserved-fcmod? %x", lsflags
);
959 ND_PRINT("intr req count %u ", fcval
);
962 ND_PRINT("reserved-fcval-int? %x", lsflags
);
968 ND_PRINT("reserved-subtype? %x %u > %u", flags
, src
, dst
);
973 switch (flags
& NSP_SUBMASK
) {
975 ND_PRINT("data-ack %u>%u ", src
, dst
);
977 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
980 if (nsplen
< sizeof(struct ackmsg
))
983 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
984 if (ack
& SGQ_ACK
) { /* acknum field */
985 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
986 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
988 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
989 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
990 if (ack
& SGQ_OACK
) { /* ackoth field */
991 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
992 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
994 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
1000 ND_PRINT("ils-ack %u>%u ", src
, dst
);
1002 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
1005 if (nsplen
< sizeof(struct ackmsg
))
1007 ND_TCHECK_SIZE(amp
);
1008 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
1009 if (ack
& SGQ_ACK
) { /* acknum field */
1010 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
1011 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
1013 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
1014 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
1015 if (ack
& SGQ_OACK
) { /* ackdat field */
1016 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
1017 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
1019 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
1025 ND_PRINT("conn-ack %u", dst
);
1028 ND_PRINT("reserved-acktype? %x %u > %u", flags
, src
, dst
);
1033 switch (flags
& NSP_SUBMASK
) {
1036 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
1037 ND_PRINT("conn-initiate ");
1039 ND_PRINT("retrans-conn-initiate ");
1040 ND_PRINT("%u>%u ", src
, dst
);
1042 const struct cimsg
*cimp
= (const struct cimsg
*)nspp
;
1043 u_int services
, info
, segsize
;
1045 if (nsplen
< sizeof(struct cimsg
))
1047 ND_TCHECK_SIZE(cimp
);
1048 services
= GET_U_1(cimp
->ci_services
);
1049 info
= GET_U_1(cimp
->ci_info
);
1050 segsize
= GET_LE_U_2(cimp
->ci_segsize
);
1052 switch (services
& COS_MASK
) {
1062 switch (info
& COI_MASK
) {
1064 ND_PRINT("ver 3.2 ");
1067 ND_PRINT("ver 3.1 ");
1070 ND_PRINT("ver 4.0 ");
1073 ND_PRINT("ver 4.1 ");
1076 ND_PRINT("segsize %u ", segsize
);
1080 ND_PRINT("conn-confirm %u>%u ", src
, dst
);
1082 const struct ccmsg
*ccmp
= (const struct ccmsg
*)nspp
;
1083 u_int services
, info
;
1084 u_int segsize
, optlen
;
1086 if (nsplen
< sizeof(struct ccmsg
))
1088 ND_TCHECK_SIZE(ccmp
);
1089 services
= GET_U_1(ccmp
->cc_services
);
1090 info
= GET_U_1(ccmp
->cc_info
);
1091 segsize
= GET_LE_U_2(ccmp
->cc_segsize
);
1092 optlen
= GET_U_1(ccmp
->cc_optlen
);
1094 switch (services
& COS_MASK
) {
1104 switch (info
& COI_MASK
) {
1106 ND_PRINT("ver 3.2 ");
1109 ND_PRINT("ver 3.1 ");
1112 ND_PRINT("ver 4.0 ");
1115 ND_PRINT("ver 4.1 ");
1118 ND_PRINT("segsize %u ", segsize
);
1120 ND_PRINT("optlen %u ", optlen
);
1125 ND_PRINT("disconn-initiate %u>%u ", src
, dst
);
1127 const struct dimsg
*dimp
= (const struct dimsg
*)nspp
;
1131 if (nsplen
< sizeof(struct dimsg
))
1133 ND_TCHECK_SIZE(dimp
);
1134 reason
= GET_LE_U_2(dimp
->di_reason
);
1135 optlen
= GET_U_1(dimp
->di_optlen
);
1137 print_reason(ndo
, reason
);
1139 ND_PRINT("optlen %u ", optlen
);
1144 ND_PRINT("disconn-confirm %u>%u ", src
, dst
);
1146 const struct dcmsg
*dcmp
= (const struct dcmsg
*)nspp
;
1149 ND_TCHECK_SIZE(dcmp
);
1150 reason
= GET_LE_U_2(dcmp
->dc_reason
);
1152 print_reason(ndo
, reason
);
1156 ND_PRINT("reserved-ctltype? %x %u > %u", flags
, src
, dst
);
1161 ND_PRINT("reserved-type? %x %u > %u", flags
, src
, dst
);
1170 static const struct tok reason2str
[] = {
1171 { UC_OBJREJECT
, "object rejected connect" },
1172 { UC_RESOURCES
, "insufficient resources" },
1173 { UC_NOSUCHNODE
, "unrecognized node name" },
1174 { DI_SHUT
, "node is shutting down" },
1175 { UC_NOSUCHOBJ
, "unrecognized object" },
1176 { UC_INVOBJFORMAT
, "invalid object name format" },
1177 { UC_OBJTOOBUSY
, "object too busy" },
1178 { DI_PROTOCOL
, "protocol error discovered" },
1179 { DI_TPA
, "third party abort" },
1180 { UC_USERABORT
, "user abort" },
1181 { UC_INVNODEFORMAT
, "invalid node name format" },
1182 { UC_LOCALSHUT
, "local node shutting down" },
1183 { DI_LOCALRESRC
, "insufficient local resources" },
1184 { DI_REMUSERRESRC
, "insufficient remote user resources" },
1185 { UC_ACCESSREJECT
, "invalid access control information" },
1186 { DI_BADACCNT
, "bad ACCOUNT information" },
1187 { UC_NORESPONSE
, "no response from object" },
1188 { UC_UNREACHABLE
, "node unreachable" },
1189 { DC_NOLINK
, "no link terminate" },
1190 { DC_COMPLETE
, "disconnect complete" },
1191 { DI_BADIMAGE
, "bad image data in connect" },
1192 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
1197 print_reason(netdissect_options
*ndo
,
1200 ND_PRINT("%s ", tok2str(reason2str
, "reason-%u", reason
));
1204 dnnum_string(netdissect_options
*ndo
, u_short dnaddr
)
1208 u_int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
1209 u_int node
= dnaddr
& NODEMASK
;
1211 /* malloc() return used by the 'dnaddrtable' hash table: do not free() */
1212 str
= (char *)malloc(siz
= sizeof("00.0000"));
1214 (*ndo
->ndo_error
)(ndo
, S_ERR_ND_MEM_ALLOC
, "%s: malloc", __func__
);
1215 snprintf(str
, siz
, "%u.%u", area
, node
);