diff options
-rw-r--r-- | epan/dissectors/packet-dtls.c | 48 | ||||
-rw-r--r-- | epan/dissectors/packet-ethertype.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-sctp.c | 30 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl-utils.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl-utils.h | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl.c | 47 | ||||
-rw-r--r-- | epan/dissectors/packet-tcp.c | 19 | ||||
-rw-r--r-- | epan/dissectors/packet-udp.c | 19 |
8 files changed, 139 insertions, 38 deletions
diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index d75ddc65a6..2dbf8532d6 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -57,6 +57,7 @@ #include <epan/sctpppids.h> #include <epan/exported_pdu.h> #include <epan/decode_as.h> +#include <epan/proto_data.h> #include <wsutil/str_util.h> #include <wsutil/strtoi.h> #include <wsutil/utf8_entities.h> @@ -1660,31 +1661,68 @@ dtlsdecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, c static void dtls_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + srcport = pi->srcport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", srcport, UTF8_RIGHTWARDS_ARROW); } static gpointer dtls_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->srcport); + + return GUINT_TO_POINTER(pi->srcport); } static void dtls_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + SslPacketInfo* pi; + guint32 destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + destport = pi->destport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, destport); } static gpointer dtls_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->destport); + + return GUINT_TO_POINTER(pi->destport); } static void dtls_both_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport, + destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_dtls, pinfo->curr_layer_num); + if (pi != NULL) + { + srcport = pi->srcport; + destport = pi->destport; + } + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } void proto_reg_handoff_dtls(void); diff --git a/epan/dissectors/packet-ethertype.c b/epan/dissectors/packet-ethertype.c index 92fb9a0722..6f5a37e2c8 100644 --- a/epan/dissectors/packet-ethertype.c +++ b/epan/dissectors/packet-ethertype.c @@ -193,12 +193,12 @@ const value_string etype_vals[] = { static void eth_prompt(packet_info *pinfo, gchar* result) { g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Ethertype 0x%04x as", - GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_ethertype, 0))); + GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_ethertype, pinfo->curr_layer_num))); } static gpointer eth_value(packet_info *pinfo) { - return p_get_proto_data(pinfo->pool, pinfo, proto_ethertype, 0); + return p_get_proto_data(pinfo->pool, pinfo, proto_ethertype, pinfo->curr_layer_num); } static void add_dix_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, @@ -257,7 +257,7 @@ dissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat next_tvb = tvb_new_subset_length_caplen(tvb, ethertype_data->offset_after_ethertype, captured_length, reported_length); - p_add_proto_data(pinfo->pool, pinfo, proto_ethertype, 0, GUINT_TO_POINTER((guint)ethertype_data->etype)); + p_add_proto_data(pinfo->pool, pinfo, proto_ethertype, pinfo->curr_layer_num, GUINT_TO_POINTER((guint)ethertype_data->etype)); /* Look for sub-dissector, and call it if found. Catch exceptions, so that if the reported length of "next_tvb" diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index 7b150a5ba6..11ee2e85d4 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -740,40 +740,44 @@ find_assoc_index(assoc_info_t* tmpinfo, gboolean visited) static void sctp_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->srcport); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%s%u)", UTF8_RIGHTWARDS_ARROW, port); } static gpointer sctp_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + return p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num); } static void sctp_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port); } static gpointer sctp_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + return p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num); } static void sctp_both_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport); + guint32 srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num)), + destport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } static void sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result) { - guint32 ppid; - void *tmp = p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0); - - ppid = GPOINTER_TO_UINT(tmp); + guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0)); if (ppid == LAST_PPID) { g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)"); @@ -785,10 +789,7 @@ sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result) static void sctp_ppi_prompt2(packet_info *pinfo _U_, gchar* result) { - guint32 ppid; - void *tmp = p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1); - - ppid = GPOINTER_TO_UINT(tmp); + guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1)); if (ppid == LAST_PPID) { g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)"); @@ -4783,6 +4784,9 @@ dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ set_address(&sctp_info.ip_src, pinfo->src.type, pinfo->src.len, pinfo->src.data); set_address(&sctp_info.ip_dst, pinfo->dst.type, pinfo->dst.len, pinfo->dst.data); + p_add_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->srcport)); + p_add_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->destport)); + dissect_sctp_packet(tvb, pinfo, tree, FALSE); if (!pinfo->flags.in_error_pkt && sctp_info.number_of_tvbs > 0) tap_queue_packet(sctp_tap, pinfo, &sctp_info); diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c index 0de394fe9b..ea527cee00 100644 --- a/epan/dissectors/packet-ssl-utils.c +++ b/epan/dissectors/packet-ssl-utils.c @@ -4873,10 +4873,12 @@ ssl_add_record_info(gint proto, packet_info *pinfo, const guchar *data, gint dat SslRecordInfo* rec, **prec; SslPacketInfo* pi; - pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0); + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, pinfo->curr_layer_num); if (!pi) { pi = wmem_new0(wmem_file_scope(), SslPacketInfo); + pi->srcport = pinfo->srcport; + pi->destport = pinfo->destport; p_add_proto_data(wmem_file_scope(), pinfo, proto, 0, pi); } @@ -4910,7 +4912,7 @@ ssl_get_record_info(tvbuff_t *parent_tvb, int proto, packet_info *pinfo, gint re { SslRecordInfo* rec; SslPacketInfo* pi; - pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0); + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, pinfo->curr_layer_num); if (!pi) return NULL; diff --git a/epan/dissectors/packet-ssl-utils.h b/epan/dissectors/packet-ssl-utils.h index 871306584e..269618dee8 100644 --- a/epan/dissectors/packet-ssl-utils.h +++ b/epan/dissectors/packet-ssl-utils.h @@ -396,6 +396,8 @@ typedef struct _SslRecordInfo { typedef struct { SslRecordInfo *records; /**< Decrypted records within this frame. */ + guint32 srcport; /**< Used for Decode As */ + guint32 destport; } SslPacketInfo; typedef struct _SslSession { diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index df5d850126..f49732f178 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -3724,31 +3724,68 @@ ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, co static void ssl_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, pinfo->curr_layer_num); + if (pi != NULL) + srcport = pi->srcport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", srcport, UTF8_RIGHTWARDS_ARROW); } static gpointer ssl_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->srcport); + + return GUINT_TO_POINTER(pi->srcport); } static void ssl_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + SslPacketInfo* pi; + guint32 destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, pinfo->curr_layer_num); + if (pi != NULL) + destport = pi->destport; + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, destport); } static gpointer ssl_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + SslPacketInfo* pi; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, pinfo->curr_layer_num); + if (pi == NULL) + return GUINT_TO_POINTER(pinfo->destport); + + return GUINT_TO_POINTER(pi->destport); } static void ssl_both_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport); + SslPacketInfo* pi; + guint32 srcport = pinfo->srcport, + destport = pinfo->destport; + + pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto_ssl, pinfo->curr_layer_num); + if (pi != NULL) + { + srcport = pi->srcport; + destport = pi->destport; + } + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } /********************************************************************* diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index b2aa3c8ea5..1e29f63896 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -617,31 +617,37 @@ const unit_name_string units_64bit_version = { " (64bits version)", NULL }; static void tcp_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", port, UTF8_RIGHTWARDS_ARROW); } static gpointer tcp_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + return p_get_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num); } static void tcp_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port); } static gpointer tcp_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + return p_get_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num); } static void tcp_both_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport); + guint32 srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num)), + destport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num)); + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport); } static const char* tcp_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter) @@ -5749,6 +5755,9 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) pinfo->srcport = tcph->th_sport; pinfo->destport = tcph->th_dport; + p_add_proto_data(pinfo->pool, pinfo, hf_tcp_srcport, pinfo->curr_layer_num, GUINT_TO_POINTER(tcph->th_sport)); + p_add_proto_data(pinfo->pool, pinfo, hf_tcp_dstport, pinfo->curr_layer_num, GUINT_TO_POINTER(tcph->th_dport)); + tcph->th_rawseq = tvb_get_ntohl(tvb, offset + 4); tcph->th_seq = tcph->th_rawseq; tcph->th_ack = tvb_get_ntohl(tvb, offset + 8); diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 86b3228fad..fa6f2a2b60 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -186,31 +186,37 @@ typedef struct static void udp_src_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", pinfo->srcport, UTF8_RIGHTWARDS_ARROW); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hfi_udp_srcport.id, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%u%s)", port, UTF8_RIGHTWARDS_ARROW); } static gpointer udp_src_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->srcport); + return p_get_proto_data(pinfo->pool, pinfo, hfi_udp_srcport.id, pinfo->curr_layer_num); } static void udp_dst_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, pinfo->destport); + guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hfi_udp_dstport.id, pinfo->curr_layer_num)); + + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port); } static gpointer udp_dst_value(packet_info *pinfo) { - return GUINT_TO_POINTER(pinfo->destport); + return p_get_proto_data(pinfo->pool, pinfo, hfi_udp_dstport.id, pinfo->curr_layer_num); } static void udp_both_prompt(packet_info *pinfo, gchar *result) { - g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Both (%u%s%u)", pinfo->srcport, UTF8_LEFT_RIGHT_ARROW, pinfo->destport); + guint32 srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hfi_udp_srcport.id, pinfo->curr_layer_num)), + dstport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hfi_udp_dstport.id, pinfo->curr_layer_num)); + g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "Both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, dstport); } /* Conversation and process code originally copied from packet-tcp.c */ @@ -923,6 +929,9 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto) src_port_item = proto_tree_add_item(udp_tree, &hfi_udp_srcport, tvb, offset, 2, ENC_BIG_ENDIAN); dst_port_item = proto_tree_add_item(udp_tree, &hfi_udp_dstport, tvb, offset + 2, 2, ENC_BIG_ENDIAN); + p_add_proto_data(pinfo->pool, pinfo, hfi_udp_srcport.id, pinfo->curr_layer_num, GUINT_TO_POINTER(udph->uh_sport)); + p_add_proto_data(pinfo->pool, pinfo, hfi_udp_dstport.id, pinfo->curr_layer_num, GUINT_TO_POINTER(udph->uh_dport)); + hidden_item = proto_tree_add_item(udp_tree, &hfi_udp_port, tvb, offset, 2, ENC_BIG_ENDIAN); PROTO_ITEM_SET_HIDDEN(hidden_item); hidden_item = proto_tree_add_item(udp_tree, &hfi_udp_port, tvb, offset + 2, 2, ENC_BIG_ENDIAN); |