2 * Routines for giFT Internet File Transfer dissection
3 * Copyright 2000, Jon Oberheide <jon@oberheide.org>
5 * See http://www.giftproject.org/
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include <epan/strutil.h>
19 void proto_register_gift(void);
20 void proto_reg_handoff_gift(void);
22 static dissector_handle_t gift_handle
;
24 #define TCP_PORT_GIFT 1213 /* Not IANA registered */
26 static int proto_gift
;
27 static int hf_gift_response
;
28 static int hf_gift_request
;
29 static int hf_gift_response_cmd
;
30 static int hf_gift_response_arg
;
31 static int hf_gift_request_cmd
;
32 static int hf_gift_request_arg
;
35 static int ett_gift_cmd
;
38 dissect_gift(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
40 proto_item
*ti
, *hidden_item
;
41 proto_tree
*gift_tree
, *cmd_tree
;
44 const unsigned char *line
;
48 const unsigned char *next_token
;
50 /* set "Protocol" column text */
51 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "giFT");
53 /* determine whether it is a request to or response from the server */
54 if (pinfo
->match_uint
== pinfo
->destport
)
59 linelen
= tvb_find_line_end(tvb
, offset
, -1, &next_offset
, false);
60 line
= tvb_get_ptr(tvb
, offset
, linelen
);
62 /* set "Info" column text */
63 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s: %s",
64 is_request
? "Request" : "Response",
65 format_text(pinfo
->pool
, line
, linelen
));
67 /* if tree != NULL, build protocol tree */
69 ti
= proto_tree_add_item(tree
, proto_gift
, tvb
, 0, -1, ENC_NA
);
70 gift_tree
= proto_item_add_subtree(ti
, ett_gift
);
73 hidden_item
= proto_tree_add_boolean(gift_tree
, hf_gift_request
, tvb
, 0, 0, true);
75 hidden_item
= proto_tree_add_boolean(gift_tree
, hf_gift_response
, tvb
, 0, 0, true);
77 proto_item_set_hidden(hidden_item
);
79 ti
= proto_tree_add_format_text(gift_tree
, tvb
, offset
, next_offset
- offset
);
80 cmd_tree
= proto_item_add_subtree(ti
, ett_gift_cmd
);
82 tokenlen
= get_token_len(line
, line
+ linelen
, &next_token
);
85 proto_tree_add_string(cmd_tree
, hf_gift_request_cmd
, tvb
, offset
,
86 tokenlen
, format_text(pinfo
->pool
, line
, tokenlen
));
88 proto_tree_add_string(cmd_tree
, hf_gift_response_cmd
, tvb
, offset
,
89 tokenlen
, format_text(pinfo
->pool
, line
, tokenlen
));
91 offset
+= (int) (next_token
- line
);
92 linelen
-= (int) (next_token
- line
);
98 proto_tree_add_string(cmd_tree
, hf_gift_request_arg
, tvb
, offset
,
99 linelen
, format_text(pinfo
->pool
, line
, linelen
));
101 proto_tree_add_string(cmd_tree
, hf_gift_response_arg
, tvb
, offset
,
102 linelen
, format_text(pinfo
->pool
, line
, linelen
));
106 return tvb_captured_length(tvb
);
110 proto_register_gift(void)
112 static hf_register_info hf
[] = {
114 { "Response", "gift.response", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "true if giFT response", HFILL
}
117 { "Request", "gift.request", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "true if giFT request", HFILL
}
119 { &hf_gift_response_cmd
,
120 { "Response Command", "gift.response_cmd", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
122 { &hf_gift_response_arg
,
123 { "Response Arg", "gift.response_arg", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
125 { &hf_gift_request_cmd
,
126 { "Request Command", "gift.request_cmd", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
128 { &hf_gift_request_arg
,
129 { "Request Arg", "gift.request_arg", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
133 static int *ett
[] = {
138 proto_gift
= proto_register_protocol("giFT Internet File Transfer",
141 proto_register_field_array(proto_gift
, hf
, array_length(hf
));
142 proto_register_subtree_array(ett
, array_length(ett
));
144 gift_handle
= register_dissector("gift", dissect_gift
, proto_gift
);
148 proto_reg_handoff_gift(void)
150 dissector_add_uint_with_preference("tcp.port", TCP_PORT_GIFT
, gift_handle
);
154 * Editor modelines - https://www.wireshark.org/tools/modelines.html
159 * indent-tabs-mode: t
162 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
163 * :indentSize=8:tabSize=8:noTabs=false: