aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-xot.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-xot.c')
-rw-r--r--epan/dissectors/packet-xot.c103
1 files changed, 48 insertions, 55 deletions
diff --git a/epan/dissectors/packet-xot.c b/epan/dissectors/packet-xot.c
index e6f78d4c10..c8b6543aea 100644
--- a/epan/dissectors/packet-xot.c
+++ b/epan/dissectors/packet-xot.c
@@ -13,8 +13,10 @@
#include "config.h"
#include <epan/packet.h>
-#include "packet-tcp.h"
#include <epan/prefs.h>
+#include <epan/conversation.h>
+
+#include "packet-tcp.h"
#define TCP_PORT_XOT 1998
#define XOT_HEADER_LENGTH 4
@@ -60,29 +62,30 @@ static const value_string xot_pvc_status_vals[] = {
{ 0, NULL}
};
-static gint proto_xot = -1;
-static gint ett_xot = -1;
-static gint hf_xot_version = -1;
-static gint hf_xot_length = -1;
-
-static gint hf_x25_gfi = -1;
-static gint hf_x25_lcn = -1;
-static gint hf_x25_type = -1;
-
-static gint hf_xot_pvc_version = -1;
-static gint hf_xot_pvc_status = -1;
-static gint hf_xot_pvc_init_itf_name_len = -1;
-static gint hf_xot_pvc_init_lcn = -1;
-static gint hf_xot_pvc_resp_itf_name_len = -1;
-static gint hf_xot_pvc_resp_lcn = -1;
-static gint hf_xot_pvc_send_inc_window = -1;
-static gint hf_xot_pvc_send_out_window = -1;
-static gint hf_xot_pvc_send_inc_pkt_size = -1;
-static gint hf_xot_pvc_send_out_pkt_size = -1;
-static gint hf_xot_pvc_init_itf_name = -1;
-static gint hf_xot_pvc_resp_itf_name = -1;
+static gint proto_xot;
+static gint ett_xot;
+static gint hf_xot_version;
+static gint hf_xot_length;
+
+static gint hf_x25_gfi;
+static gint hf_x25_lcn;
+static gint hf_x25_type;
+
+static gint hf_xot_pvc_version;
+static gint hf_xot_pvc_status;
+static gint hf_xot_pvc_init_itf_name_len;
+static gint hf_xot_pvc_init_lcn;
+static gint hf_xot_pvc_resp_itf_name_len;
+static gint hf_xot_pvc_resp_lcn;
+static gint hf_xot_pvc_send_inc_window;
+static gint hf_xot_pvc_send_out_window;
+static gint hf_xot_pvc_send_inc_pkt_size;
+static gint hf_xot_pvc_send_out_pkt_size;
+static gint hf_xot_pvc_init_itf_name;
+static gint hf_xot_pvc_resp_itf_name;
static dissector_handle_t xot_handle;
+static dissector_handle_t xot_tcp_handle;
static dissector_handle_t x25_handle;
@@ -251,12 +254,11 @@ static int dissect_xot_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
pkt_size = tvb_get_guint8(tvb, hdr_offset);
proto_tree_add_uint_format_value(xot_tree, hf_xot_pvc_send_out_pkt_size, tvb, hdr_offset, 1, pkt_size, "2^%u", pkt_size);
hdr_offset += 1;
- proto_tree_add_item(xot_tree, hf_xot_pvc_init_itf_name, tvb, hdr_offset, init_itf_name_len, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(xot_tree, hf_xot_pvc_init_itf_name, tvb, hdr_offset, init_itf_name_len, ENC_ASCII);
hdr_offset += init_itf_name_len;
- proto_tree_add_item(xot_tree, hf_xot_pvc_resp_itf_name, tvb, hdr_offset, resp_itf_name_len, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(xot_tree, hf_xot_pvc_resp_itf_name, tvb, hdr_offset, resp_itf_name_len, ENC_ASCII);
} else {
- next_tvb = tvb_new_subset_length_caplen(tvb, offset,
- MIN(plen, tvb_captured_length_remaining(tvb, offset)), plen);
+ next_tvb = tvb_new_subset_length(tvb, offset, plen);
call_dissector(x25_handle, next_tvb, pinfo, tree);
}
}
@@ -283,55 +285,45 @@ static int dissect_xot_mult(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
while (offset <= offset_max - XOT_HEADER_LENGTH){
int plen = get_xot_pdu_len(pinfo, tvb, offset, NULL);
- next_tvb = tvb_new_subset_length_caplen(tvb, offset,plen, plen);
- /*MIN(plen,tvb_captured_length_remaining(tvb, offset)),plen*/
+ next_tvb = tvb_new_subset_length(tvb, offset, plen);
dissect_xot_pdu(next_tvb, pinfo, tree, data);
offset += plen;
}
return tvb_captured_length(tvb);
}
-static int dissect_xot_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
-{
- int tvb_len = tvb_captured_length(tvb);
- int len = 0;
-
- if (tvb_len >= 2 && tvb_get_ntohs(tvb,0) != XOT_VERSION) {
- return 0;
- }
+static int
+dissect_xot_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
+{
if (!x25_desegment || !xot_desegment){
tcp_dissect_pdus(tvb, pinfo, tree, xot_desegment,
XOT_HEADER_LENGTH,
get_xot_pdu_len,
dissect_xot_pdu, data);
- len=get_xot_pdu_len(pinfo, tvb, 0, NULL);
} else {
/* Use length version that "peeks" into X25, possibly several XOT packets */
tcp_dissect_pdus(tvb, pinfo, tree, xot_desegment,
XOT_HEADER_LENGTH,
get_xot_pdu_len_mult,
dissect_xot_mult, data);
- len=get_xot_pdu_len_mult(pinfo, tvb, 0, NULL);
}
- /*As tcp_dissect_pdus will not report the success/failure, we have to compute
- again */
- if (len < XOT_HEADER_LENGTH) {
- /* TCP has reported bounds error */
- len = 0;
- } else if (tvb_len < XOT_HEADER_LENGTH) {
- pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
- len=tvb_len - XOT_HEADER_LENGTH; /* bytes missing */
- } else if (tvb_len < len) {
- if (x25_desegment){
- /* As the "fixed_len" is not fixed here, just request new segments */
- pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
- } else {
- pinfo->desegment_len = len - tvb_len;
- }
- len=tvb_len - len; /* bytes missing */
+ return tvb_reported_length(tvb);
+}
+
+static int dissect_xot_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
+{
+ int tvb_len = tvb_captured_length(tvb);
+ conversation_t *conversation;
+
+ if (tvb_len < 2 || tvb_get_ntohs(tvb, 0) != XOT_VERSION) {
+ return 0;
}
- return len;
+
+ conversation = find_or_create_conversation(pinfo);
+ conversation_set_dissector(conversation, xot_tcp_handle);
+
+ return dissect_xot_tcp(tvb, pinfo, tree, data);
}
/* Register the protocol with Wireshark */
@@ -417,6 +409,7 @@ proto_register_xot(void)
proto_register_field_array(proto_xot, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
xot_handle = register_dissector("xot", dissect_xot_tcp_heur, proto_xot);
+ xot_tcp_handle = create_dissector_handle(dissect_xot_tcp, proto_xot);
xot_module = prefs_register_protocol(proto_xot, NULL);
prefs_register_bool_preference(xot_module, "desegment",