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 * $Id: packet-echo.c,v 1.1 2003/06/25 13:42:18 deniel Exp $
11 * Ethereal - Network traffic analyzer
12 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #include <epan/packet.h>
41 static int proto_echo = -1;
43 static int hf_echo_data = -1;
44 static int hf_echo_request = -1;
45 static int hf_echo_response = -1;
47 static gint ett_echo = -1;
49 static void dissect_echo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
52 proto_tree *echo_tree = NULL;
55 gboolean request = FALSE;
56 const char *data = tvb_get_ptr(tvb, offset, -1);
58 if (pinfo->destport == ECHO_PORT) {
62 if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
63 col_add_str(pinfo->cinfo, COL_PROTOCOL, "ECHO");
66 if (check_col(pinfo->cinfo, COL_INFO)) {
67 col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
68 (request) ? "Request" : "Response");
73 ti = proto_tree_add_item(tree, proto_echo, tvb, offset, -1, FALSE);
74 echo_tree = proto_item_add_subtree(ti, ett_echo);
77 proto_tree_add_boolean_hidden(echo_tree, hf_echo_request, tvb, 0, 0, 1);
80 proto_tree_add_boolean_hidden(echo_tree, hf_echo_response, tvb, 0, 0, 1);
83 proto_tree_add_bytes(echo_tree, hf_echo_data, tvb, offset, -1, data);
89 void proto_register_echo(void)
92 static hf_register_info hf[] = {
94 { "Echo data", "echo.data",
95 FT_BYTES, BASE_HEX, NULL, 0x0,
96 "Echo data", HFILL }},
98 { "Echo request", "echo.request",
99 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
100 "Echo data", HFILL }},
102 { "Echo response","echo.response",
103 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
104 "Echo data", HFILL }}
107 static gint *ett[] = {
111 proto_echo = proto_register_protocol("Echo", "ECHO", "echo");
112 proto_register_field_array(proto_echo, hf, array_length(hf));
113 proto_register_subtree_array(ett, array_length(ett));
117 void proto_reg_handoff_echo(void)
120 dissector_handle_t echo_handle = NULL;
122 echo_handle = create_dissector_handle(dissect_echo, proto_echo);
124 dissector_add("udp.port", ECHO_PORT, echo_handle);
125 dissector_add("tcp.port", ECHO_PORT, echo_handle);