From 2a9886bf09eb27489d1f95bc73ccaa05da446794 Mon Sep 17 00:00:00 2001 From: Darien Spencer Date: Thu, 17 May 2018 17:20:04 +0300 Subject: [PATCH] RRC: Make the U-RNTI field filterable U-RNTI is defined in ASN.1 as a 'SEQUENCE' of 2 numbers. this update adds the U-RNTI field to the tree as a UINT32 with the value of the numbers combined so it could be filtered. Change-Id: I31e9f39a257aaf98c36eebb2cb7c33eb156a0e9f Reviewed-on: https://code.wireshark.org/review/27566 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin --- .../dissectors/asn1/rrc/packet-rrc-template.c | 15 +++ epan/dissectors/asn1/rrc/rrc.cnf | 42 +++++-- epan/dissectors/packet-rrc.c | 107 ++++++++++++------ 3 files changed, 115 insertions(+), 49 deletions(-) diff --git a/epan/dissectors/asn1/rrc/packet-rrc-template.c b/epan/dissectors/asn1/rrc/packet-rrc-template.c index 2911612821..4423dcc5d2 100644 --- a/epan/dissectors/asn1/rrc/packet-rrc-template.c +++ b/epan/dissectors/asn1/rrc/packet-rrc-template.c @@ -266,6 +266,9 @@ static int dissect_SysInfoType22_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tr /* Initialize the protocol and registered fields */ int proto_rrc = -1; static int hf_test; +static int hf_urnti; +static int hf_urnti_new; +static int hf_urnti_current; #include "packet-rrc-hf.c" /* Initialize the subtree pointers */ @@ -490,6 +493,18 @@ void proto_register_rrc(void) { { "RAB Test", "rrc.RAB.test", FT_UINT8, BASE_DEC, NULL, 0, "rrc.RAB_Info_r6", HFILL }}, + { &hf_urnti, + { "U-RNTI", "rrc.urnti", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_urnti_new, + { "New U-RNTI", "rrc.urnti_new", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_urnti_current, + { "Current U-RNTI", "rrc.urnti_current", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, { &hf_rrc_eutra_feat_group_ind_1, { "Indicator 1", "rrc.eutra_feat_group_ind_1", FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_1_val), 0, diff --git a/epan/dissectors/asn1/rrc/rrc.cnf b/epan/dissectors/asn1/rrc/rrc.cnf index 3fac36430b..0c8d0c558f 100644 --- a/epan/dissectors/asn1/rrc/rrc.cnf +++ b/epan/dissectors/asn1/rrc/rrc.cnf @@ -1123,22 +1123,40 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE guint32 s_rnc_id; guint32 s_rnti; guint32 u_rnti_value; + guint32 original_offset; + proto_item *ti; + guint32 item_len; + proto_tree *sub_tree; + gboolean is_new_urnti; + int generated_field_hf; + original_offset = offset; %(DEFAULT_BODY)s - gboolean is_new_urnti = hf_index != hf_rrc_u_RNTI; /* hf_rrc_u_RNTI is for current U-RNTI, any other hf is for new U-RNTI */ + + /* Reconstructing the U-RNTI from the parsed components */ s_rnc_id = private_data_get_s_rnc_id(actx); s_rnti = private_data_get_s_rnti(actx); - if(s_rnc_id != 0 && s_rnti != 0) { - u_rnti_value = (s_rnc_id << 20) | s_rnti; - /* Distinguishing between new allocated U-RNTIs and previously used ones */ - if (is_new_urnti) { - private_data_set_new_u_rnti(actx, u_rnti_value); - } - else { - private_data_set_current_u_rnti(actx, u_rnti_value); - } - /* Adding U-RNTI value to it's tree item */ - proto_item_append_text(actx->created_item,": %%08x", u_rnti_value); + u_rnti_value = (s_rnc_id << 20) | s_rnti; + + /* Distinguishing between new allocated U-RNTIs and previously used ones */ + /* hf_rrc_u_RNTI is for current U-RNTI, any other hf is for new U-RNTI */ + is_new_urnti = hf_index != hf_rrc_u_RNTI; + if (is_new_urnti) { + private_data_set_new_u_rnti(actx, u_rnti_value); + generated_field_hf = hf_urnti_new; } + else { + private_data_set_current_u_rnti(actx, u_rnti_value); + generated_field_hf = hf_urnti_current; + } + + /* Adding a "Current U-RNTI" or "New U-RNTI" as generated field */ + sub_tree = proto_item_get_subtree(actx->created_item); + item_len = proto_item_get_len(actx->created_item); + ti = proto_tree_add_uint(sub_tree, generated_field_hf, tvb, original_offset/8, item_len, u_rnti_value); + PROTO_ITEM_SET_GENERATED(ti); + ti = proto_tree_add_uint(sub_tree, hf_urnti, tvb, original_offset/8, item_len, u_rnti_value); + PROTO_ITEM_SET_HIDDEN(ti); + private_data_set_s_rnc_id(actx, 0); private_data_set_s_rnti(actx, 0); diff --git a/epan/dissectors/packet-rrc.c b/epan/dissectors/packet-rrc.c index 2cffd5d07c..a2ffcb2c28 100644 --- a/epan/dissectors/packet-rrc.c +++ b/epan/dissectors/packet-rrc.c @@ -473,6 +473,9 @@ static int dissect_SysInfoType22_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tr /* Initialize the protocol and registered fields */ int proto_rrc = -1; static int hf_test; +static int hf_urnti; +static int hf_urnti_new; +static int hf_urnti_current; /*--- Included file: packet-rrc-hf.c ---*/ #line 1 "./asn1/rrc/packet-rrc-hf.c" @@ -11337,7 +11340,7 @@ static int hf_rrc_GsmSecurityCapability_a5_2 = -1; static int hf_rrc_GsmSecurityCapability_a5_1 = -1; /*--- End of included file: packet-rrc-hf.c ---*/ -#line 270 "./asn1/rrc/packet-rrc-template.c" +#line 273 "./asn1/rrc/packet-rrc-template.c" /* Initialize the subtree pointers */ static int ett_rrc = -1; @@ -18262,7 +18265,7 @@ static gint ett_rrc_UE_RadioAccessCapability_r6 = -1; static gint ett_rrc_UL_RFC3095_Context = -1; /*--- End of included file: packet-rrc-ett.c ---*/ -#line 275 "./asn1/rrc/packet-rrc-template.c" +#line 278 "./asn1/rrc/packet-rrc-template.c" static gint ett_rrc_eutraFeatureGroupIndicators = -1; static gint ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo = -1; @@ -18635,7 +18638,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 1405 "./asn1/rrc/rrc.cnf" +#line 1423 "./asn1/rrc/rrc.cnf" guint32 rbid; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 1U, 32U, &rbid, FALSE); @@ -18652,7 +18655,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 1411 "./asn1/rrc/rrc.cnf" +#line 1429 "./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); @@ -18673,7 +18676,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 1375 "./asn1/rrc/rrc.cnf" +#line 1393 "./asn1/rrc/rrc.cnf" fp_info *fpinf; rlc_info *rlcinf; rrc_ciphering_info *ciphering_info; @@ -18791,24 +18794,42 @@ dissect_rrc_U_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, prot guint32 s_rnc_id; guint32 s_rnti; guint32 u_rnti_value; + guint32 original_offset; + proto_item *ti; + guint32 item_len; + proto_tree *sub_tree; + gboolean is_new_urnti; + int generated_field_hf; + original_offset = offset; offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_U_RNTI, U_RNTI_sequence); - gboolean is_new_urnti = hf_index != hf_rrc_u_RNTI; /* hf_rrc_u_RNTI is for current U-RNTI, any other hf is for new U-RNTI */ + + /* Reconstructing the U-RNTI from the parsed components */ s_rnc_id = private_data_get_s_rnc_id(actx); s_rnti = private_data_get_s_rnti(actx); - if(s_rnc_id != 0 && s_rnti != 0) { - u_rnti_value = (s_rnc_id << 20) | s_rnti; - /* Distinguishing between new allocated U-RNTIs and previously used ones */ - if (is_new_urnti) { - private_data_set_new_u_rnti(actx, u_rnti_value); - } - else { - private_data_set_current_u_rnti(actx, u_rnti_value); - } - /* Adding U-RNTI value to it's tree item */ - proto_item_append_text(actx->created_item,": %08x", u_rnti_value); + u_rnti_value = (s_rnc_id << 20) | s_rnti; + + /* Distinguishing between new allocated U-RNTIs and previously used ones */ + /* hf_rrc_u_RNTI is for current U-RNTI, any other hf is for new U-RNTI */ + is_new_urnti = hf_index != hf_rrc_u_RNTI; + if (is_new_urnti) { + private_data_set_new_u_rnti(actx, u_rnti_value); + generated_field_hf = hf_urnti_new; } + else { + private_data_set_current_u_rnti(actx, u_rnti_value); + generated_field_hf = hf_urnti_current; + } + + /* Adding a "Current U-RNTI" or "New U-RNTI" as generated field */ + sub_tree = proto_item_get_subtree(actx->created_item); + item_len = proto_item_get_len(actx->created_item); + ti = proto_tree_add_uint(sub_tree, generated_field_hf, tvb, original_offset/8, item_len, u_rnti_value); + PROTO_ITEM_SET_GENERATED(ti); + ti = proto_tree_add_uint(sub_tree, hf_urnti, tvb, original_offset/8, item_len, u_rnti_value); + PROTO_ITEM_SET_HIDDEN(ti); + private_data_set_s_rnc_id(actx, 0); private_data_set_s_rnti(actx, 0); @@ -22653,7 +22674,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 1229 "./asn1/rrc/rrc.cnf" +#line 1247 "./asn1/rrc/rrc.cnf" tvbuff_t * cell_id_tvb = NULL; proto_item *temp_ti; proto_tree *cell_identity_tree; @@ -22878,7 +22899,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 1317 "./asn1/rrc/rrc.cnf" +#line 1335 "./asn1/rrc/rrc.cnf" tvbuff_t *hrnti_tvb; struct rrc_info *rrcinf; offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index, @@ -22887,7 +22908,7 @@ dissect_rrc_H_RNTI(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, prot -#line 1322 "./asn1/rrc/rrc.cnf" +#line 1340 "./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); @@ -28387,7 +28408,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 1216 "./asn1/rrc/rrc.cnf" +#line 1234 "./asn1/rrc/rrc.cnf" guint32 scrambling_code; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 16777215U, &scrambling_code, FALSE); @@ -39132,7 +39153,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 1146 "./asn1/rrc/rrc.cnf" +#line 1164 "./asn1/rrc/rrc.cnf" fp_info *fpinf = NULL; umts_mac_info *macinf = NULL; rlc_info *rlcinf = NULL; @@ -39221,7 +39242,7 @@ static const value_string rrc_RRC_StateIndicator_vals[] = { static int dissect_rrc_RRC_StateIndicator(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 1221 "./asn1/rrc/rrc.cnf" +#line 1239 "./asn1/rrc/rrc.cnf" gint32 state_dec = -1; offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index, 4, &state_dec, FALSE, 0, NULL); @@ -46250,7 +46271,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 1314 "./asn1/rrc/rrc.cnf" +#line 1332 "./asn1/rrc/rrc.cnf" offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 7U, &flowd, FALSE); @@ -46298,7 +46319,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 1243 "./asn1/rrc/rrc.cnf" +#line 1261 "./asn1/rrc/rrc.cnf" /*Here we try to figure out which HS-DSCH channels are multiplexed*/ guint *flowd_p; guint *cur_val=NULL; @@ -49772,7 +49793,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 1278 "./asn1/rrc/rrc.cnf" +#line 1296 "./asn1/rrc/rrc.cnf" /*Here we try to figure out which HS-DSCH channels are multiplexed*/ guint *flowd_p; guint *cur_val=NULL; @@ -90946,7 +90967,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 1433 "./asn1/rrc/rrc.cnf" +#line 1451 "./asn1/rrc/rrc.cnf" guint32 value; offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index, 8, &value, FALSE, 0, NULL); @@ -100487,7 +100508,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 1416 "./asn1/rrc/rrc.cnf" +#line 1434 "./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); @@ -100507,7 +100528,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 1419 "./asn1/rrc/rrc.cnf" +#line 1437 "./asn1/rrc/rrc.cnf" offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_rrc_DL_DCCH_Message, DL_DCCH_Message_sequence); @@ -100521,7 +100542,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 1330 "./asn1/rrc/rrc.cnf" +#line 1348 "./asn1/rrc/rrc.cnf" tvbuff_t * start_val; fp_info *fpinf; rlc_info *rlcinf; @@ -130322,7 +130343,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 1422 "./asn1/rrc/rrc.cnf" +#line 1440 "./asn1/rrc/rrc.cnf" offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, ett_rrc_HandoverToUTRANCommand, HandoverToUTRANCommand_choice, NULL); @@ -130463,7 +130484,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 1425 "./asn1/rrc/rrc.cnf" +#line 1443 "./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); @@ -130866,7 +130887,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 1429 "./asn1/rrc/rrc.cnf" +#line 1447 "./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); @@ -163975,7 +163996,7 @@ static int dissect_MeasurementReport_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _ /*--- End of included file: packet-rrc-fn.c ---*/ -#line 406 "./asn1/rrc/packet-rrc-template.c" +#line 409 "./asn1/rrc/packet-rrc-template.c" static int @@ -207495,11 +207516,23 @@ void proto_register_rrc(void) { NULL, HFILL }}, /*--- End of included file: packet-rrc-hfarr.c ---*/ -#line 489 "./asn1/rrc/packet-rrc-template.c" +#line 492 "./asn1/rrc/packet-rrc-template.c" { &hf_test, { "RAB Test", "rrc.RAB.test", FT_UINT8, BASE_DEC, NULL, 0, "rrc.RAB_Info_r6", HFILL }}, + { &hf_urnti, + { "U-RNTI", "rrc.urnti", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_urnti_new, + { "New U-RNTI", "rrc.urnti_new", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, + { &hf_urnti_current, + { "Current U-RNTI", "rrc.urnti_current", + FT_UINT32, BASE_HEX, NULL, 0, + NULL, HFILL }}, { &hf_rrc_eutra_feat_group_ind_1, { "Indicator 1", "rrc.eutra_feat_group_ind_1", FT_BOOLEAN, BASE_NONE, TFS(&rrc_eutra_feat_group_ind_1_val), 0, @@ -214465,7 +214498,7 @@ void proto_register_rrc(void) { &ett_rrc_UL_RFC3095_Context, /*--- End of included file: packet-rrc-ettarr.c ---*/ -#line 539 "./asn1/rrc/packet-rrc-template.c" +#line 554 "./asn1/rrc/packet-rrc-template.c" &ett_rrc_eutraFeatureGroupIndicators, &ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo, &ett_rrc_ims_info, @@ -214566,7 +214599,7 @@ void proto_register_rrc(void) { /*--- End of included file: packet-rrc-dis-reg.c ---*/ -#line 564 "./asn1/rrc/packet-rrc-template.c" +#line 579 "./asn1/rrc/packet-rrc-template.c"