#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>
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);
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,
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"
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)");
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)");
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);
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);
}
{
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;
typedef struct {
SslRecordInfo *records; /**< Decrypted records within this frame. */
+ guint32 srcport; /**< Used for Decode As */
+ guint32 destport;
} SslPacketInfo;
typedef struct _SslSession {
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);
}
/*********************************************************************
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)
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);
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 */
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);