]>
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
[6]; /* 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 ND_TCHECK_LEN(ap
, sizeof(short));
498 pktlen
= GET_LE_U_2(ap
);
499 if (pktlen
< sizeof(struct shorthdr
)) {
503 if (pktlen
> length
) {
509 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
510 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
512 if (mflags
& RMF_PAD
) {
513 /* pad bytes of some sort in front of message */
514 u_int padlen
= mflags
& RMF_PADMASK
;
516 ND_PRINT("[pad:%u] ", padlen
);
517 if (length
< padlen
+ 2) {
521 ND_TCHECK_LEN(ap
+ sizeof(short), padlen
);
525 rhp
= (const union routehdr
*)(ap
+ sizeof(short));
526 mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
529 if (mflags
& RMF_FVER
) {
530 ND_PRINT("future-version-decnet");
531 ND_DEFAULTPRINT(ap
, ND_MIN(length
, caplen
));
535 /* is it a control message? */
536 if (mflags
& RMF_CTLMSG
) {
537 if (!print_decnet_ctlmsg(ndo
, rhp
, length
, caplen
))
542 switch (mflags
& RMF_MASK
) {
544 if (length
< sizeof(struct longhdr
)) {
548 ND_TCHECK_SIZE(&rhp
->rh_long
);
550 GET_LE_U_2(rhp
->rh_long
.lg_dst
.dne_remote
.dne_nodeaddr
);
552 GET_LE_U_2(rhp
->rh_long
.lg_src
.dne_remote
.dne_nodeaddr
);
553 hops
= GET_U_1(rhp
->rh_long
.lg_visits
);
554 nspp
= ap
+ sizeof(short) + sizeof(struct longhdr
);
555 nsplen
= length
- sizeof(struct longhdr
);
558 ND_TCHECK_SIZE(&rhp
->rh_short
);
559 dst
= GET_LE_U_2(rhp
->rh_short
.sh_dst
);
560 src
= GET_LE_U_2(rhp
->rh_short
.sh_src
);
561 hops
= (GET_U_1(rhp
->rh_short
.sh_visits
) & VIS_MASK
)+1;
562 nspp
= ap
+ sizeof(short) + sizeof(struct shorthdr
);
563 nsplen
= length
- sizeof(struct shorthdr
);
566 ND_PRINT("unknown message flags under mask");
567 ND_DEFAULTPRINT((const u_char
*)ap
, ND_MIN(length
, caplen
));
571 ND_PRINT("%s > %s %u ",
572 dnaddr_string(ndo
, src
), dnaddr_string(ndo
, dst
), pktlen
);
573 if (ndo
->ndo_vflag
) {
574 if (mflags
& RMF_RQR
)
576 if (mflags
& RMF_RTS
)
580 ND_PRINT("%u hops ", hops
);
583 if (!print_nsp(ndo
, nspp
, nsplen
))
592 print_decnet_ctlmsg(netdissect_options
*ndo
,
593 const union routehdr
*rhp
, u_int length
,
596 /* Our caller has already checked for mflags */
597 u_int mflags
= GET_U_1(rhp
->rh_short
.sh_flags
);
598 const union controlmsg
*cmp
= (const union controlmsg
*)rhp
;
600 u_int info
, blksize
, eco
, ueco
, hello
, other
, vers
;
602 const u_char
*rhpx
= (const u_char
*)rhp
;
605 switch (mflags
& RMF_CTLMASK
) {
608 if (length
< sizeof(struct initmsg
))
610 ND_TCHECK_SIZE(&cmp
->cm_init
);
611 src
= GET_LE_U_2(cmp
->cm_init
.in_src
);
612 info
= GET_U_1(cmp
->cm_init
.in_info
);
613 blksize
= GET_LE_U_2(cmp
->cm_init
.in_blksize
);
614 vers
= GET_U_1(cmp
->cm_init
.in_vers
);
615 eco
= GET_U_1(cmp
->cm_init
.in_eco
);
616 ueco
= GET_U_1(cmp
->cm_init
.in_ueco
);
617 hello
= GET_LE_U_2(cmp
->cm_init
.in_hello
);
618 print_t_info(ndo
, info
);
619 ND_PRINT("src %sblksize %u vers %u eco %u ueco %u hello %u",
620 dnaddr_string(ndo
, src
), blksize
, vers
, eco
, ueco
,
625 ND_PRINT("verification ");
626 if (length
< sizeof(struct verifmsg
))
628 ND_TCHECK_SIZE(&cmp
->cm_ver
);
629 src
= GET_LE_U_2(cmp
->cm_ver
.ve_src
);
630 other
= GET_U_1(cmp
->cm_ver
.ve_fcnval
);
631 ND_PRINT("src %s fcnval %o", dnaddr_string(ndo
, src
), other
);
636 if (length
< sizeof(struct testmsg
))
638 ND_TCHECK_SIZE(&cmp
->cm_test
);
639 src
= GET_LE_U_2(cmp
->cm_test
.te_src
);
640 other
= GET_U_1(cmp
->cm_test
.te_data
);
641 ND_PRINT("src %s data %o", dnaddr_string(ndo
, src
), other
);
645 ND_PRINT("lev-1-routing ");
646 if (length
< sizeof(struct l1rout
))
648 ND_TCHECK_SIZE(&cmp
->cm_l1rou
);
649 src
= GET_LE_U_2(cmp
->cm_l1rou
.r1_src
);
650 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
651 ret
= print_l1_routes(ndo
, &(rhpx
[sizeof(struct l1rout
)]),
652 length
- sizeof(struct l1rout
));
655 ND_PRINT("lev-2-routing ");
656 if (length
< sizeof(struct l2rout
))
658 ND_TCHECK_SIZE(&cmp
->cm_l2rout
);
659 src
= GET_LE_U_2(cmp
->cm_l2rout
.r2_src
);
660 ND_PRINT("src %s ", dnaddr_string(ndo
, src
));
661 ret
= print_l2_routes(ndo
, &(rhpx
[sizeof(struct l2rout
)]),
662 length
- sizeof(struct l2rout
));
665 ND_PRINT("router-hello ");
666 if (length
< sizeof(struct rhellomsg
))
668 ND_TCHECK_SIZE(&cmp
->cm_rhello
);
669 vers
= GET_U_1(cmp
->cm_rhello
.rh_vers
);
670 eco
= GET_U_1(cmp
->cm_rhello
.rh_eco
);
671 ueco
= GET_U_1(cmp
->cm_rhello
.rh_ueco
);
673 GET_LE_U_2(cmp
->cm_rhello
.rh_src
.dne_remote
.dne_nodeaddr
);
674 info
= GET_U_1(cmp
->cm_rhello
.rh_info
);
675 blksize
= GET_LE_U_2(cmp
->cm_rhello
.rh_blksize
);
676 priority
= GET_U_1(cmp
->cm_rhello
.rh_priority
);
677 hello
= GET_LE_U_2(cmp
->cm_rhello
.rh_hello
);
678 print_i_info(ndo
, info
);
679 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u pri %u hello %u",
680 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
681 blksize
, priority
, hello
);
682 ret
= print_elist(&(rhpx
[sizeof(struct rhellomsg
)]),
683 length
- sizeof(struct rhellomsg
));
686 ND_PRINT("endnode-hello ");
687 if (length
< sizeof(struct ehellomsg
))
689 ND_TCHECK_SIZE(&cmp
->cm_ehello
);
690 vers
= GET_U_1(cmp
->cm_ehello
.eh_vers
);
691 eco
= GET_U_1(cmp
->cm_ehello
.eh_eco
);
692 ueco
= GET_U_1(cmp
->cm_ehello
.eh_ueco
);
694 GET_LE_U_2(cmp
->cm_ehello
.eh_src
.dne_remote
.dne_nodeaddr
);
695 info
= GET_U_1(cmp
->cm_ehello
.eh_info
);
696 blksize
= GET_LE_U_2(cmp
->cm_ehello
.eh_blksize
);
699 GET_LE_U_2(cmp
->cm_ehello
.eh_router
.dne_remote
.dne_nodeaddr
);
700 hello
= GET_LE_U_2(cmp
->cm_ehello
.eh_hello
);
701 other
= GET_U_1(cmp
->cm_ehello
.eh_data
);
702 print_i_info(ndo
, info
);
703 ND_PRINT("vers %u eco %u ueco %u src %s blksize %u rtr %s hello %u data %o",
704 vers
, eco
, ueco
, dnaddr_string(ndo
, src
),
705 blksize
, dnaddr_string(ndo
, dst
), hello
, other
);
710 ND_PRINT("unknown control message");
711 ND_DEFAULTPRINT((const u_char
*)rhp
, ND_MIN(length
, caplen
));
722 print_t_info(netdissect_options
*ndo
,
725 u_int ntype
= info
& 3;
727 case 0: ND_PRINT("reserved-ntype? "); break;
728 case TI_L2ROUT
: ND_PRINT("l2rout "); break;
729 case TI_L1ROUT
: ND_PRINT("l1rout "); break;
730 case TI_ENDNODE
: ND_PRINT("endnode "); break;
739 print_l1_routes(netdissect_options
*ndo
,
740 const u_char
*rp
, u_int len
)
746 /* The last short is a checksum */
747 while (len
> (3 * sizeof(short))) {
748 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
749 count
= GET_LE_U_2(rp
);
751 return (1); /* seems to be bogus from here on */
753 len
-= sizeof(short);
756 len
-= sizeof(short);
757 info
= GET_LE_U_2(rp
);
759 len
-= sizeof(short);
760 ND_PRINT("{ids %u-%u cost %u hops %u} ", id
, id
+ count
,
761 RI_COST(info
), RI_HOPS(info
));
770 print_l2_routes(netdissect_options
*ndo
,
771 const u_char
*rp
, u_int len
)
777 /* The last short is a checksum */
778 while (len
> (3 * sizeof(short))) {
779 ND_TCHECK_LEN(rp
, 3 * sizeof(short));
780 count
= GET_LE_U_2(rp
);
782 return (1); /* seems to be bogus from here on */
784 len
-= sizeof(short);
785 area
= GET_LE_U_2(rp
);
787 len
-= sizeof(short);
788 info
= GET_LE_U_2(rp
);
790 len
-= sizeof(short);
791 ND_PRINT("{areas %u-%u cost %u hops %u} ", area
, area
+ count
,
792 RI_COST(info
), RI_HOPS(info
));
801 print_i_info(netdissect_options
*ndo
,
804 u_int ntype
= info
& II_TYPEMASK
;
806 case 0: ND_PRINT("reserved-ntype? "); break;
807 case II_L2ROUT
: ND_PRINT("l2rout "); break;
808 case II_L1ROUT
: ND_PRINT("l1rout "); break;
809 case II_ENDNODE
: ND_PRINT("endnode "); break;
813 if (info
& II_NOMCAST
)
814 ND_PRINT("nomcast ");
820 print_elist(const u_char
*elp _U_
, u_int len _U_
)
822 /* Not enough examples available for me to debug this */
827 print_nsp(netdissect_options
*ndo
,
828 const u_char
*nspp
, u_int nsplen
)
830 const struct nsphdr
*nsphp
= (const struct nsphdr
*)nspp
;
831 u_int dst
, src
, flags
;
833 if (nsplen
< sizeof(struct nsphdr
))
835 ND_TCHECK_SIZE(nsphp
);
836 flags
= GET_U_1(nsphp
->nh_flags
);
837 dst
= GET_LE_U_2(nsphp
->nh_dst
);
838 src
= GET_LE_U_2(nsphp
->nh_src
);
840 switch (flags
& NSP_TYPEMASK
) {
842 switch (flags
& NSP_SUBMASK
) {
846 case MFS_BOM
+MFS_EOM
:
847 ND_PRINT("data %u>%u ", src
, dst
);
849 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
851 u_int data_off
= sizeof(struct minseghdr
);
853 if (nsplen
< data_off
)
855 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
856 if (ack
& SGQ_ACK
) { /* acknum field */
857 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
858 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
860 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
861 data_off
+= sizeof(short);
862 if (nsplen
< data_off
)
864 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
865 if (ack
& SGQ_OACK
) { /* ackoth field */
866 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
867 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
869 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
870 data_off
+= sizeof(short);
871 if (nsplen
< data_off
)
873 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
876 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
879 case MFS_ILS
+MFS_INT
:
882 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
884 u_int data_off
= sizeof(struct minseghdr
);
886 if (nsplen
< data_off
)
888 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
889 if (ack
& SGQ_ACK
) { /* acknum field */
890 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
891 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
893 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
894 data_off
+= sizeof(short);
895 if (nsplen
< data_off
)
897 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
898 if (ack
& SGQ_OACK
) { /* ackdat field */
899 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
900 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
902 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
903 data_off
+= sizeof(short);
904 if (nsplen
< data_off
)
906 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
909 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
913 ND_PRINT("link-service %u>%u ", src
, dst
);
915 const struct seghdr
*shp
= (const struct seghdr
*)nspp
;
916 const struct lsmsg
*lsmp
=
917 (const struct lsmsg
*)(nspp
+ sizeof(struct seghdr
));
919 u_int lsflags
, fcval
;
921 if (nsplen
< sizeof(struct seghdr
) + sizeof(struct lsmsg
))
923 ack
= GET_LE_U_2(shp
->sh_seq
[0]);
924 if (ack
& SGQ_ACK
) { /* acknum field */
925 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
926 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
928 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
929 ack
= GET_LE_U_2(shp
->sh_seq
[1]);
930 if (ack
& SGQ_OACK
) { /* ackdat field */
931 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
932 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
934 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
935 ack
= GET_LE_U_2(shp
->sh_seq
[2]);
938 ND_PRINT("seg %u ", ack
& SGQ_MASK
);
939 ND_TCHECK_SIZE(lsmp
);
940 lsflags
= GET_U_1(lsmp
->ls_lsflags
);
941 fcval
= GET_U_1(lsmp
->ls_fcval
);
942 switch (lsflags
& LSI_MASK
) {
944 ND_PRINT("dat seg count %u ", fcval
);
945 switch (lsflags
& LSM_MASK
) {
949 ND_PRINT("donotsend-data ");
952 ND_PRINT("send-data ");
955 ND_PRINT("reserved-fcmod? %x", lsflags
);
960 ND_PRINT("intr req count %u ", fcval
);
963 ND_PRINT("reserved-fcval-int? %x", lsflags
);
969 ND_PRINT("reserved-subtype? %x %u > %u", flags
, src
, dst
);
974 switch (flags
& NSP_SUBMASK
) {
976 ND_PRINT("data-ack %u>%u ", src
, dst
);
978 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
981 if (nsplen
< sizeof(struct ackmsg
))
984 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
985 if (ack
& SGQ_ACK
) { /* acknum field */
986 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
987 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
989 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
990 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
991 if (ack
& SGQ_OACK
) { /* ackoth field */
992 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
993 ND_PRINT("onak %u ", ack
& SGQ_MASK
);
995 ND_PRINT("oack %u ", ack
& SGQ_MASK
);
1001 ND_PRINT("ils-ack %u>%u ", src
, dst
);
1003 const struct ackmsg
*amp
= (const struct ackmsg
*)nspp
;
1006 if (nsplen
< sizeof(struct ackmsg
))
1008 ND_TCHECK_SIZE(amp
);
1009 ack
= GET_LE_U_2(amp
->ak_acknum
[0]);
1010 if (ack
& SGQ_ACK
) { /* acknum field */
1011 if ((ack
& SGQ_NAK
) == SGQ_NAK
)
1012 ND_PRINT("nak %u ", ack
& SGQ_MASK
);
1014 ND_PRINT("ack %u ", ack
& SGQ_MASK
);
1015 ack
= GET_LE_U_2(amp
->ak_acknum
[1]);
1016 if (ack
& SGQ_OACK
) { /* ackdat field */
1017 if ((ack
& SGQ_ONAK
) == SGQ_ONAK
)
1018 ND_PRINT("nakdat %u ", ack
& SGQ_MASK
);
1020 ND_PRINT("ackdat %u ", ack
& SGQ_MASK
);
1026 ND_PRINT("conn-ack %u", dst
);
1029 ND_PRINT("reserved-acktype? %x %u > %u", flags
, src
, dst
);
1034 switch (flags
& NSP_SUBMASK
) {
1037 if ((flags
& NSP_SUBMASK
) == MFS_CI
)
1038 ND_PRINT("conn-initiate ");
1040 ND_PRINT("retrans-conn-initiate ");
1041 ND_PRINT("%u>%u ", src
, dst
);
1043 const struct cimsg
*cimp
= (const struct cimsg
*)nspp
;
1044 u_int services
, info
, segsize
;
1046 if (nsplen
< sizeof(struct cimsg
))
1048 ND_TCHECK_SIZE(cimp
);
1049 services
= GET_U_1(cimp
->ci_services
);
1050 info
= GET_U_1(cimp
->ci_info
);
1051 segsize
= GET_LE_U_2(cimp
->ci_segsize
);
1053 switch (services
& COS_MASK
) {
1063 switch (info
& COI_MASK
) {
1065 ND_PRINT("ver 3.2 ");
1068 ND_PRINT("ver 3.1 ");
1071 ND_PRINT("ver 4.0 ");
1074 ND_PRINT("ver 4.1 ");
1077 ND_PRINT("segsize %u ", segsize
);
1081 ND_PRINT("conn-confirm %u>%u ", src
, dst
);
1083 const struct ccmsg
*ccmp
= (const struct ccmsg
*)nspp
;
1084 u_int services
, info
;
1085 u_int segsize
, optlen
;
1087 if (nsplen
< sizeof(struct ccmsg
))
1089 ND_TCHECK_SIZE(ccmp
);
1090 services
= GET_U_1(ccmp
->cc_services
);
1091 info
= GET_U_1(ccmp
->cc_info
);
1092 segsize
= GET_LE_U_2(ccmp
->cc_segsize
);
1093 optlen
= GET_U_1(ccmp
->cc_optlen
);
1095 switch (services
& COS_MASK
) {
1105 switch (info
& COI_MASK
) {
1107 ND_PRINT("ver 3.2 ");
1110 ND_PRINT("ver 3.1 ");
1113 ND_PRINT("ver 4.0 ");
1116 ND_PRINT("ver 4.1 ");
1119 ND_PRINT("segsize %u ", segsize
);
1121 ND_PRINT("optlen %u ", optlen
);
1126 ND_PRINT("disconn-initiate %u>%u ", src
, dst
);
1128 const struct dimsg
*dimp
= (const struct dimsg
*)nspp
;
1132 if (nsplen
< sizeof(struct dimsg
))
1134 ND_TCHECK_SIZE(dimp
);
1135 reason
= GET_LE_U_2(dimp
->di_reason
);
1136 optlen
= GET_U_1(dimp
->di_optlen
);
1138 print_reason(ndo
, reason
);
1140 ND_PRINT("optlen %u ", optlen
);
1145 ND_PRINT("disconn-confirm %u>%u ", src
, dst
);
1147 const struct dcmsg
*dcmp
= (const struct dcmsg
*)nspp
;
1150 ND_TCHECK_SIZE(dcmp
);
1151 reason
= GET_LE_U_2(dcmp
->dc_reason
);
1153 print_reason(ndo
, reason
);
1157 ND_PRINT("reserved-ctltype? %x %u > %u", flags
, src
, dst
);
1162 ND_PRINT("reserved-type? %x %u > %u", flags
, src
, dst
);
1171 static const struct tok reason2str
[] = {
1172 { UC_OBJREJECT
, "object rejected connect" },
1173 { UC_RESOURCES
, "insufficient resources" },
1174 { UC_NOSUCHNODE
, "unrecognized node name" },
1175 { DI_SHUT
, "node is shutting down" },
1176 { UC_NOSUCHOBJ
, "unrecognized object" },
1177 { UC_INVOBJFORMAT
, "invalid object name format" },
1178 { UC_OBJTOOBUSY
, "object too busy" },
1179 { DI_PROTOCOL
, "protocol error discovered" },
1180 { DI_TPA
, "third party abort" },
1181 { UC_USERABORT
, "user abort" },
1182 { UC_INVNODEFORMAT
, "invalid node name format" },
1183 { UC_LOCALSHUT
, "local node shutting down" },
1184 { DI_LOCALRESRC
, "insufficient local resources" },
1185 { DI_REMUSERRESRC
, "insufficient remote user resources" },
1186 { UC_ACCESSREJECT
, "invalid access control information" },
1187 { DI_BADACCNT
, "bad ACCOUNT information" },
1188 { UC_NORESPONSE
, "no response from object" },
1189 { UC_UNREACHABLE
, "node unreachable" },
1190 { DC_NOLINK
, "no link terminate" },
1191 { DC_COMPLETE
, "disconnect complete" },
1192 { DI_BADIMAGE
, "bad image data in connect" },
1193 { DI_SERVMISMATCH
, "cryptographic service mismatch" },
1198 print_reason(netdissect_options
*ndo
,
1201 ND_PRINT("%s ", tok2str(reason2str
, "reason-%u", reason
));
1205 dnnum_string(netdissect_options
*ndo
, u_short dnaddr
)
1209 u_int area
= (u_short
)(dnaddr
& AREAMASK
) >> AREASHIFT
;
1210 u_int node
= dnaddr
& NODEMASK
;
1212 /* malloc() return used by the 'dnaddrtable' hash table: do not free() */
1213 str
= (char *)malloc(siz
= sizeof("00.0000"));
1215 (*ndo
->ndo_error
)(ndo
, S_ERR_ND_MEM_ALLOC
, "dnnum_string: malloc");
1216 snprintf(str
, siz
, "%u.%u", area
, node
);