From 445df19e7cb15c0164ea5822d89c4b79c0633822 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Mon, 4 Jan 2021 11:03:22 +0000 Subject: [PATCH] PDCP NR: Get DRB params when RLC not present --- epan/dissectors/asn1/nr-rrc/nr-rrc.cnf | 16 +++++-- epan/dissectors/packet-mac-nr.h | 1 + epan/dissectors/packet-nr-rrc.c | 16 +++++-- epan/dissectors/packet-pdcp-nr.c | 24 ++++++++++ epan/dissectors/packet-rlc-nr.c | 64 +++++++++++++++----------- epan/dissectors/packet-rlc-nr.h | 20 ++++++-- 6 files changed, 102 insertions(+), 39 deletions(-) diff --git a/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf b/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf index e3bbc40b01..75d16b3424 100644 --- a/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf +++ b/epan/dissectors/asn1/nr-rrc/nr-rrc.cnf @@ -1480,6 +1480,7 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni struct mac_nr_info *p_mac_nr_info; /* Get the struct and clear it out */ nr_drb_mac_rlc_mapping_t *drb_mapping = &nr_rrc_get_private_data(actx)->drb_rlc_mapping; + drb_mapping->active = TRUE; memset(drb_mapping, 0, sizeof(nr_drb_mac_rlc_mapping_t)); %(DEFAULT_BODY)s /* Need UE identifier */ @@ -1489,12 +1490,17 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni /* Tell MAC about this mapping */ set_mac_nr_bearer_mapping(drb_mapping); } + drb_mapping->active = FALSE; #.FN_BODY DRB-Identity VAL_PTR=&value guint32 value; - nr_drb_mac_rlc_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_rlc_mapping; %(DEFAULT_BODY)s - mapping->drbid = (guint8)value; + if (nr_rrc_get_private_data(actx)->drb_rlc_mapping.active) { + nr_rrc_get_private_data(actx)->drb_rlc_mapping.drbid = (guint8)value; + } + else if (nr_rrc_get_private_data(actx)->drb_pdcp_mapping.active) { + nr_rrc_get_private_data(actx)->drb_pdcp_mapping.drbid = (guint8)value; + } #.FN_BODY RLC-Config VAL_PTR=&value guint32 value; @@ -1560,6 +1566,7 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni #.FN_BODY DRB-ToAddMod nr_drb_rlc_pdcp_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_pdcp_mapping; + mapping->active = TRUE; memset(mapping, 0, sizeof(*mapping)); %(DEFAULT_BODY)s /* Need UE identifier. Use mac-nr. */ @@ -1567,10 +1574,11 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni if (p_mac_nr_info) { /* Configure PDCP SN length(s) for this DRB */ if (mapping->pdcpUlSnLength_present || mapping->pdcpDlSnLength_present) { - set_rlc_nr_drb_pdcp_seqnum_length(actx->pinfo, //p_mac_nr_info->ueid, mapping->drbid, - mapping); + mapping->ueid = p_mac_nr_info->ueid; + set_rlc_nr_drb_pdcp_mapping(actx->pinfo, mapping); } } + mapping->active = FALSE; #.FN_BODY SDAP-Config/sdap-HeaderDL VAL_PTR=&value guint32 value; diff --git a/epan/dissectors/packet-mac-nr.h b/epan/dissectors/packet-mac-nr.h index 8e777c73d1..03baa8e175 100644 --- a/epan/dissectors/packet-mac-nr.h +++ b/epan/dissectors/packet-mac-nr.h @@ -116,6 +116,7 @@ void set_mac_nr_proto_data(packet_info *pinfo, mac_nr_info *p_mac_nr_info); /* Some are optional, and may not be seen (e.g. on reestablishment) */ typedef struct nr_drb_mac_rlc_mapping_t { + gboolean active; guint16 ueid; /* Mandatory */ guint8 drbid; /* Mandatory */ diff --git a/epan/dissectors/packet-nr-rrc.c b/epan/dissectors/packet-nr-rrc.c index c191d0cbf9..972a4fd63b 100644 --- a/epan/dissectors/packet-nr-rrc.c +++ b/epan/dissectors/packet-nr-rrc.c @@ -25299,11 +25299,15 @@ dissect_nr_rrc_T_cnAssociation(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac static int dissect_nr_rrc_DRB_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { guint32 value; - nr_drb_mac_rlc_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_rlc_mapping; offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 1U, 32U, &value, FALSE); - mapping->drbid = (guint8)value; + if (nr_rrc_get_private_data(actx)->drb_rlc_mapping.active) { + nr_rrc_get_private_data(actx)->drb_rlc_mapping.drbid = (guint8)value; + } + else if (nr_rrc_get_private_data(actx)->drb_pdcp_mapping.active) { + nr_rrc_get_private_data(actx)->drb_pdcp_mapping.drbid = (guint8)value; + } return offset; @@ -25381,6 +25385,7 @@ static const per_sequence_t DRB_ToAddMod_sequence[] = { static int dissect_nr_rrc_DRB_ToAddMod(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { nr_drb_rlc_pdcp_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_pdcp_mapping; + mapping->active = TRUE; memset(mapping, 0, sizeof(*mapping)); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_DRB_ToAddMod, DRB_ToAddMod_sequence); @@ -25390,10 +25395,11 @@ dissect_nr_rrc_DRB_ToAddMod(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx if (p_mac_nr_info) { /* Configure PDCP SN length(s) for this DRB */ if (mapping->pdcpUlSnLength_present || mapping->pdcpDlSnLength_present) { - set_rlc_nr_drb_pdcp_seqnum_length(actx->pinfo, //p_mac_nr_info->ueid, mapping->drbid, - mapping); + mapping->ueid = p_mac_nr_info->ueid; + set_rlc_nr_drb_pdcp_mapping(actx->pinfo, mapping); } } + mapping->active = FALSE; return offset; @@ -56506,6 +56512,7 @@ dissect_nr_rrc_RLC_BearerConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *a struct mac_nr_info *p_mac_nr_info; /* Get the struct and clear it out */ nr_drb_mac_rlc_mapping_t *drb_mapping = &nr_rrc_get_private_data(actx)->drb_rlc_mapping; + drb_mapping->active = TRUE; memset(drb_mapping, 0, sizeof(nr_drb_mac_rlc_mapping_t)); offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index, ett_nr_rrc_RLC_BearerConfig, RLC_BearerConfig_sequence); @@ -56517,6 +56524,7 @@ dissect_nr_rrc_RLC_BearerConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *a /* Tell MAC about this mapping */ set_mac_nr_bearer_mapping(drb_mapping); } + drb_mapping->active = FALSE; return offset; diff --git a/epan/dissectors/packet-pdcp-nr.c b/epan/dissectors/packet-pdcp-nr.c index bc3eb708e8..bd7c0300c3 100644 --- a/epan/dissectors/packet-pdcp-nr.c +++ b/epan/dissectors/packet-pdcp-nr.c @@ -1844,6 +1844,30 @@ static int dissect_pdcp_nr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p_pdcp_info = (struct pdcp_nr_info *)data; } + /* If no RLC layer in this frame, query RLC table for configured drb settings */ + if (!p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc_nr, 0)) { + /* If DRB channel, query rlc table */ + if (p_pdcp_info->plane == NR_USER_PLANE) { + pdcp_bearer_parameters *params = get_rlc_nr_drb_pdcp_mapping(p_pdcp_info->ueid, p_pdcp_info->bearerId); + if (params) { + if (p_pdcp_info->direction == DIRECTION_UPLINK) { + p_pdcp_info->seqnum_length = params->pdcp_sn_bits_ul; + if (params->pdcp_sdap_ul) { + p_pdcp_info->sdap_header |= PDCP_NR_UL_SDAP_HEADER_PRESENT; + } + } + else { + p_pdcp_info->seqnum_length = params->pdcp_sn_bits_dl; + if (params->pdcp_sdap_dl) { + p_pdcp_info->sdap_header |= PDCP_NR_DL_SDAP_HEADER_PRESENT; + } + } + p_pdcp_info->maci_present = params->pdcp_integrity; + p_pdcp_info->ciphering_disabled = params->pdcp_ciphering_disabled; + } + } + } + /* Don't want to overwrite the RLC Info column if configured not to */ if ((global_pdcp_nr_layer_to_show == ShowRLCLayer) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc_nr, 0) != NULL)) { diff --git a/epan/dissectors/packet-rlc-nr.c b/epan/dissectors/packet-rlc-nr.c index 4697a72e53..fd825e3f50 100644 --- a/epan/dissectors/packet-rlc-nr.c +++ b/epan/dissectors/packet-rlc-nr.c @@ -64,16 +64,7 @@ static gboolean global_rlc_nr_headers_expected = FALSE; static gboolean global_rlc_nr_reassemble_um_pdus = FALSE; static gboolean global_rlc_nr_reassemble_am_pdus = TRUE; -/* Tree storing UE related parameters */ -typedef struct rlc_ue_parameters { - guint32 id; - guint8 pdcp_sn_bits_ul; - guint8 pdcp_sn_bits_dl; - gboolean pdcp_sdap_ul; - gboolean pdcp_sdap_dl; - gboolean pdcp_integrity; - gboolean pdcp_ciphering_disabled; -} rlc_ue_parameters; +/* Tree storing UE related parameters (ueid, drbid) -> pdcp_bearer_parameters */ static wmem_tree_t *ue_parameters_tree; @@ -401,9 +392,9 @@ static void show_PDU_in_info(packet_info *pinfo, static void show_PDU_in_tree(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, rlc_nr_info *rlc_info, guint32 seg_info, gboolean is_reassembled) { - wmem_tree_key_t key[3]; + wmem_tree_key_t key[2]; guint32 id; - rlc_ue_parameters *params; + pdcp_bearer_parameters *params; /* Add raw data (according to mode) */ if (!is_reassembled) { @@ -463,13 +454,11 @@ static void show_PDU_in_tree(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb id = (rlc_info->bearerId << 16) | rlc_info->ueid; key[0].length = 1; key[0].key = &id; - key[1].length = 1; - key[1].key = &pinfo->num; - key[2].length = 0; - key[2].key = NULL; + key[1].length = 0; + key[1].key = NULL; /* Look up configured params for this PDCP DRB. */ - params = (rlc_ue_parameters *)wmem_tree_lookup32_array_le(ue_parameters_tree, key); + params = (pdcp_bearer_parameters *)wmem_tree_lookup32_array_le(ue_parameters_tree, key); if (params && (params->id != id)) { params = NULL; } @@ -1304,13 +1293,13 @@ static void dissect_rlc_nr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree } -/* Configure number of PDCP SN bits to use for DRB channels */ -void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, - nr_drb_rlc_pdcp_mapping_t *drb_mapping) +/* Configure DRB PDCP channel properties. */ +void set_rlc_nr_drb_pdcp_mapping(packet_info *pinfo, + nr_drb_rlc_pdcp_mapping_t *drb_mapping) { - wmem_tree_key_t key[3]; + wmem_tree_key_t key[2]; guint32 id; - rlc_ue_parameters *params; + pdcp_bearer_parameters *params; if (PINFO_FD_VISITED(pinfo)) { return; @@ -1319,19 +1308,17 @@ void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, id = (drb_mapping->drbid << 16) | drb_mapping->ueid; key[0].length = 1; key[0].key = &id; - key[1].length = 1; - key[1].key = &pinfo->num; - key[2].length = 0; - key[2].key = NULL; + key[1].length = 0; + key[1].key = NULL; /* Look up entry for this UEId/drbid */ - params = (rlc_ue_parameters *)wmem_tree_lookup32_array_le(ue_parameters_tree, key); + params = (pdcp_bearer_parameters *)wmem_tree_lookup32_array_le(ue_parameters_tree, key); if (params && (params->id != id)) { params = NULL; } if (params == NULL) { /* Not found so create new entry */ - params = (rlc_ue_parameters *)wmem_new(wmem_file_scope(), rlc_ue_parameters); + params = (pdcp_bearer_parameters *)wmem_new(wmem_file_scope(), pdcp_bearer_parameters); params->id = id; wmem_tree_insert32_array(ue_parameters_tree, key, (void *)params); } @@ -1345,6 +1332,27 @@ void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, params->pdcp_ciphering_disabled = drb_mapping->pdcpCipheringDisabled; } +pdcp_bearer_parameters* get_rlc_nr_drb_pdcp_mapping(guint16 ue_id, guint8 drb_id) +{ + wmem_tree_key_t key[2]; + guint32 id; + pdcp_bearer_parameters *params; + + id = (drb_id << 16) | ue_id; + key[0].length = 1; + key[0].key = &id; + key[1].length = 0; + key[1].key = NULL; + + /* Look up configured params for this PDCP DRB. */ + params = (pdcp_bearer_parameters *)wmem_tree_lookup32_array_le(ue_parameters_tree, key); + if (params && (params->id != id)) { + params = NULL; + } + + return params; +} + void proto_register_rlc_nr(void) { diff --git a/epan/dissectors/packet-rlc-nr.h b/epan/dissectors/packet-rlc-nr.h index fea251928d..74cb5116d6 100644 --- a/epan/dissectors/packet-rlc-nr.h +++ b/epan/dissectors/packet-rlc-nr.h @@ -49,6 +49,7 @@ typedef struct rlc_nr_info typedef struct nr_drb_rlc_pdcp_mapping_t { + gboolean active; guint16 ueid; /* Mandatory */ guint8 drbid; /* Mandatory */ @@ -63,9 +64,22 @@ typedef struct nr_drb_rlc_pdcp_mapping_t } nr_drb_rlc_pdcp_mapping_t; -/* Configure number of PDCP SN bits to use for DRB channels. */ -void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, - nr_drb_rlc_pdcp_mapping_t *drb_mapping); +/* TODO: could probably merge this struct with above */ +typedef struct pdcp_ue_parameters { + guint32 id; + guint8 pdcp_sn_bits_ul; + guint8 pdcp_sn_bits_dl; + gboolean pdcp_sdap_ul; + gboolean pdcp_sdap_dl; + gboolean pdcp_integrity; + gboolean pdcp_ciphering_disabled; +} pdcp_bearer_parameters; + +/* Configure DRB PDCP channel properties. */ +void set_rlc_nr_drb_pdcp_mapping(packet_info *pinfo, + nr_drb_rlc_pdcp_mapping_t *drb_mapping); + +pdcp_bearer_parameters* get_rlc_nr_drb_pdcp_mapping(guint16 ue_id, guint8 drb_id); /*****************************************************************/ /* UDP framing format */