aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sgsap.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-sgsap.c')
-rw-r--r--epan/dissectors/packet-sgsap.c123
1 files changed, 42 insertions, 81 deletions
diff --git a/epan/dissectors/packet-sgsap.c b/epan/dissectors/packet-sgsap.c
index b6d8b1887d..2a1d0813ab 100644
--- a/epan/dissectors/packet-sgsap.c
+++ b/epan/dissectors/packet-sgsap.c
@@ -38,35 +38,34 @@ static dissector_handle_t gsm_a_dtap_handle;
* The payload protocol identifier to be used for SGsAP is 0.
*/
#define SGSAP_SCTP_PORT_RANGE "29118"
-static range_t *global_sgsap_port_range;
/* Initialize the protocol and registered fields */
-static int proto_sgsap = -1;
-
-static int hf_sgsap_msg_type = -1;
-int hf_sgsap_elem_id = -1;
-static int hf_sgsap_eps_location_update_type = -1;
-static int hf_sgsap_service_indicator_value = -1;
-static int hf_sgsap_sgs_cause = -1;
-static int hf_sgsap_ue_emm_mode = -1;
-static int hf_sgsap_eci = -1;
-static int hf_sgsap_cn_id = -1;
-static int hf_sgsap_imsi_det_eps = -1;
-static int hf_sgsap_imsi_det_non_eps = -1;
-static int hf_sgsap_lcs_indic = -1;
-static int hf_sgsap_mme_name = -1;
-static int hf_sgsap_vlr_name = -1;
-static int hf_sgsap_imeisv = -1;
-static int hf_sgsap_unknown_msg = -1;
-static int hf_sgsap_message_elements = -1;
-static int hf_sgsap_csri = -1;
-static int hf_sgsap_sel_cs_dmn_op = -1;
-
-static int ett_sgsap = -1;
-static int ett_sgsap_sel_cs_dmn_op = -1;
-
-static expert_field ei_sgsap_extraneous_data = EI_INIT;
-static expert_field ei_sgsap_missing_mandatory_element = EI_INIT;
+static int proto_sgsap;
+
+static int hf_sgsap_msg_type;
+int hf_sgsap_elem_id;
+static int hf_sgsap_eps_location_update_type;
+static int hf_sgsap_service_indicator_value;
+static int hf_sgsap_sgs_cause;
+static int hf_sgsap_ue_emm_mode;
+static int hf_sgsap_eci;
+static int hf_sgsap_cn_id;
+static int hf_sgsap_imsi_det_eps;
+static int hf_sgsap_imsi_det_non_eps;
+static int hf_sgsap_lcs_indic;
+static int hf_sgsap_mme_name;
+static int hf_sgsap_vlr_name;
+static int hf_sgsap_imeisv;
+static int hf_sgsap_unknown_msg;
+static int hf_sgsap_message_elements;
+static int hf_sgsap_csri;
+static int hf_sgsap_sel_cs_dmn_op;
+
+static int ett_sgsap;
+static int ett_sgsap_sel_cs_dmn_op;
+
+static expert_field ei_sgsap_extraneous_data;
+static expert_field ei_sgsap_missing_mandatory_element;
static dissector_handle_t sgsap_handle;
@@ -109,7 +108,7 @@ de_sgsap_eps_loc_upd_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U
proto_tree_add_item(tree, hf_sgsap_eps_location_update_type, tvb, offset, 1, ENC_BIG_ENDIAN);
if (add_string) {
oct = tvb_get_guint8(tvb, curr_offset);
- g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_eps_location_update_type_values, "Reserved"));
+ snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_eps_location_update_type_values, "Reserved"));
}
curr_offset++;
@@ -135,7 +134,7 @@ de_sgsap_err_msg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 of
* Octet 3 - Octet n
* Erroneous message including the message type.
*/
- /* Messge type IE*/
+ /* Message type IE*/
oct = tvb_get_guint8(tvb, offset);
msg_fcn_p = NULL;
ett_tree = -1;
@@ -147,7 +146,7 @@ de_sgsap_err_msg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 of
get_sgsap_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p);
if (msg_str) {
if (add_string)
- g_snprintf(add_string, string_len, " - %s", msg_str);
+ snprintf(add_string, string_len, " - %s", msg_str);
}
if (msg_fcn_p){
@@ -224,10 +223,10 @@ de_sgsap_imeisv(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32
curr_offset = offset;
- proto_tree_add_item_ret_display_string(tree, hf_sgsap_imeisv, tvb, curr_offset, len, ENC_BCD_DIGITS_0_9, pinfo->pool, &imeisv_str);
+ proto_tree_add_item_ret_display_string(tree, hf_sgsap_imeisv, tvb, curr_offset, len, ENC_BCD_DIGITS_0_9|ENC_LITTLE_ENDIAN, pinfo->pool, &imeisv_str);
if (add_string) {
/* (len<<2)+4 = the maximum number of bytes to produce (including the terminating nul character). */
- g_snprintf(add_string, (len<<2)+4, " - %s", imeisv_str);
+ snprintf(add_string, (len<<2)+4, " - %s", imeisv_str);
}
return(len);
@@ -351,7 +350,7 @@ de_sgsap_mm_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint3
static guint16
de_sgsap_mme_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
{
- guint name_len, tmp;
+ guint name_len;
guint8 *fqdn = NULL;
/* The MME name information element specifies the MME name and is coded as shown in figure 9.4.13.1. Octets 3
@@ -363,20 +362,13 @@ de_sgsap_mme_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint
name_len = tvb_get_guint8(tvb, offset);
if (name_len < 0x20) {
- fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset + 1, len - 1, ENC_ASCII);
- for (;;) {
- if (name_len >= len - 1)
- break;
- tmp = name_len;
- name_len = name_len + fqdn[tmp] + 1;
- fqdn[tmp] = '.';
- }
+ fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_APN_STR);
} else{
fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII);
}
proto_tree_add_string(tree, hf_sgsap_mme_name, tvb, offset, len, fqdn);
if (add_string)
- g_snprintf(add_string, string_len, " - %s", fqdn);
+ snprintf(add_string, string_len, " - %s", fqdn);
}
@@ -447,7 +439,7 @@ de_sgsap_serv_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, gui
proto_tree_add_item(tree, hf_sgsap_service_indicator_value, tvb, offset, 1, ENC_BIG_ENDIAN);
if (add_string) {
oct = tvb_get_guint8(tvb, curr_offset);
- g_snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_service_indicator_values, "Reserved"));
+ snprintf(add_string, string_len, " - %s", val_to_str_const(oct, sgsap_service_indicator_values, "Reserved"));
}
curr_offset++;
@@ -490,7 +482,7 @@ de_sgsap_sgs_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guin
proto_tree_add_item(tree, hf_sgsap_sgs_cause, tvb, offset, 1, ENC_BIG_ENDIAN);
if (add_string) {
oct = tvb_get_guint8(tvb, curr_offset);
- g_snprintf(add_string, string_len, " - %s", val_to_str_ext_const(oct, &sgsap_sgs_cause_values_ext, "Reserved"));
+ snprintf(add_string, string_len, " - %s", val_to_str_ext_const(oct, &sgsap_sgs_cause_values_ext, "Reserved"));
}
curr_offset++;
@@ -553,7 +545,7 @@ de_sgsap_ue_emm_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, gu
static guint16
de_sgsap_vlr_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
{
- guint name_len, tmp;
+ guint name_len;
guint8 *fqdn = NULL;
/* The VLR name information element specifies the VLR name and is coded as shown in figure 9.4.22.1.
@@ -564,20 +556,13 @@ de_sgsap_vlr_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint
name_len = tvb_get_guint8(tvb, offset);
if (name_len < 0x20) {
- fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset + 1, len - 1, ENC_ASCII);
- for (;;) {
- if (name_len >= len - 1)
- break;
- tmp = name_len;
- name_len = name_len + fqdn[tmp] + 1;
- fqdn[tmp] = '.';
- }
+ fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_APN_STR);
} else{
fqdn = tvb_get_string_enc(pinfo->pool, tvb, offset, len, ENC_ASCII);
}
proto_tree_add_string(tree, hf_sgsap_vlr_name, tvb, offset, len, fqdn);
if (add_string)
- g_snprintf(add_string, string_len, " - %s", fqdn);
+ snprintf(add_string, string_len, " - %s", fqdn);
}
return(len);
@@ -1540,7 +1525,7 @@ dissect_sgsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
item = proto_tree_add_item(tree, proto_sgsap, tvb, 0, -1, ENC_NA);
sgsap_tree = proto_item_add_subtree(item, ett_sgsap);
- /* Messge type IE*/
+ /* Message type IE*/
oct = tvb_get_guint8(tvb, offset);
msg_fcn_p = NULL;
ett_tree = -1;
@@ -1583,7 +1568,6 @@ dissect_sgsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
void proto_register_sgsap(void) {
guint i;
guint last_offset;
- module_t *sgsap_module;
/* List of fields */
@@ -1700,13 +1684,11 @@ void proto_register_sgsap(void) {
for (i=0; i < NUM_SGSAP_ELEM; i++, last_offset++)
{
- ett_sgsap_elem[i] = -1;
ett[last_offset] = &ett_sgsap_elem[i];
}
for (i=0; i < NUM_SGSAP_MSG; i++, last_offset++)
{
- ett_sgsap_msg[i] = -1;
ett[last_offset] = &ett_sgsap_msg[i];
}
@@ -1721,16 +1703,8 @@ void proto_register_sgsap(void) {
/* Register dissector */
sgsap_handle = register_dissector(PFNAME, dissect_sgsap, proto_sgsap);
- /* Set default SCTP ports */
- range_convert_str(wmem_epan_scope(), &global_sgsap_port_range, SGSAP_SCTP_PORT_RANGE, MAX_SCTP_PORT);
+ /* sgsap_module = prefs_register_protocol(proto_sgsap, NULL); */
- sgsap_module = prefs_register_protocol(proto_sgsap, proto_reg_handoff_sgsap);
-
- prefs_register_range_preference(sgsap_module, "sctp_ports",
- "SGsAP SCTP port numbers",
- "Port numbers used for SGsAP traffic "
- "(default " SGSAP_SCTP_PORT_RANGE ")",
- &global_sgsap_port_range, MAX_SCTP_PORT);
}
void
@@ -1739,21 +1713,8 @@ proto_reg_handoff_sgsap(void)
/* The registered SCTP port number for SGsAP is 29118.
* The payload protocol identifier to be used for SGsAP is 0.
*/
- static gboolean Initialized = FALSE;
- static range_t *sgsap_port_range;
-
gsm_a_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_sgsap);
-
- if (!Initialized) {
- dissector_add_for_decode_as("sctp.port", sgsap_handle);
- Initialized=TRUE;
- } else {
- dissector_delete_uint_range("sctp.port", sgsap_port_range, sgsap_handle);
- wmem_free(wmem_epan_scope(), sgsap_port_range);
- }
-
- sgsap_port_range = range_copy(wmem_epan_scope(), global_sgsap_port_range);
- dissector_add_uint_range("sctp.port", sgsap_port_range, sgsap_handle);
+ dissector_add_uint_range_with_preference("sctp.port", SGSAP_SCTP_PORT_RANGE, sgsap_handle);
}
/*