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>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include <epan/packet.h>
37 void proto_register_echo(void);
38 void proto_reg_handoff_echo(void);
40 static int proto_echo
= -1;
42 static int hf_echo_data
= -1;
43 static int hf_echo_request
= -1;
44 static int hf_echo_response
= -1;
46 static gint ett_echo
= -1;
48 static void dissect_echo(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
52 gboolean request
= FALSE
;
54 if (pinfo
->destport
== ECHO_PORT
) {
58 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ECHO");
60 col_set_str(pinfo
->cinfo
, COL_INFO
,
61 (request
) ? "Request" : "Response");
64 proto_tree
*echo_tree
;
65 proto_item
*ti
, *hidden_item
;
67 ti
= proto_tree_add_item(tree
, proto_echo
, tvb
, offset
, -1, ENC_NA
);
68 echo_tree
= proto_item_add_subtree(ti
, ett_echo
);
71 hidden_item
= proto_tree_add_boolean(echo_tree
, hf_echo_request
, tvb
, 0, 0, 1);
73 hidden_item
= proto_tree_add_boolean(echo_tree
, hf_echo_response
, tvb
, 0, 0, 1);
75 PROTO_ITEM_SET_HIDDEN(hidden_item
);
77 proto_tree_add_item(echo_tree
, hf_echo_data
, tvb
, offset
, -1, ENC_NA
);
83 void proto_register_echo(void)
86 static hf_register_info hf
[] = {
88 { "Echo data", "echo.data",
89 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
92 { "Echo request", "echo.request",
93 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
94 "Echo data", HFILL
}},
96 { "Echo response","echo.response",
97 FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0,
101 static gint
*ett
[] = {
105 proto_echo
= proto_register_protocol("Echo", "ECHO", "echo");
106 proto_register_field_array(proto_echo
, hf
, array_length(hf
));
107 proto_register_subtree_array(ett
, array_length(ett
));
111 void proto_reg_handoff_echo(void)
114 dissector_handle_t echo_handle
;
116 echo_handle
= create_dissector_handle(dissect_echo
, proto_echo
);
118 dissector_add_uint("udp.port", ECHO_PORT
, echo_handle
);
119 dissector_add_uint("tcp.port", ECHO_PORT
, echo_handle
);