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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
33 #include <epan/strutil.h>
35 #define TCP_PORT_GIFT 1213
37 static int proto_gift
= -1;
38 static int hf_gift_response
= -1;
39 static int hf_gift_request
= -1;
41 static gint ett_gift
= -1;
42 static gint ett_gift_cmd
= -1;
45 dissect_gift(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
47 proto_item
*ti
, *hidden_item
;
48 proto_tree
*gift_tree
, *cmd_tree
;
55 const guchar
*next_token
;
57 /* set "Protocol" column text */
58 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "giFT");
60 /* determine whether it is a request to or response from the server */
61 if (pinfo
->match_uint
== pinfo
->destport
)
66 linelen
= tvb_find_line_end(tvb
, offset
, -1, &next_offset
, FALSE
);
67 line
= tvb_get_ptr(tvb
, offset
, linelen
);
69 /* set "Info" column text */
70 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s: %s",
71 is_request
? "Request" : "Response",
72 format_text(line
, linelen
));
74 /* if tree != NULL, build protocol tree */
76 ti
= proto_tree_add_item(tree
, proto_gift
, tvb
, 0, -1, ENC_NA
);
77 gift_tree
= proto_item_add_subtree(ti
, ett_gift
);
80 hidden_item
= proto_tree_add_boolean(gift_tree
, hf_gift_request
, tvb
, 0, 0, TRUE
);
82 hidden_item
= proto_tree_add_boolean(gift_tree
, hf_gift_response
, tvb
, 0, 0, TRUE
);
84 PROTO_ITEM_SET_HIDDEN(hidden_item
);
86 ti
= proto_tree_add_text(gift_tree
, tvb
, offset
, next_offset
- offset
, "%s",
87 tvb_format_text(tvb
, offset
, next_offset
- offset
));
88 cmd_tree
= proto_item_add_subtree(ti
, ett_gift_cmd
);
90 tokenlen
= get_token_len(line
, line
+ linelen
, &next_token
);
93 proto_tree_add_text(cmd_tree
, tvb
, offset
,
94 tokenlen
, "Request Command: %s",
95 format_text(line
, tokenlen
));
97 proto_tree_add_text(cmd_tree
, tvb
, offset
,
98 tokenlen
, "Response Command: %s",
99 format_text(line
, tokenlen
));
101 offset
+= (gint
) (next_token
- line
);
102 linelen
-= (int) (next_token
- line
);
108 proto_tree_add_text(cmd_tree
, tvb
, offset
,
109 linelen
, "Request Arg: %s",
110 format_text(line
, linelen
));
112 proto_tree_add_text(cmd_tree
, tvb
, offset
,
113 linelen
, "Response Arg: %s",
114 format_text(line
, linelen
));
121 proto_register_gift(void)
123 static hf_register_info hf
[] = {
125 { "Response", "gift.response", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "TRUE if giFT response", HFILL
}
128 { "Request", "gift.request", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "TRUE if giFT request", HFILL
}
132 static gint
*ett
[] = {
137 proto_gift
= proto_register_protocol("giFT Internet File Transfer",
140 proto_register_field_array(proto_gift
, hf
, array_length(hf
));
141 proto_register_subtree_array(ett
, array_length(ett
));
145 proto_reg_handoff_gift(void)
147 dissector_handle_t gift_handle
;
149 gift_handle
= create_dissector_handle(dissect_gift
, proto_gift
);
150 dissector_add_uint("tcp.port", TCP_PORT_GIFT
, gift_handle
);