Convert AT_SS7PC to a "dissector address type"

The formatting of the address type is determined by a preference in
packet-mtp3.c, so just make MTP3 register the address type.
Use address_type_get_by_name in other dissectors (and export_pdu)
to use the address type.

Change-Id: Ifb32d7de27aeaa23cee8e803e25ffb3c905547b5
Reviewed-on: https://code.wireshark.org/review/15856
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Michael Mann 2016-06-12 12:28:02 -04:00 committed by Anders Broman
parent e2e84563ee
commit 04b82a7dc9
17 changed files with 149 additions and 101 deletions

View File

@ -824,7 +824,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
memory_usage_get@Base 1.12.0~rc1
mibenum_charset_to_encoding@Base 2.1.0
mibenum_vals_character_sets_ext@Base 2.1.0
mtp3_addr_to_str_buf@Base 1.9.1
mtp3_network_indicator_vals@Base 1.9.1
mtp3_service_indicator_code_short_vals@Base 1.9.1
mtp3_standard_vals@Base 1.9.1

View File

@ -49,7 +49,6 @@ typedef enum {
AT_VINES, /* Banyan Vines */
AT_FC, /* Fibre Channel */
AT_FCWWN, /* Fibre Channel WWN */
AT_SS7PC, /* SS7 Point Code */
AT_STRINGZ, /* null-terminated string */
AT_EUI64, /* IEEE EUI-64 */
AT_IB, /* Infiniband GID/LID */

View File

@ -427,22 +427,6 @@ static int fcwwn_name_res_len(void)
return MAX_ADDR_STR_LEN; /* XXX - This can be lower */
}
/******************************************************************************
* AT_SS7PC
* XXX - This should really be a dissector address type as its address string
* is partially determined by a dissector preference.
******************************************************************************/
static int ss7pc_to_str(const address* addr, gchar *buf, int buf_len)
{
mtp3_addr_to_str_buf((const mtp3_addr_pc_t *)addr->data, buf, buf_len);
return (int)(strlen(buf)+1);
}
static int ss7pc_str_len(const address* addr _U_)
{
return 50;
}
/******************************************************************************
* AT_STRINGZ
******************************************************************************/
@ -672,18 +656,6 @@ void address_types_initialize(void)
fcwwn_name_res_len, /* addr_name_res_len */
};
static address_type_t ss7pc_address = {
AT_SS7PC, /* addr_type */
"AT_SS7PC", /* name */
"SS7 Point Code", /* pretty_name */
ss7pc_to_str, /* addr_to_str */
ss7pc_str_len, /* addr_str_len */
NULL, /* addr_col_filter */
NULL, /* addr_fixed_len */
NULL, /* addr_name_res_str */
NULL, /* addr_name_res_len */
};
static address_type_t stringz_address = {
AT_STRINGZ, /* addr_type */
"AT_STRINGZ", /* name */
@ -758,7 +730,6 @@ void address_types_initialize(void)
address_type_register(AT_VINES, &vines_address );
address_type_register(AT_FC, &fc_address );
address_type_register(AT_FCWWN, &fcwwn_address );
address_type_register(AT_SS7PC, &ss7pc_address );
address_type_register(AT_STRINGZ, &stringz_address );
address_type_register(AT_EUI64, &eui64_address );
address_type_register(AT_IB, &ib_address );

View File

@ -31,6 +31,7 @@
#include <epan/asn1.h>
#include <epan/prefs.h>
#include <epan/exported_pdu.h>
#include <epan/address_types.h>
#include "packet-alcap.h"
#include "packet-ber.h"
#include "packet-tpkt.h"
@ -104,6 +105,8 @@ static expert_field ei_h248_octet_string_expected = EI_INIT;
static dissector_table_t subdissector_table;
static int ss7pc_address_type = -1;
/* Gateway Control Protocol -- Context Tracking */
const value_string gcp_cmd_type[] = {
@ -199,14 +202,16 @@ gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean keep_persistent_data) {
memcpy((guint8*)&(m->hi_addr),hi_addr->data,4);
memcpy((guint8*)&(m->lo_addr),lo_addr->data,4);
break;
case AT_SS7PC:
m->hi_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)hi_addr->data);
m->lo_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)lo_addr->data);
break;
default:
/* XXX: heuristic and error prone */
m->hi_addr = g_str_hash(address_to_str(wmem_packet_scope(), hi_addr));
m->lo_addr = g_str_hash(address_to_str(wmem_packet_scope(), lo_addr));
if (lo_addr->type == ss7pc_address_type) {
m->hi_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)hi_addr->data);
m->lo_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)lo_addr->data);
}
else {
/* XXX: heuristic and error prone */
m->hi_addr = g_str_hash(address_to_str(wmem_packet_scope(), hi_addr));
m->lo_addr = g_str_hash(address_to_str(wmem_packet_scope(), lo_addr));
}
break;
}
@ -2437,6 +2442,7 @@ void proto_reg_handoff_h248(void) {
dissector_add_uint("tcp.port", tcp_port, h248_tpkt_handle);
}
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
}

