diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2017-11-30 09:31:43 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-11-30 12:17:48 +0000 |
commit | a6d0ffca86662357893c2ba6986964cb341a73d1 (patch) | |
tree | 53efb9c4cb560b58180eefa9e7ca028d07828f3b /epan | |
parent | 6a00fa767fec78020203e1f53062c6a2e5a117c6 (diff) |
RRC: reset strbuf pointer after its use
While we are at it, let's add a partial dissection of
PLMN-IdentityWithOptionalMCC-r6 IE.
Bug: 14248
Change-Id: I20b76bc74c248914db21629f8ce77799fccb1612
Reviewed-on: https://code.wireshark.org/review/24661
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/asn1/rrc/rrc.cnf | 48 | ||||
-rw-r--r-- | epan/dissectors/packet-rrc.c | 111 |
2 files changed, 114 insertions, 45 deletions
diff --git a/epan/dissectors/asn1/rrc/rrc.cnf b/epan/dissectors/asn1/rrc/rrc.cnf index 213c2bd0aa..4837a7c887 100644 --- a/epan/dissectors/asn1/rrc/rrc.cnf +++ b/epan/dissectors/asn1/rrc/rrc.cnf @@ -780,21 +780,21 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me tvbuff_t* mcc_mnc_tvb; /* Reset the digits string in the private data struct */ - /* Maximal length: 6 = 3 digits MCC + 3 digits MNC + trailing '\0'*/ + /* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */ mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7); private_data_set_digits_strbuf(actx, mcc_mnc_strbuf); /* Reset parsing failure flag*/ private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE); %(DEFAULT_BODY)s + private_data_set_digits_strbuf(actx, NULL); /* Check for parsing errors */ if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { return offset; } - /* Extracing the string collected in the strbuf */ + /* Extracting the string collected in the strbuf */ string_len = (guint32)wmem_strbuf_get_len(mcc_mnc_strbuf); - mcc_mnc_string = wmem_strdup(actx->pinfo->pool, wmem_strbuf_get_str(mcc_mnc_strbuf)); - wmem_strbuf_truncate(mcc_mnc_strbuf, 0); + mcc_mnc_string = wmem_strbuf_finalize(mcc_mnc_strbuf); /* Creating TVB from extracted string*/ mcc_mnc_tvb = tvb_new_child_real_data(tvb, (guint8*)mcc_mnc_string, string_len, string_len); @@ -803,6 +803,40 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me /* Calling E.212 */ dissect_e212_mcc_mnc_in_utf8_address(mcc_mnc_tvb, actx->pinfo, tree, 0); +#.FN_BODY PLMN-IdentityWithOptionalMCC-r6 + wmem_strbuf_t* mcc_mnc_strbuf; + guint32 string_len; + gchar* mcc_mnc_string; + tvbuff_t* mcc_mnc_tvb; + + /* Reset the digits string in the private data struct */ + /* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */ + mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7); + private_data_set_digits_strbuf(actx, mcc_mnc_strbuf); + /* Reset parsing failure flag*/ + private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE); +%(DEFAULT_BODY)s + private_data_set_digits_strbuf(actx, NULL); + /* Check for parsing errors */ + if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { + return offset; + } + + /* Extracting the string collected in the strbuf */ + string_len = (guint32)wmem_strbuf_get_len(mcc_mnc_strbuf); + if (string_len >= 5) { + /* optional MCC was present, we can call E.212 dissector */ + /* if not present, we could apply the algorithm in 25.331 chapter 8.1.1.5 */ + mcc_mnc_string = wmem_strbuf_finalize(mcc_mnc_strbuf); + + /* Creating TVB from extracted string*/ + mcc_mnc_tvb = tvb_new_child_real_data(tvb, (guint8*)mcc_mnc_string, string_len, string_len); + add_new_data_source(actx->pinfo, mcc_mnc_tvb, "MCC-MNC"); + + /* Calling E.212 */ + dissect_e212_mcc_mnc_in_utf8_address(mcc_mnc_tvb, actx->pinfo, tree, 0); + } + #.FN_BODY IMSI-GSM-MAP wmem_strbuf_t* imsi_strbuf; guint32 string_len; @@ -815,15 +849,15 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me /* Reset parsing failure flag*/ private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE); %(DEFAULT_BODY)s + private_data_set_digits_strbuf(actx, NULL); /* Check for parsing errors */ if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { return offset; } - /* Extracing the string collected in the strbuf */ + /* Extracting the string collected in the strbuf */ string_len = (guint32)wmem_strbuf_get_len(imsi_strbuf); - imsi_string = wmem_strdup(actx->pinfo->pool, wmem_strbuf_get_str(imsi_strbuf)); - wmem_strbuf_truncate(imsi_strbuf, 0); + imsi_string = wmem_strbuf_finalize(imsi_strbuf); /* Creating TVB from extracted string*/ imsi_tvb = tvb_new_child_real_data(tvb, (guint8*)imsi_string, string_len, string_len); diff --git a/epan/dissectors/packet-rrc.c b/epan/dissectors/packet-rrc.c index b1c694f57b..3a8ee418fc 100644 --- a/epan/dissectors/packet-rrc.c +++ b/epan/dissectors/packet-rrc.c @@ -18578,7 +18578,7 @@ dissect_rrc_ActivationTime(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _ static int dissect_rrc_RB_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1241 "./asn1/rrc/rrc.cnf" +#line 1275 "./asn1/rrc/rrc.cnf" guint32 rbid; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 1U, 32U, &rbid, FALSE); @@ -18595,7 +18595,7 @@ private_data_set_rbid(actx, rbid); static int dissect_rrc_RLC_SequenceNumber(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1247 "./asn1/rrc/rrc.cnf" +#line 1281 "./asn1/rrc/rrc.cnf" guint32 rlc_ciphering_sqn; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 4095U, &rlc_ciphering_sqn, FALSE); @@ -18616,7 +18616,7 @@ static const per_sequence_t RB_ActivationTimeInfo_sequence[] = { static int dissect_rrc_RB_ActivationTimeInfo(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1213 "./asn1/rrc/rrc.cnf" +#line 1247 "./asn1/rrc/rrc.cnf" fp_info *fpinf; rlc_info *rlcinf; rrc_ciphering_info *ciphering_info; @@ -18685,7 +18685,7 @@ dissect_rrc_CipheringModeInfo(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act static int dissect_rrc_SRNC_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 954 "./asn1/rrc/rrc.cnf" +#line 988 "./asn1/rrc/rrc.cnf" tvbuff_t * s_rnc_id_tvb = NULL; offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index, 12, 12, FALSE, &s_rnc_id_tvb, NULL); @@ -18703,7 +18703,7 @@ dissect_rrc_SRNC_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U static int dissect_rrc_S_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 961 "./asn1/rrc/rrc.cnf" +#line 995 "./asn1/rrc/rrc.cnf" tvbuff_t * s_rnti_tvb = NULL; offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index, 20, 20, FALSE, &s_rnti_tvb, NULL); @@ -18726,7 +18726,7 @@ static const per_sequence_t U_RNTI_sequence[] = { static int dissect_rrc_U_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 968 "./asn1/rrc/rrc.cnf" +#line 1002 "./asn1/rrc/rrc.cnf" private_data_set_s_rnc_id(actx, 0); private_data_set_s_rnti(actx, 0); guint32 s_rnc_id; @@ -18762,7 +18762,7 @@ dissect_rrc_U_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, prot static int dissect_rrc_Digit(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 836 "./asn1/rrc/rrc.cnf" +#line 870 "./asn1/rrc/rrc.cnf" guint32 digit; wmem_strbuf_t* digits_strbuf; /* The string of either an IMSI or a MCC-MNC pair */ offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, @@ -18838,7 +18838,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U tvbuff_t* mcc_mnc_tvb; /* Reset the digits string in the private data struct */ - /* Maximal length: 6 = 3 digits MCC + 3 digits MNC + trailing '\0'*/ + /* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */ mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7); private_data_set_digits_strbuf(actx, mcc_mnc_strbuf); /* Reset parsing failure flag*/ @@ -18846,15 +18846,15 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_PLMN_Identity, PLMN_Identity_sequence); + private_data_set_digits_strbuf(actx, NULL); /* Check for parsing errors */ if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { return offset; } - /* Extracing the string collected in the strbuf */ + /* Extracting the string collected in the strbuf */ string_len = (guint32)wmem_strbuf_get_len(mcc_mnc_strbuf); - mcc_mnc_string = wmem_strdup(actx->pinfo->pool, wmem_strbuf_get_str(mcc_mnc_strbuf)); - wmem_strbuf_truncate(mcc_mnc_strbuf, 0); + mcc_mnc_string = wmem_strbuf_finalize(mcc_mnc_strbuf); /* Creating TVB from extracted string*/ mcc_mnc_tvb = tvb_new_child_real_data(tvb, (guint8*)mcc_mnc_string, string_len, string_len); @@ -18872,7 +18872,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U static int dissect_rrc_NAS_SystemInformationGSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 922 "./asn1/rrc/rrc.cnf" +#line 956 "./asn1/rrc/rrc.cnf" tvbuff_t *nas_sys_info_gsm_map_tvb = NULL; guint32 length; enum nas_sys_info_gsm_map cn_domain; @@ -18915,7 +18915,7 @@ dissect_rrc_NAS_SystemInformationGSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1 static int dissect_rrc_T_cn_CommonGSM_MAP_NAS_SysInfo(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 906 "./asn1/rrc/rrc.cnf" +#line 940 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_CN_COMMON); offset = dissect_rrc_NAS_SystemInformationGSM_MAP(tvb, offset, actx, tree, hf_index); @@ -18935,7 +18935,7 @@ static const value_string rrc_CN_DomainIdentity_vals[] = { static int dissect_rrc_CN_DomainIdentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 899 "./asn1/rrc/rrc.cnf" +#line 933 "./asn1/rrc/rrc.cnf" guint32 nas_sys_info; offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index, 2, &nas_sys_info, FALSE, 0, NULL); @@ -22594,7 +22594,7 @@ dissect_rrc_SSDT_UL(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pro static int dissect_rrc_CellIdentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1067 "./asn1/rrc/rrc.cnf" +#line 1101 "./asn1/rrc/rrc.cnf" tvbuff_t * cell_id_tvb = NULL; proto_item *temp_ti; proto_tree *cell_identity_tree; @@ -22819,7 +22819,7 @@ dissect_rrc_T_r3(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_ static int dissect_rrc_H_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1155 "./asn1/rrc/rrc.cnf" +#line 1189 "./asn1/rrc/rrc.cnf" tvbuff_t *hrnti_tvb; struct rrc_info *rrcinf; offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index, @@ -22828,7 +22828,7 @@ dissect_rrc_H_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, prot -#line 1160 "./asn1/rrc/rrc.cnf" +#line 1194 "./asn1/rrc/rrc.cnf" rrcinf = (struct rrc_info *)p_get_proto_data(wmem_file_scope(), actx->pinfo, proto_rrc, 0); if (!rrcinf) { rrcinf = wmem_new0(wmem_file_scope(), struct rrc_info); @@ -22854,7 +22854,7 @@ dissect_rrc_E_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, prot static int dissect_rrc_T_cn_CommonGSM_MAP_NAS_SysInfo_01(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 910 "./asn1/rrc/rrc.cnf" +#line 944 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_CN_COMMON); offset = dissect_rrc_NAS_SystemInformationGSM_MAP(tvb, offset, actx, tree, hf_index); @@ -28328,7 +28328,7 @@ dissect_rrc_ScramblingCodeType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac static int dissect_rrc_UL_ScramblingCode(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1062 "./asn1/rrc/rrc.cnf" +#line 1096 "./asn1/rrc/rrc.cnf" guint32 scrambling_code; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 16777215U, &scrambling_code, FALSE); @@ -39073,7 +39073,7 @@ dissect_rrc_CellChangeOrderFromUTRAN(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx static int dissect_rrc_C_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 993 "./asn1/rrc/rrc.cnf" +#line 1027 "./asn1/rrc/rrc.cnf" fp_info *fpinf = NULL; umts_mac_info *macinf = NULL; rlc_info *rlcinf = NULL; @@ -46181,7 +46181,7 @@ dissect_rrc_RLC_Info_r5(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, static int dissect_rrc_MAC_d_FlowIdentity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1152 "./asn1/rrc/rrc.cnf" +#line 1186 "./asn1/rrc/rrc.cnf" offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 7U, &flowd, FALSE); @@ -46229,7 +46229,7 @@ static const per_choice_t DL_TransportChannelType_r5_choice[] = { static int dissect_rrc_DL_TransportChannelType_r5(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1081 "./asn1/rrc/rrc.cnf" +#line 1115 "./asn1/rrc/rrc.cnf" /*Here we try to figure out which HS-DSCH channels are multiplexed*/ guint *flowd_p; guint *cur_val=NULL; @@ -49703,7 +49703,7 @@ static const per_choice_t DL_TransportChannelType_r7_choice[] = { static int dissect_rrc_DL_TransportChannelType_r7(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1116 "./asn1/rrc/rrc.cnf" +#line 1150 "./asn1/rrc/rrc.cnf" /*Here we try to figure out which HS-DSCH channels are multiplexed*/ guint *flowd_p; guint *cur_val=NULL; @@ -90281,7 +90281,7 @@ static const value_string rrc_ReleaseCause_vals[] = { static int dissect_rrc_ReleaseCause(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1269 "./asn1/rrc/rrc.cnf" +#line 1303 "./asn1/rrc/rrc.cnf" guint32 value; offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index, 8, &value, FALSE, 0, NULL); @@ -95944,7 +95944,7 @@ dissect_rrc_UE_ConnTimersAndConstants(tvbuff_t *tvb _U_, int offset _U_, asn1_ct static int dissect_rrc_T_cn_CommonGSM_MAP_NAS_SysInfo_02(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 914 "./asn1/rrc/rrc.cnf" +#line 948 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_CN_COMMON); offset = dissect_rrc_NAS_SystemInformationGSM_MAP(tvb, offset, actx, tree, hf_index); @@ -98611,7 +98611,7 @@ dissect_rrc_T_r8_04(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, pro static int dissect_rrc_T_ims_Information(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 861 "./asn1/rrc/rrc.cnf" +#line 895 "./asn1/rrc/rrc.cnf" tvbuff_t *imsInformation_tvb=NULL; offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index, 1, 32, FALSE, &imsInformation_tvb); @@ -99801,7 +99801,7 @@ static const per_choice_t DL_DCCH_MessageType_choice[] = { static int dissect_rrc_DL_DCCH_MessageType(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1252 "./asn1/rrc/rrc.cnf" +#line 1286 "./asn1/rrc/rrc.cnf" offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, ett_rrc_DL_DCCH_MessageType, DL_DCCH_MessageType_choice, &msg_type); @@ -99821,7 +99821,7 @@ static const per_sequence_t DL_DCCH_Message_sequence[] = { static int dissect_rrc_DL_DCCH_Message(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1255 "./asn1/rrc/rrc.cnf" +#line 1289 "./asn1/rrc/rrc.cnf" offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_DL_DCCH_Message, DL_DCCH_Message_sequence); @@ -99835,7 +99835,7 @@ dissect_rrc_DL_DCCH_Message(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx static int dissect_rrc_START_Value(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1168 "./asn1/rrc/rrc.cnf" +#line 1202 "./asn1/rrc/rrc.cnf" tvbuff_t * start_val; fp_info *fpinf; rlc_info *rlcinf; @@ -115027,7 +115027,7 @@ static const per_sequence_t IMSI_GSM_MAP_sequence_of[1] = { static int dissect_rrc_IMSI_GSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 807 "./asn1/rrc/rrc.cnf" +#line 841 "./asn1/rrc/rrc.cnf" wmem_strbuf_t* imsi_strbuf; guint32 string_len; gchar* imsi_string; @@ -115042,15 +115042,15 @@ dissect_rrc_IMSI_GSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_ ett_rrc_IMSI_GSM_MAP, IMSI_GSM_MAP_sequence_of, 6, 21, FALSE); + private_data_set_digits_strbuf(actx, NULL); /* Check for parsing errors */ if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { return offset; } - /* Extracing the string collected in the strbuf */ + /* Extracting the string collected in the strbuf */ string_len = (guint32)wmem_strbuf_get_len(imsi_strbuf); - imsi_string = wmem_strdup(actx->pinfo->pool, wmem_strbuf_get_str(imsi_strbuf)); - wmem_strbuf_truncate(imsi_strbuf, 0); + imsi_string = wmem_strbuf_finalize(imsi_strbuf); /* Creating TVB from extracted string*/ imsi_tvb = tvb_new_child_real_data(tvb, (guint8*)imsi_string, string_len, string_len); @@ -129620,7 +129620,7 @@ static const per_choice_t HandoverToUTRANCommand_choice[] = { static int dissect_rrc_HandoverToUTRANCommand(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1258 "./asn1/rrc/rrc.cnf" +#line 1292 "./asn1/rrc/rrc.cnf" offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, ett_rrc_HandoverToUTRANCommand, HandoverToUTRANCommand_choice, NULL); @@ -129761,7 +129761,7 @@ static const per_sequence_t UE_SecurityInformation_sequence[] = { static int dissect_rrc_UE_SecurityInformation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1261 "./asn1/rrc/rrc.cnf" +#line 1295 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_CS); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_UE_SecurityInformation, UE_SecurityInformation_sequence); @@ -130164,7 +130164,7 @@ static const per_sequence_t UE_SecurityInformation2_sequence[] = { static int dissect_rrc_UE_SecurityInformation2(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1265 "./asn1/rrc/rrc.cnf" +#line 1299 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_PS); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_UE_SecurityInformation2, UE_SecurityInformation2_sequence); @@ -134699,9 +134699,44 @@ static const per_sequence_t PLMN_IdentityWithOptionalMCC_r6_sequence[] = { static int dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { +#line 807 "./asn1/rrc/rrc.cnf" + wmem_strbuf_t* mcc_mnc_strbuf; + guint32 string_len; + gchar* mcc_mnc_string; + tvbuff_t* mcc_mnc_tvb; + + /* Reset the digits string in the private data struct */ + /* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */ + mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7); + private_data_set_digits_strbuf(actx, mcc_mnc_strbuf); + /* Reset parsing failure flag*/ + private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_PLMN_IdentityWithOptionalMCC_r6, PLMN_IdentityWithOptionalMCC_r6_sequence); + private_data_set_digits_strbuf(actx, NULL); + /* Check for parsing errors */ + if(private_data_get_digits_strbuf_parsing_failed_flag(actx)) { + return offset; + } + + /* Extracting the string collected in the strbuf */ + string_len = (guint32)wmem_strbuf_get_len(mcc_mnc_strbuf); + if (string_len >= 5) { + /* optional MCC was present, we can call E.212 dissector */ + /* if not present, we could apply the algorithm in 25.331 chapter 8.1.1.5 */ + mcc_mnc_string = wmem_strbuf_finalize(mcc_mnc_strbuf); + + /* Creating TVB from extracted string*/ + mcc_mnc_tvb = tvb_new_child_real_data(tvb, (guint8*)mcc_mnc_string, string_len, string_len); + add_new_data_source(actx->pinfo, mcc_mnc_tvb, "MCC-MNC"); + + /* Calling E.212 */ + dissect_e212_mcc_mnc_in_utf8_address(mcc_mnc_tvb, actx->pinfo, tree, 0); + } + + + return offset; } @@ -150858,7 +150893,7 @@ dissect_rrc_ExtSIBTypeInfoSchedulingInfo_List3(tvbuff_t *tvb _U_, int offset _U_ static int dissect_rrc_HNBName(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 893 "./asn1/rrc/rrc.cnf" +#line 927 "./asn1/rrc/rrc.cnf" tvbuff_t *hnbname_tvb = NULL; offset = dissect_per_octet_string(tvb, offset, actx, tree, -1, @@ -151449,7 +151484,7 @@ dissect_rrc_SIB_ReferenceList2(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac static int dissect_rrc_T_cn_CommonGSM_MAP_NAS_SysInfo_03(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 918 "./asn1/rrc/rrc.cnf" +#line 952 "./asn1/rrc/rrc.cnf" private_data_set_cn_domain(actx, RRC_NAS_SYS_INFO_CN_COMMON); offset = dissect_rrc_NAS_SystemInformationGSM_MAP(tvb, offset, actx, tree, hf_index); |