2 * Routines for rsh packet disassembly
4 * Robert Tsai <rtsai@netapp.com>
5 * Liberally copied from packet-http.c, by Guy Harris <guy@alum.mit.edu>
7 * $Id: packet-rsh.c,v 1.4 2000/09/11 16:16:02 gram Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@zing.org>
11 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #ifdef HAVE_SYS_TYPES_H
36 #include <sys/types.h>
43 static int proto_rsh = -1;
44 static int hf_rsh_response = -1;
45 static int hf_rsh_request = -1;
46 static gint ett_rsh = -1;
48 #define TCP_PORT_RSH 514
51 dissect_rsh(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
55 const u_char *data, *dataend;
56 const u_char *lineend, *eol;
59 OLD_CHECK_DISPLAY_AS_DATA(proto_rsh, pd, offset, fd, tree);
62 dataend = data + END_OF_FRAME;
64 if (check_col(fd, COL_PROTOCOL))
65 col_add_str(fd, COL_PROTOCOL, "RSH");
66 if (check_col(fd, COL_INFO)) {
67 /* Put the first line from the buffer into the summary. */
68 lineend = find_line_end(data, dataend, &eol);
69 linelen = lineend - data;
70 col_add_str(fd, COL_INFO, format_text(data, linelen));
73 ti = proto_tree_add_item(tree, proto_rsh, NullTVB, offset,
75 rsh_tree = proto_item_add_subtree(ti, ett_rsh);
77 while (data < dataend) {
79 * Find the end of the line.
81 lineend = find_line_end(data, dataend, &eol);
82 linelen = lineend - data;
87 proto_tree_add_text(rsh_tree, NullTVB, offset,
88 linelen, "%s", format_text(data, linelen));
93 if (pi.match_port == pi.destport)
94 proto_tree_add_boolean_hidden(rsh_tree,
95 hf_rsh_request, NullTVB, 0, 0, 1);
97 proto_tree_add_boolean_hidden(rsh_tree,
98 hf_rsh_response, NullTVB, 0, 0, 1);
101 old_dissect_data(&pd[offset], offset, fd, rsh_tree);
106 proto_register_rsh(void)
109 static hf_register_info hf[] = {
111 { "Response", "rsh.response",
112 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
113 "TRUE if rsh response" }},
115 { "Request", "rsh.request",
116 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
117 "TRUE if rsh request" }},
120 static gint *ett[] = {
124 proto_rsh = proto_register_protocol("Remote Shell", "rsh");
125 proto_register_field_array(proto_rsh, hf, array_length(hf));
126 proto_register_subtree_array(ett, array_length(ett));
130 proto_reg_handoff_rsh(void)
132 old_dissector_add("tcp.port", TCP_PORT_RSH, dissect_rsh);