2 * Routines for giFT Internet File Transfer dissection
3 * Copyright 2000, Jon Oberheide <jon@oberheide.org>
5 * See http://www.giftproject.org/
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
37 #include <epan/strutil.h>
39 #define TCP_PORT_GIFT 1213
41 static int proto_gift = -1;
42 static int hf_gift_response = -1;
43 static int hf_gift_request = -1;
45 static gint ett_gift = -1;
46 static gint ett_gift_cmd = -1;
49 dissect_gift(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
51 proto_item *ti, *hidden_item;
52 proto_tree *gift_tree, *cmd_tree;
59 const guchar *next_token;
61 /* set "Protocol" column text */
62 if (check_col(pinfo->cinfo, COL_PROTOCOL))
63 col_set_str(pinfo->cinfo, COL_PROTOCOL, "giFT");
65 /* determine whether it is a request to or response from the server */
66 if (pinfo->match_port == pinfo->destport)
71 linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
72 line = tvb_get_ptr(tvb, offset, linelen);
74 /* clear the "Info" column */
75 if (check_col(pinfo->cinfo, COL_INFO))
76 col_clear(pinfo->cinfo, COL_INFO);
78 /* set "Info" column text */
79 if (check_col(pinfo->cinfo, COL_INFO))
80 col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
81 is_request ? "Request" : "Response",
82 format_text(line, linelen));
84 /* if tree != NULL, build protocol tree */
86 ti = proto_tree_add_item(tree, proto_gift, tvb, 0, -1, FALSE);
87 gift_tree = proto_item_add_subtree(ti, ett_gift);
90 hidden_item = proto_tree_add_boolean(gift_tree, hf_gift_request, tvb, 0, 0, TRUE);
92 hidden_item = proto_tree_add_boolean(gift_tree, hf_gift_response, tvb, 0, 0, TRUE);
94 PROTO_ITEM_SET_HIDDEN(hidden_item);
96 ti = proto_tree_add_text(gift_tree, tvb, offset, next_offset - offset, "%s",
97 tvb_format_text(tvb, offset, next_offset - offset));
98 cmd_tree = proto_item_add_subtree(ti, ett_gift_cmd);
100 tokenlen = get_token_len(line, line + linelen, &next_token);
103 proto_tree_add_text(cmd_tree, tvb, offset,
104 tokenlen, "Request Command: %s",
105 format_text(line, tokenlen));
107 proto_tree_add_text(cmd_tree, tvb, offset,
108 tokenlen, "Response Command: %s",
109 format_text(line, tokenlen));
111 offset += (gint) (next_token - line);
112 linelen -= (int) (next_token - line);
118 proto_tree_add_text(cmd_tree, tvb, offset,
119 linelen, "Request Arg: %s",
120 format_text(line, linelen));
122 proto_tree_add_text(cmd_tree, tvb, offset,
123 linelen, "Response Arg: %s",
124 format_text(line, linelen));
131 proto_register_gift(void)
133 static hf_register_info hf[] = {
135 { "Response", "gift.response", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "TRUE if giFT response", HFILL }
138 { "Request", "gift.request", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "TRUE if giFT request", HFILL }
142 static gint *ett[] = {
147 proto_gift = proto_register_protocol("giFT Internet File Transfer",
150 proto_register_field_array(proto_gift, hf, array_length(hf));
151 proto_register_subtree_array(ett, array_length(ett));
155 proto_reg_handoff_gift(void)
157 dissector_handle_t gift_handle;
159 gift_handle = create_dissector_handle(dissect_gift, proto_gift);
160 dissector_add("tcp.port", TCP_PORT_GIFT, gift_handle);