View File

@ -30,6 +30,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
#include <epan/address_types.h>
#include <epan/strutil.h>
#include <epan/show_exception.h>
@ -70,6 +71,8 @@ static struct tcapsrt_info_t * gp_tcapsrt_info;
static gboolean tcap_subdissector_used=FALSE;
static dissector_handle_t requested_subdissector_handle = NULL;
static int ss7pc_address_type = -1;
static struct tcaphash_context_t * gp_tcap_context=NULL;
#include "packet-tcap-ett.c"
@ -973,7 +976,7 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* prepare the key data */
tcaphash_begin_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -1165,7 +1168,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* look only for matching request, if matching conversation is available. */
tcaphash_cont_key.src_tid = p_tcapsrt_info->src_tid;
tcaphash_cont_key.dst_tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_cont_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -1194,7 +1197,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* Find the TCAP transaction according to the TC_BEGIN (from dtid,dst) */
tcaphash_begin_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -1217,7 +1220,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* Do we have a continue from the same source? (stid,src) */
tcaphash_begin_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -1250,7 +1253,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Create END for (stid,src) */
tcaphash_end_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -1321,7 +1324,7 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* look only for matching request, if matching conversation is available. */
tcaphash_end_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -1343,7 +1346,7 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
dbg(12,"EnotFound ");
#endif
tcaphash_begin_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -1439,7 +1442,7 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* prepare the key data */
tcaphash_ansi_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_ansi_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -2064,6 +2067,8 @@ proto_reg_handoff_tcap(void)
ansi_tcap_handle = find_dissector_add_dependency("ansi_tcap", proto_tcap);
ber_oid_dissector_table = find_dissector_table("ber.oid");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
#include "packet-tcap-dis-tab.c"
}

View File

@ -26,6 +26,7 @@
#include <epan/packet.h>
#include <wiretap/wtap.h>
#include <epan/to_str.h>
#include <epan/address_types.h>
#include <epan/exported_pdu.h>
#include "packet-mtp3.h"
#include "packet-dvbci.h"
@ -67,6 +68,8 @@ static int hf_exported_pdu_col_proto_str = -1;
static gint ett_exported_pdu = -1;
static gint ett_exported_pdu_tag = -1;
static int ss7pc_address_type = -1;
#define EXPORTED_PDU_NEXT_PROTO_STR 0
#define EXPORTED_PDU_NEXT_HEUR_PROTO_STR 1
#define EXPORTED_PDU_NEXT_DIS_TABLE_STR 2
@ -213,7 +216,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
break;
case EXP_PDU_TAG_SS7_DPC:
proto_tree_add_item(tag_tree, hf_exported_pdu_ss7_dpc, tvb, offset, 4, ENC_BIG_ENDIAN);
@ -221,7 +224,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr);
break;
case EXP_PDU_TAG_ORIG_FNO:
proto_tree_add_item(tag_tree, hf_exported_pdu_orig_fno, tvb, offset, 4, ENC_BIG_ENDIAN);
@ -458,6 +461,8 @@ proto_reg_handoff_exported_pdu(void)
initialized = TRUE;
}
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
/* Get the hf id of some fields from the IP dissectors to be able to use them here*/
hf_ip_addr = proto_registrar_get_id_byname("ip.addr");
hf_ip_dst = proto_registrar_get_id_byname("ip.dst");

View File

@ -39,6 +39,7 @@
#include <epan/asn1.h>
#include <epan/prefs.h>
#include <epan/exported_pdu.h>
#include <epan/address_types.h>
#include "packet-alcap.h"
#include "packet-ber.h"
#include "packet-tpkt.h"
@ -402,7 +403,7 @@ static int hf_h248_NotifyCompletion_otherReason = -1;
static int hf_h248_NotifyCompletion_onIteration = -1;
/*--- End of included file: packet-h248-hf.c ---*/
#line 79 "./asn1/h248/packet-h248-template.c"
#line 80 "./asn1/h248/packet-h248-template.c"
/* Initialize the subtree pointers */
static gint ett_h248 = -1;
@ -570,7 +571,7 @@ static gint ett_h248_EventParameterV1 = -1;
static gint ett_h248_SigParameterV1 = -1;
/*--- End of included file: packet-h248-ett.c ---*/
#line 99 "./asn1/h248/packet-h248-template.c"
#line 100 "./asn1/h248/packet-h248-template.c"
static expert_field ei_h248_errored_command = EI_INIT;
static expert_field ei_h248_transactionId64 = EI_INIT;
@ -579,6 +580,8 @@ static expert_field ei_h248_octet_string_expected = EI_INIT;
static dissector_table_t subdissector_table;
static int ss7pc_address_type = -1;
/* Gateway Control Protocol -- Context Tracking */
const value_string gcp_cmd_type[] = {
@ -674,14 +677,16 @@ gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean keep_persistent_data) {
memcpy((guint8*)&(m->hi_addr),hi_addr->data,4);
memcpy((guint8*)&(m->lo_addr),lo_addr->data,4);
break;
case AT_SS7PC:
m->hi_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)hi_addr->data);
m->lo_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)lo_addr->data);
break;
default:
/* XXX: heuristic and error prone */
m->hi_addr = g_str_hash(address_to_str(wmem_packet_scope(), hi_addr));
m->lo_addr = g_str_hash(address_to_str(wmem_packet_scope(), lo_addr));
if (lo_addr->type == ss7pc_address_type) {
m->hi_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)hi_addr->data);
m->lo_addr = mtp3_pc_hash((const mtp3_addr_pc_t *)lo_addr->data);
}
else {
/* XXX: heuristic and error prone */
m->hi_addr = g_str_hash(address_to_str(wmem_packet_scope(), hi_addr));
m->lo_addr = g_str_hash(address_to_str(wmem_packet_scope(), lo_addr));
}
break;
}
@ -6090,7 +6095,7 @@ dissect_h248_SigParameterV1(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of
/*--- End of included file: packet-h248-fn.c ---*/
#line 2168 "./asn1/h248/packet-h248-template.c"
#line 2173 "./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);
@ -7516,7 +7521,7 @@ void proto_register_h248(void) {
NULL, HFILL }},
/*--- End of included file: packet-h248-hfarr.c ---*/
#line 2337 "./asn1/h248/packet-h248-template.c"
#line 2342 "./asn1/h248/packet-h248-template.c"
GCP_HF_ARR_ELEMS("h248",h248_arrel)
@ -7682,7 +7687,7 @@ void proto_register_h248(void) {
&ett_h248_SigParameterV1,
/*--- End of included file: packet-h248-ettarr.c ---*/
#line 2355 "./asn1/h248/packet-h248-template.c"
#line 2360 "./asn1/h248/packet-h248-template.c"
};
static ei_register_info ei[] = {
@ -7768,6 +7773,7 @@ void proto_reg_handoff_h248(void) {
dissector_add_uint("tcp.port", tcp_port, h248_tpkt_handle);
}
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
}

