summaryrefslogtreecommitdiff
path: root/epan/exported_pdu.c
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2013-05-10 13:13:50 +0000
committerPascal Quantin <pascal.quantin@gmail.com>2013-05-10 13:13:50 +0000
commit914099a5a9b0dc2dea9ab00c7ccd27952f636832 (patch)
treef5e50ed8b409dfc89de3ec01489acc84adabff03 /epan/exported_pdu.c
parent27816067e88e5cff07129ee193e2ebc42a20fc3f (diff)
downloadwireshark-914099a5a9b0dc2dea9ab00c7ccd27952f636832.tar.gz
Fix a few bugs related to PDU export feature:
- tag length is wrong if proto name was a multiple of 4 bytes - tag length is wrong in case no IP address is available in packet_info structwhile tag is requested - endianness issue when dumping the port number - overlapping tag IPv4 Dst address and IPv6 Src address - do not call dissector when it is not found - typo errors Enhancements: - add a subtree for tag content - display IPv6 Src/Dst address svn path=/trunk/; revision=49232
Diffstat (limited to 'epan/exported_pdu.c')
-rw-r--r--epan/exported_pdu.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/epan/exported_pdu.c b/epan/exported_pdu.c
index 4559e52fd3..3523464fb3 100644
--- a/epan/exported_pdu.c
+++ b/epan/exported_pdu.c
@@ -31,8 +31,8 @@
#include <epan/exported_pdu.h>
/**
- * Allcotates and fills the exp_pdu_data_t struct according to the wanted_exp_tags
- * bit_fileld, if proto_name is != NULL, wtap_encap must be -1 or viceversa
+ * Allocates and fills the exp_pdu_data_t struct according to the wanted_exp_tags
+ * bit_fileld, if proto_name is != NULL, wtap_encap must be -1 or vice-versa
*/
exp_pdu_data_t *
load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap _U_, guint32 tags_bit_field)
@@ -45,19 +45,16 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
exp_pdu_data = (exp_pdu_data_t *)g_malloc(sizeof(exp_pdu_data_t));
- /* If we have a protocol name, calculate the buffersize needed including padding and tag + length */
+ /* If we have a protocol name, calculate the buffer size needed including padding and tag + length */
if(proto_name){
str_len = (int)strlen(proto_name);
- /* Add padding if needed */
- if(str_len % 4){
- tag_str_len = str_len + (4 - str_len % 4);
- }
+ /* Ensure that tag length is a multiple of 4 bytes */
+ tag_str_len = (str_len + 3) & 0xfffffffc;
/* Add Tag + length */
tag_buf_size = tag_str_len + 4;
}
-
if((tags_bit_field & EXP_PDU_TAG_IP_SRC_BIT) == EXP_PDU_TAG_IP_SRC_BIT){
/* tag+length */
tag_buf_size+=4;
@@ -71,7 +68,7 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
if((tags_bit_field & EXP_PDU_TAG_IP_DST_BIT) == EXP_PDU_TAG_IP_DST_BIT){
/* tag+length */
tag_buf_size+=4;
- if(pinfo->net_src.type == AT_IPv4){
+ if(pinfo->net_dst.type == AT_IPv4){
tag_buf_size = tag_buf_size + EXP_PDU_TAG_IPV4_DST_LEN;
}else{
tag_buf_size = tag_buf_size + EXP_PDU_TAG_IPV6_DST_LEN;
@@ -128,7 +125,7 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
}
memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_src.data, pinfo->net_src.len);
- i = i + pinfo->net_src.len;
+ i += (pinfo->net_src.type == AT_IPv4) ? EXP_PDU_TAG_IPV4_SRC_LEN : EXP_PDU_TAG_IPV6_SRC_LEN;
}
if((tags_bit_field & EXP_PDU_TAG_IP_DST_BIT) == EXP_PDU_TAG_IP_DST_BIT){
@@ -153,7 +150,7 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
}
memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_dst.data, pinfo->net_dst.len);
- i = i + pinfo->net_src.len;
+ i += (pinfo->net_dst.type == AT_IPv4) ? EXP_PDU_TAG_IPV4_DST_LEN : EXP_PDU_TAG_IPV6_DST_LEN;
}
if((tags_bit_field & EXP_PDU_TAG_SRC_PORT_BIT) == EXP_PDU_TAG_SRC_PORT_BIT){
@@ -165,7 +162,10 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
i++;
exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SRC_PORT_LEN; /* tag length */
i++;
- memcpy(exp_pdu_data->tlv_buffer+i, &pinfo->srcport, EXP_PDU_TAG_SRC_PORT_LEN);
+ exp_pdu_data->tlv_buffer[i] = (pinfo->srcport & 0xff000000) >> 24;
+ exp_pdu_data->tlv_buffer[i+1] = (pinfo->srcport & 0x00ff0000) >> 16;
+ exp_pdu_data->tlv_buffer[i+2] = (pinfo->srcport & 0x0000ff00) >> 8;
+ exp_pdu_data->tlv_buffer[i+3] = (pinfo->srcport & 0x000000ff);
i = i +EXP_PDU_TAG_SRC_PORT_LEN;
}
@@ -178,7 +178,10 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap
i++;
exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DST_PORT_LEN; /* tag length */
i++;
- memcpy(exp_pdu_data->tlv_buffer+i, &pinfo->destport, EXP_PDU_TAG_DST_PORT_LEN);
+ exp_pdu_data->tlv_buffer[i] = (pinfo->destport & 0xff000000) >> 24;
+ exp_pdu_data->tlv_buffer[i+1] = (pinfo->destport & 0x00ff0000) >> 16;
+ exp_pdu_data->tlv_buffer[i+2] = (pinfo->destport & 0x0000ff00) >> 8;
+ exp_pdu_data->tlv_buffer[i+3] = (pinfo->destport & 0x000000ff);
i = i +EXP_PDU_TAG_DST_PORT_LEN;
}