PDCP-NR: add ciphering and integrity checking

There may be some scope to share some code with PDCP-LTE,
but it may make the code harder to read.
This commit is contained in:
Martin Mathieson 2020-12-29 13:55:35 +00:00 committed by Martin Mathieson
parent 4e8474fa29
commit 9164d7f9ce
13 changed files with 1341 additions and 139 deletions

View File

@ -2512,7 +2512,7 @@ DRX-Config/setup/shortDRX/drxShortCycleTimer DISPLAY=BASE_DEC|BASE_UNIT_STRING S
#.FN_BODY SecurityAlgorithmConfig
pdcp_lte_info *p_pdcp_lte_info;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = private_data_pdcp_security_algorithms(actx);
p_security_algorithms->configuration_frame = actx->pinfo->num;
@ -2529,17 +2529,17 @@ DRX-Config/setup/shortDRX/drxShortCycleTimer DISPLAY=BASE_DEC|BASE_UNIT_STRING S
#.FN_BODY CipheringAlgorithm-r12 VAL_PTR=&value
guint32 value;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = private_data_pdcp_security_algorithms(actx);
p_security_algorithms->ciphering = (enum security_ciphering_algorithm_e)value;
p_security_algorithms->ciphering = (enum lte_security_ciphering_algorithm_e)value;
#.FN_BODY SecurityAlgorithmConfig/integrityProtAlgorithm VAL_PTR=&value
guint32 value;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = private_data_pdcp_security_algorithms(actx);
p_security_algorithms->integrity = (enum security_integrity_algorithm_e)value;
p_security_algorithms->integrity = (enum lte_security_integrity_algorithm_e)value;
#.FN_BODY SchedulingRequestConfig/setup/sr-ConfigIndex VAL_PTR=&value
guint32 value;

View File

@ -2737,7 +2737,7 @@ typedef struct lte_rrc_private_data_t
guint8 warning_message_segment_number;
drb_mapping_t drb_mapping;
drx_config_t drx_config;
pdcp_security_info_t pdcp_security;
pdcp_lte_security_info_t pdcp_security;
meas_capabilities_item_band_mappings_t meas_capabilities_item_band_mappings;
simult_pucch_pusch_cell_type cell_type;
gboolean bcch_dl_sch_msg;
@ -2873,7 +2873,7 @@ static void private_data_set_ra_preambles(asn1_ctx_t *actx, guint8 ra_preambles)
/* PDCP Security info */
static pdcp_security_info_t* private_data_pdcp_security_algorithms(asn1_ctx_t *actx)
static pdcp_lte_security_info_t* private_data_pdcp_security_algorithms(asn1_ctx_t *actx)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
return &private_data->pdcp_security;

View File

