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.
23 static const char rcsid
[] _U_
=
24 "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
31 #include <tcpdump-stdinc.h>
36 #include "netdissect.h"
37 #include "addrtoname.h"
39 #include "ethertype.h"
40 #include "extract.h" /* must come after interface.h */
43 * Transparent Inter-Process Communication (TIPC) protocol.
45 * http://tipc.sourceforge.net/doc/draft-spec-tipc-07.html
46 * http://tipc.sourceforge.net/doc/tipc_message_formats.html
49 #define TIPC_USER_LOW_IMPORTANCE 0
50 #define TIPC_USER_MEDIUM_IMPORTANCE 1
51 #define TIPC_USER_HIGH_IMPORTANCE 2
52 #define TIPC_USER_CRITICAL_IMPORTANCE 3
53 #define TIPC_USER_BCAST_PROTOCOL 5
54 #define TIPC_USER_MSG_BUNDLER 6
55 #define TIPC_USER_LINK_PROTOCOL 7
56 #define TIPC_USER_CONN_MANAGER 8
57 #define TIPC_USER_CHANGEOVER_PROTOCOL 10
58 #define TIPC_USER_NAME_DISTRIBUTOR 11
59 #define TIPC_USER_MSG_FRAGMENTER 12
60 #define TIPC_USER_LINK_CONFIG 13
62 #define TIPC_CONN_MSG 0
63 #define TIPC_DIRECT_MSG 1
64 #define TIPC_NAMED_MSG 2
65 #define TIPC_MCAST_MSG 3
67 #define TIPC_ZONE(addr) (((addr) >> 24) & 0xFF)
68 #define TIPC_CLUSTER(addr) (((addr) >> 12) & 0xFFF)
69 #define TIPC_NODE(addr) (((addr) >> 0) & 0xFFF)
75 #define TIPC_VER(w0) (((w0) >> 29) & 0x07)
76 #define TIPC_USER(w0) (((w0) >> 25) & 0x0F)
77 #define TIPC_HSIZE(w0) (((w0) >> 21) & 0x0F)
78 #define TIPC_MSIZE(w0) (((w0) >> 0) & 0xFFFF)
79 #define TIPC_MTYPE(w1) (((w1) >> 29) & 0x07)
80 #define TIPC_BROADCAST_ACK(w1) (((w1) >> 0) & 0xFFFF)
81 #define TIPC_LINK_ACK(w2) (((w2) >> 16) & 0xFFFF)
82 #define TIPC_LINK_SEQ(w2) (((w2) >> 0) & 0xFFFF)
84 static const struct tok tipcuser_values
[] = {
85 { TIPC_USER_LOW_IMPORTANCE
, "Low Importance Data payload" },
86 { TIPC_USER_MEDIUM_IMPORTANCE
, "Medium Importance Data payload" },
87 { TIPC_USER_HIGH_IMPORTANCE
, "High Importance Data payload" },
88 { TIPC_USER_CRITICAL_IMPORTANCE
, "Critical Importance Data payload" },
89 { TIPC_USER_BCAST_PROTOCOL
, "Broadcast Link Protocol internal" },
90 { TIPC_USER_MSG_BUNDLER
, "Message Bundler Protocol internal" },
91 { TIPC_USER_LINK_PROTOCOL
, "Link State Protocol internal" },
92 { TIPC_USER_CONN_MANAGER
, "Connection Manager internal" },
93 { TIPC_USER_CHANGEOVER_PROTOCOL
, "Link Changeover Protocol internal" },
94 { TIPC_USER_NAME_DISTRIBUTOR
, "Name Table Update Protocol internal" },
95 { TIPC_USER_MSG_FRAGMENTER
, "Message Fragmentation Protocol internal" },
96 { TIPC_USER_LINK_CONFIG
, "Neighbor Detection Protocol internal" },
100 static const struct tok tipcmtype_values
[] = {
101 { TIPC_CONN_MSG
, "CONN_MSG" },
102 { TIPC_DIRECT_MSG
, "MCAST_MSG" },
103 { TIPC_NAMED_MSG
, "NAMED_MSG" },
104 { TIPC_MCAST_MSG
, "DIRECT_MSG" },
108 struct payload_tipc_pkthdr
{
122 struct internal_tipc_pkthdr
{
135 #define TIPC_SEQ_GAP(w1) (((w1) >> 16) & 0x1FFF)
136 #define TIPC_BC_GAP_AFTER(w2) (((w2) >> 16) & 0xFFFF)
137 #define TIPC_BC_GAP_TO(w2) (((w2) >> 0) & 0xFFFF)
138 #define TIPC_LAST_SENT_FRAG(w4) (((w4) >> 16) & 0xFFFF)
139 #define TIPC_NEXT_SENT_FRAG(w4) (((w4) >> 0) & 0xFFFF)
140 #define TIPC_SESS_NO(w5) (((w5) >> 16) & 0xFFFF)
141 #define TIPC_MSG_CNT(w9) (((w9) >> 16) & 0xFFFF)
142 #define TIPC_LINK_TOL(w9) (((w9) >> 0) & 0xFFFF)
144 struct link_conf_tipc_pkthdr
{
147 u_int32_t dest_domain
;
151 u_int8_t media_address
[16];
154 #define TIPC_NODE_SIG(w1) (((w1) >> 0) & 0xFFFF)
155 #define TIPC_MEDIA_ID(w5) (((w5) >> 0) & 0xFF)
158 print_payload(netdissect_options
*ndo
, struct payload_tipc_pkthdr
*ap
)
160 u_int32_t w0
, w1
, w2
;
175 w0
= EXTRACT_32BITS(&ap
->w0
);
176 user
= TIPC_USER(w0
);
177 hsize
= TIPC_HSIZE(w0
);
178 msize
= TIPC_MSIZE(w0
);
179 w1
= EXTRACT_32BITS(&ap
->w1
);
180 mtype
= TIPC_MTYPE(w1
);
181 broadcast_ack
= TIPC_BROADCAST_ACK(w1
);
182 w2
= EXTRACT_32BITS(&ap
->w2
);
183 link_ack
= TIPC_LINK_ACK(w2
);
184 link_seq
= TIPC_LINK_SEQ(w2
);
185 orig_node
= EXTRACT_32BITS(&ap
->orig_node
);
186 orig_port
= EXTRACT_32BITS(&ap
->orig_port
);
187 dest_node
= EXTRACT_32BITS(&ap
->dest_node
);
188 dest_port
= EXTRACT_32BITS(&ap
->dest_port
);
189 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
191 ND_PRINT((ndo
, "<%u.%u.%u> : %u > <%u.%u.%u> : %u, Previous Node <%u.%u.%u>, Broadcast Ack %u, Link Ack %u, Link Sequence %u, headerlength %u bytes, MessageSize %u bytes, %s messageType %s\n\n",
192 TIPC_ZONE(orig_node
), TIPC_CLUSTER(orig_node
), TIPC_NODE(orig_node
),
194 TIPC_ZONE(dest_node
), TIPC_CLUSTER(dest_node
), TIPC_NODE(dest_node
),
196 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
197 broadcast_ack
, link_ack
, link_seq
, hsize
*4, msize
,
198 tok2str(tipcuser_values
, "unknown", user
),
199 tok2str(tipcmtype_values
, "Unknown", mtype
)));
203 ND_PRINT((ndo
, "[|TIPC]"));
207 print_internal(netdissect_options
*ndo
, struct internal_tipc_pkthdr
*ap
)
209 u_int32_t w0
, w1
, w2
, w4
, w5
, w9
;
219 u_int last_sent_frag
;
220 u_int next_sent_frag
;
229 w0
= EXTRACT_32BITS(&ap
->w0
);
230 user
= TIPC_USER(w0
);
231 hsize
= TIPC_HSIZE(w0
);
232 msize
= TIPC_MSIZE(w0
);
233 w1
= EXTRACT_32BITS(&ap
->w1
);
234 mtype
= TIPC_MTYPE(w1
);
235 seq_gap
= TIPC_SEQ_GAP(w1
);
236 broadcast_ack
= TIPC_BROADCAST_ACK(w1
);
237 w2
= EXTRACT_32BITS(&ap
->w2
);
238 bc_gap_after
= TIPC_BC_GAP_AFTER(w2
);
239 bc_gap_to
= TIPC_BC_GAP_TO(w2
);
240 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
241 w4
= EXTRACT_32BITS(&ap
->w4
);
242 last_sent_frag
= TIPC_LAST_SENT_FRAG(w4
);
243 next_sent_frag
= TIPC_NEXT_SENT_FRAG(w4
);
244 w5
= EXTRACT_32BITS(&ap
->w5
);
245 sess_no
= TIPC_SESS_NO(w5
);
246 orig_node
= EXTRACT_32BITS(&ap
->orig_node
);
247 dest_node
= EXTRACT_32BITS(&ap
->dest_node
);
248 trans_seq
= EXTRACT_32BITS(&ap
->trans_seq
);
249 w9
= EXTRACT_32BITS(&ap
->w9
);
250 msg_cnt
= TIPC_MSG_CNT(w9
);
251 link_tol
= TIPC_LINK_TOL(w9
);
253 ND_PRINT((ndo
, "<%u.%u.%u> > <%u.%u.%u>, Previous 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, headerlength %u bytes, MessageSize %u bytes, %s messageType %s\n\n",
254 TIPC_ZONE(orig_node
), TIPC_CLUSTER(orig_node
), TIPC_NODE(orig_node
),
255 TIPC_ZONE(dest_node
), TIPC_CLUSTER(dest_node
), TIPC_NODE(dest_node
),
256 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
257 sess_no
, broadcast_ack
, seq_gap
, bc_gap_after
, bc_gap_to
,
258 last_sent_frag
, next_sent_frag
, trans_seq
, msg_cnt
, link_tol
,
260 tok2str(tipcuser_values
, "unknown", user
),
261 tok2str(tipcmtype_values
, "Unknown", mtype
)));
265 ND_PRINT((ndo
, "[|TIPC]"));
269 print_link_conf(netdissect_options
*ndo
, struct link_conf_tipc_pkthdr
*ap
)
271 u_int32_t w0
, w1
, w5
;
283 w0
= EXTRACT_32BITS(&ap
->w0
);
284 user
= TIPC_USER(w0
);
285 hsize
= TIPC_HSIZE(w0
);
286 msize
= TIPC_MSIZE(w0
);
287 w1
= EXTRACT_32BITS(&ap
->w1
);
288 mtype
= TIPC_MTYPE(w1
);
289 node_sig
= TIPC_NODE_SIG(w1
);
290 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
291 dest_domain
= EXTRACT_32BITS(&ap
->dest_domain
);
292 prev_node
= EXTRACT_32BITS(&ap
->prev_node
);
293 ntwrk_id
= EXTRACT_32BITS(&ap
->ntwrk_id
);
294 w5
= EXTRACT_32BITS(&ap
->w5
);
295 media_id
= TIPC_MEDIA_ID(w5
);
297 ND_PRINT((ndo
, "<%u.%u.%u> > <%u.%u.%u> NodeSignature %u, network_id %u, %s, headerlength %u bytes, MessageSize %u bytes, messageType %s, media_id %u\n\n",
298 TIPC_ZONE(prev_node
), TIPC_CLUSTER(prev_node
), TIPC_NODE(prev_node
),
299 TIPC_ZONE(dest_domain
), TIPC_CLUSTER(dest_domain
), TIPC_NODE(dest_domain
),
301 tok2str(tipcuser_values
, "unknown", user
),
303 tok2str(tipcmtype_values
, "Unknown", mtype
),
308 ND_PRINT((ndo
, "[|TIPC]"));
312 tipc_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length _U_
,
315 struct tipc_pkthdr
*ap
;
319 ap
= (struct tipc_pkthdr
*)bp
;
321 w0
= EXTRACT_32BITS(&ap
->w0
);
322 ND_PRINT((ndo
, "TIPC Protocol Packet version %u.0\n", TIPC_VER(w0
)));
327 case TIPC_USER_LOW_IMPORTANCE
:
328 case TIPC_USER_MEDIUM_IMPORTANCE
:
329 case TIPC_USER_HIGH_IMPORTANCE
:
330 case TIPC_USER_CRITICAL_IMPORTANCE
:
331 case TIPC_USER_NAME_DISTRIBUTOR
:
332 case TIPC_USER_CONN_MANAGER
:
333 print_payload(ndo
, (struct payload_tipc_pkthdr
*)bp
);
336 case TIPC_USER_LINK_CONFIG
:
337 print_link_conf(ndo
, (struct link_conf_tipc_pkthdr
*)bp
);
340 case TIPC_USER_BCAST_PROTOCOL
:
341 case TIPC_USER_MSG_BUNDLER
:
342 case TIPC_USER_LINK_PROTOCOL
:
343 case TIPC_USER_CHANGEOVER_PROTOCOL
:
344 case TIPC_USER_MSG_FRAGMENTER
:
345 print_internal(ndo
, (struct internal_tipc_pkthdr
*)bp
);
352 ND_PRINT((ndo
, "[|TIPC]"));