From 900695547b096b1be34fb58bea98c0474e9c72ab Mon Sep 17 00:00:00 2001 From: "S. Shapira" Date: Fri, 12 May 2017 00:03:29 +0300 Subject: UMTS Iub: Resolve U-RNTI for C-RNTI This commit includes logic used to store pairs of C-RNTIs and U-RNTIs based on allocations in RRC and logic to retrive those when encountering C-RNTIs in the MAC header for DCCH over FACH/RACH. Change-Id: I629ab061b7a73416e5730a980480b81a1aaade11 Reviewed-on: https://code.wireshark.org/review/21607 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-umts_mac.c | 81 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) (limited to 'epan/dissectors/packet-umts_mac.c') diff --git a/epan/dissectors/packet-umts_mac.c b/epan/dissectors/packet-umts_mac.c index 70dcca49da..9d4ef97e1b 100644 --- a/epan/dissectors/packet-umts_mac.c +++ b/epan/dissectors/packet-umts_mac.c @@ -47,6 +47,8 @@ static int hf_mac_ct = -1; static int hf_mac_ueid_type = -1; static int hf_mac_crnti = -1; static int hf_mac_urnti = -1; +static int hf_mac_resolved_urnti = -1; +static int hf_mac_crnti_urnti_match_frame = -1; static int hf_mac_channel = -1; /* static int hf_mac_channel_str = -1; */ @@ -78,6 +80,7 @@ static int ett_mac_edch = -1; static int ett_mac_hsdsch = -1; static int ett_mac_edch_type2 = -1; static int ett_mac_edch_type2_sdu = -1; +static int ett_mac_resolved_urnti = -1; static expert_field ei_mac_cs_dtch_not_implemented = EI_INIT; static expert_field ei_mac_rach_tctf_unknown = EI_INIT; @@ -231,6 +234,12 @@ static guint16 tree_add_common_dcch_dtch_fields(tvbuff_t *tvb, packet_info *pinf proto_tree *tree, guint16 bitoffs, fp_info *fpinf, umts_mac_info *macinf, rlc_info *rlcinf) { guint8 ueid_type; + conversation_t *p_conv; + umts_fp_conversation_info_t *umts_fp_conversation_info = NULL; + fp_rach_channel_info_t *fp_rach_channel_info = NULL; + fp_fach_channel_info_t *fp_fach_channel_info = NULL; + guint16 c_rnti; + fp_crnti_allocation_info_t *fp_crnti_allocation_info = NULL; ueid_type = tvb_get_bits8(tvb, bitoffs, 2); proto_tree_add_bits_item(tree, hf_mac_ueid_type, tvb, bitoffs, 2, ENC_BIG_ENDIAN); @@ -241,7 +250,62 @@ static guint16 tree_add_common_dcch_dtch_fields(tvbuff_t *tvb, packet_info *pinf bitoffs += 32; } else if (ueid_type == MAC_UEID_TYPE_CRNTI) { proto_tree_add_bits_item(tree, hf_mac_crnti, tvb, 4, 16, ENC_BIG_ENDIAN); - rlcinf->urnti[fpinf->cur_tb] = tvb_get_bits16(tvb, bitoffs, 16,ENC_BIG_ENDIAN); + c_rnti = tvb_get_bits16(tvb, bitoffs, 16,ENC_BIG_ENDIAN); + p_conv = (conversation_t *)find_conversation(pinfo->num, &pinfo->net_dst, &pinfo->net_src, + pinfo->ptype, + pinfo->destport, pinfo->srcport, NO_ADDR_B); + if (p_conv != NULL) { + umts_fp_conversation_info = (umts_fp_conversation_info_t *)conversation_get_proto_data(p_conv, proto_fp); + } + /* Trying to resolve the U-RNTI for this C-RNTI based on the channel type*/ + switch(fpinf->channel){ + case CHANNEL_RACH_FDD: + /* In RACH: First look in the channel's RNTIs map */ + if (umts_fp_conversation_info) { + fp_rach_channel_info = (fp_rach_channel_info_t *)umts_fp_conversation_info->channel_specific_info; + if(fp_rach_channel_info) { + fp_crnti_allocation_info = (fp_crnti_allocation_info_t *)wmem_tree_lookup32(fp_rach_channel_info->crnti_to_urnti_map, c_rnti); + } + } + if(fp_crnti_allocation_info == NULL) { + /* If not found in the channel's map, Look in the global RNTIs map */ + fp_crnti_allocation_info = (fp_crnti_allocation_info_t *)wmem_tree_lookup32(rrc_rach_urnti_crnti_map, c_rnti); + if(fp_crnti_allocation_info != NULL) { + /* If found in the global map, remove and insert to the channel's map*/ + wmem_tree_remove32(rrc_rach_urnti_crnti_map, c_rnti); + if(fp_rach_channel_info) { + wmem_tree_insert32(fp_rach_channel_info->crnti_to_urnti_map, c_rnti, (void *)fp_crnti_allocation_info); + } + } + } + break; + case CHANNEL_FACH_FDD: + /* In FACH: Look in the channel's RNTIs map */ + if (umts_fp_conversation_info) { + fp_fach_channel_info = (fp_fach_channel_info_t *)umts_fp_conversation_info->channel_specific_info; + if(fp_fach_channel_info) { + fp_crnti_allocation_info = (fp_crnti_allocation_info_t *)wmem_tree_lookup32(fp_fach_channel_info->crnti_to_urnti_map, c_rnti); + } + } + break; + } + /* Choosing between resolved U-RNTI (if found) or the C-RNTI as UE-ID for RLC */ + if(fp_crnti_allocation_info != NULL) { + /* Using U-RNTI */ + rlcinf->urnti[fpinf->cur_tb] = fp_crnti_allocation_info->urnti; + /* Adding 'Resolved U-RNTI' related tree items*/ + proto_item *temp; + proto_tree *resolved_urnti_tree; + temp = proto_tree_add_uint(tree, hf_mac_resolved_urnti, tvb, 0, 0, fp_crnti_allocation_info->urnti); + PROTO_ITEM_SET_GENERATED(temp); + resolved_urnti_tree = proto_item_add_subtree(temp, ett_mac_resolved_urnti); + temp = proto_tree_add_uint(resolved_urnti_tree , hf_mac_crnti_urnti_match_frame, tvb, 0, 0, fp_crnti_allocation_info->alloc_frame_number); + PROTO_ITEM_SET_GENERATED(temp); + } + else { + /* Using C-RNTI */ + rlcinf->urnti[fpinf->cur_tb] = c_rnti; + } bitoffs += 16; } @@ -1311,7 +1375,8 @@ proto_register_umts_mac(void) &ett_mac_edch, &ett_mac_hsdsch, &ett_mac_edch_type2, - &ett_mac_edch_type2_sdu + &ett_mac_edch_type2_sdu, + &ett_mac_resolved_urnti }; /** XX: Looks like some duplicate filter names ?? **/ /** XX: May be OK: See doc/README.developer **/ @@ -1340,6 +1405,18 @@ proto_register_umts_mac(void) { "U-RNTI (UEID)", "mac.ueid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } }, + { &hf_mac_resolved_urnti, + { "Resolved U-RNTI", "mac.resolved_urnti", + FT_UINT32, BASE_HEX, NULL, 0x0, + "The U-RNTI of the UE which is using the C-RNTI seen in this frame", + HFILL } + }, + { &hf_mac_crnti_urnti_match_frame, + { "C-RNTI Allocation Frame", "mac.crnti_urnti_match_frame", + FT_FRAMENUM, BASE_NONE, NULL, 0x0, + "The frame number where the C-RNTI was allocated for the UE", + HFILL } + }, { &hf_mac_channel, { "Logical Channel Type", "mac.logical_channel", FT_UINT16, BASE_DEC, VALS(mac_logical_channel_vals), 0, NULL, HFILL } -- cgit v1.2.3