@ -470,7 +470,17 @@ RAT-Type TYPE_PREFIX
#.FN_HDR SecurityModeComplete
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "Security Mode Complete");
#.FN_HDR SecurityModeFailure
#.FN_BODY SecurityModeFailure
mac_nr_info *p_mac_nr_info;
%(DEFAULT_BODY)s
/* Look for UE identifier */
p_mac_nr_info = (mac_nr_info *)p_get_proto_data(wmem_file_scope(), actx->pinfo, proto_mac_nr, 0);
if (p_mac_nr_info != NULL) {
/* Inform PDCP that the UE failed to execute the securityModeCommand */
set_pdcp_nr_security_algorithms_failed(p_mac_nr_info->ueid);
}
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "Security Mode Failure");
#.FN_HDR ULInformationTransfer
@ -1549,6 +1559,23 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni
mapping->rlcDlSnLength = (value=0) ? 12 : 18;
}
#.FN_BODY SDAP-Config/sdap-HeaderDL VAL_PTR=&value
guint32 value;
%(DEFAULT_BODY)s
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpDlSdap = !value;
#.FN_BODY SDAP-Config/sdap-HeaderUL VAL_PTR=&value
guint32 value;
%(DEFAULT_BODY)s
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpUlSdap = !value;
#.FN_BODY PDCP-Config/drb/integrityProtection
%(DEFAULT_BODY)s
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpIntegrityProtection = TRUE;
#.FN_BODY DRB-ToAddMod
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
memset(mapping, 0, sizeof(*mapping));
@ -1559,7 +1586,9 @@ VisitedCellInfo-r16/timeSpent-r16 DISPLAY=BASE_DEC|BASE_UNIT_STRING STRINGS=&uni
/* 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->pdcpUlSnLength, mapping->pdcpDlSnLength);
mapping->pdcpUlSnLength, mapping->pdcpDlSnLength,
mapping->pdcpUlSdap, mapping->pdcpDlSdap,
mapping->pdcpIntegrityProtection);
}
}
@ -1679,6 +1708,38 @@ CA-ParametersEUTRA-v1570/dl-1024QAM-TotalWeightedLayers DISPLAY=BASE_CUSTOM STRI
dissect_lte_rrc_MeasResultSCG_FailureMRDC_r15_PDU(meas_result_scg_fail_mrdc_tvb, actx->pinfo, subtree, NULL);
}
#.FN_BODY SecurityAlgorithmConfig
pdcp_nr_info *p_pdcp_nr_info;
pdcp_nr_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->configuration_frame = actx->pinfo->num;
p_security_algorithms->previous_configuration_frame = 0;
p_security_algorithms->previous_integrity = nia0;
p_security_algorithms->previous_ciphering = nea0;
/* Look for UE identifier */
p_pdcp_nr_info = (pdcp_nr_info *)p_get_proto_data(wmem_file_scope(), actx->pinfo, proto_pdcp_nr, 0);
if (p_pdcp_nr_info != NULL) {
/* Configure algorithms */
set_pdcp_nr_security_algorithms(p_pdcp_nr_info->ueid, p_security_algorithms);
}
#.FN_BODY CipheringAlgorithm VAL_PTR=&value
guint32 value;
pdcp_nr_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->ciphering = (enum nr_security_ciphering_algorithm_e)value;
#.FN_BODY IntegrityProtAlgorithm VAL_PTR=&value
guint32 value;
pdcp_nr_security_info_t *p_security_algorithms;
%(DEFAULT_BODY)s
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->integrity = (enum nr_security_integrity_algorithm_e)value;
#.FN_HDR SBCCH-SL-BCH-Message
proto_item *ti;
@ -1717,3 +1778,6 @@ CA-ParametersEUTRA-v1570/dl-1024QAM-TotalWeightedLayers DISPLAY=BASE_CUSTOM STRI
#.FN_HDR UECapabilityInformationSidelink
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "UE Capability Information Sidelink");

View File

@ -31,6 +31,7 @@
#include "packet-cell_broadcast.h"
#include "packet-mac-nr.h"
#include "packet-rlc-nr.h"
#include "packet-pdcp-nr.h"
#include "packet-rrc.h"
#include "packet-lte-rrc.h"
#include "packet-nr-rrc.h"
@ -56,6 +57,7 @@ static reassembly_table nr_rrc_sib7_reassembly_table;
static reassembly_table nr_rrc_sib8_reassembly_table;
extern int proto_mac_nr;
extern int proto_pdcp_nr;
/* Include constants */
#include "packet-nr-rrc-val.h"
@ -166,6 +168,7 @@ typedef struct {
guint8 warning_message_segment_number;
nr_drb_mapping_t drb_mapping;
lpp_pos_sib_type_t pos_sib_type;
pdcp_nr_security_info_t pdcp_security;
} nr_rrc_private_data_t;
/* Helper function to get or create a struct that will be actx->private_data */

View File

@ -15046,7 +15046,7 @@ typedef struct lte_rrc_private_data_t
guint8 warning_message_segment_number;
drb_mapping_t drb_mapping;
drx_config_t drx_config;
pdcp_security_info_t pdcp_security;
pdcp_lte_security_info_t pdcp_security;
meas_capabilities_item_band_mappings_t meas_capabilities_item_band_mappings;
simult_pucch_pusch_cell_type cell_type;
gboolean bcch_dl_sch_msg;
@ -15182,7 +15182,7 @@ static void private_data_set_ra_preambles(asn1_ctx_t *actx, guint8 ra_preambles)
/* PDCP Security info */
static pdcp_security_info_t* private_data_pdcp_security_algorithms(asn1_ctx_t *actx)
static pdcp_lte_security_info_t* private_data_pdcp_security_algorithms(asn1_ctx_t *actx)
{
lte_rrc_private_data_t *private_data = (lte_rrc_private_data_t*)lte_rrc_get_private_data(actx);
return &private_data->pdcp_security;
@ -40763,12 +40763,12 @@ static const value_string lte_rrc_CipheringAlgorithm_r12_vals[] = {
static int
dissect_lte_rrc_CipheringAlgorithm_r12(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
8, &value, TRUE, 0, NULL);
p_security_algorithms = private_data_pdcp_security_algorithms(actx);
p_security_algorithms->ciphering = (enum security_ciphering_algorithm_e)value;
p_security_algorithms->ciphering = (enum lte_security_ciphering_algorithm_e)value;
return offset;
@ -40791,12 +40791,12 @@ static const value_string lte_rrc_T_integrityProtAlgorithm_vals[] = {
static int
dissect_lte_rrc_T_integrityProtAlgorithm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
8, &value, TRUE, 0, NULL);
p_security_algorithms = private_data_pdcp_security_algorithms(actx);
p_security_algorithms->integrity = (enum security_integrity_algorithm_e)value;
p_security_algorithms->integrity = (enum lte_security_integrity_algorithm_e)value;
return offset;
@ -40812,7 +40812,7 @@ static const per_sequence_t SecurityAlgorithmConfig_sequence[] = {
static int
dissect_lte_rrc_SecurityAlgorithmConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
pdcp_lte_info *p_pdcp_lte_info;
pdcp_security_info_t *p_security_algorithms;
pdcp_lte_security_info_t *p_security_algorithms;
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_lte_rrc_SecurityAlgorithmConfig, SecurityAlgorithmConfig_sequence);

View File

@ -134,6 +134,9 @@ typedef struct nr_drb_mapping_t
guint8 pdcpUlSnLength; /* Part of PDCP config - optional */
gboolean pdcpDlSnLength_present;
guint8 pdcpDlSnLength; /* Part of PDCP config - optional */
gboolean pdcpUlSdap;
gboolean pdcpDlSdap;
gboolean pdcpIntegrityProtection;
} nr_drb_mapping_t;

View File

@ -39,6 +39,7 @@
#include "packet-cell_broadcast.h"
#include "packet-mac-nr.h"
#include "packet-rlc-nr.h"
#include "packet-pdcp-nr.h"
#include "packet-rrc.h"
#include "packet-lte-rrc.h"
#include "packet-nr-rrc.h"
@ -64,6 +65,7 @@ static reassembly_table nr_rrc_sib7_reassembly_table;
static reassembly_table nr_rrc_sib8_reassembly_table;
extern int proto_mac_nr;
extern int proto_pdcp_nr;
/* Include constants */
@ -361,7 +363,7 @@ typedef enum _T_targetRAT_Type_enum {
} T_targetRAT_Type_enum;
/*--- End of included file: packet-nr-rrc-val.h ---*/
#line 62 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 64 "./asn1/nr-rrc/packet-nr-rrc-template.c"
/* Initialize the protocol and registered fields */
static int proto_nr_rrc = -1;
@ -6207,7 +6209,7 @@ static int hf_nr_rrc_lowSE_64QAM_MCS_TableSidelink_r16_01 = -1; /* T_lowSE_64QA
static int dummy_hf_nr_rrc_eag_field = -1; /* never registered */
/*--- End of included file: packet-nr-rrc-hf.c ---*/
#line 66 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 68 "./asn1/nr-rrc/packet-nr-rrc-template.c"
static int hf_nr_rrc_serialNumber_gs = -1;
static int hf_nr_rrc_serialNumber_msg_code = -1;
static int hf_nr_rrc_serialNumber_upd_nb = -1;
@ -8594,7 +8596,7 @@ static gint ett_nr_rrc_T_fr1_r16_02 = -1;
static gint ett_nr_rrc_T_fr2_r16_02 = -1;
/*--- End of included file: packet-nr-rrc-ett.c ---*/
#line 103 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 105 "./asn1/nr-rrc/packet-nr-rrc-template.c"
static gint ett_nr_rrc_DedicatedNAS_Message = -1;
static gint ett_nr_rrc_targetRAT_MessageContainer = -1;
static gint ett_nr_rrc_nas_Container = -1;
@ -8661,6 +8663,7 @@ typedef struct {
guint8 warning_message_segment_number;
nr_drb_mapping_t drb_mapping;
lpp_pos_sib_type_t pos_sib_type;
pdcp_nr_security_info_t pdcp_security;
} nr_rrc_private_data_t;
/* Helper function to get or create a struct that will be actx->private_data */
@ -24612,6 +24615,10 @@ dissect_nr_rrc_T_integrityProtection(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
1, NULL, FALSE, 0, NULL);
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpIntegrityProtection = TRUE;
return offset;
}
@ -25187,8 +25194,13 @@ static const value_string nr_rrc_T_sdap_HeaderDL_vals[] = {
static int
dissect_nr_rrc_T_sdap_HeaderDL(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
2, NULL, FALSE, 0, NULL);
2, &value, FALSE, 0, NULL);
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpDlSdap = !value;
return offset;
}
@ -25203,8 +25215,13 @@ static const value_string nr_rrc_T_sdap_HeaderUL_vals[] = {
static int
dissect_nr_rrc_T_sdap_HeaderUL(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
2, NULL, FALSE, 0, NULL);
2, &value, FALSE, 0, NULL);
nr_drb_mapping_t *mapping = &nr_rrc_get_private_data(actx)->drb_mapping;
mapping->pdcpUlSdap = !value;
return offset;
}
@ -25371,7 +25388,9 @@ dissect_nr_rrc_DRB_ToAddMod(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
/* 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->pdcpUlSnLength, mapping->pdcpDlSnLength);
mapping->pdcpUlSnLength, mapping->pdcpDlSnLength,
mapping->pdcpUlSdap, mapping->pdcpDlSdap,
mapping->pdcpIntegrityProtection);
}
}
@ -25423,8 +25442,14 @@ static const value_string nr_rrc_CipheringAlgorithm_vals[] = {
static int
dissect_nr_rrc_CipheringAlgorithm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
pdcp_nr_security_info_t *p_security_algorithms;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
8, NULL, TRUE, 0, NULL);
8, &value, TRUE, 0, NULL);
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->ciphering = (enum nr_security_ciphering_algorithm_e)value;
return offset;
}
@ -25445,8 +25470,15 @@ static const value_string nr_rrc_IntegrityProtAlgorithm_vals[] = {
static int
dissect_nr_rrc_IntegrityProtAlgorithm(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
guint32 value;
pdcp_nr_security_info_t *p_security_algorithms;
offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
8, NULL, TRUE, 0, NULL);
8, &value, TRUE, 0, NULL);
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->integrity = (enum nr_security_integrity_algorithm_e)value;
return offset;
}
@ -25460,9 +25492,25 @@ static const per_sequence_t SecurityAlgorithmConfig_sequence[] = {
static int
dissect_nr_rrc_SecurityAlgorithmConfig(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
pdcp_nr_info *p_pdcp_nr_info;
pdcp_nr_security_info_t *p_security_algorithms;
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_nr_rrc_SecurityAlgorithmConfig, SecurityAlgorithmConfig_sequence);
p_security_algorithms = &(nr_rrc_get_private_data(actx)->pdcp_security);
p_security_algorithms->configuration_frame = actx->pinfo->num;
p_security_algorithms->previous_configuration_frame = 0;
p_security_algorithms->previous_integrity = nia0;
p_security_algorithms->previous_ciphering = nea0;
/* Look for UE identifier */
p_pdcp_nr_info = (pdcp_nr_info *)p_get_proto_data(wmem_file_scope(), actx->pinfo, proto_pdcp_nr, 0);
if (p_pdcp_nr_info != NULL) {
/* Configure algorithms */
set_pdcp_nr_security_algorithms(p_pdcp_nr_info->ueid, p_security_algorithms);
}
return offset;
}
@ -41136,11 +41184,21 @@ static const per_sequence_t SecurityModeFailure_sequence[] = {
static int
dissect_nr_rrc_SecurityModeFailure(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "Security Mode Failure");
mac_nr_info *p_mac_nr_info;
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_nr_rrc_SecurityModeFailure, SecurityModeFailure_sequence);
/* Look for UE identifier */
p_mac_nr_info = (mac_nr_info *)p_get_proto_data(wmem_file_scope(), actx->pinfo, proto_mac_nr, 0);
if (p_mac_nr_info != NULL) {
/* Inform PDCP that the UE failed to execute the securityModeCommand */
set_pdcp_nr_security_algorithms_failed(p_mac_nr_info->ueid);
}
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "Security Mode Failure");
return offset;
}
@ -85852,6 +85910,9 @@ dissect_nr_rrc_UECapabilityInformationSidelink(tvbuff_t *tvb _U_, int offset _U_
proto_item *prot_ti = proto_tree_add_item(tree, proto_nr_rrc, tvb, 0, -1, ENC_NA);
proto_item_set_hidden(prot_ti);
col_append_sep_str(actx->pinfo->cinfo, COL_INFO, NULL, "UE Capability Information Sidelink");
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_nr_rrc_UECapabilityInformationSidelink, UECapabilityInformationSidelink_sequence);
@ -86694,7 +86755,7 @@ static int dissect_UECapabilityEnquiry_v1560_IEs_PDU(tvbuff_t *tvb _U_, packet_i
/*--- End of included file: packet-nr-rrc-fn.c ---*/
#line 515 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 518 "./asn1/nr-rrc/packet-nr-rrc-template.c"
int
dissect_nr_rrc_nr_RLF_Report_r16_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
@ -110075,7 +110136,7 @@ proto_register_nr_rrc(void) {
"T_lowSE_64QAM_MCS_TableSidelink_r16_01", HFILL }},
/*--- End of included file: packet-nr-rrc-hfarr.c ---*/
#line 547 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 550 "./asn1/nr-rrc/packet-nr-rrc-template.c"
{ &hf_nr_rrc_serialNumber_gs,
{ "Geographical Scope", "nr-rrc.serialNumber.gs",
@ -112563,7 +112624,7 @@ proto_register_nr_rrc(void) {
&ett_nr_rrc_T_fr2_r16_02,
/*--- End of included file: packet-nr-rrc-ettarr.c ---*/
#line 685 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 688 "./asn1/nr-rrc/packet-nr-rrc-template.c"
&ett_nr_rrc_DedicatedNAS_Message,
&ett_nr_rrc_targetRAT_MessageContainer,
&ett_nr_rrc_nas_Container,
@ -112650,7 +112711,7 @@ proto_register_nr_rrc(void) {
/*--- End of included file: packet-nr-rrc-dis-reg.c ---*/
#line 751 "./asn1/nr-rrc/packet-nr-rrc-template.c"
#line 754 "./asn1/nr-rrc/packet-nr-rrc-template.c"
nr_rrc_etws_cmas_dcs_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(),
g_direct_hash, g_direct_equal);

View File

@ -12,7 +12,6 @@
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
@ -358,8 +357,8 @@ static gboolean global_pdcp_ignore_sec = FALSE; /* Ignore Set Security
/* Use these values where we know the keys but may have missed the algorithm,
e.g. when handing over and RRCReconfigurationRequest goes to target cell only */
static enum security_ciphering_algorithm_e global_default_ciphering_algorithm = eea0;
static enum security_integrity_algorithm_e global_default_integrity_algorithm = eia0;
static enum lte_security_ciphering_algorithm_e global_default_ciphering_algorithm = eea0;
static enum lte_security_integrity_algorithm_e global_default_integrity_algorithm = eia0;
static const value_string direction_vals[] =
@ -605,8 +604,8 @@ static wmem_map_t *pdcp_lte_sequence_analysis_report_hash = NULL;
/* Gather together security settings in order to be able to do deciphering */
typedef struct pdu_security_settings_t
{
enum security_ciphering_algorithm_e ciphering;
enum security_integrity_algorithm_e integrity;
enum lte_security_ciphering_algorithm_e ciphering;
enum lte_security_integrity_algorithm_e integrity;
guint8* cipherKey;
guint8* integrityKey;
gboolean cipherKeyValid;
@ -704,6 +703,7 @@ static void addChannelSequenceInfo(pdcp_sequence_report_in_frame *p,
/* May also be able to add key inputs to security tree here */
if ((pdu_security->ciphering != eea0) ||
(pdu_security->integrity != eia0)) {
guint32 hfn_multiplier;
guint32 count;
gchar *cipher_key = NULL;
@ -713,6 +713,7 @@ static void addChannelSequenceInfo(pdcp_sequence_report_in_frame *p,
ti = proto_tree_add_uint(security_tree, hf_pdcp_lte_security_bearer,
tvb, 0, 0, p_pdcp_lte_info->channelId-1);
proto_item_set_generated(ti);
pdu_security->bearer = p_pdcp_lte_info->channelId-1;
/* DIRECTION */
@ -869,7 +870,7 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb,
guint32 snLimit = 0;
/* If find stat_report_in_frame already, use that and get out */
if (pinfo->fd->visited) {
if (PINFO_FD_VISITED(pinfo)) {
p_report_in_frame =
(pdcp_sequence_report_in_frame*)wmem_map_lookup(pdcp_lte_sequence_analysis_report_hash,
get_report_hash_key(sequenceNumber,
@ -1022,14 +1023,6 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb,
/* Hash table for security state for a UE
Maps UEId -> pdcp_security_info_t* */
static gint pdcp_lte_ueid_hash_equal(gconstpointer v, gconstpointer v2)
{
return (v == v2);
}
static guint pdcp_lte_ueid_hash_func(gconstpointer v)
{
return GPOINTER_TO_UINT(v);
}
static wmem_map_t *pdcp_security_hash = NULL;
/* Result is (ueid, framenum) -> pdcp_security_info_t* */
@ -1453,11 +1446,11 @@ static gboolean dissect_pdcp_lte_heur(tvbuff_t *tvb, packet_info *pinfo,
}
/* Called from control protocol to configure security algorithms for the given UE */
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *security_info)
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_lte_security_info_t *security_info)
{
/* Use for this frame so can check integrity on SecurityCommandRequest frame */
/* N.B. won't work for internal, non-RRC signalling methods... */
pdcp_security_info_t *p_frame_security;
pdcp_lte_security_info_t *p_frame_security;
/* Disable this entire sub-routine with the Preference */
/* Used when the capture is already deciphered */
@ -1466,12 +1459,12 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi
}
/* Create or update current settings, by UEID */
pdcp_security_info_t* ue_security =
(pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)ueid));
pdcp_lte_security_info_t* ue_security =
(pdcp_lte_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)ueid));
if (ue_security == NULL) {
/* Copy whole security struct */
ue_security = wmem_new(wmem_file_scope(), pdcp_security_info_t);
ue_security = wmem_new(wmem_file_scope(), pdcp_lte_security_info_t);
*ue_security = *security_info;
/* And add into security table */
@ -1491,7 +1484,7 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi
/* Also add an entry for this PDU already to use these settings, as otherwise it won't be present
when we query it on the first pass. */
p_frame_security = wmem_new(wmem_file_scope(), pdcp_security_info_t);
p_frame_security = wmem_new(wmem_file_scope(), pdcp_lte_security_info_t);
*p_frame_security = *ue_security;
wmem_map_insert(pdcp_security_result_hash,
get_ueid_frame_hash_key(ueid, ue_security->configuration_frame, TRUE),
@ -1502,9 +1495,9 @@ void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *securi
void set_pdcp_lte_security_algorithms_failed(guint16 ueid)
{
/* Look up current state by UEID */
pdcp_security_info_t* ue_security =
(pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)ueid));
pdcp_lte_security_info_t* ue_security =
(pdcp_lte_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)ueid));
if (ue_security != NULL) {
/* TODO: could remove from table if previous_configuration_frame is 0 */
/* Go back to previous state */
@ -1785,8 +1778,8 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint32 reserved_value;
guint32 seqnum = 0;
pdcp_security_info_t *current_security = NULL; /* current security for this UE */
pdcp_security_info_t *pdu_security; /* security in place for this PDU */
pdcp_lte_security_info_t *current_security = NULL; /* current security for this UE */
pdcp_lte_security_info_t *pdu_security; /* security in place for this PDU */
proto_tree *security_tree = NULL;
proto_item *security_ti;
tvbuff_t *payload_tvb;
@ -1840,13 +1833,13 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/***************************************/
/* UE security algorithms */
if (!pinfo->fd->visited) {
if (!PINFO_FD_VISITED(pinfo)) {
/* Look up current state by UEID */
current_security = (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)p_pdcp_info->ueid));
current_security = (pdcp_lte_security_info_t*)wmem_map_lookup(pdcp_security_hash,
GUINT_TO_POINTER((guint)p_pdcp_info->ueid));
if (current_security != NULL) {
/* Store any result for this frame in the result table */
pdcp_security_info_t *security_to_store = wmem_new(wmem_file_scope(), pdcp_security_info_t);
pdcp_lte_security_info_t *security_to_store = wmem_new(wmem_file_scope(), pdcp_lte_security_info_t);
/* Take a deep copy of the settings */
*security_to_store = *current_security;
wmem_map_insert(pdcp_security_result_hash,
@ -1858,7 +1851,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if ((global_default_ciphering_algorithm != eea0) ||
(global_default_integrity_algorithm != eia0)) {
/* Copy algorithms from preference defaults */
pdcp_security_info_t *security_to_store = wmem_new0(wmem_file_scope(), pdcp_security_info_t);
pdcp_lte_security_info_t *security_to_store = wmem_new0(wmem_file_scope(), pdcp_lte_security_info_t);
security_to_store->ciphering = global_default_ciphering_algorithm;
security_to_store->integrity = global_default_integrity_algorithm;
security_to_store->seen_next_ul_pdu = TRUE;
@ -1870,8 +1863,8 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
}
/* Show security settings for this PDU */
pdu_security = (pdcp_security_info_t*)wmem_map_lookup(pdcp_security_result_hash,
get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, FALSE));
pdu_security = (pdcp_lte_security_info_t*)wmem_map_lookup(pdcp_security_result_hash,
get_ueid_frame_hash_key(p_pdcp_info->ueid, pinfo->num, FALSE));
if (pdu_security != NULL) {
/* Create subtree */
security_ti = proto_tree_add_string_format(pdcp_tree,
@ -2312,8 +2305,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Now deal with the payload */
/*******************************************************/
/* Check pdu_security_settings - may need to do deciphering before calling
further dissectors on payload */
payload_tvb = decipher_payload(tvb, pinfo, &offset, &pdu_security_settings, p_pdcp_info,
pdu_security ? pdu_security->seen_next_ul_pdu: FALSE, &payload_deciphered);
@ -2337,6 +2328,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
Call lte-rrc dissector (according to direction and channel type) if we have valid data */
if ((global_pdcp_dissect_signalling_plane_as_rrc) &&
((pdu_security == NULL) || (pdu_security->ciphering == eea0) || payload_deciphered || !pdu_security->seen_next_ul_pdu)) {
/* Get appropriate dissector handle */
dissector_handle_t rrc_handle = lookup_rrc_dissector_handle(p_pdcp_info);
@ -2355,11 +2347,11 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
}
else {
/* Just show data */
proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, payload_tvb, offset,
data_length, ENC_NA);
proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, payload_tvb, offset,
data_length, ENC_NA);
}
if (!pinfo->fd->visited &&
if (!PINFO_FD_VISITED(pinfo) &&
(current_security != NULL) && !current_security->seen_next_ul_pdu &&
p_pdcp_info->direction == DIRECTION_UPLINK)
{
@ -2824,6 +2816,7 @@ void proto_register_pdcp(void)
}
},
/* Security fields */
{ &hf_pdcp_lte_security,
{ "Security Config",
"pdcp-lte.security-config", FT_STRING, BASE_NONE, 0, 0x0,
@ -2877,7 +2870,7 @@ void proto_register_pdcp(void)
"pdcp-lte.security-config.integrity-key", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL
}
},
}
};
static gint *ett[] =
@ -3043,9 +3036,9 @@ void proto_register_pdcp(void)
pdcp_sequence_analysis_channel_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal);
pdcp_lte_sequence_analysis_report_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_result_hash_func, pdcp_result_hash_equal);
pdcp_security_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal);
pdcp_security_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal);
pdcp_security_result_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_frame_hash_func, pdcp_lte_ueid_frame_hash_equal);
pdcp_security_key_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal);
pdcp_security_key_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), g_direct_hash, g_direct_equal);
}
void proto_reg_handoff_pdcp_lte(void)

