Exported PDU dissector improvements

This commit is contained in:
David Perry 2023-01-26 18:02:23 +00:00 committed by A Wireshark GitLab Utility
parent ef2ea2acdd
commit db010b5a27
1 changed files with 87 additions and 15 deletions

View File

@ -16,6 +16,7 @@
#include <epan/to_str.h>
#include <epan/address_types.h>
#include <epan/exported_pdu.h>
#include <epan/expert.h>
#include "packet-mtp3.h"
#include "packet-dvbci.h"
#include "packet-tcp.h"
@ -39,6 +40,13 @@ static int hf_exported_pdu_heur_prot_name = -1;
static int hf_exported_pdu_dis_table_name = -1;
static int hf_exported_pdu_p2p_dir = -1;
static int hf_exported_pdu_dissector_data = -1;
static int hf_exported_pdu_ddata_version = -1;
static int hf_exported_pdu_ddata_seq = -1;
static int hf_exported_pdu_ddata_nxtseq = -1;
static int hf_exported_pdu_ddata_lastackseq = -1;
static int hf_exported_pdu_ddata_is_reassembled = -1;
static int hf_exported_pdu_ddata_flags = -1;
static int hf_exported_pdu_ddata_urgent_pointer = -1;
static int hf_exported_pdu_ipv4_src = -1;
static int hf_exported_pdu_ipv4_dst = -1;
static int hf_exported_pdu_ipv6_src = -1;
@ -63,6 +71,9 @@ static int ss7pc_address_type = -1;
static dissector_handle_t exported_pdu_handle;
static expert_field ei_exported_pdu_unsupported_version = EI_INIT;
static expert_field ei_exported_pdu_unknown_tag = EI_INIT;
#define EXPORTED_PDU_NEXT_DISSECTOR_STR 0
#define EXPORTED_PDU_NEXT_HEUR_DISSECTOR_STR 1
#define EXPORTED_PDU_NEXT_DIS_TABLE_STR 2
@ -309,20 +320,30 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
case EXP_PDU_TAG_TCP_INFO_DATA:
{
struct tcpinfo* tcpdata = wmem_new0(pinfo->pool, struct tcpinfo);
guint16 version;
proto_tree_add_item(tag_tree, hf_exported_pdu_dissector_data, tvb, offset, tag_len, ENC_NA);
guint32 u32;
version = tvb_get_ntohs(tvb, offset);
DISSECTOR_ASSERT(version == 1); /* Only version 1 is currently supported */
item = proto_tree_add_item(tag_tree, hf_exported_pdu_dissector_data, tvb, offset, tag_len, ENC_NA);
tcpdata->seq = tvb_get_ntohl(tvb, offset+2);
tcpdata->nxtseq = tvb_get_ntohl(tvb, offset+6);
tcpdata->lastackseq = tvb_get_ntohl(tvb, offset+10);
tcpdata->is_reassembled = tvb_get_guint8(tvb, offset+14);
tcpdata->flags = tvb_get_ntohs(tvb, offset+15);
tcpdata->urgent_pointer = tvb_get_ntohs(tvb, offset+17);
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_version, tvb, offset, 2, ENC_BIG_ENDIAN, &u32);
if (u32 == 1) {
/* Keep old bytes-only field, but hide it */
proto_item_set_hidden(item);
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_seq, tvb, offset+2, 4, ENC_BIG_ENDIAN, &tcpdata->seq);
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_nxtseq, tvb, offset+6, 4, ENC_BIG_ENDIAN, &tcpdata->nxtseq);
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_lastackseq, tvb, offset+10, 4, ENC_BIG_ENDIAN, &tcpdata->lastackseq);
proto_tree_add_item_ret_boolean(tag_tree, hf_exported_pdu_ddata_is_reassembled, tvb, offset+14, 1, ENC_BIG_ENDIAN, &tcpdata->is_reassembled);
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_flags, tvb, offset+15, 2, ENC_BIG_ENDIAN, &u32);
tcpdata->flags = u32;
proto_tree_add_item_ret_uint(tag_tree, hf_exported_pdu_ddata_urgent_pointer, tvb, offset+17, 2, ENC_BIG_ENDIAN, &u32);
tcpdata->urgent_pointer = u32;
dissector_data = tcpdata;
}
else { /* Only version 1 is currently supported */
proto_tree_add_expert(tag_tree, pinfo, &ei_exported_pdu_unsupported_version, tvb, offset, tag_len);
}
dissector_data = tcpdata;
}
break;
case EXP_PDU_TAG_P2P_DIRECTION:
@ -333,7 +354,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
break;
default:
proto_tree_add_item(tag_tree, hf_exported_pdu_unknown_tag_val, tvb, offset, tag_len, ENC_NA);
/* Add an expert item too? */
proto_tree_add_expert(tag_tree, pinfo, &ei_exported_pdu_unknown_tag, tvb, offset, tag_len);
break;
}
@ -436,10 +457,45 @@ proto_register_exported_pdu(void)
NULL, HFILL }
},
{ &hf_exported_pdu_dissector_data,
{ "Dissector Data", "exported_pdu.dissector_data",
{ "TCP Dissector Data", "exported_pdu.tcp_dissector_data",
FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_version,
{ "TCP Dissector Data version", "exported_pdu.tcp_dissector_data.version",
FT_UINT16, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_seq,
{ "Sequence number", "exported_pdu.tcp_dissector_data.seq",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_nxtseq,
{ "Next sequence number", "exported_pdu.tcp_dissector_data.nxtseq",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_lastackseq,
{ "Last acked sequence number", "exported_pdu.tcp_dissector_data.lastackseq",
FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_is_reassembled,
{ "Is reassembled", "exported_pdu.tcp_dissector_data.is_reassembled",
FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_flags,
{ "Flags", "exported_pdu.tcp_dissector_data.flags",
FT_UINT16, BASE_HEX, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ddata_urgent_pointer,
{ "Urgent pointer", "exported_pdu.tcp_dissector_data.urgent_pointer",
FT_UINT16, BASE_DEC, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_ipv4_src,
{ "IPv4 Src", "exported_pdu.ipv4_src",
FT_IPv4, BASE_NONE, NULL, 0,
@ -496,8 +552,8 @@ proto_register_exported_pdu(void)
NULL, HFILL }
},
{ &hf_exported_pdu_exported_pdu,
{ "Exported PDU", "exported_pdu.exported_pdu",
FT_BYTES, BASE_NONE, NULL, 0,
{ "Exported PDU data", "exported_pdu.exported_pdu",
FT_BYTES, BASE_NONE|BASE_NO_DISPLAY_VALUE, NULL, 0,
NULL, HFILL }
},
{ &hf_exported_pdu_dis_table_val,
@ -518,10 +574,26 @@ proto_register_exported_pdu(void)
&ett_exported_pdu_tag
};
/* Setup expert information */
static ei_register_info ei[] = {
{ &ei_exported_pdu_unsupported_version,
{ "exported_pdu.tcp_dissector_data.version.invalid",
PI_PROTOCOL, PI_WARN, "Unsupported TCP Dissector Data version", EXPFILL }
},
{ &ei_exported_pdu_unknown_tag,
{ "exported_pdu.tag.unknown",
PI_PROTOCOL, PI_WARN, "Unrecognized tag", EXPFILL }
},
};
expert_module_t *expert_exported_pdu;
/* Register the protocol name and description */
proto_exported_pdu = proto_register_protocol("EXPORTED_PDU",
"exported_pdu", "exported_pdu");
expert_exported_pdu = expert_register_protocol(proto_exported_pdu);
expert_register_field_array(expert_exported_pdu, ei, array_length(ei));
exported_pdu_handle = register_dissector("exported_pdu", dissect_exported_pdu, proto_exported_pdu);
/* Required function calls to register the header fields and subtrees */