diff options
Diffstat (limited to 'epan/dissectors/packet-mtp3.c')
-rw-r--r-- | epan/dissectors/packet-mtp3.c | 208 |
1 files changed, 105 insertions, 103 deletions
diff --git a/epan/dissectors/packet-mtp3.c b/epan/dissectors/packet-mtp3.c index de858a76..c62acf2f 100644 --- a/epan/dissectors/packet-mtp3.c +++ b/epan/dissectors/packet-mtp3.c @@ -33,6 +33,8 @@ #include <wiretap/wtap.h> #include <epan/addr_resolv.h> +#include <wsutil/array.h> + #include "packet-q708.h" #include "packet-sccp.h" #include "packet-frame.h" @@ -41,54 +43,54 @@ void proto_register_mtp3(void); void proto_reg_handoff_mtp3(void); /* Initialize the protocol and registered fields */ -static int proto_mtp3 = -1; +static int proto_mtp3; -static int mtp3_tap = -1; +static int mtp3_tap; static dissector_handle_t mtp3_handle; static module_t *mtp3_module; -static int hf_mtp3_service_indicator = -1; -static int hf_mtp3_network_indicator = -1; -static int hf_mtp3_itu_spare = -1; -static int hf_mtp3_itu_priority = -1; -static int hf_mtp3_ansi_priority = -1; -static int hf_mtp3_itu_pc = -1; -static int hf_mtp3_24bit_pc = -1; -static int hf_mtp3_itu_opc = -1; -static int hf_mtp3_24bit_opc = -1; -static int hf_mtp3_ansi_opc = -1; -static int hf_mtp3_chinese_opc = -1; -static int hf_mtp3_opc_network = -1; -static int hf_mtp3_opc_cluster = -1; -static int hf_mtp3_opc_member = -1; -static int hf_mtp3_itu_dpc = -1; -static int hf_mtp3_24bit_dpc = -1; -static int hf_mtp3_ansi_dpc = -1; -static int hf_mtp3_chinese_dpc = -1; -static int hf_mtp3_dpc_network = -1; -static int hf_mtp3_dpc_cluster = -1; -static int hf_mtp3_dpc_member = -1; -static int hf_mtp3_itu_sls = -1; -static int hf_mtp3_ansi_5_bit_sls = -1; -static int hf_mtp3_ansi_8_bit_sls = -1; -static int hf_mtp3_chinese_itu_sls = -1; -static int hf_mtp3_japan_dpc = -1; -static int hf_mtp3_japan_opc = -1; -static int hf_mtp3_japan_pc = -1; -static int hf_mtp3_japan_4_bit_sls = -1; -static int hf_mtp3_japan_4_bit_sls_spare = -1; -static int hf_mtp3_japan_5_bit_sls = -1; -static int hf_mtp3_japan_5_bit_sls_spare = -1; -static int hf_mtp3_heuristic_standard = -1; +static int hf_mtp3_service_indicator; +static int hf_mtp3_network_indicator; +static int hf_mtp3_itu_spare; +static int hf_mtp3_itu_priority; +static int hf_mtp3_ansi_priority; +static int hf_mtp3_itu_pc; +static int hf_mtp3_24bit_pc; +static int hf_mtp3_itu_opc; +static int hf_mtp3_24bit_opc; +static int hf_mtp3_ansi_opc; +static int hf_mtp3_chinese_opc; +static int hf_mtp3_opc_network; +static int hf_mtp3_opc_cluster; +static int hf_mtp3_opc_member; +static int hf_mtp3_itu_dpc; +static int hf_mtp3_24bit_dpc; +static int hf_mtp3_ansi_dpc; +static int hf_mtp3_chinese_dpc; +static int hf_mtp3_dpc_network; +static int hf_mtp3_dpc_cluster; +static int hf_mtp3_dpc_member; +static int hf_mtp3_itu_sls; +static int hf_mtp3_ansi_5_bit_sls; +static int hf_mtp3_ansi_8_bit_sls; +static int hf_mtp3_chinese_itu_sls; +static int hf_mtp3_japan_dpc; +static int hf_mtp3_japan_opc; +static int hf_mtp3_japan_pc; +static int hf_mtp3_japan_4_bit_sls; +static int hf_mtp3_japan_4_bit_sls_spare; +static int hf_mtp3_japan_5_bit_sls; +static int hf_mtp3_japan_5_bit_sls_spare; +static int hf_mtp3_heuristic_standard; /* Initialize the subtree pointers */ -static gint ett_mtp3 = -1; -static gint ett_mtp3_sio = -1; -static gint ett_mtp3_label = -1; -static gint ett_mtp3_label_dpc = -1; -static gint ett_mtp3_label_opc = -1; +static int ett_mtp3; +static int ett_mtp3_sio; +static int ett_mtp3_label; +static int ett_mtp3_label_dpc; +static int ett_mtp3_label_opc; static dissector_table_t mtp3_sio_dissector_table; @@ -106,15 +108,15 @@ typedef enum { JAPAN_PC_STRUCTURE_3_4_4_5 = 3 } JAPAN_PC_Structure_Type; -static gint itu_pc_structure = ITU_PC_STRUCTURE_NONE; -static gint japan_pc_structure = JAPAN_PC_STRUCTURE_NONE; +static int itu_pc_structure = ITU_PC_STRUCTURE_NONE; +static int japan_pc_structure = JAPAN_PC_STRUCTURE_NONE; #include "packet-mtp3.h" -gint mtp3_standard = ITU_STANDARD; -gboolean mtp3_heuristic_standard = FALSE; +int mtp3_standard = ITU_STANDARD; +bool mtp3_heuristic_standard; -static gint pref_mtp3_standard; +static int pref_mtp3_standard; const value_string mtp3_standard_vals[] = { { ITU_STANDARD, "ITU_STANDARD" }, @@ -124,10 +126,10 @@ const value_string mtp3_standard_vals[] = { { 0, NULL } }; -static gboolean mtp3_use_ansi_5_bit_sls = FALSE; -static gboolean mtp3_use_japan_5_bit_sls = FALSE; -static gboolean mtp3_show_itu_priority = FALSE; -static gint mtp3_addr_fmt = MTP3_ADDR_FMT_DASHED; +static bool mtp3_use_ansi_5_bit_sls; +static bool mtp3_use_japan_5_bit_sls; +static bool mtp3_show_itu_priority; +static int mtp3_addr_fmt = MTP3_ADDR_FMT_DASHED; #define SIO_LENGTH 1 #define SLS_LENGTH 1 @@ -226,7 +228,7 @@ const value_string mtp3_network_indicator_vals[] = { */ static void -mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len) +mtp3_pc_to_str_buf(const uint32_t pc, char *buf, int buf_len) { switch (mtp3_standard) { @@ -275,25 +277,25 @@ mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len) #define MAX_STRUCTURED_PC_LENGTH 20 -gchar * -mtp3_pc_to_str(const guint32 pc) +char * +mtp3_pc_to_str(const uint32_t pc) { - gchar *str; + char *str; - str=(gchar *)wmem_alloc(wmem_packet_scope(), MAX_STRUCTURED_PC_LENGTH); + str=(char *)wmem_alloc(wmem_packet_scope(), MAX_STRUCTURED_PC_LENGTH); mtp3_pc_to_str_buf(pc, str, MAX_STRUCTURED_PC_LENGTH); return str; } -gboolean +bool mtp3_pc_structured(void) { if ((mtp3_standard == ITU_STANDARD) && (itu_pc_structure == ITU_PC_STRUCTURE_NONE)) - return FALSE; + return false; else if ((mtp3_standard == JAPAN_STANDARD) && (japan_pc_structure == JAPAN_PC_STRUCTURE_NONE)) - return FALSE; + return false; else - return TRUE; + return true; } /* @@ -302,7 +304,7 @@ mtp3_pc_structured(void) static void mtp3_addr_to_str_buf(const mtp3_addr_pc_t *addr_pc_p, - gchar *buf, int buf_len) + char *buf, int buf_len) { switch (mtp3_addr_fmt) { @@ -379,9 +381,9 @@ mtp3_addr_to_str_buf(const mtp3_addr_pc_t *addr_pc_p, } } -guint32 +uint32_t mtp3_pc_hash(const mtp3_addr_pc_t *addr_pc_p) { - guint32 pc; + uint32_t pc; switch (addr_pc_p->type) { @@ -397,7 +399,7 @@ 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) +static int mtp3_addr_to_str(const address* addr, char *buf, int buf_len) { mtp3_addr_to_str_buf((const mtp3_addr_pc_t *)addr->data, buf, buf_len); return (int)(strlen(buf)+1); @@ -408,7 +410,7 @@ static int mtp3_str_addr_len(const address* addr _U_) return 50; } -static const char* mtp3_addr_col_filter_str(const address* addr _U_, gboolean is_src) +static const char* mtp3_addr_col_filter_str(const address* addr _U_, bool is_src) { if (is_src) return "mtp3.opc"; @@ -421,16 +423,16 @@ int mtp3_addr_len(void) return sizeof(mtp3_addr_pc_t); } -static const gchar* mtp3_addr_name_res_str(const address* addr) +static const char* mtp3_addr_name_res_str(const address* addr) { const mtp3_addr_pc_t *mtp3_addr = (const mtp3_addr_pc_t *)addr->data; - const gchar *tmp; + const char *tmp; tmp = get_hostname_ss7pc(mtp3_addr->ni, mtp3_addr->pc); if (tmp[0] == '\0') { - gchar* str; - str = (gchar *)wmem_alloc(NULL, MAXNAMELEN); + char* str; + str = (char *)wmem_alloc(NULL, MAXNAMELEN); mtp3_addr_to_str_buf(mtp3_addr, str, MAXNAMELEN); fill_unresolved_ss7pc(str, mtp3_addr->ni, mtp3_addr->pc); wmem_free(NULL, str); @@ -450,10 +452,10 @@ static int mtp3_addr_name_res_len(void) /* 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, +dissect_mtp3_3byte_pc(tvbuff_t *tvb, unsigned offset, proto_tree *tree, int ett_pc, int hf_pc_string, int hf_pc_network, int hf_pc_cluster, int hf_pc_member, int hf_dpc, int hf_pc) { - guint32 pc; + uint32_t pc; proto_item *pc_item, *hidden_item; proto_tree *pc_tree; char pc_string[MAX_STRUCTURED_PC_LENGTH]; @@ -498,12 +500,12 @@ static void dissect_mtp3_sio(tvbuff_t *tvb, proto_tree *mtp3_tree, mtp3_addr_pc_t *mtp3_addr_opc, mtp3_addr_pc_t *mtp3_addr_dpc) { - guint8 sio; + uint8_t sio; proto_tree *sio_tree; sio_tree = proto_tree_add_subtree(mtp3_tree, tvb, SIO_OFFSET, SIO_LENGTH, ett_mtp3_sio, NULL, "Service information octet"); - sio = tvb_get_guint8(tvb, SIO_OFFSET); + sio = tvb_get_uint8(tvb, SIO_OFFSET); proto_tree_add_uint(sio_tree, hf_mtp3_network_indicator, tvb, SIO_OFFSET, SIO_LENGTH, sio); mtp3_addr_opc->ni = (sio & NETWORK_INDICATOR_MASK) >> 6; @@ -535,7 +537,7 @@ static void dissect_mtp3_routing_label(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mtp3_tree, mtp3_addr_pc_t *mtp3_addr_opc, mtp3_addr_pc_t *mtp3_addr_dpc) { - guint32 label, dpc, opc; + uint32_t label, dpc, opc; proto_item *label_dpc_item, *label_opc_item; proto_item *hidden_item; proto_tree *label_tree; @@ -652,21 +654,21 @@ 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, mtp3_address_type, mtp3_addr_len(), (guint8 *) mtp3_addr_opc); + set_address(&pinfo->src, mtp3_address_type, mtp3_addr_len(), (uint8_t *) mtp3_addr_opc); mtp3_addr_dpc->type = (Standard_Type)mtp3_standard; mtp3_addr_dpc->pc = dpc; - set_address(&pinfo->dst, mtp3_address_type, mtp3_addr_len(), (guint8 *) mtp3_addr_dpc); + set_address(&pinfo->dst, mtp3_address_type, mtp3_addr_len(), (uint8_t *) mtp3_addr_dpc); } static void dissect_mtp3_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - guint8 sio; - guint8 service_indicator; + uint8_t sio; + uint8_t service_indicator; tvbuff_t *payload_tvb = NULL; - sio = tvb_get_guint8(tvb, SIO_OFFSET); + sio = tvb_get_uint8(tvb, SIO_OFFSET); service_indicator = sio & SERVICE_INDICATOR_MASK; switch (mtp3_standard) { @@ -690,8 +692,8 @@ dissect_mtp3_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) call_data_dissector(payload_tvb, pinfo, tree); } -static guint -heur_mtp3_standard(tvbuff_t *tvb, packet_info *pinfo, guint8 si) +static unsigned +heur_mtp3_standard(tvbuff_t *tvb, packet_info *pinfo, uint8_t si) { tvbuff_t *payload; @@ -734,9 +736,9 @@ reset_mtp3_standard(void) static int dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - mtp3_tap_rec_t* tap_rec = wmem_new0(wmem_packet_scope(), mtp3_tap_rec_t); - gint heuristic_standard; - guint8 si; + mtp3_tap_rec_t* tap_rec = wmem_new0(pinfo->pool, mtp3_tap_rec_t); + int heuristic_standard; + uint8_t si; mtp3_addr_pc_t* mtp3_addr_dpc; mtp3_addr_pc_t* mtp3_addr_opc; @@ -748,7 +750,7 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ mtp3_item = proto_tree_add_item(tree, proto_mtp3, tvb, 0, -1, ENC_NA); - si = tvb_get_guint8(tvb, SIO_OFFSET) & SERVICE_INDICATOR_MASK; + si = tvb_get_uint8(tvb, SIO_OFFSET) & SERVICE_INDICATOR_MASK; if (mtp3_heuristic_standard) { heuristic_standard = heur_mtp3_standard(tvb, pinfo, si); if (heuristic_standard == HEURISTIC_FAILED_STANDARD) { @@ -801,7 +803,7 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ memcpy(&(tap_rec->addr_opc), mtp3_addr_opc, sizeof(mtp3_addr_pc_t)); memcpy(&(tap_rec->addr_dpc), mtp3_addr_dpc, sizeof(mtp3_addr_pc_t)); - tap_rec->mtp3_si_code = (tvb_get_guint8(tvb, SIO_OFFSET) & SERVICE_INDICATOR_MASK); + tap_rec->mtp3_si_code = (tvb_get_uint8(tvb, SIO_OFFSET) & SERVICE_INDICATOR_MASK); tap_rec->size = tvb_reported_length(tvb); tap_queue_packet(mtp3_tap, pinfo, tap_rec); @@ -836,7 +838,7 @@ static stat_tap_table_item mtp3_stat_fields[] = { static void mtp3_stat_init(stat_tap_table_ui* new_stat) { const char *table_name = "MTP3 Statistics"; - int num_fields = sizeof(mtp3_stat_fields)/sizeof(stat_tap_table_item); + int num_fields = array_length(mtp3_stat_fields); stat_tap_table *table; table = stat_tap_find_table(new_stat, table_name); @@ -856,12 +858,12 @@ mtp3_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, { stat_data_t* stat_data = (stat_data_t*)tapdata; const mtp3_tap_rec_t *m3tr = (const mtp3_tap_rec_t *)m3tr_ptr; - gboolean found = FALSE; - guint element; + bool found = false; + unsigned element; stat_tap_table* table; stat_tap_table_item_type* item_data; - guint msu_count; - guint byte_count; + unsigned msu_count; + unsigned byte_count; double avg_bytes = 0.0; if (m3tr->mtp3_si_code >= MTP3_NUM_SI_CODE) @@ -890,7 +892,7 @@ mtp3_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, { if (m3tr->mtp3_si_code == si_data->user_data.uint_value) { - found = TRUE; + found = true; break; } } @@ -900,8 +902,8 @@ mtp3_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, if (!found) { /* Add a new row */ /* XXX The old version added a row per SI. */ - int num_fields = sizeof(mtp3_stat_fields)/sizeof(stat_tap_table_item); - stat_tap_table_item_type items[sizeof(mtp3_stat_fields)/sizeof(stat_tap_table_item)]; + int num_fields = array_length(mtp3_stat_fields); + stat_tap_table_item_type items[array_length(mtp3_stat_fields)]; char str[256]; const char *sis; char *col_str; @@ -965,7 +967,7 @@ mtp3_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, static void mtp3_stat_reset(stat_tap_table* table) { - guint element; + unsigned element; stat_tap_table_item_type* item_data; for (element = 0; element < table->num_elements; element++) @@ -981,7 +983,7 @@ mtp3_stat_reset(stat_tap_table* table) } static void -mtp3_stat_free_table_item(stat_tap_table* table _U_, guint row _U_, guint column, stat_tap_table_item_type* field_data) +mtp3_stat_free_table_item(stat_tap_table* table _U_, unsigned row _U_, unsigned column, stat_tap_table_item_type* field_data) { switch(column) { case OPC_COLUMN: @@ -1039,7 +1041,7 @@ proto_register_mtp3(void) }; /* Setup protocol subtree array */ - static gint *ett[] = { + static int *ett[] = { &ett_mtp3, &ett_mtp3_sio, &ett_mtp3_label, @@ -1079,11 +1081,11 @@ proto_register_mtp3(void) }; static tap_param mtp3_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } + { PARAM_FILTER, "filter", "Filter", NULL, true } }; static stat_tap_table_ui mtp3_stat_table = { - REGISTER_STAT_GROUP_TELEPHONY_MTP3, + REGISTER_TELEPHONY_GROUP_MTP3, "MTP3 Statistics", "mtp3", "mtp3,msus", @@ -1092,8 +1094,8 @@ proto_register_mtp3(void) mtp3_stat_reset, mtp3_stat_free_table_item, NULL, - sizeof(mtp3_stat_fields)/sizeof(stat_tap_table_item), mtp3_stat_fields, - sizeof(mtp3_stat_params)/sizeof(tap_param), mtp3_stat_params, + array_length(mtp3_stat_fields), mtp3_stat_fields, + array_length(mtp3_stat_params), mtp3_stat_params, NULL, 0 }; @@ -1126,15 +1128,15 @@ proto_register_mtp3(void) prefs_register_enum_preference(mtp3_module, "standard", "MTP3 standard", "The SS7 standard used in MTP3 packets", - &mtp3_standard, mtp3_options, FALSE); + &mtp3_standard, mtp3_options, false); prefs_register_enum_preference(mtp3_module, "itu_pc_structure", "ITU Pointcode structure", "The structure of the pointcodes in ITU networks", - &itu_pc_structure, itu_pc_structures, FALSE); + &itu_pc_structure, itu_pc_structures, false); prefs_register_enum_preference(mtp3_module, "japan_pc_structure", "Japan Pointcode structure", "The structure of the pointcodes in Japan networks", - &japan_pc_structure, japan_pc_structures, FALSE); + &japan_pc_structure, japan_pc_structures, false); prefs_register_bool_preference(mtp3_module, "ansi_5_bit_sls", "Use 5-bit SLS (ANSI only)", @@ -1148,7 +1150,7 @@ proto_register_mtp3(void) prefs_register_enum_preference(mtp3_module, "addr_format", "Address Format", "Format for point code in the address columns", - &mtp3_addr_fmt, mtp3_addr_fmt_str_e, FALSE); + &mtp3_addr_fmt, mtp3_addr_fmt_str_e, false); prefs_register_bool_preference(mtp3_module, "itu_priority", "Show MSU priority (national option, ITU and China ITU only)", |