View File

@ -45,21 +45,21 @@ typedef enum
#define PDCP_SN_LENGTH_15_BITS 15
#define PDCP_SN_LENGTH_18_BITS 18
enum security_integrity_algorithm_e { eia0, eia1, eia2, eia3 };
enum security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 };
enum lte_security_integrity_algorithm_e { eia0, eia1, eia2, eia3 };
enum lte_security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 };
typedef struct pdcp_security_info_t
typedef struct pdcp_lte_security_info_t
{
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum security_integrity_algorithm_e integrity;
enum security_ciphering_algorithm_e ciphering;
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum lte_security_integrity_algorithm_e integrity;
enum lte_security_ciphering_algorithm_e ciphering;
/* Store previous settings so can revert if get SecurityModeFailure */
guint32 previous_configuration_frame;
enum security_integrity_algorithm_e previous_integrity;
enum security_ciphering_algorithm_e previous_ciphering;
} pdcp_security_info_t;
guint32 previous_configuration_frame;
enum lte_security_integrity_algorithm_e previous_integrity;
enum lte_security_ciphering_algorithm_e previous_ciphering;
} pdcp_lte_security_info_t;
/* Info attached to each LTE PDCP/RoHC packet */
@ -174,7 +174,7 @@ typedef struct pdcp_lte_info
/* Called by RRC, or other configuration protocols */
/* Function to configure ciphering & integrity algorithms */
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_security_info_t *security_info);
void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_lte_security_info_t *security_info);
/* Function to indicate securityModeCommand did not complete */
void set_pdcp_lte_security_algorithms_failed(guint16 ueid);

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,23 @@ typedef enum NRBearerType
#define PDCP_NR_UL_SDAP_HEADER_PRESENT 0x01
#define PDCP_NR_DL_SDAP_HEADER_PRESENT 0x02
enum nr_security_integrity_algorithm_e { nia0, nia1, nia2, nia3 };
enum nr_security_ciphering_algorithm_e { nea0, nea1, nea2, nea3 };
typedef struct pdcp_nr_security_info_t
{
guint32 configuration_frame;
gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */
enum nr_security_integrity_algorithm_e integrity;
enum nr_security_ciphering_algorithm_e ciphering;
/* Store previous settings so can revert if get SecurityModeFailure */
guint32 previous_configuration_frame;
enum nr_security_integrity_algorithm_e previous_integrity;
enum nr_security_ciphering_algorithm_e previous_ciphering;
} pdcp_nr_security_info_t;
/* Info attached to each nr PDCP/RoHC packet */
typedef struct pdcp_nr_info
{
@ -78,7 +95,7 @@ void set_pdcp_nr_proto_data(packet_info *pinfo, pdcp_nr_info *p_pdcp_nr_info);
/* and implemented by this dissector, using the definitions */
/* below. */
/* */
/* A heuristic dissecter (enabled by a preference) will */
/* A heuristic dissector (enabled by a preference) will */
/* recognise a signature at the beginning of these frames. */
/* Until someone is using this format, suggestions for changes */
/* are welcome. */
@ -154,6 +171,21 @@ void set_pdcp_nr_proto_data(packet_info *pinfo, pdcp_nr_info *p_pdcp_nr_info);
#define PDCP_NR_PAYLOAD_TAG 0x01
/* Called by RRC, or other configuration protocols */
/* Function to configure ciphering & integrity algorithms */
void set_pdcp_nr_security_algorithms(guint16 ueid, pdcp_nr_security_info_t *security_info);
/* Function to indicate securityModeCommand did not complete */
void set_pdcp_nr_security_algorithms_failed(guint16 ueid);
/* Called by external dissectors */
void set_pdcp_nr_rrc_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_nr_rrc_integrity_key(guint16 ueid, const char *key);
void set_pdcp_nr_up_ciphering_key(guint16 ueid, const char *key);
void set_pdcp_nr_up_integrity_key(guint16 ueid, const char *key);
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*

View File

@ -66,9 +66,12 @@ 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;
guint32 id;
guint8 pdcp_sn_bits_ul;
guint8 pdcp_sn_bits_dl;
gboolean pdcp_sdap_ul;
gboolean pdcp_sdap_dl;
gboolean pdcp_integrity;
} rlc_ue_parameters;
static wmem_tree_t *ue_parameters_tree;
@ -471,10 +474,17 @@ static void show_PDU_in_tree(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb
if (params) {
if (p_pdcp_nr_info->direction == DIRECTION_UPLINK) {
p_pdcp_nr_info->seqnum_length = params->pdcp_sn_bits_ul;
if (params->pdcp_sdap_ul) {
p_pdcp_nr_info->sdap_header &= PDCP_NR_UL_SDAP_HEADER_PRESENT;
}
}
else {
p_pdcp_nr_info->seqnum_length = params->pdcp_sn_bits_dl;
if (params->pdcp_sdap_dl) {
p_pdcp_nr_info->sdap_header &= PDCP_NR_DL_SDAP_HEADER_PRESENT;
}
}
p_pdcp_nr_info->maci_present = params->pdcp_integrity;
}
break;
@ -1294,7 +1304,10 @@ 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, guint16 ueid, guint8 drbid,
guint8 userplane_seqnum_length_ul,
guint8 userplane_seqnum_length_dl)
guint8 userplane_seqnum_length_dl,
gboolean sdap_ul,
gboolean sdap_dl,
gboolean integrity)
{
wmem_tree_key_t key[3];
guint32 id;
@ -1312,17 +1325,24 @@ void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, guint16 ueid, guint8
key[2].length = 0;
key[2].key = NULL;
/* Look up entry for this UEId/drbid */
params = (rlc_ue_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->id = id;
wmem_tree_insert32_array(ue_parameters_tree, key, (void *)params);
}
/* Populate params */
params->pdcp_sn_bits_ul = userplane_seqnum_length_ul;
params->pdcp_sn_bits_dl = userplane_seqnum_length_dl;
params->pdcp_sdap_ul = sdap_ul;
params->pdcp_sdap_dl = sdap_dl;
params->pdcp_integrity = integrity;
}

View File

@ -50,7 +50,9 @@ typedef struct rlc_nr_info
/* Configure number of PDCP SN bits to use for DRB channels. */
void set_rlc_nr_drb_pdcp_seqnum_length(packet_info *pinfo, guint16 ueid, guint8 drbid,
guint8 userplane_seqnum_length_ul,
guint8 userplane_seqnum_length_dl);
guint8 userplane_seqnum_length_dl,
gboolean sdap_ul, gboolean sdap_dl,
gboolean integrity);
/*****************************************************************/
/* UDP framing format */