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>
This commit is contained in:
parent
46561910f4
commit
be12a252dd
|
@ -529,6 +529,8 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
expert_register_protocol@Base 1.12.0~rc1
|
||||
expert_severity_vals@Base 1.12.0~rc1
|
||||
expert_update_comment_count@Base 1.12.0~rc1
|
||||
export_pdu_create_common_tags@Base 2.1.1
|
||||
export_pdu_create_tags@Base 2.1.1
|
||||
ext_menubar_add_entry@Base 1.99.8
|
||||
ext_menubar_add_separator@Base 1.99.8
|
||||
ext_menubar_add_submenu@Base 1.99.8
|
||||
|
@ -815,7 +817,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
link_type_vals@Base 2.1.0
|
||||
list_stat_cmd_args@Base 1.9.1
|
||||
llc_add_oui@Base 1.9.1
|
||||
load_export_pdu_tags@Base 1.12.0~rc1
|
||||
make_printable_string@Base 1.9.1
|
||||
manually_resolve_cleanup@Base 1.12.0~rc1
|
||||
mark_frame_as_depended_upon@Base 1.9.1
|
||||
|
|
|
@ -106,13 +106,7 @@ dissect_credssp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
|||
ver = tvb_get_guint8(tvb, offset);
|
||||
if((length == 1) && ((ver == 2) || (ver == 3))) {
|
||||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "credssp", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "credssp", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -1436,14 +1436,7 @@ static guint8 wild_card = 0xFF; /* place to store wildcardField */
|
|||
static void
|
||||
export_h248_pdu(packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "h248", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "h248", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -381,13 +381,7 @@ dissect_credssp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
|||
ver = tvb_get_guint8(tvb, offset);
|
||||
if((length == 1) && ((ver == 2) || (ver == 3))) {
|
||||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "credssp", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "credssp", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
@ -513,7 +507,7 @@ void proto_register_credssp(void) {
|
|||
"OCTET_STRING", HFILL }},
|
||||
|
||||
/*--- End of included file: packet-credssp-hfarr.c ---*/
|
||||
#line 153 "./asn1/credssp/packet-credssp-template.c"
|
||||
#line 147 "./asn1/credssp/packet-credssp-template.c"
|
||||
};
|
||||
|
||||
/* List of subtrees */
|
||||
|
@ -531,7 +525,7 @@ void proto_register_credssp(void) {
|
|||
&ett_credssp_TSRequest,
|
||||
|
||||
/*--- End of included file: packet-credssp-ettarr.c ---*/
|
||||
#line 159 "./asn1/credssp/packet-credssp-template.c"
|
||||
#line 153 "./asn1/credssp/packet-credssp-template.c"
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -338,13 +338,7 @@ static guint32 subscription_id_type;
|
|||
static void
|
||||
export_diameter_pdu(packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "diameter", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "diameter", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -614,13 +614,9 @@ decrypt_dtls_record(tvbuff_t *tvb, packet_info *pinfo, guint32 offset,
|
|||
}
|
||||
|
||||
static void
|
||||
export_pdu_packet(tvbuff_t *tvb, packet_info *pinfo, guint tag, const gchar *name)
|
||||
export_pdu_packet(tvbuff_t *tvb, packet_info *pinfo, guint8 tag, const gchar *name)
|
||||
{
|
||||
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, tag, name, &tags, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, name, tag);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -1671,8 +1671,7 @@ dvbci_set_addrs(guint8 event, packet_info *pinfo)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
guint8
|
||||
static guint8
|
||||
dvbci_get_evt_from_addrs(packet_info *pinfo)
|
||||
{
|
||||
/* this should be working from C89 on */
|
||||
|
@ -3344,6 +3343,23 @@ dissect_dvbci_payload_cup(guint32 tag, gint len_field _U_,
|
|||
}
|
||||
}
|
||||
|
||||
static int exp_pdu_data_dvbci_size(packet_info *pinfo _U_, void* data _U_)
|
||||
{
|
||||
return EXP_PDU_TAG_DVBCI_EVT_LEN + 4;
|
||||
}
|
||||
|
||||
static int exp_pdu_data_dvbci_populate_data(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 buffer_size _U_)
|
||||
{
|
||||
tlv_buffer[0] = 0;
|
||||
tlv_buffer[1] = EXP_PDU_TAG_DVBCI_EVT;
|
||||
tlv_buffer[2] = 0;
|
||||
tlv_buffer[3] = EXP_PDU_TAG_DVBCI_EVT_LEN;
|
||||
tlv_buffer[4] = dvbci_get_evt_from_addrs(pinfo);
|
||||
|
||||
return exp_pdu_data_dvbci_size(pinfo, data);
|
||||
}
|
||||
|
||||
static exp_pdu_data_item_t exp_pdu_dvbci = {exp_pdu_data_dvbci_size, exp_pdu_data_dvbci_populate_data, NULL};
|
||||
|
||||
static void
|
||||
dissect_sac_msg(guint32 tag, tvbuff_t *tvb, gint offset,
|
||||
|
@ -3438,10 +3454,13 @@ dissect_sac_msg(guint32 tag, tvbuff_t *tvb, gint offset,
|
|||
/* we call this function also to dissect exported SAC messages,
|
||||
don't try to export them a second time */
|
||||
if (!exported && is_exportable && have_tap_listener(exported_pdu_tap)) {
|
||||
static const exp_pdu_data_item_t *dvbci_exp_pdu_items[] = {
|
||||
&exp_pdu_dvbci,
|
||||
NULL
|
||||
};
|
||||
|
||||
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,
|
||||
|
@ -3449,10 +3468,7 @@ 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, EXP_PDU_TAG_PROTO_NAME, EXPORTED_SAC_MSG_PROTO, tags, 2);
|
||||
exp_pdu_data = export_pdu_create_tags(pinfo, EXPORTED_SAC_MSG_PROTO, EXP_PDU_TAG_PROTO_NAME, dvbci_exp_pdu_items);
|
||||
|
||||
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);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
WS_DLL_PUBLIC const value_string dvbci_event[];
|
||||
|
||||
gint dvbci_set_addrs(guint8 event, packet_info *pinfo);
|
||||
guint8 dvbci_get_evt_from_addrs(packet_info *pinfo);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1911,14 +1911,7 @@ static guint8 wild_card = 0xFF; /* place to store wildcardField */
|
|||
static void
|
||||
export_h248_pdu(packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "h248", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "h248", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
@ -6095,7 +6088,7 @@ dissect_h248_SigParameterV1(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
|
|||
|
||||
|
||||
/*--- End of included file: packet-h248-fn.c ---*/
|
||||
#line 2173 "./asn1/h248/packet-h248-template.c"
|
||||
#line 2166 "./asn1/h248/packet-h248-template.c"
|
||||
|
||||
static int dissect_h248_tpkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
|
||||
dissect_tpkt_encap(tvb, pinfo, tree, h248_desegment, h248_handle);
|
||||
|
@ -7521,7 +7514,7 @@ void proto_register_h248(void) {
|
|||
NULL, HFILL }},
|
||||
|
||||
/*--- End of included file: packet-h248-hfarr.c ---*/
|
||||
#line 2342 "./asn1/h248/packet-h248-template.c"
|
||||
#line 2335 "./asn1/h248/packet-h248-template.c"
|
||||
|
||||
GCP_HF_ARR_ELEMS("h248",h248_arrel)
|
||||
|
||||
|
@ -7687,7 +7680,7 @@ void proto_register_h248(void) {
|
|||
&ett_h248_SigParameterV1,
|
||||
|
||||
/*--- End of included file: packet-h248-ettarr.c ---*/
|
||||
#line 2360 "./asn1/h248/packet-h248-template.c"
|
||||
#line 2353 "./asn1/h248/packet-h248-template.c"
|
||||
};
|
||||
|
||||
static ei_register_info ei[] = {
|
||||
|
|
|
@ -1103,13 +1103,7 @@ static void
|
|||
export_ipsec_pdu(dissector_handle_t dissector_handle, packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
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, EXP_PDU_TAG_PROTO_NAME,
|
||||
dissector_handle_get_dissector_name(dissector_handle),
|
||||
&tags, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, dissector_handle_get_dissector_name(dissector_handle), EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -224,7 +224,8 @@ static void add_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, const char * sub
|
|||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
|
||||
exp_pdu_data = load_export_pdu_tags(pinfo, EXP_PDU_TAG_PROTO_NAME, subdissector_name, NULL, 0);
|
||||
exp_pdu_data = export_pdu_create_tags(pinfo, subdissector_name, EXP_PDU_TAG_PROTO_NAME, NULL);
|
||||
|
||||
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;
|
||||
|
|
|
@ -189,9 +189,9 @@ dissect_logcat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
|
|||
proto_tree_add_expert(maintree, pinfo, &ei_invalid_payload_length, tvb, offset, tvb_reported_length_remaining(tvb, offset));
|
||||
|
||||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
|
||||
exp_pdu_data = load_export_pdu_tags(pinfo, EXP_PDU_TAG_PROTO_NAME, "logcat", NULL, 0);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_tags(pinfo, "logcat", EXP_PDU_TAG_PROTO_NAME, NULL);
|
||||
|
||||
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;
|
||||
|
|
|
@ -422,14 +422,7 @@ megacostat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const
|
|||
static void
|
||||
export_megaco_pdu(packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "megaco", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "megaco", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -174,11 +174,7 @@ 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, EXP_PDU_TAG_PROTO_NAME, "reload-framing", &tags, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "reload-framing", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = effective_length;
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -3177,13 +3177,7 @@ fragment_reassembly(tvbuff_t *tvb, sctp_fragment *fragment,
|
|||
static void
|
||||
export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, const gchar *proto_name)
|
||||
{
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, proto_name, &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, proto_name, EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -1176,14 +1176,7 @@ sip_cleanup_protocol(void)
|
|||
static void
|
||||
export_sip_pdu(packet_info *pinfo, tvbuff_t *tvb)
|
||||
{
|
||||
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
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, EXP_PDU_TAG_PROTO_NAME, "sip", &tags_bit_field, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "sip", EXP_PDU_TAG_PROTO_NAME);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -1348,13 +1348,9 @@ again:
|
|||
}
|
||||
|
||||
static void
|
||||
export_pdu_packet(tvbuff_t *tvb, packet_info *pinfo, guint tag, const gchar *name)
|
||||
export_pdu_packet(tvbuff_t *tvb, packet_info *pinfo, guint8 tag, const gchar *name)
|
||||
{
|
||||
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, tag, name, &tags, 1);
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, name, tag);
|
||||
|
||||
exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
|
||||
exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
|
||||
|
|
|
@ -90,11 +90,13 @@ static user_encap_t user2_encap;
|
|||
static void export_pdu(tvbuff_t *tvb, packet_info* pinfo, char *proto_name)
|
||||
{
|
||||
if (have_tap_listener(exported_pdu_tap)) {
|
||||
exp_pdu_data_t *exp_pdu_data;
|
||||
guint8 exp_pdu_data_tag;
|
||||
static const exp_pdu_data_item_t *user_encap_exp_pdu_items[] = {
|
||||
&exp_pdu_data_orig_frame_num,
|
||||
NULL
|
||||
};
|
||||
|
||||
exp_pdu_data_t *exp_pdu_data = export_pdu_create_tags(pinfo, proto_name, EXP_PDU_TAG_PROTO_NAME, user_encap_exp_pdu_items);
|
||||
|
||||
exp_pdu_data_tag = EXP_PDU_TAG_ORIG_FNO_BIT;
|
||||
exp_pdu_data = load_export_pdu_tags(pinfo, EXP_PDU_TAG_PROTO_NAME, proto_name, &exp_pdu_data_tag, 1);
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
/* Add Tag + length */
|
||||
tag_buf_size += (proto_tag_len + 4);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
/* 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");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -135,27 +135,11 @@ typedef struct _exp_pdu_data_t {
|
|||
tvbuff_t *pdu_tvb;
|
||||
} exp_pdu_data_t;
|
||||
|
||||
/* 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_COL_PROT_BIT 0x02
|
||||
|
||||
#define EXP_PDU_TAG_IPV4_SRC_LEN 4
|
||||
#define EXP_PDU_TAG_IPV4_DST_LEN 4
|
||||
#define EXP_PDU_TAG_IPV6_SRC_LEN 16
|
||||
#define EXP_PDU_TAG_IPV6_DST_LEN 16
|
||||
#define EXP_PDU_TAG_IPV4_LEN 4
|
||||
#define EXP_PDU_TAG_IPV6_LEN 16
|
||||
|
||||
#define EXP_PDU_TAG_PORT_TYPE_LEN 4
|
||||
#define EXP_PDU_TAG_SRC_PORT_LEN 4
|
||||
#define EXP_PDU_TAG_DST_PORT_LEN 4
|
||||
#define EXP_PDU_TAG_PORT_LEN 4
|
||||
|
||||
#define EXP_PDU_TAG_SS7_OPC_LEN 8 /* 4 bytes PC, 2 bytes standard type, 1 byte NI, 1 byte padding */
|
||||
#define EXP_PDU_TAG_SS7_DPC_LEN 8 /* 4 bytes PC, 2 bytes standard type, 1 byte NI, 1 byte padding */
|
||||
|
@ -164,16 +148,67 @@ typedef struct _exp_pdu_data_t {
|
|||
|
||||
#define EXP_PDU_TAG_DVBCI_EVT_LEN 1
|
||||
|
||||
/** Compute the size (in bytes) of a pdu item
|
||||
*
|
||||
@param pinfo Packet info that may contain data for the pdu item
|
||||
@param data optional data of the pdu item
|
||||
@return the size of the pdu item
|
||||
*/
|
||||
typedef int (*exp_pdu_get_size)(packet_info *pinfo, void* data);
|
||||
|
||||
/** Populate a buffer with pdu item data
|
||||
*
|
||||
@param pinfo Packet info that may contain data for the PDU item
|
||||
@param data optional data of the PDU item
|
||||
@param tlv_buffer buffer to be populated with PDU item
|
||||
@param tlv_buffer_size size of buffer to be populated
|
||||
@return the number of bytes populated to the buffer (typically PDU item size)
|
||||
*/
|
||||
typedef int (*exp_pdu_populate_data)(packet_info *pinfo, void* data, guint8 *tlv_buffer, guint32 tlv_buffer_size);
|
||||
|
||||
typedef struct exp_pdu_data_item
|
||||
{
|
||||
exp_pdu_get_size size_func;
|
||||
exp_pdu_populate_data populate_data;
|
||||
void* data;
|
||||
} exp_pdu_data_item_t;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* 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, guint tag_type, const char* proto_name,
|
||||
guint8 *wanted_exp_tags, guint16 wanted_exp_tags_len);
|
||||
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.
|
||||
|
||||
@param pinfo Packet info that may contain data for the PDU items
|
||||
@param proto_name Name of protocol that is exporting PDU
|
||||
@param tag_type. Tag type for protocol's PDU. Must be EXP_PDU_TAG_PROTO_NAME or EXP_PDU_TAG_HEUR_PROTO_NAME.
|
||||
@param items PDU items to be exported
|
||||
@return filled exp_pdu_data_t struct
|
||||
*/
|
||||
WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_tags(packet_info *pinfo, const char* proto_name, guint16 tag_type, const exp_pdu_data_item_t **items);
|
||||
|
||||
/**
|
||||
Allocates and fills the exp_pdu_data_t struct with a common list of items
|
||||
The items that will be exported as the PDU are:
|
||||
1. Source IP
|
||||
2. Destintaiton IP
|
||||
3. Port type
|
||||
4. Source Port
|
||||
5. Destination Port
|
||||
6. Original frame number
|
||||
|
||||
@param pinfo Packet info that may contain data for the PDU items
|
||||
@param tag_type. Tag type for protocol's PDU. Must be EXP_PDU_TAG_PROTO_NAME or EXP_PDU_TAG_HEUR_PROTO_NAME.
|
||||
@param proto_name Name of protocol that is exporting PDU
|
||||
@return filled exp_pdu_data_t struct
|
||||
*/
|
||||
WS_DLL_PUBLIC exp_pdu_data_t *export_pdu_create_common_tags(packet_info *pinfo, const char *proto_name, guint16 tag_type);
|
||||
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_ip;
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_ip;
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_port_type;
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_src_port;
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_dst_port;
|
||||
WS_DLL_PUBLIC exp_pdu_data_item_t exp_pdu_data_orig_frame_num;
|
||||
|
||||
extern void export_pdu_init(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue