diff options
author | Michael Mann <mmann78@netscape.net> | 2016-06-23 23:10:08 -0400 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-29 18:53:46 +0000 |
commit | be12a252dd0bfeddc4b82da4690bcd582aa94d4a (patch) | |
tree | 3c15ef50b693d971ef35105a798dbd6540743aad /epan/exported_pdu.c | |
parent | 46561910f4372ac9fc591bb225298bee7e2879b8 (diff) |
Provide new interface for Export PDU.
Rather than have a bitmask for each desired field, have a dissector
provide a list of structures that represent data that goes into
the PDU.
Change-Id: I125190cbaee489ebffb7d9f5d8bc6f3be2d06353
Reviewed-on: https://code.wireshark.org/review/16122
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/exported_pdu.c')
-rw-r--r-- | epan/exported_pdu.c | 471 |
1 files changed, 189 insertions, 282 deletions
diff --git a/epan/exported_pdu.c b/epan/exported_pdu.c index 62d7aeb3d7..c17a55a0f2 100644 --- a/epan/exported_pdu.c +++ b/epan/exported_pdu.c @@ -29,99 +29,193 @@ #include <epan/exported_pdu.h> #include <epan/address_types.h> #include <epan/tap.h> -#include <epan/dissectors/packet-mtp3.h> -#include <epan/dissectors/packet-dvbci.h> -GSList *export_pdu_tap_name_list = NULL; +static GSList *export_pdu_tap_name_list = NULL; -static int ss7pc_address_type = -1; +static int exp_pdu_data_ip_size(const address* addr) +{ + if (addr->type == AT_IPv4){ + return 4 + EXP_PDU_TAG_IPV4_LEN; + } else if(addr->type == AT_IPv6){ + return 4 + EXP_PDU_TAG_IPV6_LEN; + } + + return 0; +} + +static int exp_pdu_data_src_ip_size(packet_info *pinfo, void* data _U_) +{ + return exp_pdu_data_ip_size(&pinfo->net_src); +} + +static int exp_pdu_data_src_ip_populate_data(packet_info *pinfo, void* data _U_, guint8 *tlv_buffer, guint32 buffer_size _U_) +{ + if(pinfo->net_src.type == AT_IPv4){ + tlv_buffer[0] = 0; + tlv_buffer[1] = EXP_PDU_TAG_IPV4_SRC; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_IPV4_LEN; /* tag length */ + memcpy(tlv_buffer+4, pinfo->net_src.data, EXP_PDU_TAG_IPV4_LEN); + return 4 + EXP_PDU_TAG_IPV4_LEN; + }else if(pinfo->net_src.type == AT_IPv6){ + tlv_buffer[0] = 0; + tlv_buffer[1] = EXP_PDU_TAG_IPV6_SRC; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_IPV6_LEN; /* tag length */ + memcpy(tlv_buffer+4, pinfo->net_src.data, EXP_PDU_TAG_IPV6_LEN); + return 4 + EXP_PDU_TAG_IPV6_LEN; + } + + return 0; +} + +static int exp_pdu_data_dst_ip_size(packet_info *pinfo, void* data _U_) +{ + return exp_pdu_data_ip_size(&pinfo->net_dst); +} + +static int exp_pdu_data_dst_ip_populate_data(packet_info *pinfo, void* data _U_, guint8 *tlv_buffer, guint32 buffer_size _U_) +{ + if(pinfo->net_dst.type == AT_IPv4){ + tlv_buffer[0] = 0; + tlv_buffer[1] = EXP_PDU_TAG_IPV4_DST; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_IPV4_LEN; /* tag length */ + memcpy(tlv_buffer+4, pinfo->net_dst.data, EXP_PDU_TAG_IPV4_LEN); + return 4 + EXP_PDU_TAG_IPV4_LEN; + }else if(pinfo->net_dst.type == AT_IPv6){ + tlv_buffer[0] = 0; + tlv_buffer[1] = EXP_PDU_TAG_IPV6_DST; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_IPV6_LEN; /* tag length */ + memcpy(tlv_buffer+4, pinfo->net_dst.data, EXP_PDU_TAG_IPV6_LEN); + return 4 + EXP_PDU_TAG_IPV6_LEN; + } + + return 0; +} + +static int exp_pdu_data_port_type_size(packet_info *pinfo _U_, void* data _U_) +{ + return EXP_PDU_TAG_PORT_LEN + 4; +} + +static int exp_pdu_data_port_type_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size _U_) +{ + 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); + + return exp_pdu_data_port_type_size(pinfo, data); +} + +static int exp_pdu_data_port_size(packet_info *pinfo _U_, void* data _U_) +{ + return EXP_PDU_TAG_PORT_LEN + 4; +} + +static int exp_pdu_data_port_populate_data(guint32 port, guint8 porttype, guint8 *tlv_buffer, guint32 buffer_size _U_) +{ + tlv_buffer[0] = 0; + tlv_buffer[1] = porttype; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_PORT_LEN; /* tag length */ + tlv_buffer[4] = (port & 0xff000000) >> 24; + tlv_buffer[5] = (port & 0x00ff0000) >> 16; + tlv_buffer[6] = (port & 0x0000ff00) >> 8; + tlv_buffer[7] = (port & 0x000000ff); + + return EXP_PDU_TAG_PORT_LEN + 4; +} + +static int exp_pdu_data_src_port_populate_data(packet_info *pinfo, void* data _U_, guint8 *tlv_buffer, guint32 buffer_size) +{ + return exp_pdu_data_port_populate_data(pinfo->srcport, EXP_PDU_TAG_SRC_PORT, tlv_buffer, buffer_size); +} + +static int exp_pdu_data_dst_port_populate_data(packet_info *pinfo, void* data _U_, guint8 *tlv_buffer, guint32 buffer_size) +{ + return exp_pdu_data_port_populate_data(pinfo->destport, EXP_PDU_TAG_DST_PORT, tlv_buffer, buffer_size); +} + +static int exp_pdu_data_orig_frame_num_size(packet_info *pinfo _U_, void* data _U_) +{ + return EXP_PDU_TAG_ORIG_FNO_LEN + 4; +} + +static int exp_pdu_data_orig_frame_num_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size _U_) +{ + tlv_buffer[0] = 0; + tlv_buffer[1] = EXP_PDU_TAG_ORIG_FNO; + tlv_buffer[2] = 0; + tlv_buffer[3] = EXP_PDU_TAG_ORIG_FNO_LEN; /* tag length */ + tlv_buffer[4] = (pinfo->num & 0xff000000) >> 24; + tlv_buffer[5] = (pinfo->num & 0x00ff0000) >> 16; + tlv_buffer[6] = (pinfo->num & 0x0000ff00) >> 8; + tlv_buffer[7] = (pinfo->num & 0x000000ff); + + return exp_pdu_data_orig_frame_num_size(pinfo, data); +} + +exp_pdu_data_item_t exp_pdu_data_src_ip = {exp_pdu_data_src_ip_size, exp_pdu_data_src_ip_populate_data, NULL}; +exp_pdu_data_item_t exp_pdu_data_dst_ip = {exp_pdu_data_dst_ip_size, exp_pdu_data_dst_ip_populate_data, NULL}; +exp_pdu_data_item_t exp_pdu_data_port_type = {exp_pdu_data_port_type_size, exp_pdu_data_port_type_populate_data, NULL}; +exp_pdu_data_item_t exp_pdu_data_src_port = {exp_pdu_data_port_size, exp_pdu_data_src_port_populate_data, NULL}; +exp_pdu_data_item_t exp_pdu_data_dst_port = {exp_pdu_data_port_size, exp_pdu_data_dst_port_populate_data, NULL}; +exp_pdu_data_item_t exp_pdu_data_orig_frame_num = {exp_pdu_data_orig_frame_num_size, exp_pdu_data_orig_frame_num_populate_data, NULL}; + +exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type) +{ + const exp_pdu_data_item_t *common_exp_pdu_items[] = { + &exp_pdu_data_src_ip, + &exp_pdu_data_dst_ip, + &exp_pdu_data_port_type, + &exp_pdu_data_src_port, + &exp_pdu_data_dst_port, + &exp_pdu_data_orig_frame_num, + NULL + }; + + return export_pdu_create_tags(pinfo, proto_name, tag_type, common_exp_pdu_items); +} /** - * Allocates and fills the exp_pdu_data_t struct according to the wanted_exp_tags - * bit field of wanted_exp_tags_len bytes length - * tag_type should be either EXP_PDU_TAG_PROTO_NAME or EXP_PDU_TAG_HEUR_PROTO_NAME - * proto_name interpretation depends on tag_type value + * Allocates and fills the exp_pdu_data_t struct according to the list of items * * The tags in the tag buffer SHOULD be added in numerical order. */ exp_pdu_data_t * -load_export_pdu_tags(packet_info *pinfo, guint tag_type, const char* proto_name, - guint8 *wanted_exp_tags, guint16 wanted_exp_tags_len) +export_pdu_create_tags(packet_info *pinfo, const char* proto_name, guint16 tag_type, const exp_pdu_data_item_t **items_list) { exp_pdu_data_t *exp_pdu_data; + const exp_pdu_data_item_t **loop_items = items_list; int tag_buf_size = 0; - int str_len = 0; - int tag_str_len = 0; - int i = 0; - gboolean port_type_defined = FALSE; + int proto_str_len, proto_tag_len, buf_remaining, item_size; + guint8* buffer_data; + + DISSECTOR_ASSERT(proto_name != NULL); + DISSECTOR_ASSERT((tag_type == EXP_PDU_TAG_PROTO_NAME) || (tag_type == EXP_PDU_TAG_HEUR_PROTO_NAME)); exp_pdu_data = (exp_pdu_data_t *)g_malloc(sizeof(exp_pdu_data_t)); - /* 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); + /* Start by computing size of protocol name as a tag */ + proto_str_len = (int)strlen(proto_name); - /* 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; - } + /* Ensure that tag length is a multiple of 4 bytes */ + proto_tag_len = ((proto_str_len + 3) & 0xfffffffc); - /* Check first byte of optional tags bitmap */ - if (wanted_exp_tags_len >= 1) { - if((wanted_exp_tags[0] & EXP_PDU_TAG_IP_SRC_BIT) == EXP_PDU_TAG_IP_SRC_BIT){ - if(pinfo->net_src.type == AT_IPv4){ - tag_buf_size += 4 + EXP_PDU_TAG_IPV4_SRC_LEN; - }else if(pinfo->net_src.type == AT_IPv6){ - tag_buf_size += 4 + EXP_PDU_TAG_IPV6_SRC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_IP_DST_BIT) == EXP_PDU_TAG_IP_DST_BIT){ - if(pinfo->net_dst.type == AT_IPv4){ - tag_buf_size += 4 + EXP_PDU_TAG_IPV4_DST_LEN; - }else if(pinfo->net_dst.type == AT_IPv6){ - tag_buf_size += 4 + EXP_PDU_TAG_IPV6_DST_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SRC_PORT_BIT) == EXP_PDU_TAG_SRC_PORT_BIT){ - if (!port_type_defined) { - tag_buf_size= tag_buf_size + EXP_PDU_TAG_PORT_TYPE_LEN + 4; - port_type_defined = TRUE; - } - tag_buf_size= tag_buf_size + EXP_PDU_TAG_SRC_PORT_LEN + 4; - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_DST_PORT_BIT) == EXP_PDU_TAG_DST_PORT_BIT){ - if (!port_type_defined) { - tag_buf_size= tag_buf_size + EXP_PDU_TAG_PORT_TYPE_LEN + 4; - } - tag_buf_size= tag_buf_size + EXP_PDU_TAG_DST_PORT_LEN + 4; - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){ - if(pinfo->src.type == ss7pc_address_type){ - tag_buf_size += 4 + EXP_PDU_TAG_SS7_OPC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){ - if(pinfo->dst.type == ss7pc_address_type){ - tag_buf_size += 4 + EXP_PDU_TAG_SS7_DPC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_ORIG_FNO_BIT) == EXP_PDU_TAG_ORIG_FNO_BIT){ - tag_buf_size= tag_buf_size + EXP_PDU_TAG_ORIG_FNO_LEN + 4; - } - } + /* Add Tag + length */ + tag_buf_size += (proto_tag_len + 4); - /* Check second byte of optional tags bitmap */ - if (wanted_exp_tags_len >= 2) { - if((wanted_exp_tags[1] & EXP_PDU_TAG_DVBCI_EVT_BIT) == EXP_PDU_TAG_DVBCI_EVT_BIT){ - tag_buf_size= tag_buf_size + EXP_PDU_TAG_DVBCI_EVT_LEN + 4; - } + /* Compute size of items */ + while (*loop_items) { + tag_buf_size += (*loop_items)->size_func(pinfo, (*loop_items)->data); + loop_items++; } /* Add end of options length */ @@ -129,212 +223,26 @@ load_export_pdu_tags(packet_info *pinfo, guint tag_type, const char* proto_name, exp_pdu_data->tlv_buffer = (guint8 *)g_malloc0(tag_buf_size); exp_pdu_data->tlv_buffer_len = tag_buf_size; - port_type_defined = FALSE; - - if(proto_name){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = tag_type; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = tag_str_len; /* tag length */ - i++; - memcpy(exp_pdu_data->tlv_buffer+i, proto_name, str_len); - i = i + tag_str_len; - - } - - /* Check first byte of optional tags bitmap */ - if (wanted_exp_tags_len >= 1) { - if((wanted_exp_tags[0] & EXP_PDU_TAG_IP_SRC_BIT) == EXP_PDU_TAG_IP_SRC_BIT){ - if(pinfo->net_src.type == AT_IPv4){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV4_SRC; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV4_SRC_LEN; /* tag length */ - i++; - memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_src.data, EXP_PDU_TAG_IPV4_SRC_LEN); - i += EXP_PDU_TAG_IPV4_SRC_LEN; - }else if(pinfo->net_src.type == AT_IPv6){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV6_SRC; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV6_SRC_LEN; /* tag length */ - i++; - memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_src.data, EXP_PDU_TAG_IPV6_SRC_LEN); - i += EXP_PDU_TAG_IPV6_SRC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_IP_DST_BIT) == EXP_PDU_TAG_IP_DST_BIT){ - if(pinfo->net_dst.type == AT_IPv4){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV4_DST; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV4_DST_LEN; /* tag length */ - i++; - memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_dst.data, EXP_PDU_TAG_IPV4_DST_LEN); - i += EXP_PDU_TAG_IPV4_DST_LEN; - }else if(pinfo->net_dst.type == AT_IPv6){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV6_DST; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_IPV6_DST_LEN; /* tag length */ - i++; - memcpy(exp_pdu_data->tlv_buffer+i, pinfo->net_dst.data, EXP_PDU_TAG_IPV6_DST_LEN); - i += EXP_PDU_TAG_IPV6_DST_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SRC_PORT_BIT) == EXP_PDU_TAG_SRC_PORT_BIT){ - if (!port_type_defined) { - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_PORT_TYPE; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_PORT_TYPE_LEN; /* tag length */ - i++; - exp_pdu_data->tlv_buffer[i] = (pinfo->ptype & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (pinfo->ptype & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (pinfo->ptype & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (pinfo->ptype & 0x000000ff); - i = i +EXP_PDU_TAG_PORT_TYPE_LEN; - port_type_defined = TRUE; - } - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SRC_PORT; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SRC_PORT_LEN; /* tag length */ - i++; - 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; - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_DST_PORT_BIT) == EXP_PDU_TAG_DST_PORT_BIT){ - if (!port_type_defined) { - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_PORT_TYPE; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_PORT_TYPE_LEN; /* tag length */ - i++; - exp_pdu_data->tlv_buffer[i] = (pinfo->ptype & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (pinfo->ptype & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (pinfo->ptype & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (pinfo->ptype & 0x000000ff); - i = i +EXP_PDU_TAG_PORT_TYPE_LEN; - } - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DST_PORT; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DST_PORT_LEN; /* tag length */ - i++; - 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; - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){ - if(pinfo->src.type == ss7pc_address_type){ - const mtp3_addr_pc_t *mtp3_addr = (const mtp3_addr_pc_t *)(pinfo->src.data); - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SS7_OPC; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SS7_OPC_LEN; /* tag length */ - i++; - exp_pdu_data->tlv_buffer[i] = (mtp3_addr->pc & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (mtp3_addr->pc & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (mtp3_addr->pc & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (mtp3_addr->pc & 0x000000ff); - exp_pdu_data->tlv_buffer[i+4] = (mtp3_addr->type & 0xff00) >> 8; - exp_pdu_data->tlv_buffer[i+5] = (mtp3_addr->type & 0x00ff); - exp_pdu_data->tlv_buffer[i+6] = mtp3_addr->ni; - i += EXP_PDU_TAG_SS7_OPC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){ - if(pinfo->dst.type == ss7pc_address_type){ - const mtp3_addr_pc_t *mtp3_addr = (const mtp3_addr_pc_t *)(pinfo->dst.data); - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SS7_DPC; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SS7_DPC_LEN; /* tag length */ - i++; - exp_pdu_data->tlv_buffer[i] = (mtp3_addr->pc & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (mtp3_addr->pc & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (mtp3_addr->pc & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (mtp3_addr->pc & 0x000000ff); - exp_pdu_data->tlv_buffer[i+4] = (mtp3_addr->type & 0xff00) >> 8; - exp_pdu_data->tlv_buffer[i+5] = (mtp3_addr->type & 0x00ff); - exp_pdu_data->tlv_buffer[i+6] = mtp3_addr->ni; - i += EXP_PDU_TAG_SS7_DPC_LEN; - } - } - - if((wanted_exp_tags[0] & EXP_PDU_TAG_ORIG_FNO_BIT) == EXP_PDU_TAG_ORIG_FNO_BIT){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_ORIG_FNO; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_ORIG_FNO_LEN; /* tag length */ - i++; - exp_pdu_data->tlv_buffer[i] = (pinfo->num & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (pinfo->num & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (pinfo->num & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (pinfo->num & 0x000000ff); - /*i = i +EXP_PDU_TAG_ORIG_FNO_LEN;*/ - } - } - if (wanted_exp_tags_len >= 2) { - if((wanted_exp_tags[1] & EXP_PDU_TAG_DVBCI_EVT_BIT) == EXP_PDU_TAG_DVBCI_EVT_BIT){ - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DVBCI_EVT; - i++; - exp_pdu_data->tlv_buffer[i] = 0; - i++; - exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DVBCI_EVT_LEN; - i++; - exp_pdu_data->tlv_buffer[i] = dvbci_get_evt_from_addrs(pinfo); - } + buffer_data = exp_pdu_data->tlv_buffer; + buf_remaining = exp_pdu_data->tlv_buffer_len; + + /* Start by adding protocol name as a tag */ + buffer_data[0] = (tag_type & 0xff00) >> 8; + buffer_data[1] = tag_type & 0x00ff; + buffer_data[2] = (proto_tag_len & 0xff00) >> 8; + buffer_data[3] = proto_tag_len & 0x00ff; /* tag length */ + memcpy(buffer_data+4, proto_name, proto_str_len); + buffer_data += (proto_tag_len+4); + buf_remaining -= (proto_tag_len+4); + + /* Populate data */ + loop_items = items_list; + while (*loop_items) { + item_size = (*loop_items)->populate_data(pinfo, (*loop_items)->data, buffer_data, buf_remaining); + buffer_data += item_size; + buf_remaining -= item_size; + loop_items++; } return exp_pdu_data; @@ -363,7 +271,6 @@ get_export_pdu_tap_list(void) void export_pdu_init(void) { - ss7pc_address_type = address_type_get_by_name("AT_SS7PC"); } /* |