View File

@ -34,6 +34,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/address_types.h>
#include <epan/sctpppids.h>
#include <wsutil/str_util.h>
#include "packet-mtp3.h"
@ -313,6 +314,8 @@ static module_t *m3ua_module;
static dissector_handle_t mtp3_handle;
static dissector_table_t si_dissector_table;
static int ss7pc_address_type = -1;
/* stuff for supporting multiple versions */
typedef enum {
M3UA_V5,
@ -1194,13 +1197,13 @@ dissect_protocol_data_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, pro
mtp3_tap->addr_dpc.type = (Standard_Type)mtp3_standard;
mtp3_tap->addr_dpc.pc = dpc;
mtp3_tap->addr_dpc.ni = tvb_get_guint8(parameter_tvb, DATA_NI_OFFSET);
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) &mtp3_tap->addr_dpc);
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) &mtp3_tap->addr_dpc);
mtp3_tap->addr_opc.type = (Standard_Type)mtp3_standard;
mtp3_tap->addr_opc.pc = opc;
mtp3_tap->addr_opc.ni = tvb_get_guint8(parameter_tvb, DATA_NI_OFFSET);
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) &mtp3_tap->addr_opc);
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) &mtp3_tap->addr_opc);
mtp3_tap->mtp3_si_code = tvb_get_guint8(parameter_tvb, DATA_SI_OFFSET);
mtp3_tap->size = 0;
@ -2159,6 +2162,8 @@ proto_reg_handoff_m3ua(void)
dissector_add_uint("sctp.port", SCTP_PORT_M3UA, m3ua_handle);
si_dissector_table = find_dissector_table("mtp3.service_indicator");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
}
/*

View File

@ -41,6 +41,7 @@
#include <epan/stat_tap_ui.h>
#include <epan/tap.h>
#include <epan/prefs.h>
#include <epan/address_types.h>
#include <wiretap/wtap.h>
#include "packet-q708.h"
@ -102,6 +103,8 @@ static gint ett_mtp3_label_opc = -1;
static dissector_table_t mtp3_sio_dissector_table;
static int mtp3_address_type = -1;
typedef enum {
ITU_PC_STRUCTURE_NONE = 1,
ITU_PC_STRUCTURE_3_8_3 = 2,
@ -233,7 +236,7 @@ const value_string mtp3_network_indicator_vals[] = {
* helper routine to format a point code in structured form
*/
void
static void
mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len)
{
switch (mtp3_standard)
@ -308,7 +311,7 @@ mtp3_pc_structured(void)
* helper routine to format address to string
*/
void
static void
mtp3_addr_to_str_buf(const mtp3_addr_pc_t *addr_pc_p,
gchar *buf, int buf_len)
{
@ -405,6 +408,22 @@ mtp3_pc_hash(const mtp3_addr_pc_t *addr_pc_p) {
return pc;
}
static int mtp3_addr_to_str(const address* addr, gchar *buf, int buf_len)
{
mtp3_addr_to_str_buf((const mtp3_addr_pc_t *)addr->data, buf, buf_len);
return (int)(strlen(buf)+1);
}
static int mtp3_str_addr_len(const address* addr _U_)
{
return 50;
}
int mtp3_addr_len(void)
{
return sizeof(mtp3_addr_pc_t);
}
/* Common function for dissecting 3-byte (ANSI or China) PCs. */
void
dissect_mtp3_3byte_pc(tvbuff_t *tvb, guint offset, proto_tree *tree, gint ett_pc, int hf_pc_string, int hf_pc_network,
@ -608,11 +627,11 @@ dissect_mtp3_routing_label(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mtp3_t
mtp3_addr_opc->type = (Standard_Type)mtp3_standard;
mtp3_addr_opc->pc = opc;
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
set_address(&pinfo->src, mtp3_address_type, mtp3_addr_len(), (guint8 *) mtp3_addr_opc);
mtp3_addr_dpc->type = (Standard_Type)mtp3_standard;
mtp3_addr_dpc->pc = dpc;
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
set_address(&pinfo->dst, mtp3_address_type, mtp3_addr_len(), (guint8 *) mtp3_addr_dpc);
}
static void
@ -1057,6 +1076,10 @@ proto_register_mtp3(void)
"MTP3 Service indicator",
proto_mtp3, FT_UINT8, BASE_HEX, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
mtp3_address_type = address_type_dissector_register("AT_SS7PC", "SS7 Point Code", mtp3_addr_to_str, mtp3_str_addr_len, NULL,
mtp3_addr_len, NULL, NULL);
mtp3_tap = register_tap("mtp3");
mtp3_module = prefs_register_protocol(proto_mtp3, NULL);

View File

@ -78,11 +78,10 @@ typedef struct _mtp3_tap_rec_t {
extern "C" {
#endif /* __cplusplus */
WS_DLL_PUBLIC void mtp3_addr_to_str_buf(const mtp3_addr_pc_t *addr_pc_p, gchar *buf, int buf_len);
extern void mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len);
extern gchar* mtp3_pc_to_str(const guint32 pc);
extern gboolean mtp3_pc_structured(void);
extern guint32 mtp3_pc_hash(const mtp3_addr_pc_t *addr_pc_p);
extern int mtp3_addr_len(void);
#ifdef __PROTO_H__
/* epan/to_str.c includes this file, but it does not include proto.h so

View File

@ -23,8 +23,9 @@
#include "config.h"
#include <epan/packet.h>
#include "packet-mtp3.h"
#include <epan/address_types.h>
#include <epan/prefs.h>
#include "packet-mtp3.h"
#define INVALID_SSN 0xff
@ -48,6 +49,8 @@ static dissector_table_t sccp_ssn_dissector_table;
static mtp3_addr_pc_t* mtp3_addr_opc;
static mtp3_addr_pc_t* mtp3_addr_dpc;
static int ss7pc_address_type = -1;
static gint ett_ppcap = -1;
static gint ett_ppcap1 = -1;
static gint ett_ppcap_new = -1;
@ -277,8 +280,8 @@ dissect_ppcap_source_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree * ppc
mtp3_addr_opc->pc = (guint32 )tvb_get_ntoh24(tvb, offset);
mtp3_addr_opc->type = ITU_STANDARD;
mtp3_addr_opc->ni = 0;
/*set_address(&pinfo->net_src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);*/
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
/*set_address(&pinfo->net_src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);*/
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
if (msg_len%4)
msg_len = msg_len + (4 - (msg_len%4));
@ -294,7 +297,7 @@ dissect_ppcap_source_address(tvbuff_t *tvb, packet_info *pinfo, proto_tree * ppc
mtp3_addr_opc->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr_opc->type = ITU_STANDARD;
mtp3_addr_opc->ni = 0;
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_opc);
}
else if (key1 == 3)
{
@ -367,7 +370,7 @@ dissect_ppcap_destination_address(tvbuff_t *tvb, packet_info * pinfo, proto_tree
mtp3_addr_dpc->pc = (guint32)tvb_get_ntoh24(tvb, offset);
mtp3_addr_dpc->type = ITU_STANDARD;
mtp3_addr_dpc->ni = 0;
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
if (msg_len%4)
msg_len = msg_len + (4 - (msg_len%4));
@ -385,7 +388,7 @@ dissect_ppcap_destination_address(tvbuff_t *tvb, packet_info * pinfo, proto_tree
mtp3_addr_dpc->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr_dpc->type = ITU_STANDARD;
mtp3_addr_dpc->ni = 0;
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) mtp3_addr_dpc);
}
else if (key2 == 3)
{
@ -700,6 +703,7 @@ void proto_reg_handoff_ppcap(void)
sccp_ssn_dissector_table = find_dissector_table("sccp.ssn");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
}
/*

View File

@ -40,6 +40,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include <epan/address_types.h>
#include <epan/asn1.h>
#include <epan/uat.h>
#include <epan/expert.h>
@ -719,6 +720,8 @@ static gboolean sccp_reassemble = TRUE;
static gboolean show_key_params = FALSE;
static gboolean set_addresses = FALSE;
static int ss7pc_address_type = -1;
static int sccp_tap = -1;
@ -1334,8 +1337,8 @@ get_sccp_assoc(packet_info *pinfo, guint offset, sccp_decode_context_t* value)
if (value->assoc)
return value->assoc;
opck = opc->type == AT_SS7PC ? mtp3_pc_hash((const mtp3_addr_pc_t *)opc->data) : g_str_hash(address_to_str(wmem_packet_scope(), opc));
dpck = dpc->type == AT_SS7PC ? mtp3_pc_hash((const mtp3_addr_pc_t *)dpc->data) : g_str_hash(address_to_str(wmem_packet_scope(), dpc));
opck = opc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)opc->data) : g_str_hash(address_to_str(wmem_packet_scope(), opc));
dpck = dpc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)dpc->data) : g_str_hash(address_to_str(wmem_packet_scope(), dpc));
switch (value->message_type) {
@ -2311,7 +2314,7 @@ dissect_sccp_data_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, scc
}
if ((num_sccp_users) && (pinfo->src.type == AT_SS7PC)) {
if ((num_sccp_users) && (pinfo->src.type == ss7pc_address_type)) {
guint i;
dissector_handle_t handle = NULL;
gboolean uses_tcap = FALSE;
@ -3336,7 +3339,7 @@ dissect_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree *sccp_tree = NULL;
const mtp3_addr_pc_t *mtp3_addr_p;
if ((pinfo->src.type == AT_SS7PC) &&
if ((pinfo->src.type == ss7pc_address_type) &&
((mtp3_addr_p = (const mtp3_addr_pc_t *)pinfo->src.data)->type <= CHINESE_ITU_STANDARD)) {
/*
* Allow a protocol beneath to specify how the SCCP layer should be
@ -3378,7 +3381,7 @@ dissect_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/* Set whether message is UPLINK, DOWNLINK, or of UNKNOWN direction */
if (pinfo->src.type == AT_SS7PC) {
if (pinfo->src.type == ss7pc_address_type) {
/*
* XXX - we assume that the "data" pointers of the source and destination
* addresses are set to point to "mtp3_addr_pc_t" structures, so that
@ -4163,6 +4166,8 @@ proto_reg_handoff_sccp(void)
camel_handle = find_dissector_add_dependency("camel", proto_sccp);
inap_handle = find_dissector_add_dependency("inap", proto_sccp);
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
initialised = TRUE;
}

View File

@ -30,6 +30,7 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/address_types.h>
#include <epan/prefs.h>
#include <epan/sctpppids.h>
#include <epan/tap.h>
@ -381,6 +382,8 @@ static heur_dissector_list_t heur_subdissector_list;
static guint32 message_class, message_type, drn, srn;
static int ss7pc_address_type = -1;
#define INVALID_SSN 0xff
static guint next_assoc_id = 1;
@ -436,8 +439,8 @@ sua_assoc(packet_info* pinfo, address* opc, address* dpc, guint src_rn, guint ds
return &no_sua_assoc;
}
opck = opc->type == AT_SS7PC ? mtp3_pc_hash((const mtp3_addr_pc_t *)opc->data) : g_str_hash(address_to_str(wmem_packet_scope(), opc));
dpck = dpc->type == AT_SS7PC ? mtp3_pc_hash((const mtp3_addr_pc_t *)dpc->data) : g_str_hash(address_to_str(wmem_packet_scope(), dpc));
opck = opc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)opc->data) : g_str_hash(address_to_str(wmem_packet_scope(), opc));
dpck = dpc->type == ss7pc_address_type ? mtp3_pc_hash((const mtp3_addr_pc_t *)dpc->data) : g_str_hash(address_to_str(wmem_packet_scope(), dpc));
switch (message_type) {
case MESSAGE_TYPE_CORE:
@ -2242,9 +2245,9 @@ dissect_sua_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *sua_t
if (set_addresses) {
if (sua_opc->type)
set_address(&pinfo->src, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) sua_opc);
set_address(&pinfo->src, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) sua_opc);
if (sua_dpc->type)
set_address(&pinfo->dst, AT_SS7PC, sizeof(mtp3_addr_pc_t), (guint8 *) sua_dpc);
set_address(&pinfo->dst, ss7pc_address_type, sizeof(mtp3_addr_pc_t), (guint8 *) sua_dpc);
if (sua_source_gt)
set_address(&pinfo->src, AT_STRINGZ, 1+(int)strlen(sua_source_gt), wmem_strdup(pinfo->pool, sua_source_gt));
@ -2486,6 +2489,7 @@ proto_reg_handoff_sua(void)
sccp_ssn_dissector_table = find_dissector_table("sccp.ssn");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
}
/*

View File

@ -38,6 +38,7 @@
#include <epan/prefs.h>
#include <epan/oids.h>
#include <epan/asn1.h>
#include <epan/address_types.h>
#include <epan/strutil.h>
#include <epan/show_exception.h>
@ -136,7 +137,7 @@ static int hf_tcap_AARQ_protocol_version_version1 = -1;
static int hf_tcap_AARE_protocol_version_version1 = -1;
/*--- End of included file: packet-tcap-hf.c ---*/
#line 60 "./asn1/tcap/packet-tcap-template.c"
#line 61 "./asn1/tcap/packet-tcap-template.c"
/* Initialize the subtree pointers */
static gint ett_tcap = -1;
@ -150,6 +151,8 @@ static struct tcapsrt_info_t * gp_tcapsrt_info;
static gboolean tcap_subdissector_used=FALSE;
static dissector_handle_t requested_subdissector_handle = NULL;
static int ss7pc_address_type = -1;
static struct tcaphash_context_t * gp_tcap_context=NULL;
@ -190,7 +193,7 @@ static gint ett_tcap_ABRT_user_information = -1;
static gint ett_tcap_Associate_source_diagnostic = -1;
/*--- End of included file: packet-tcap-ett.c ---*/
#line 76 "./asn1/tcap/packet-tcap-template.c"
#line 79 "./asn1/tcap/packet-tcap-template.c"
/* When several Tcap components are received in a single TCAP message,
we have to use several buffers for the stored parameters
@ -1420,7 +1423,7 @@ static int dissect_DialoguePDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pr
/*--- End of included file: packet-tcap-fn.c ---*/
#line 154 "./asn1/tcap/packet-tcap-template.c"
#line 157 "./asn1/tcap/packet-tcap-template.c"
/*
* DEBUG functions
@ -2243,7 +2246,7 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* prepare the key data */
tcaphash_begin_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -2435,7 +2438,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* look only for matching request, if matching conversation is available. */
tcaphash_cont_key.src_tid = p_tcapsrt_info->src_tid;
tcaphash_cont_key.dst_tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_cont_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -2464,7 +2467,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* Find the TCAP transaction according to the TC_BEGIN (from dtid,dst) */
tcaphash_begin_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -2487,7 +2490,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* Do we have a continue from the same source? (stid,src) */
tcaphash_begin_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -2520,7 +2523,7 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Create END for (stid,src) */
tcaphash_end_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -2591,7 +2594,7 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
#endif
/* look only for matching request, if matching conversation is available. */
tcaphash_end_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_end_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -2613,7 +2616,7 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
dbg(12,"EnotFound ");
#endif
tcaphash_begin_key.tid = p_tcapsrt_info->dst_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_begin_key.pc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->dst.data);
@ -2709,7 +2712,7 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* prepare the key data */
tcaphash_ansi_key.tid = p_tcapsrt_info->src_tid;
if (pinfo->src.type == AT_SS7PC && pinfo->dst.type == AT_SS7PC)
if (pinfo->src.type == ss7pc_address_type && pinfo->dst.type == ss7pc_address_type)
{
/* We have MTP3 PCs (so we can safely do this cast) */
tcaphash_ansi_key.opc_hash = mtp3_pc_hash((const mtp3_addr_pc_t *)pinfo->src.data);
@ -3334,6 +3337,8 @@ proto_reg_handoff_tcap(void)
ansi_tcap_handle = find_dissector_add_dependency("ansi_tcap", proto_tcap);
ber_oid_dissector_table = find_dissector_table("ber.oid");
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
/*--- Included file: packet-tcap-dis-tab.c ---*/
#line 1 "./asn1/tcap/packet-tcap-dis-tab.c"
@ -3342,7 +3347,7 @@ proto_reg_handoff_tcap(void)
/*--- End of included file: packet-tcap-dis-tab.c ---*/
#line 2068 "./asn1/tcap/packet-tcap-template.c"
#line 2073 "./asn1/tcap/packet-tcap-template.c"
}
static void init_tcap(void);
@ -3684,7 +3689,7 @@ proto_register_tcap(void)
NULL, HFILL }},
/*--- End of included file: packet-tcap-hfarr.c ---*/
#line 2141 "./asn1/tcap/packet-tcap-template.c"
#line 2146 "./asn1/tcap/packet-tcap-template.c"
};
/* Setup protocol subtree array */
@ -3732,7 +3737,7 @@ proto_register_tcap(void)
&ett_tcap_Associate_source_diagnostic,
/*--- End of included file: packet-tcap-ettarr.c ---*/
#line 2151 "./asn1/tcap/packet-tcap-template.c"
#line 2156 "./asn1/tcap/packet-tcap-template.c"
};
/*static enum_val_t tcap_options[] = {

View File

@ -53,6 +53,7 @@
#include "expert.h"
#include "print.h"
#include "capture_dissectors.h"
#include "exported_pdu.h"
#ifdef HAVE_LUA
#include <lua.h>
@ -130,6 +131,7 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
final_registration_all_protocols();
print_cache_field_handles();
expert_packet_init();
export_pdu_init();
#ifdef HAVE_LUA
wslua_init(cb, client_data);
#endif

View File

@ -27,12 +27,15 @@
#include <epan/packet.h>
#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 int ss7pc_address_type = -1;
/**
* Allocates and fills the exp_pdu_data_t struct according to the wanted_exp_tags
* bit field of wanted_exp_tags_len bytes length
@ -98,13 +101,13 @@ load_export_pdu_tags(packet_info *pinfo, guint tag_type, const char* proto_name,
}
if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){
if(pinfo->src.type == AT_SS7PC){
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 == AT_SS7PC){
if(pinfo->dst.type == ss7pc_address_type){
tag_buf_size += 4 + EXP_PDU_TAG_SS7_DPC_LEN;
}
}
@ -260,7 +263,7 @@ load_export_pdu_tags(packet_info *pinfo, guint tag_type, const char* proto_name,
}
if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_OPC_BIT) == EXP_PDU_TAG_SS7_OPC_BIT){
if(pinfo->src.type == AT_SS7PC){
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++;
@ -282,7 +285,7 @@ load_export_pdu_tags(packet_info *pinfo, guint tag_type, const char* proto_name,
}
if((wanted_exp_tags[0] & EXP_PDU_TAG_SS7_DPC_BIT) == EXP_PDU_TAG_SS7_DPC_BIT){
if(pinfo->dst.type == AT_SS7PC){
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++;
@ -358,6 +361,11 @@ get_export_pdu_tap_list(void)
return export_pdu_tap_name_list;
}
void export_pdu_init(void)
{
ss7pc_address_type = address_type_get_by_name("AT_SS7PC");
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*

View File

@ -175,6 +175,8 @@ typedef struct _exp_pdu_data_t {
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);
extern void export_pdu_init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */