Fix dissector TCP support
This commit is contained in:
@@ -35,6 +35,10 @@
|
|||||||
#include "wivrn_packets.h"
|
#include "wivrn_packets.h"
|
||||||
|
|
||||||
#if WIRESHARK_VERSION_MAJOR > 4 || (WIRESHARK_VERSION_MAJOR == 4 && WIRESHARK_VERSION_MINOR >= 4)
|
#if WIRESHARK_VERSION_MAJOR > 4 || (WIRESHARK_VERSION_MAJOR == 4 && WIRESHARK_VERSION_MINOR >= 4)
|
||||||
|
static inline uint32_t get_uint32(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
||||||
|
{
|
||||||
|
return tvb_get_uint32(tvb, offset, encoding);
|
||||||
|
}
|
||||||
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
||||||
{
|
{
|
||||||
return tvb_get_uint16(tvb, offset, encoding);
|
return tvb_get_uint16(tvb, offset, encoding);
|
||||||
@@ -45,6 +49,10 @@ static inline uint16_t get_uint8(tvbuff_t * tvb, const int offset)
|
|||||||
return tvb_get_uint8(tvb, offset);
|
return tvb_get_uint8(tvb, offset);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
static inline uint32_t get_uint32(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
||||||
|
{
|
||||||
|
return tvb_get_guint32(tvb, offset, encoding);
|
||||||
|
}
|
||||||
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
|
||||||
{
|
{
|
||||||
return tvb_get_guint16(tvb, offset, encoding);
|
return tvb_get_guint16(tvb, offset, encoding);
|
||||||
@@ -794,19 +802,38 @@ int dissect_wivrn(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, vo
|
|||||||
/* Clear out stuff in the info column */
|
/* Clear out stuff in the info column */
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
col_clear(pinfo->cinfo, COL_INFO);
|
||||||
|
|
||||||
proto_item * ti = proto_tree_add_item(tree, proto, tvb, 0, -1, ENC_NA);
|
int offset = 0;
|
||||||
proto_tree * subtree = proto_item_add_subtree(ti, subtree_handles.at(""));
|
|
||||||
int start = 0;
|
|
||||||
|
|
||||||
if (tcp)
|
while (true)
|
||||||
start += sizeof(uint16_t);
|
{
|
||||||
|
proto_item * ti = proto_tree_add_item(tree, proto, tvb, 0, -1, ENC_NA);
|
||||||
|
proto_tree * subtree = proto_item_add_subtree(ti, subtree_handles.at(""));
|
||||||
|
|
||||||
if (pinfo->destport == wivrn::default_port)
|
int remaining = tvb_reported_length_remaining(tvb, offset);
|
||||||
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, start);
|
|
||||||
else
|
|
||||||
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, start);
|
|
||||||
|
|
||||||
return tvb_captured_length(tvb);
|
if (tcp)
|
||||||
|
{
|
||||||
|
if (remaining < sizeof(uint32_t))
|
||||||
|
return remaining - sizeof(uint32_t);
|
||||||
|
remaining -= sizeof(uint32_t);
|
||||||
|
|
||||||
|
uint32_t size = get_uint32(tvb, offset, ENC_LITTLE_ENDIAN);
|
||||||
|
if (remaining < size)
|
||||||
|
return remaining - size;
|
||||||
|
offset += sizeof(uint32_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pinfo->destport == wivrn::default_port)
|
||||||
|
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, offset);
|
||||||
|
else
|
||||||
|
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, offset);
|
||||||
|
|
||||||
|
if (not tcp)
|
||||||
|
return offset;
|
||||||
|
|
||||||
|
if (tvb_reported_length(tvb) <= offset)
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int dissect_wivrn_udp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, void * data _U_)
|
int dissect_wivrn_udp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, void * data _U_)
|
||||||
|
|||||||
Reference in New Issue
Block a user