2 * Routines for ECHO packet disassembly (RFC862)
4 * Only useful to mark the packets as ECHO in the summary and in the
5 * protocol hierarchy statistics (since not so many fields to decode ;-)
7 * Laurent Deniel <laurent.deniel@free.fr>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include <epan/packet.h>
22 void proto_register_echo(void);
23 void proto_reg_handoff_echo(void);
25 static dissector_handle_t echo_handle
;
26 static int proto_echo
;
28 static int hf_echo_data
;
29 static int hf_echo_request
;
30 static int hf_echo_response
;
34 static int dissect_echo(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
37 proto_tree
*echo_tree
;
38 proto_item
*ti
, *hidden_item
;
40 request
= (pinfo
->destport
== pinfo
->match_uint
);
42 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ECHO");
43 col_set_str(pinfo
->cinfo
, COL_INFO
, request
? "Request" : "Response");
45 ti
= proto_tree_add_item(tree
, proto_echo
, tvb
, 0, -1, ENC_NA
);
46 echo_tree
= proto_item_add_subtree(ti
, ett_echo
);
48 hidden_item
= proto_tree_add_boolean(echo_tree
,
49 request
? hf_echo_request
: hf_echo_response
, tvb
, 0, 0, 1);
50 proto_item_set_hidden(hidden_item
);
52 proto_tree_add_item(echo_tree
, hf_echo_data
, tvb
, 0, -1, ENC_NA
);
54 return tvb_captured_length(tvb
);
57 void proto_register_echo(void)
60 static hf_register_info hf
[] = {
62 { "Echo data", "echo.data", FT_BYTES
, BASE_NONE
,
63 NULL
, 0x0, NULL
, HFILL
}},
65 { "Echo request", "echo.request", FT_BOOLEAN
, BASE_NONE
,
66 NULL
, 0x0, NULL
, HFILL
}},
68 { "Echo response","echo.response", FT_BOOLEAN
, BASE_NONE
,
69 NULL
, 0x0, NULL
, HFILL
}}
76 proto_echo
= proto_register_protocol("Echo", "ECHO", "echo");
77 proto_register_field_array(proto_echo
, hf
, array_length(hf
));
78 proto_register_subtree_array(ett
, array_length(ett
));
79 echo_handle
= register_dissector("echo", dissect_echo
, proto_echo
);
82 void proto_reg_handoff_echo(void)
84 dissector_add_uint_with_preference("udp.port", ECHO_PORT
, echo_handle
);
85 dissector_add_uint_with_preference("tcp.port", ECHO_PORT
, echo_handle
);
89 * Editor modelines - https://www.wireshark.org/tools/modelines.html
94 * indent-tabs-mode: nil
97 * ex: set shiftwidth=2 tabstop=8 expandtab:
98 * :indentSize=2:tabSize=8:noTabs=true: