1 /* packet-ipvs-syncd.c 2001 Ronnie Sahlberg <See AUTHORS for email>
2 * Routines for IGMP packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
15 void proto_register_ipvs_syncd(void);
16 void proto_reg_handoff_ipvs_syncd(void);
18 static dissector_handle_t ipvs_syncd_handle
;
20 static int proto_ipvs_syncd
;
21 static int hf_conn_count
;
25 static int hf_version
;
34 static int hf_flags_conn_type
;
35 static int hf_flags_hashed_entry
;
36 static int hf_flags_no_output_packets
;
37 static int hf_flags_conn_not_established
;
38 static int hf_flags_adjust_output_seq
;
39 static int hf_flags_adjust_input_seq
;
40 static int hf_flags_no_client_port_set
;
42 static int hf_in_seq_init
;
43 static int hf_in_seq_delta
;
44 static int hf_in_seq_pdelta
;
45 static int hf_out_seq_init
;
46 static int hf_out_seq_delta
;
47 static int hf_out_seq_pdelta
;
52 static int hf_size_v1
;
53 static int hf_flags_v1
;
55 static int hf_timeout
;
60 static int ett_ipvs_syncd
;
64 #define IPVS_SYNCD_MC_GROUP "224.0.0.18"
65 #define IPVS_SYNCD_PORT 8848 /* Not IANA registered */
67 static const value_string proto_strings
[] = {
73 static const value_string state_strings
[] = {
80 static const value_string type_strings
[] = {
87 * IPVS Connection Flags
88 * Pulled from include/net/ip_vs.h in linux kernel source
90 #define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */
91 #define IP_VS_CONN_F_MASQ 0x0000 /* masquerading */
92 #define IP_VS_CONN_F_LOCALNODE 0x0001 /* local node */
93 #define IP_VS_CONN_F_TUNNEL 0x0002 /* tunneling */
94 #define IP_VS_CONN_F_DROUTE 0x0003 /* direct routing */
95 #define IP_VS_CONN_F_BYPASS 0x0004 /* cache bypass */
96 #define IP_VS_CONN_F_HASHED 0x0040 /* hashed entry */
97 #define IP_VS_CONN_F_NOOUTPUT 0x0080 /* no output packets */
98 #define IP_VS_CONN_F_INACTIVE 0x0100 /* not established */
99 #define IP_VS_CONN_F_OUT_SEQ 0x0200 /* must do output seq adjust */
100 #define IP_VS_CONN_F_IN_SEQ 0x0400 /* must do input seq adjust */
101 #define IP_VS_CONN_F_SEQ_MASK 0x0600 /* in/out sequence mask */
102 #define IP_VS_CONN_F_NO_CPORT 0x0800 /* no client port set yet */
104 static const value_string connection_type_strings
[] = {
105 {IP_VS_CONN_F_MASQ
, "Masquerade"},
106 {IP_VS_CONN_F_LOCALNODE
, "Local Node"},
107 {IP_VS_CONN_F_TUNNEL
, "Tunnel"},
108 {IP_VS_CONN_F_DROUTE
, "Direct Routing"},
114 dissect_ipvs_syncd(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
123 item
= proto_tree_add_item(parent_tree
, proto_ipvs_syncd
, tvb
, offset
, -1, ENC_NA
);
124 tree
= proto_item_add_subtree(item
, ett_ipvs_syncd
);
127 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IPVS");
128 col_clear(pinfo
->cinfo
, COL_INFO
);
130 cnt
= tvb_get_uint8(tvb
, offset
);
131 if(cnt
== 0) { //Version 1 (or after...) first byte is reserved
132 proto_tree_add_item(tree
, hf_resv
, tvb
, offset
, 1, ENC_NA
);
133 col_set_str(pinfo
->cinfo
, COL_INFO
, "v1");
135 proto_tree_add_item(tree
, hf_conn_count
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
136 col_set_str(pinfo
->cinfo
, COL_INFO
, "v0");
140 proto_tree_add_item(tree
, hf_syncid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
143 proto_tree_add_item(tree
, hf_size
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
146 if(cnt
== 0) { //Version 1 (or after...)
147 cnt
= tvb_get_uint8(tvb
, offset
);
148 proto_tree_add_item(tree
, hf_conn_count
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
151 version
= tvb_get_uint8(tvb
, offset
);
152 proto_tree_add_item(tree
, hf_version
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
155 proto_tree_add_item(tree
, hf_resv
, tvb
, offset
, 2, ENC_NA
);
158 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " %u Connection(s)", cnt
);
160 for (conn
= 0; conn
< cnt
; conn
++)
168 ctree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, 36, ett_conn
, NULL
,
169 "Connection #%d", conn
+1);
171 type
= tvb_get_uint8(tvb
, offset
);
172 proto_tree_add_item(ctree
, hf_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
175 proto_tree_add_item(ctree
, hf_proto
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
178 size
= (tvb_get_ntohs(tvb
, offset
) & 0x1FFF);
179 proto_item_set_len(ctree
, size
);
180 proto_tree_add_item(ctree
, hf_ver
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
181 proto_tree_add_item(ctree
, hf_size_v1
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
184 proto_tree_add_item(ctree
, hf_flags_v1
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
187 proto_tree_add_item(ctree
, hf_state
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
190 proto_tree_add_item(ctree
, hf_cport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
193 proto_tree_add_item(ctree
, hf_vport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
196 proto_tree_add_item(ctree
, hf_dport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
199 proto_tree_add_item(ctree
, hf_fwmark
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
202 proto_tree_add_item(ctree
, hf_timeout
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
205 if(type
== 0){ /* IPv4 */
207 proto_tree_add_item(ctree
, hf_caddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
210 proto_tree_add_item(ctree
, hf_vaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
213 proto_tree_add_item(ctree
, hf_daddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
217 proto_tree_add_item(ctree
, hf_caddr6
, tvb
, offset
, 16, ENC_NA
);
220 proto_tree_add_item(ctree
, hf_vaddr6
, tvb
, offset
, 16, ENC_NA
);
223 proto_tree_add_item(ctree
, hf_daddr6
, tvb
, offset
, 16, ENC_NA
);
230 proto_tree
*ftree
, *fi
;
233 ctree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, 24, ett_conn
, NULL
,
234 "Connection #%d", conn
+1);
236 proto_tree_add_item(ctree
, hf_resv
, tvb
, offset
, 1, ENC_NA
);
239 proto_tree_add_item(ctree
, hf_proto
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
242 proto_tree_add_item(ctree
, hf_cport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
245 proto_tree_add_item(ctree
, hf_vport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
248 proto_tree_add_item(ctree
, hf_dport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
251 proto_tree_add_item(ctree
, hf_caddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
254 proto_tree_add_item(ctree
, hf_vaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
257 proto_tree_add_item(ctree
, hf_daddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
260 flags
= tvb_get_ntohs(tvb
, offset
);
261 fi
= proto_tree_add_item(ctree
, hf_flags
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
262 ftree
= proto_item_add_subtree(fi
, ett_flags
);
263 proto_tree_add_item(ftree
, hf_flags_conn_type
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
264 proto_tree_add_item(ftree
, hf_flags_hashed_entry
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
265 proto_tree_add_item(ftree
, hf_flags_no_output_packets
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
266 proto_tree_add_item(ftree
, hf_flags_conn_not_established
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
267 proto_tree_add_item(ftree
, hf_flags_adjust_output_seq
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
268 proto_tree_add_item(ftree
, hf_flags_adjust_input_seq
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
269 proto_tree_add_item(ftree
, hf_flags_no_client_port_set
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
273 proto_tree_add_item(ctree
, hf_state
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
276 /* we have full connection info */
277 if ( flags
& IP_VS_CONN_F_SEQ_MASK
)
279 proto_tree_add_item(ctree
, hf_in_seq_init
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
282 proto_tree_add_item(ctree
, hf_in_seq_delta
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
285 proto_tree_add_item(ctree
, hf_in_seq_pdelta
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
288 proto_tree_add_item(ctree
, hf_out_seq_init
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
291 proto_tree_add_item(ctree
, hf_out_seq_delta
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
294 proto_tree_add_item(ctree
, hf_out_seq_pdelta
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
302 return tvb_captured_length(tvb
);
306 proto_register_ipvs_syncd(void)
308 static hf_register_info hf
[] = {
310 { "Connection Count", "ipvs.conncount", FT_UINT8
, BASE_DEC
,
311 NULL
, 0, NULL
, HFILL
}},
314 { "Synchronization ID", "ipvs.syncid", FT_UINT8
, BASE_DEC
,
315 NULL
, 0, NULL
, HFILL
}},
318 { "Size", "ipvs.size", FT_UINT16
, BASE_DEC
,
319 NULL
, 0, NULL
, HFILL
}},
322 { "Reserved", "ipvs.resv", FT_BYTES
, BASE_NONE
,
323 NULL
, 0, NULL
, HFILL
}},
326 { "Version", "ipvs.version", FT_UINT8
, BASE_DEC
,
327 NULL
, 0, NULL
, HFILL
}},
330 { "Protocol", "ipvs.proto", FT_UINT8
, BASE_HEX
,
331 VALS(proto_strings
), 0, NULL
, HFILL
}},
334 { "Client Port", "ipvs.cport", FT_UINT16
, BASE_DEC
,
335 NULL
, 0, NULL
, HFILL
}},
338 { "Virtual Port", "ipvs.vport", FT_UINT16
, BASE_DEC
,
339 NULL
, 0, NULL
, HFILL
}},
342 { "Destination Port", "ipvs.dport", FT_UINT16
, BASE_DEC
,
343 NULL
, 0, NULL
, HFILL
}},
346 { "Client Address", "ipvs.caddr", FT_IPv4
, BASE_NONE
,
347 NULL
, 0, NULL
, HFILL
}},
350 { "Virtual Address", "ipvs.vaddr", FT_IPv4
, BASE_NONE
,
351 NULL
, 0, NULL
, HFILL
}},
354 { "Destination Address", "ipvs.daddr", FT_IPv4
, BASE_NONE
,
355 NULL
, 0, NULL
, HFILL
}},
358 { "Flags", "ipvs.flags", FT_UINT16
, BASE_HEX
,
359 NULL
, 0, NULL
, HFILL
}},
361 { &hf_flags_conn_type
,
362 { "Connection Type", "ipvs.flags.conn_type", FT_UINT16
, BASE_HEX
,
363 VALS(connection_type_strings
), 0x0F, NULL
, HFILL
}},
365 { &hf_flags_hashed_entry
,
366 { "Hashed Entry", "ipvs.flags.hashed_entry", FT_BOOLEAN
, 16,
367 NULL
, IP_VS_CONN_F_HASHED
, NULL
, HFILL
}},
369 { &hf_flags_no_output_packets
,
370 { "No Output Packets", "ipvs.flags.no_output_packets", FT_BOOLEAN
, 16,
371 NULL
, IP_VS_CONN_F_NOOUTPUT
, NULL
, HFILL
}},
373 { &hf_flags_conn_not_established
,
374 { "Connection Not Established", "ipvs.flags.conn_not_established", FT_BOOLEAN
, 16,
375 NULL
, IP_VS_CONN_F_INACTIVE
, NULL
, HFILL
}},
377 { &hf_flags_adjust_output_seq
,
378 { "Adjust Output Sequence", "ipvs.flags.adjust_output_seq", FT_BOOLEAN
, 16,
379 NULL
, IP_VS_CONN_F_OUT_SEQ
, NULL
, HFILL
}},
381 { &hf_flags_adjust_input_seq
,
382 { "Adjust Input Sequence", "ipvs.flags.adjust_input_seq", FT_BOOLEAN
, 16,
383 NULL
, IP_VS_CONN_F_IN_SEQ
, NULL
, HFILL
}},
385 { &hf_flags_no_client_port_set
,
386 { "No Client Port Set", "ipvs.flags.no_client_port_set", FT_BOOLEAN
, 16,
387 NULL
, IP_VS_CONN_F_NO_CPORT
, NULL
, HFILL
}},
390 { "State", "ipvs.state", FT_UINT16
, BASE_HEX
,
391 VALS(state_strings
), 0, NULL
, HFILL
}},
394 { "Input Sequence (Initial)", "ipvs.in_seq.initial", FT_UINT32
,
395 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
398 { "Input Sequence (Delta)", "ipvs.in_seq.delta", FT_UINT32
,
399 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
402 { "Input Sequence (Previous Delta)", "ipvs.in_seq.pdelta", FT_UINT32
,
403 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
406 { "Output Sequence (Initial)", "ipvs.out_seq.initial", FT_UINT32
,
407 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
410 { "Output Sequence (Delta)", "ipvs.out_seq.delta", FT_UINT32
,
411 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
413 { &hf_out_seq_pdelta
,
414 { "Output Sequence (Previous Delta)", "ipvs.out_seq.pdelta", FT_UINT32
,
415 BASE_HEX
, NULL
, 0, NULL
, HFILL
}},
420 { "Type", "ipvs.type", FT_UINT8
, BASE_DEC
,
421 VALS(type_strings
), 0, NULL
, HFILL
}},
424 { "Version", "ipvs.ver", FT_UINT16
, BASE_DEC
,
425 NULL
, 0xE000, NULL
, HFILL
}},
428 { "Size", "ipvs.size.v1", FT_UINT16
, BASE_DEC
,
429 NULL
, 0x1FFF, NULL
, HFILL
}},
432 { "Flags", "ipvs.flags.v1", FT_UINT32
, BASE_HEX
,
433 NULL
, 0, NULL
, HFILL
}},
436 { "FWmark", "ipvs.fwmark", FT_UINT32
, BASE_HEX
,
437 NULL
, 0, NULL
, HFILL
}},
440 { "Timeout", "ipvs.timeout", FT_UINT32
, BASE_DEC
,
441 NULL
, 0, NULL
, HFILL
}},
444 { "Client Address", "ipvs.caddr6", FT_IPv6
, BASE_NONE
,
445 NULL
, 0, NULL
, HFILL
}},
448 { "Virtual Address", "ipvs.vaddr6", FT_IPv6
, BASE_NONE
,
449 NULL
, 0, NULL
, HFILL
}},
452 { "Destination Address", "ipvs.daddr6", FT_IPv6
, BASE_NONE
,
453 NULL
, 0, NULL
, HFILL
}},
456 static int *ett
[] = {
462 proto_ipvs_syncd
= proto_register_protocol("IP Virtual Services Sync Daemon", "IPVS", "ipvs");
463 proto_register_field_array(proto_ipvs_syncd
, hf
, array_length(hf
));
464 proto_register_subtree_array(ett
, array_length(ett
));
466 ipvs_syncd_handle
= register_dissector("ipvs", dissect_ipvs_syncd
, proto_ipvs_syncd
);
470 proto_reg_handoff_ipvs_syncd(void)
472 dissector_add_uint_with_preference("udp.port", IPVS_SYNCD_PORT
, ipvs_syncd_handle
);
476 * Editor modelines - https://www.wireshark.org/tools/modelines.html
481 * indent-tabs-mode: t
484 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
485 * :indentSize=8:tabSize=8:noTabs=false: