"Hardcode" the port types used by Export PDU functionality
The "internal" port type has been serialized by export PDU functionality and nettrace_3gpp_32_423 wiretap. To better support "endpoint" functionality the port types will be removed/updated and that changes the implicit values from the port_type enum. Take a snapshot of the current port_type values and use those specific values when reading/writing export PDU data and provide conversion functions that can be modified when port_types are removed. Do the same for nettrace_3gpp_32_423 wiretap. Change-Id: I770bd0cab22e84f3cf49032fc86c5927bf85263f Reviewed-on: https://code.wireshark.org/review/24169 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
1e8e9a807f
commit
765a67b68a
|
@ -110,6 +110,72 @@ static const value_string exported_pdu_tag_vals[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string exported_pdu_port_type_vals[] = {
|
||||
{ OLD_PT_NONE, "NONE" },
|
||||
{ OLD_PT_SCTP, "SCTP" },
|
||||
{ OLD_PT_TCP, "TCP" },
|
||||
{ OLD_PT_UDP, "UDP" },
|
||||
{ OLD_PT_DCCP, "DCCP" },
|
||||
{ OLD_PT_IPX, "IPX" },
|
||||
{ OLD_PT_NCP, "NCP" },
|
||||
{ OLD_PT_EXCHG, "FC EXCHG" },
|
||||
{ OLD_PT_DDP, "DDP" },
|
||||
{ OLD_PT_SBCCS, "FICON SBCCS" },
|
||||
{ OLD_PT_IDP, "IDP" },
|
||||
{ OLD_PT_TIPC, "TIPC" },
|
||||
{ OLD_PT_USB, "USB" },
|
||||
{ OLD_PT_I2C, "I2C" },
|
||||
{ OLD_PT_IBQP, "IBQP" },
|
||||
{ OLD_PT_BLUETOOTH,"BLUETOOTH" },
|
||||
{ OLD_PT_TDMOP, "TDMOP" },
|
||||
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static port_type exp_pdu_old_to_new_port_type(guint type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case OLD_PT_NONE:
|
||||
return PT_NONE;
|
||||
case OLD_PT_SCTP:
|
||||
return PT_SCTP;
|
||||
case OLD_PT_TCP:
|
||||
return PT_TCP;
|
||||
case OLD_PT_UDP:
|
||||
return PT_UDP;
|
||||
case OLD_PT_DCCP:
|
||||
return PT_DCCP;
|
||||
case OLD_PT_IPX:
|
||||
return PT_IPX;
|
||||
case OLD_PT_NCP:
|
||||
return PT_NCP;
|
||||
case OLD_PT_EXCHG:
|
||||
return PT_EXCHG;
|
||||
case OLD_PT_DDP:
|
||||
return PT_DDP;
|
||||
case OLD_PT_SBCCS:
|
||||
return PT_SBCCS;
|
||||
case OLD_PT_IDP:
|
||||
return PT_IDP;
|
||||
case OLD_PT_TIPC:
|
||||
return PT_TIPC;
|
||||
case OLD_PT_USB:
|
||||
return PT_USB;
|
||||
case OLD_PT_I2C:
|
||||
return PT_I2C;
|
||||
case OLD_PT_IBQP:
|
||||
return PT_IBQP;
|
||||
case OLD_PT_BLUETOOTH:
|
||||
return PT_BLUETOOTH;
|
||||
case OLD_PT_TDMOP:
|
||||
return PT_TDMOP;
|
||||
}
|
||||
|
||||
DISSECTOR_ASSERT(FALSE);
|
||||
return PT_NONE;
|
||||
}
|
||||
|
||||
/* Code to actually dissect the packets */
|
||||
static int
|
||||
dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||
|
@ -201,9 +267,8 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
|
|||
copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
|
||||
break;
|
||||
case EXP_PDU_TAG_PORT_TYPE:
|
||||
pinfo->ptype = (port_type)tvb_get_ntohl(tvb, offset);
|
||||
proto_tree_add_uint_format_value(tag_tree, hf_exported_pdu_port_type, tvb, offset, 4, pinfo->ptype,
|
||||
"%s (%u)", port_type_to_str(pinfo->ptype), pinfo->ptype);
|
||||
pinfo->ptype = exp_pdu_old_to_new_port_type(tvb_get_ntohl(tvb, offset));
|
||||
proto_tree_add_item(tag_tree, hf_exported_pdu_port_type, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
break;
|
||||
case EXP_PDU_TAG_SRC_PORT:
|
||||
proto_tree_add_item(tag_tree, hf_exported_pdu_src_port, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
|
@ -380,7 +445,7 @@ proto_register_exported_pdu(void)
|
|||
},
|
||||
{ &hf_exported_pdu_port_type,
|
||||
{ "Port Type", "exported_pdu.port_type",
|
||||
FT_UINT32, BASE_DEC, NULL, 0,
|
||||
FT_UINT32, BASE_DEC, VALS(exported_pdu_port_type_vals), 0,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_exported_pdu_src_port,
|
||||
|
|
|
@ -100,16 +100,63 @@ static int exp_pdu_data_port_type_size(packet_info *pinfo _U_, void* data _U_)
|
|||
return EXP_PDU_TAG_PORT_LEN + 4;
|
||||
}
|
||||
|
||||
static guint exp_pdu_new_to_old_port_type(port_type pt)
|
||||
{
|
||||
switch (pt)
|
||||
{
|
||||
case PT_NONE:
|
||||
return OLD_PT_NONE;
|
||||
case PT_SCTP:
|
||||
return OLD_PT_SCTP;
|
||||
case PT_TCP:
|
||||
return OLD_PT_TCP;
|
||||
case PT_UDP:
|
||||
return OLD_PT_UDP;
|
||||
case PT_DCCP:
|
||||
return OLD_PT_DCCP;
|
||||
case PT_IPX:
|
||||
return OLD_PT_IPX;
|
||||
case PT_NCP:
|
||||
return OLD_PT_NCP;
|
||||
case PT_EXCHG:
|
||||
return OLD_PT_EXCHG;
|
||||
case PT_DDP:
|
||||
return OLD_PT_DDP;
|
||||
case PT_SBCCS:
|
||||
return OLD_PT_SBCCS;
|
||||
case PT_IDP:
|
||||
return OLD_PT_IDP;
|
||||
case PT_TIPC:
|
||||
return OLD_PT_TIPC;
|
||||
case PT_USB:
|
||||
return OLD_PT_USB;
|
||||
case PT_I2C:
|
||||
return OLD_PT_I2C;
|
||||
case PT_IBQP:
|
||||
return OLD_PT_IBQP;
|
||||
case PT_BLUETOOTH:
|
||||
return OLD_PT_BLUETOOTH;
|
||||
case PT_TDMOP:
|
||||
return OLD_PT_TDMOP;
|
||||
}
|
||||
|
||||
DISSECTOR_ASSERT(FALSE);
|
||||
return OLD_PT_NONE;
|
||||
}
|
||||
|
||||
static int exp_pdu_data_port_type_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size _U_)
|
||||
{
|
||||
guint pt;
|
||||
|
||||
tlv_buffer[0] = 0;
|
||||
tlv_buffer[1] = EXP_PDU_TAG_PORT_TYPE;
|
||||
tlv_buffer[2] = 0;
|
||||
tlv_buffer[3] = EXP_PDU_TAG_PORT_TYPE_LEN; /* tag length */
|
||||
tlv_buffer[4] = (pinfo->ptype & 0xff000000) >> 24;
|
||||
tlv_buffer[5] = (pinfo->ptype & 0x00ff0000) >> 16;
|
||||
tlv_buffer[6] = (pinfo->ptype & 0x0000ff00) >> 8;
|
||||
tlv_buffer[7] = (pinfo->ptype & 0x000000ff);
|
||||
pt = exp_pdu_new_to_old_port_type(pinfo->ptype);
|
||||
tlv_buffer[4] = (pt & 0xff000000) >> 24;
|
||||
tlv_buffer[5] = (pt & 0x00ff0000) >> 16;
|
||||
tlv_buffer[6] = (pt & 0x0000ff00) >> 8;
|
||||
tlv_buffer[7] = (pt & 0x000000ff);
|
||||
|
||||
return exp_pdu_data_port_type_size(pinfo, data);
|
||||
}
|
||||
|
|
|
@ -161,6 +161,29 @@ typedef struct _exp_pdu_data_t {
|
|||
|
||||
#define EXP_PDU_TAG_DISSECTOR_TABLE_NUM_VAL_LEN 4
|
||||
|
||||
/* Port types are no longer used for conversation/endpoints so
|
||||
many of the enumerated values have been eliminated
|
||||
Since export PDU functionality is serializing them,
|
||||
keep the old values around for conversion */
|
||||
#define OLD_PT_NONE 0
|
||||
#define OLD_PT_SCTP 1
|
||||
#define OLD_PT_TCP 2
|
||||
#define OLD_PT_UDP 3
|
||||
#define OLD_PT_DCCP 4
|
||||
#define OLD_PT_IPX 5
|
||||
#define OLD_PT_NCP 6
|
||||
#define OLD_PT_EXCHG 7
|
||||
#define OLD_PT_DDP 8
|
||||
#define OLD_PT_SBCCS 9
|
||||
#define OLD_PT_IDP 10
|
||||
#define OLD_PT_TIPC 11
|
||||
#define OLD_PT_USB 12
|
||||
#define OLD_PT_I2C 13
|
||||
#define OLD_PT_IBQP 14
|
||||
#define OLD_PT_BLUETOOTH 15
|
||||
#define OLD_PT_TDMOP 16
|
||||
|
||||
|
||||
/** Compute the size (in bytes) of a pdu item
|
||||
*
|
||||
@param pinfo Packet info that may contain data for the pdu item
|
||||
|
|
|
@ -67,26 +67,29 @@ typedef struct nettrace_3gpp_32_423_file_info {
|
|||
wtap *wth_tmp_file;
|
||||
} nettrace_3gpp_32_423_file_info_t;
|
||||
|
||||
/* From epan/address.h Types of port numbers Wireshark knows about. */
|
||||
typedef enum {
|
||||
PT_NONE, /* no port number */
|
||||
PT_SCTP, /* SCTP */
|
||||
PT_TCP, /* TCP */
|
||||
PT_UDP, /* UDP */
|
||||
PT_DCCP, /* DCCP */
|
||||
PT_IPX, /* IPX sockets */
|
||||
PT_NCP, /* NCP connection */
|
||||
PT_EXCHG, /* Fibre Channel exchange */
|
||||
PT_DDP, /* DDP AppleTalk connection */
|
||||
PT_SBCCS, /* FICON */
|
||||
PT_IDP, /* XNS IDP sockets */
|
||||
PT_TIPC, /* TIPC PORT */
|
||||
PT_USB, /* USB endpoint 0xffff means the host */
|
||||
PT_I2C,
|
||||
PT_IBQP, /* Infiniband QP number */
|
||||
PT_BLUETOOTH,
|
||||
PT_TDMOP
|
||||
} port_type;
|
||||
/* From epan/exported_pdu.h
|
||||
Port types are no longer used for conversation/endpoints so
|
||||
many of the enumerated values have been eliminated
|
||||
Since export PDU functionality is serializing them,
|
||||
keep the old values around for conversion */
|
||||
#define OLD_PT_NONE 0
|
||||
#define OLD_PT_SCTP 1
|
||||
#define OLD_PT_TCP 2
|
||||
#define OLD_PT_UDP 3
|
||||
#define OLD_PT_DCCP 4
|
||||
#define OLD_PT_IPX 5
|
||||
#define OLD_PT_NCP 6
|
||||
#define OLD_PT_EXCHG 7
|
||||
#define OLD_PT_DDP 8
|
||||
#define OLD_PT_SBCCS 9
|
||||
#define OLD_PT_IDP 10
|
||||
#define OLD_PT_TIPC 11
|
||||
#define OLD_PT_USB 12
|
||||
#define OLD_PT_I2C 13
|
||||
#define OLD_PT_IBQP 14
|
||||
#define OLD_PT_BLUETOOTH 15
|
||||
#define OLD_PT_TDMOP 16
|
||||
|
||||
|
||||
typedef struct exported_pdu_info {
|
||||
guint32 precense_flags;
|
||||
|
@ -95,7 +98,7 @@ typedef struct exported_pdu_info {
|
|||
guint8 src_ipv4_d2;
|
||||
guint8 src_ipv4_d3;
|
||||
guint8 src_ipv4_d4;
|
||||
port_type ptype; /* epan/address.h port_type valid for both src and dst*/
|
||||
guint32 ptype; /* Based on epan/address.h port_type valid for both src and dst*/
|
||||
guint32 src_port;
|
||||
guint8 dst_ipv4_d1;
|
||||
guint8 dst_ipv4_d2;
|
||||
|
@ -738,7 +741,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
exported_pdu_info.src_ipv4_d2 = 0;
|
||||
exported_pdu_info.src_ipv4_d3 = 0;
|
||||
exported_pdu_info.src_ipv4_d4 = 0;
|
||||
exported_pdu_info.ptype = PT_NONE;
|
||||
exported_pdu_info.ptype = OLD_PT_NONE;
|
||||
exported_pdu_info.src_port = 0;
|
||||
exported_pdu_info.dst_ipv4_d1 = 0;
|
||||
exported_pdu_info.dst_ipv4_d2 = 0;
|
||||
|
@ -897,7 +900,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
wtap_open_return_val temp_val;
|
||||
/* Clear for each itteration */
|
||||
exported_pdu_info.precense_flags = 0;
|
||||
exported_pdu_info.ptype = PT_NONE;
|
||||
exported_pdu_info.ptype = OLD_PT_NONE;
|
||||
|
||||
curr_pos = curr_pos + 4;
|
||||
next_msg_pos = strstr(curr_pos, "</msg>");
|
||||
|
@ -970,10 +973,10 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
exported_pdu_info.src_ipv4_d4 = d4;
|
||||
|
||||
/* Only add port_type once */
|
||||
if(exported_pdu_info.ptype == PT_NONE){
|
||||
if (g_ascii_strncasecmp(transp_str, "udp", 3) == 0) exported_pdu_info.ptype = PT_UDP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "tcp", 3) == 0) exported_pdu_info.ptype = PT_TCP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "sctp", 4) == 0) exported_pdu_info.ptype = PT_SCTP;
|
||||
if(exported_pdu_info.ptype == OLD_PT_NONE){
|
||||
if (g_ascii_strncasecmp(transp_str, "udp", 3) == 0) exported_pdu_info.ptype = OLD_PT_UDP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "tcp", 3) == 0) exported_pdu_info.ptype = OLD_PT_TCP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "sctp", 4) == 0) exported_pdu_info.ptype = OLD_PT_SCTP;
|
||||
}
|
||||
exported_pdu_info.src_port = port;
|
||||
} else {
|
||||
|
@ -1016,10 +1019,10 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
exported_pdu_info.dst_ipv4_d3 = d3;
|
||||
exported_pdu_info.dst_ipv4_d4 = d4;
|
||||
/* Only add port_type once */
|
||||
if (exported_pdu_info.ptype == PT_NONE) {
|
||||
if (g_ascii_strncasecmp(transp_str, "udp", 3) == 0) exported_pdu_info.ptype = PT_UDP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "tcp", 3) == 0) exported_pdu_info.ptype = PT_TCP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "sctp", 4) == 0) exported_pdu_info.ptype = PT_SCTP;
|
||||
if (exported_pdu_info.ptype == OLD_PT_NONE) {
|
||||
if (g_ascii_strncasecmp(transp_str, "udp", 3) == 0) exported_pdu_info.ptype = OLD_PT_UDP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "tcp", 3) == 0) exported_pdu_info.ptype = OLD_PT_TCP;
|
||||
else if (g_ascii_strncasecmp(transp_str, "sctp", 4) == 0) exported_pdu_info.ptype = OLD_PT_SCTP;
|
||||
}
|
||||
exported_pdu_info.dst_port = port;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue