2 * Routines for pulse dissection
3 * Copyright 2013, Masatake YAMATO <yamato@redhat.com>
4 * Copyright 2013, Red Hat, Inc.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 http://sourceware.org/piranha/ */
19 #include <epan/packet.h>
21 #define PORT_PULSE 539 /* Not IANA registered */
23 void proto_register_pulse(void);
24 void proto_reg_handoff_pulse(void);
26 static dissector_handle_t pulse_handle
;
28 static int proto_pulse
;
29 static int hf_pulse_magic
;
33 #define PULSE_HEARTBEAT_RUNNING_MAGIC 0xbdaddbda
34 #define PULSE_HEARTBEAT_STOPPED_MAGIC 0xadbddabd
36 static const value_string pulse_magic_type
[] = {
37 { PULSE_HEARTBEAT_RUNNING_MAGIC
, "running" },
38 { PULSE_HEARTBEAT_STOPPED_MAGIC
, "stopped" },
43 dissect_pulse(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
49 const char* magic_str
;
52 if (tvb_captured_length(tvb
) < 4)
55 /* Try to read MAGIC in both endians */
56 endian
= ENC_LITTLE_ENDIAN
;
57 magic
= tvb_get_letohl(tvb
, 0);
58 magic_str
= try_val_to_str(magic
, pulse_magic_type
);
59 if (magic_str
== NULL
) {
60 magic
= tvb_get_ntohl(tvb
, 0);
61 magic_str
= try_val_to_str(magic
, pulse_magic_type
);
62 if (magic_str
== NULL
) {
65 endian
= ENC_BIG_ENDIAN
;
68 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PULSE");
69 col_set_str(pinfo
->cinfo
, COL_INFO
, magic_str
);
72 item
= proto_tree_add_item(parent_tree
, proto_pulse
, tvb
, 0,
74 tree
= proto_item_add_subtree(item
, ett_pulse
);
75 proto_tree_add_item(tree
, hf_pulse_magic
, tvb
, 0, 4, endian
);
81 proto_register_pulse(void)
83 static hf_register_info hf
[] = {
85 { "Magic", "pulse.magic",
86 FT_UINT32
, BASE_HEX
, VALS(pulse_magic_type
), 0x0,
95 proto_pulse
= proto_register_protocol("PULSE protocol for Linux Virtual Server redundancy", "PULSE", "pulse");
96 proto_register_field_array(proto_pulse
, hf
, array_length(hf
));
97 proto_register_subtree_array(ett
, array_length(ett
));
99 pulse_handle
= register_dissector("pulse", dissect_pulse
, proto_pulse
);
103 proto_reg_handoff_pulse(void)
105 dissector_add_uint_with_preference("udp.port", PORT_PULSE
, pulse_handle
);
109 * Editor modelines - https://www.wireshark.org/tools/modelines.html
114 * indent-tabs-mode: nil
117 * vi: set shiftwidth=4 tabstop=8 expandtab:
118 * :indentSize=4:tabSize=8:noTabs=true: