2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 #include <tcpdump-stdinc.h>
31 #include "netdissect.h"
32 #include "addrtoname.h"
34 #include "ethertype.h"
35 #include "extract.h" /* must come after interface.h */
37 static const char tstr
[] = "[|TIPC]";
40 * Transparent Inter-Process Communication (TIPC) protocol.
42 * http://tipc.sourceforge.net/doc/draft-spec-tipc-07.html
43 * http://tipc.sourceforge.net/doc/tipc_message_formats.html
46 #define TIPC_USER_LOW_IMPORTANCE 0
47 #define TIPC_USER_MEDIUM_IMPORTANCE 1
48 #define TIPC_USER_HIGH_IMPORTANCE 2
49 #define TIPC_USER_CRITICAL_IMPORTANCE 3
50 #define TIPC_USER_BCAST_PROTOCOL 5
51 #define TIPC_USER_MSG_BUNDLER 6
52 #define TIPC_USER_LINK_PROTOCOL 7
53 #define TIPC_USER_CONN_MANAGER 8
54 #define TIPC_USER_CHANGEOVER_PROTOCOL 10
55 #define TIPC_USER_NAME_DISTRIBUTOR 11
56 #define TIPC_USER_MSG_FRAGMENTER 12
57 #define TIPC_USER_LINK_CONFIG 13
59 #define TIPC_CONN_MSG 0
60 #define TIPC_DIRECT_MSG 1
61 #define TIPC_NAMED_MSG 2
62 #define TIPC_MCAST_MSG 3
64 #define TIPC_ZONE(addr) (((addr) >> 24) & 0xFF)
65 #define TIPC_CLUSTER(addr) (((addr) >> 12) & 0xFFF)
66 #define TIPC_NODE(addr) (((addr) >> 0) & 0xFFF)
73 #define TIPC_VER(w0) (((w0) >> 29) & 0x07)
74 #define TIPC_USER(w0) (((w0) >> 25) & 0x0F)
75 #define TIPC_HSIZE(w0) (((w0) >> 21) & 0x0F)
76 #define TIPC_MSIZE(w0) (((w0) >> 0) & 0xFFFF)
77 #define TIPC_MTYPE(w1) (((w1) >> 29) & 0x07)
78 #define TIPC_BROADCAST_ACK(w1) (((w1) >> 0) & 0xFFFF)
79 #define TIPC_LINK_ACK(w2) (((w2) >> 16) & 0xFFFF)
80 #define TIPC_LINK_SEQ(w2) (((w2) >> 0) & 0xFFFF)
82 static const struct tok tipcuser_values
[] = {
83 { TIPC_USER_LOW_IMPORTANCE
, "Low Importance Data payload" },
84 { TIPC_USER_MEDIUM_IMPORTANCE
, "Medium Importance Data payload" },
85 { TIPC_USER_HIGH_IMPORTANCE
, "High Importance Data payload" },
86 { TIPC_USER_CRITICAL_IMPORTANCE
, "Critical Importance Data payload" },
87 { TIPC_USER_BCAST_PROTOCOL
, "Broadcast Link Protocol internal" },
88 { TIPC_USER_MSG_BUNDLER
, "Message Bundler Protocol internal" },
89 { TIPC_USER_LINK_PROTOCOL
, "Link State Protocol internal" },
90 { TIPC_USER_CONN_MANAGER
, "Connection Manager internal" },
91 { TIPC_USER_CHANGEOVER_PROTOCOL
, "Link Changeover Protocol internal" },
92 { TIPC_USER_NAME_DISTRIBUTOR
, "Name Table Update Protocol internal" },
93 { TIPC_USER_MSG_FRAGMENTER
, "Message Fragmentation Protocol internal" },
94 { TIPC_USER_LINK_CONFIG
, "Neighbor Detection Protocol internal" },
98 static const struct tok tipcmtype_values
[] = {
99 { TIPC_CONN_MSG
, "CONN_MSG" },
100 { TIPC_DIRECT_MSG
, "MCAST_MSG" },
101 { TIPC_NAMED_MSG
, "NAMED_MSG" },
102 { TIPC_MCAST_MSG
, "DIRECT_MSG" },
106 static const struct tok tipc_linkconf_mtype_values
[] = {
107 { 0, "Link request" },
108 { 1, "Link response" },
112 struct payload_tipc_pkthdr
{
126 struct internal_tipc_pkthdr
{
139 #define TIPC_SEQ_GAP(w1) (((w1) >> 16) & 0x1FFF)
140 #define TIPC_BC_GAP_AFTER(w2) (((w2) >> 16) & 0xFFFF)
141 #define TIPC_BC_GAP_TO(w2) (((w2) >> 0) & 0xFFFF)
142 #define TIPC_LAST_SENT_FRAG(w4) (((w4) >> 16) & 0xFFFF)
143 #define TIPC_NEXT_SENT_FRAG(w4) (((w4) >> 0) & 0xFFFF)
144 #define TIPC_SESS_NO(w5) (((w5) >> 16) & 0xFFFF)
145 #define TIPC_MSG_CNT(w9) (((w9) >> 16) & 0xFFFF)
146 #define TIPC_LINK_TOL(w9) (((w9) >> 0) & 0xFFFF)
148 struct link_conf_tipc_pkthdr
{
151 u_int32_t dest_domain
;
155 u_int8_t media_address
[16];
158 #define TIPC_NODE_SIG(w1) (((w1) >> 0) & 0xFFFF)
159 #define TIPC_MEDIA_ID(w5) (((w5) >> 0) & 0xFF)
162 print_payload(netdissect_options
*ndo
, const struct payload_tipc_pkthdr
*ap
)
164 u_int32_t w0
, w1
, w2
;
178 ND_TCHECK(ap
->dest_port
);
179 w0
= EXTRACT_32BITS(&ap
->w0
);
180 user
= TIPC_USER(w0
);
181 hsize
= TIPC_HSIZE(w0
);
182 msize
= TIPC_MSIZE(w0
);
183 w1
= EXTRACT_32BITS(&ap
->w1
);
184 mtype
= TIPC_MTYPE(w1
);
185 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
186 orig_port
= EXTRACT_32BITS(&ap
->orig_port
);
187 dest_port
= EXTRACT_32BITS(&ap
->dest_port
);
189 ND_PRINT((ndo
, "TIPC v%u.0 %u.%u.%u:%u > %u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s",
191 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
192 orig_port
, dest_port
,
194 tok2str(tipcuser_values
, "unknown", user
),
195 tok2str(tipcmtype_values
, "Unknown", mtype
)));
197 ND_TCHECK(ap
->dest_node
);
198 orig_node
= EXTRACT_32BITS(&ap
->orig_node
);
199 dest_node
= EXTRACT_32BITS(&ap
->dest_node
);
200 ND_PRINT((ndo
, "TIPC v%u.0 %u.%u.%u:%u > %u.%u.%u:%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s",
202 TIPC_ZONE(orig_node
), TIPC_CLUSTER(orig_node
), TIPC_NODE(orig_node
),
204 TIPC_ZONE(dest_node
), TIPC_CLUSTER(dest_node
), TIPC_NODE(dest_node
),
207 tok2str(tipcuser_values
, "unknown", user
),
208 tok2str(tipcmtype_values
, "Unknown", mtype
)));
210 if (ndo
->ndo_vflag
) {
211 broadcast_ack
= TIPC_BROADCAST_ACK(w1
);
212 w2
= EXTRACT_32BITS(&ap
->w2
);
213 link_ack
= TIPC_LINK_ACK(w2
);
214 link_seq
= TIPC_LINK_SEQ(w2
);
215 ND_PRINT((ndo
, "\n\tPrevious Node %u.%u.%u, Broadcast Ack %u, Link Ack %u, Link Sequence %u",
216 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
217 broadcast_ack
, link_ack
, link_seq
));
223 ND_PRINT((ndo
, "%s", tstr
));
227 print_internal(netdissect_options
*ndo
, const struct internal_tipc_pkthdr
*ap
)
229 u_int32_t w0
, w1
, w2
, w4
, w5
, w9
;
239 u_int last_sent_frag
;
240 u_int next_sent_frag
;
248 ND_TCHECK(ap
->dest_node
);
249 w0
= EXTRACT_32BITS(&ap
->w0
);
250 user
= TIPC_USER(w0
);
251 hsize
= TIPC_HSIZE(w0
);
252 msize
= TIPC_MSIZE(w0
);
253 w1
= EXTRACT_32BITS(&ap
->w1
);
254 mtype
= TIPC_MTYPE(w1
);
255 orig_node
= EXTRACT_32BITS(&ap
->orig_node
);
256 dest_node
= EXTRACT_32BITS(&ap
->dest_node
);
257 ND_PRINT((ndo
, "TIPC v%u.0 %u.%u.%u > %u.%u.%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s (0x%08x)",
259 TIPC_ZONE(orig_node
), TIPC_CLUSTER(orig_node
), TIPC_NODE(orig_node
),
260 TIPC_ZONE(dest_node
), TIPC_CLUSTER(dest_node
), TIPC_NODE(dest_node
),
262 tok2str(tipcuser_values
, "unknown", user
),
263 tok2str(tipcmtype_values
, "Unknown", mtype
), w1
));
265 if (ndo
->ndo_vflag
) {
267 seq_gap
= TIPC_SEQ_GAP(w1
);
268 broadcast_ack
= TIPC_BROADCAST_ACK(w1
);
269 w2
= EXTRACT_32BITS(&ap
->w2
);
270 bc_gap_after
= TIPC_BC_GAP_AFTER(w2
);
271 bc_gap_to
= TIPC_BC_GAP_TO(w2
);
272 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
273 w4
= EXTRACT_32BITS(&ap
->w4
);
274 last_sent_frag
= TIPC_LAST_SENT_FRAG(w4
);
275 next_sent_frag
= TIPC_NEXT_SENT_FRAG(w4
);
276 w5
= EXTRACT_32BITS(&ap
->w5
);
277 sess_no
= TIPC_SESS_NO(w5
);
278 trans_seq
= EXTRACT_32BITS(&ap
->trans_seq
);
279 w9
= EXTRACT_32BITS(&ap
->w9
);
280 msg_cnt
= TIPC_MSG_CNT(w9
);
281 link_tol
= TIPC_LINK_TOL(w9
);
282 ND_PRINT((ndo
, "\n\tPrevious Node %u.%u.%u, Session No. %u, Broadcast Ack %u, Sequence Gap %u, Broadcast Gap After %u, Broadcast Gap To %u, Last Sent Packet No. %u, Next sent Packet No. %u, Transport Sequence %u, msg_count %u, Link Tolerance %u",
283 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
284 sess_no
, broadcast_ack
, seq_gap
, bc_gap_after
, bc_gap_to
,
285 last_sent_frag
, next_sent_frag
, trans_seq
, msg_cnt
,
291 ND_PRINT((ndo
, "%s", tstr
));
295 print_link_conf(netdissect_options
*ndo
, const struct link_conf_tipc_pkthdr
*ap
)
297 u_int32_t w0
, w1
, w5
;
308 ND_TCHECK(ap
->prev_node
);
309 w0
= EXTRACT_32BITS(&ap
->w0
);
310 user
= TIPC_USER(w0
);
311 hsize
= TIPC_HSIZE(w0
);
312 msize
= TIPC_MSIZE(w0
);
313 w1
= EXTRACT_32BITS(&ap
->w1
);
314 mtype
= TIPC_MTYPE(w1
);
315 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
316 dest_domain
= EXTRACT_32BITS(&ap
->dest_domain
);
317 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
319 ND_PRINT((ndo
, "TIPC v%u.0 %u.%u.%u > %u.%u.%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s",
321 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
322 TIPC_ZONE(dest_domain
), TIPC_CLUSTER(dest_domain
), TIPC_NODE(dest_domain
),
324 tok2str(tipcuser_values
, "unknown", user
),
325 tok2str(tipc_linkconf_mtype_values
, "Unknown", mtype
)));
326 if (ndo
->ndo_vflag
) {
328 node_sig
= TIPC_NODE_SIG(w1
);
329 ntwrk_id
= EXTRACT_32BITS(&ap
->ntwrk_id
);
330 w5
= EXTRACT_32BITS(&ap
->w5
);
331 media_id
= TIPC_MEDIA_ID(w5
);
332 ND_PRINT((ndo
, "\n\tNodeSignature %u, network_id %u, media_id %u",
333 node_sig
, ntwrk_id
, media_id
));
338 ND_PRINT((ndo
, "%s", tstr
));
342 tipc_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length _U_
,
345 const struct tipc_pkthdr
*ap
;
349 ap
= (struct tipc_pkthdr
*)bp
;
351 w0
= EXTRACT_32BITS(&ap
->w0
);
352 user
= TIPC_USER(w0
);
356 case TIPC_USER_LOW_IMPORTANCE
:
357 case TIPC_USER_MEDIUM_IMPORTANCE
:
358 case TIPC_USER_HIGH_IMPORTANCE
:
359 case TIPC_USER_CRITICAL_IMPORTANCE
:
360 case TIPC_USER_NAME_DISTRIBUTOR
:
361 case TIPC_USER_CONN_MANAGER
:
362 print_payload(ndo
, (struct payload_tipc_pkthdr
*)bp
);
365 case TIPC_USER_LINK_CONFIG
:
366 print_link_conf(ndo
, (struct link_conf_tipc_pkthdr
*)bp
);
369 case TIPC_USER_BCAST_PROTOCOL
:
370 case TIPC_USER_MSG_BUNDLER
:
371 case TIPC_USER_LINK_PROTOCOL
:
372 case TIPC_USER_CHANGEOVER_PROTOCOL
:
373 case TIPC_USER_MSG_FRAGMENTER
:
374 print_internal(ndo
, (struct internal_tipc_pkthdr
*)bp
);
381 ND_PRINT((ndo
, "%s", tstr
));