forked from osmocom/wireshark
ZVT: Use standard TCP segment reassemble support function
Fixes #17177
(cherry picked from commit 616d44cbb6
)
This commit is contained in:
parent
e5478357e2
commit
303a7cc58f
|
@ -34,6 +34,7 @@
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
#include <epan/addr_resolv.h>
|
||||||
#include <epan/expert.h>
|
#include <epan/expert.h>
|
||||||
|
#include "packet-tcp.h"
|
||||||
|
|
||||||
/* special characters of the serial transport protocol */
|
/* special characters of the serial transport protocol */
|
||||||
#define STX 0x02
|
#define STX 0x02
|
||||||
|
@ -948,59 +949,26 @@ dissect_zvt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
||||||
return zvt_len;
|
return zvt_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static guint get_zvt_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
|
||||||
|
{
|
||||||
|
guint len = tvb_get_guint8(tvb, offset+2);
|
||||||
|
if (len == 0xFF)
|
||||||
|
if (tvb_captured_length_remaining(tvb, offset) >= 5)
|
||||||
|
len = tvb_get_letohs(tvb, offset+3) + 5;
|
||||||
|
else
|
||||||
|
len = 0;
|
||||||
|
else
|
||||||
|
len += 3;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dissect_zvt_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
dissect_zvt_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
||||||
{
|
{
|
||||||
gint offset = 0, zvt_len = 0, ret;
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, ZVT_APDU_MIN_LEN,
|
||||||
proto_item *zvt_ti;
|
get_zvt_message_len, dissect_zvt, data);
|
||||||
proto_tree *zvt_tree;
|
return tvb_captured_length(tvb);
|
||||||
|
|
||||||
if (tvb_captured_length(tvb) < ZVT_APDU_MIN_LEN) {
|
|
||||||
if (pinfo->can_desegment) {
|
|
||||||
pinfo->desegment_offset = offset;
|
|
||||||
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return zvt_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid_ctrl_field(tvb, 0))
|
|
||||||
return 0; /* reject the packet */
|
|
||||||
|
|
||||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZVT");
|
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
|
||||||
zvt_ti = proto_tree_add_protocol_format(tree, proto_zvt,
|
|
||||||
tvb, 0, -1,
|
|
||||||
"ZVT Kassenschnittstelle: Transport Protocol TCP/IP");
|
|
||||||
zvt_tree = proto_item_add_subtree(zvt_ti, ett_zvt);
|
|
||||||
|
|
||||||
while (tvb_captured_length_remaining(tvb, offset) > 0) {
|
|
||||||
ret = dissect_zvt_apdu(tvb, offset, pinfo, zvt_tree);
|
|
||||||
if (ret == 0) {
|
|
||||||
/* not a valid APDU
|
|
||||||
mark the bytes that we consumed and exit, give
|
|
||||||
other dissectors a chance to try the remaining
|
|
||||||
bytes */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (ret < 0) {
|
|
||||||
/* not enough data - ask the TCP layer for more */
|
|
||||||
|
|
||||||
if (pinfo->can_desegment) {
|
|
||||||
pinfo->desegment_offset = offset;
|
|
||||||
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
offset += ret;
|
|
||||||
zvt_len += ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
proto_item_set_len(zvt_ti, zvt_len);
|
|
||||||
return zvt_len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue