diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2014-04-18 16:43:36 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-04-18 20:15:04 +0000 |
commit | ad33357e627c02d4b4f9b78e75a78fbfebd1d12f (patch) | |
tree | 94c5f33c77f33e16ee7cd1020be4c27c2b986e10 | |
parent | be76ba5f0df80f2e0f44f2c8bad9ee2e7341a729 (diff) |
Exported PDU: add support for more than 32 tags
Change-Id: Idc9f105164919827a8a81c88b5a56de4fa25df0b
Reviewed-on: https://code.wireshark.org/review/1197
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/dissectors/packet-credssp.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-diameter.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-dtls.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-dvbci.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-ipsec.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-logcat.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-reload-framing.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-sctp.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-sip.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-ssl.c | 5 | ||||
-rw-r--r-- | epan/exported_pdu.c | 387 | ||||
-rw-r--r-- | epan/exported_pdu.h | 30 |
12 files changed, 242 insertions, 221 deletions
diff --git a/epan/dissectors/packet-credssp.c b/epan/dissectors/packet-credssp.c index 2f01b59e80..f22cfb37ea 100644 --- a/epan/dissectors/packet-credssp.c +++ b/epan/dissectors/packet-credssp.c @@ -378,10 +378,10 @@ dissect_credssp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, if((length == 1) && (tvb_get_guint8(tvb, offset) == 2)) { if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; + guint8 tags= EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | + EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT; - exp_pdu_data = load_export_pdu_tags(pinfo, "credssp", -1, - (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | - EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT)); + exp_pdu_data = load_export_pdu_tags(pinfo, "credssp", -1, &tags, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index ce824afd5e..921b7766e5 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -333,12 +333,12 @@ static void export_diameter_pdu(packet_info *pinfo, tvbuff_t *tvb) { exp_pdu_data_t *exp_pdu_data; - guint32 tags_bit_field; + guint8 tags_bit_field; tags_bit_field = EXP_PDU_TAG_IP_SRC_BIT + EXP_PDU_TAG_IP_DST_BIT + EXP_PDU_TAG_SRC_PORT_BIT+ EXP_PDU_TAG_DST_PORT_BIT + EXP_PDU_TAG_ORIG_FNO_BIT; - exp_pdu_data = load_export_pdu_tags(pinfo, "diameter", -1, tags_bit_field); + exp_pdu_data = load_export_pdu_tags(pinfo, "diameter", -1, &tags_bit_field, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c index 64a3486c02..24c93b949d 100644 --- a/epan/dissectors/packet-dtls.c +++ b/epan/dissectors/packet-dtls.c @@ -1037,10 +1037,11 @@ dissect_dtls_record(tvbuff_t *tvb, packet_info *pinfo, if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; + guint8 tags = EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | + EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT; exp_pdu_data = load_export_pdu_tags(pinfo, dissector_handle_get_dissector_name(association->handle), -1, - (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | - EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT)); + &tags, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(next_tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(next_tvb); diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c index 65f7542e54..3da8c2add2 100644 --- a/epan/dissectors/packet-dvbci.c +++ b/epan/dissectors/packet-dvbci.c @@ -3415,6 +3415,7 @@ dissect_sac_msg(guint32 tag, tvbuff_t *tvb, gint offset, tvbuff_t *clear_sac_msg_tvb; exp_pdu_data_t *exp_pdu_data; + guint8 tags[2]; clear_sac_msg_tvb = tvb_new_composite(); tvb_composite_append(clear_sac_msg_tvb, @@ -3422,8 +3423,10 @@ dissect_sac_msg(guint32 tag, tvbuff_t *tvb, gint offset, tvb_composite_append(clear_sac_msg_tvb, clear_sac_body_tvb); tvb_composite_finalize(clear_sac_msg_tvb); + tags[0] = 0; + tags[1] = EXP_PDU_TAG_DVBCI_EVT_BIT; exp_pdu_data = load_export_pdu_tags( - pinfo, EXPORTED_SAC_MSG_PROTO, -1, EXP_PDU_TAG_DVBCI_EVT_BIT); + pinfo, EXPORTED_SAC_MSG_PROTO, -1, tags, 2); exp_pdu_data->tvb_captured_length = tvb_captured_length(clear_sac_msg_tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(clear_sac_msg_tvb); diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 2ced09cfdb..48285de418 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -863,10 +863,11 @@ export_ipsec_pdu(dissector_handle_t dissector_handle, packet_info *pinfo, tvbuff { if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; + guint8 tags = EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | + EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT; exp_pdu_data = load_export_pdu_tags(pinfo, dissector_handle_get_dissector_name(dissector_handle), -1, - (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | - EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT)); + &tags, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-logcat.c b/epan/dissectors/packet-logcat.c index 8b61491dda..f52b75b4ba 100644 --- a/epan/dissectors/packet-logcat.c +++ b/epan/dissectors/packet-logcat.c @@ -179,7 +179,7 @@ dissect_logcat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; - exp_pdu_data = load_export_pdu_tags(pinfo, "logcat", -1, EXP_PDU_TAG_END_OF_OPT); + exp_pdu_data = load_export_pdu_tags(pinfo, "logcat", -1, NULL, 0); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); exp_pdu_data->pdu_tvb = tvb; diff --git a/epan/dissectors/packet-reload-framing.c b/epan/dissectors/packet-reload-framing.c index 000a1ed190..c1cf0d9341 100644 --- a/epan/dissectors/packet-reload-framing.c +++ b/epan/dissectors/packet-reload-framing.c @@ -175,10 +175,10 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr if (from_dtls && have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; + guint8 tags = EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | + EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT; - exp_pdu_data = load_export_pdu_tags(pinfo, "reload-framing", -1, - (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | - EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT)); + exp_pdu_data = load_export_pdu_tags(pinfo, "reload-framing", -1, &tags, 1); exp_pdu_data->tvb_captured_length = effective_length; exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index 2381a5fb8b..2c42b1fbe2 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -3050,12 +3050,12 @@ static void export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, const gchar *proto_name) { exp_pdu_data_t *exp_pdu_data; - guint32 tags_bit_field; + guint8 tags_bit_field; tags_bit_field = EXP_PDU_TAG_IP_SRC_BIT + EXP_PDU_TAG_IP_DST_BIT + EXP_PDU_TAG_SRC_PORT_BIT+ EXP_PDU_TAG_DST_PORT_BIT + EXP_PDU_TAG_ORIG_FNO_BIT; - exp_pdu_data = load_export_pdu_tags(pinfo, proto_name, -1, tags_bit_field); + exp_pdu_data = load_export_pdu_tags(pinfo, proto_name, -1, &tags_bit_field, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 4d8c0e9584..f2cb2c9e7a 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -991,12 +991,12 @@ export_sip_pdu(packet_info *pinfo, tvbuff_t *tvb) { exp_pdu_data_t *exp_pdu_data; - guint32 tags_bit_field; + guint8 tags_bit_field; tags_bit_field = EXP_PDU_TAG_IP_SRC_BIT + EXP_PDU_TAG_IP_DST_BIT + EXP_PDU_TAG_SRC_PORT_BIT+ EXP_PDU_TAG_DST_PORT_BIT + EXP_PDU_TAG_ORIG_FNO_BIT; - exp_pdu_data = load_export_pdu_tags(pinfo, "sip", -1, tags_bit_field); + exp_pdu_data = load_export_pdu_tags(pinfo, "sip", -1, &tags_bit_field, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c index 483bd4af1c..6f17f1eb14 100644 --- a/epan/dissectors/packet-ssl.c +++ b/epan/dissectors/packet-ssl.c @@ -1365,10 +1365,11 @@ process_ssl_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo, } else { if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; + guint8 tags = EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | + EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT; exp_pdu_data = load_export_pdu_tags(pinfo, dissector_handle_get_dissector_name(association->handle), -1, - (EXP_PDU_TAG_IP_SRC_BIT | EXP_PDU_TAG_IP_DST_BIT | EXP_PDU_TAG_SRC_PORT_BIT | - EXP_PDU_TAG_DST_PORT_BIT | EXP_PDU_TAG_ORIG_FNO_BIT)); + &tags, 1); exp_pdu_data->tvb_captured_length = tvb_captured_length(next_tvb); exp_pdu_data->tvb_reported_length = tvb_reported_length(next_tvb); diff --git a/epan/exported_pdu.c b/epan/exported_pdu.c index c5c5b7a5f8..a1a205eca8 100644 --- a/epan/exported_pdu.c +++ b/epan/exported_pdu.c @@ -32,10 +32,14 @@ /** * 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 + * bit field of wanted_exp_tags_len bytes length + * If proto_name is != NULL, wtap_encap must be -1 or vice-versa + * + * The tags in the tag buffer SHOULD be added in numerical order. */ exp_pdu_data_t * -load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap _U_, guint32 tags_bit_field) +load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap _U_, + guint8 *wanted_exp_tags, guint16 wanted_exp_tags_len) { exp_pdu_data_t *exp_pdu_data; int tag_buf_size = 0; @@ -56,55 +60,61 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap tag_buf_size = tag_str_len + 4; } - if((tags_bit_field & 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; + /* 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((tags_bit_field & 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_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((tags_bit_field & 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; + 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; } - tag_buf_size= tag_buf_size + EXP_PDU_TAG_SRC_PORT_LEN + 4; - } - if((tags_bit_field & 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; + 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; } - tag_buf_size= tag_buf_size + EXP_PDU_TAG_DST_PORT_LEN + 4; - } - if((tags_bit_field & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){ - if(pinfo->src.type == AT_SS7PC){ - tag_buf_size += 4 + EXP_PDU_TAG_SS7_OPC_LEN; + if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){ + if(pinfo->src.type == AT_SS7PC){ + tag_buf_size += 4 + EXP_PDU_TAG_SS7_OPC_LEN; + } } - } - if((tags_bit_field & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){ - if(pinfo->dst.type == AT_SS7PC){ - tag_buf_size += 4 + EXP_PDU_TAG_SS7_DPC_LEN; + if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){ + if(pinfo->dst.type == AT_SS7PC){ + tag_buf_size += 4 + EXP_PDU_TAG_SS7_DPC_LEN; + } } - } - if((tags_bit_field & 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; + 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; + } } - if((tags_bit_field & 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; + /* 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; + } } /* Add end of options length */ @@ -128,192 +138,197 @@ load_export_pdu_tags(packet_info *pinfo, const char* proto_name, int wtap_encap } - if((tags_bit_field & 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; + /* 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((tags_bit_field & 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_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((tags_bit_field & EXP_PDU_TAG_SRC_PORT_BIT) == EXP_PDU_TAG_SRC_PORT_BIT){ - if (!port_type_defined) { + 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_PORT_TYPE; + 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_PORT_TYPE_LEN; /* tag length */ + exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_SRC_PORT_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] = (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; } - 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((tags_bit_field & EXP_PDU_TAG_DST_PORT_BIT) == EXP_PDU_TAG_DST_PORT_BIT){ - if (!port_type_defined) { + 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_PORT_TYPE; + 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_PORT_TYPE_LEN; /* tag length */ + exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DST_PORT_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] = (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 == AT_SS7PC){ + 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 == AT_SS7PC){ + 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; + } } - 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((tags_bit_field & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){ - if(pinfo->src.type == AT_SS7PC){ - const mtp3_addr_pc_t *mtp3_addr = (const mtp3_addr_pc_t *)(pinfo->src.data); + 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_SS7_OPC; + 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_SS7_OPC_LEN; /* tag length */ + exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_ORIG_FNO_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; + exp_pdu_data->tlv_buffer[i] = (pinfo->fd->num & 0xff000000) >> 24; + exp_pdu_data->tlv_buffer[i+1] = (pinfo->fd->num & 0x00ff0000) >> 16; + exp_pdu_data->tlv_buffer[i+2] = (pinfo->fd->num & 0x0000ff00) >> 8; + exp_pdu_data->tlv_buffer[i+3] = (pinfo->fd->num & 0x000000ff); + /*i = i +EXP_PDU_TAG_ORIG_FNO_LEN;*/ } } - if((tags_bit_field & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){ - if(pinfo->dst.type == AT_SS7PC){ - const mtp3_addr_pc_t *mtp3_addr = (const mtp3_addr_pc_t *)(pinfo->dst.data); + 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_SS7_DPC; + 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_SS7_DPC_LEN; /* tag length */ + exp_pdu_data->tlv_buffer[i] = EXP_PDU_TAG_DVBCI_EVT_LEN; 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; + exp_pdu_data->tlv_buffer[i] = dvbci_get_evt_from_addrs(pinfo); } } - if((tags_bit_field & 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->fd->num & 0xff000000) >> 24; - exp_pdu_data->tlv_buffer[i+1] = (pinfo->fd->num & 0x00ff0000) >> 16; - exp_pdu_data->tlv_buffer[i+2] = (pinfo->fd->num & 0x0000ff00) >> 8; - exp_pdu_data->tlv_buffer[i+3] = (pinfo->fd->num & 0x000000ff); - /*i = i +EXP_PDU_TAG_ORIG_FNO_LEN;*/ - } - - if((tags_bit_field & 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); - } - return exp_pdu_data; } diff --git a/epan/exported_pdu.h b/epan/exported_pdu.h index 1bdc3ab534..8b10eca703 100644 --- a/epan/exported_pdu.h +++ b/epan/exported_pdu.h @@ -113,18 +113,17 @@ typedef struct _exp_pdu_data_t { tvbuff_t *pdu_tvb; } exp_pdu_data_t; -#define EXP_PDU_TAG_IP_SRC_BIT 0x00000001 -#define EXP_PDU_TAG_IP_DST_BIT 0x00000002 - -#define EXP_PDU_TAG_SRC_PORT_BIT 0x00000004 -#define EXP_PDU_TAG_DST_PORT_BIT 0x00000008 - -#define EXP_PDU_TAG_SS7_OPC_BIT 0x00000020 -#define EXP_PDU_TAG_SS7_DPC_BIT 0x00000040 - -#define EXP_PDU_TAG_ORIG_FNO_BIT 0x00000080 - -#define EXP_PDU_TAG_DVBCI_EVT_BIT 0x00000100 +/* 1st byte of optional tags bitmap */ +#define EXP_PDU_TAG_IP_SRC_BIT 0x01 +#define EXP_PDU_TAG_IP_DST_BIT 0x02 +#define EXP_PDU_TAG_SRC_PORT_BIT 0x04 +#define EXP_PDU_TAG_DST_PORT_BIT 0x08 +#define EXP_PDU_TAG_SS7_OPC_BIT 0x20 +#define EXP_PDU_TAG_SS7_DPC_BIT 0x40 +#define EXP_PDU_TAG_ORIG_FNO_BIT 0x80 + +/* 2nd byte of optional tags bitmap */ +#define EXP_PDU_TAG_DVBCI_EVT_BIT 0x01 #define EXP_PDU_TAG_IPV4_SRC_LEN 4 #define EXP_PDU_TAG_IPV4_DST_LEN 4 @@ -144,12 +143,13 @@ typedef struct _exp_pdu_data_t { /** * 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 + * bit field of wanted_exp_tags_len bytes length + * If proto_name is != NULL, wtap_encap must be -1 or vice-versa * * The tags in the tag buffer SHOULD be added in numerical order. */ -WS_DLL_PUBLIC exp_pdu_data_t *load_export_pdu_tags(packet_info *pinfo, - const char* proto_name, int wtap_encap, guint32 wanted_exp_tags); +WS_DLL_PUBLIC exp_pdu_data_t *load_export_pdu_tags(packet_info *pinfo, const char* proto_name, + int wtap_encap, guint8 *wanted_exp_tags, guint16 wanted_exp_tags_len); #endif /* EXPORTED_PDU_H */ |