Commit b01b7391 authored by Laurent THOMAS's avatar Laurent THOMAS

2667 synchronous work between PDCP and RRC for DCCCH messages

parent 0bcf3b79
......@@ -511,7 +511,7 @@ function main() {
# e.g., cmake_targets/ran_build/build, hence the ../../..
CMAKE_CMD="$CMAKE_CMD ../../.."
echo_info "Running \"$CMAKE_CMD\""
eval $CMAKE_CMD
$CMAKE_CMD
compilations $BUILD_DIR all.txt $TARGET_LIST
###################
# Doxygen Support #
......
......@@ -35,5 +35,6 @@ MESSAGE_DEF(RRC_NRUE_CAP_INFO_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataIn
MESSAGE_DEF(RRC_DCCH_DATA_COPY_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_copy_ind)
// gNB
MESSAGE_DEF(NR_RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, NRRrcDcchDataReq, nr_rrc_dcch_data_req)
MESSAGE_DEF(NR_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcDcchDataInd, nr_rrc_dcch_data_ind)
MESSAGE_DEF(NR_RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, NRRrcDcchDataReq, nr_rrc_dcch_data_req)
MESSAGE_DEF(NR_RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, NRRrcDcchDataInd, nr_rrc_dcch_data_ind)
MESSAGE_DEF(NR_RRC_DCCH_DATA_RESP, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataResp, nr_rrc_dcch_data_resp)
......@@ -55,8 +55,25 @@ typedef struct RrcDcchDataReq_s {
uint16_t rnti;
uint8_t module_id;
uint8_t eNB_index;
int returnTask; // itti circular include, impossible to use the correct enum
} RrcDcchDataReq;
#include "openair2/RRC/NR/nr_rrc_common.h"
#define maxMSGs (10)
#define maxSZ (maxMSGs * 100)
typedef struct RrcDcchDataResp_s {
bool doCyphering;
bool doIntegrity;
uint8_t integrityProtAlgorithm;
uint8_t cipheringAlgorithm;
uint8_t kRRCenc[NR_K_KEY_SIZE];
uint8_t kUPenc[NR_K_KEY_SIZE];
uint8_t kRRCint[NR_K_KEY_SIZE];
int srbID;
uint8_t buffer[maxSZ];
int sz[maxMSGs];
} RrcDcchDataResp;
typedef struct RrcDcchDataInd_s {
uint32_t frame;
uint8_t dcch_index;
......@@ -100,6 +117,7 @@ typedef struct NRRrcDcchDataInd_s {
uint8_t gNB_index; // LG: needed in UE
/* 'msg_integrity' is needed for RRC to check integrity of the PDCP SDU */
nr_pdcp_integrity_data_t msg_integrity;
bool integrityResult;
} NRRrcDcchDataInd;
typedef struct RrcPcchDataReq_s {
......
......@@ -308,7 +308,7 @@ static bool nr_pdcp_entity_check_integrity(struct nr_pdcp_entity_t *entity,
const nr_pdcp_integrity_data_t *msg_integrity)
{
if (!entity->has_integrity)
return false;
return true;
int header_size = msg_integrity->header_size;
......
......@@ -777,12 +777,53 @@ srb_found:
memcpy(rrc_buffer_p, buf, size);
MessageDef *message_p = itti_alloc_new_message(TASK_PDCP_UE, 0, NR_RRC_DCCH_DATA_IND);
AssertFatal(message_p != NULL, "OUT OF MEMORY\n");
NR_RRC_DCCH_DATA_IND(message_p).dcch_index = srb_id;
NR_RRC_DCCH_DATA_IND(message_p).sdu_p = rrc_buffer_p;
NR_RRC_DCCH_DATA_IND(message_p).sdu_size = size;
memcpy(&NR_RRC_DCCH_DATA_IND(message_p).msg_integrity, msg_integrity, sizeof(*msg_integrity));
ue_id_t ue_id = ue->ue_id;
itti_send_msg_to_task(TASK_RRC_NRUE, ue_id, message_p);
nr_pdcp_entity_t *rb = nr_pdcp_get_rb(ue, srb_id, true);
NR_RRC_DCCH_DATA_IND(message_p) =
(NRRrcDcchDataInd){.dcch_index = srb_id,
.sdu_p = rrc_buffer_p,
.sdu_size = size,
.msg_integrity = *msg_integrity,
.integrityResult = rb->check_integrity(rb, (const uint8_t *)buf, size, msg_integrity)};
itti_send_msg_to_task(TASK_RRC_NRUE, ue->ue_id, message_p);
MessageDef *Resp;
itti_receive_msg(TASK_PDCP_UE, &Resp);
if (Resp == NULL)
return;
RrcDcchDataResp *returned = &Resp->ittiMsg.nr_rrc_dcch_data_resp;
if (returned->doCyphering) {
// configure lower layers to apply SRB integrity protection and ciphering
for (i = 0; i < sizeofArray(ue->srb); i++) {
nr_pdcp_entity_t *rb = nr_pdcp_get_rb(ue, i, true);
if (rb)
rb->set_security(rb, returned->integrityProtAlgorithm, (char *)returned->kRRCint, 0, (char *)returned->kRRCenc);
}
}
if (returned->srbID) {
nr_pdcp_entity_t *rb = nr_pdcp_get_rb(ue, returned->srbID, true);
if (rb) {
char *ptr = (char *)returned->buffer;
for (int i = 0; i < sizeofArray(returned->sz) && returned->sz[i]; i++) {
int max_size = nr_max_pdcp_pdu_size(returned->sz[i]);
char pdu_buf[max_size];
int pdu_size = rb->process_sdu(rb, ptr, returned->sz[i], 0, pdu_buf, max_size);
deliver_pdu_srb_rlc(NULL, ue->ue_id, returned->srbID, pdu_buf, pdu_size, 0);
ptr += returned->sz[i];
}
}
}
if (returned->doCyphering) {
// configure lower layers to apply SRB integrity protection and ciphering
for (i = 0; i < sizeofArray(ue->srb); i++) {
nr_pdcp_entity_t *rb = nr_pdcp_get_rb(ue, i, true);
if (rb)
rb->set_security(rb,
returned->integrityProtAlgorithm,
(char *)returned->kRRCint,
returned->cipheringAlgorithm,
(char *)returned->kRRCenc);
}
}
itti_free(ITTI_MSG_ORIGIN_ID(Resp), Resp);
}
}
......@@ -801,7 +842,8 @@ void add_srb(int is_gnb,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
unsigned char *integrity_key,
bool alreadyLocked)
{
nr_pdcp_entity_t *pdcp_srb;
nr_pdcp_ue_t *ue;
......@@ -811,7 +853,8 @@ void add_srb(int is_gnb,
if (s->pdcp_Config != NULL && s->pdcp_Config->t_Reordering != NULL)
t_Reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering);
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
if (!alreadyLocked)
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, UEid);
if (nr_pdcp_get_rb(ue, srb_id, true) != NULL) {
LOG_E(PDCP, "warning SRB %d already exist for UE ID %ld, do nothing\n", srb_id, UEid);
......@@ -837,7 +880,8 @@ void add_srb(int is_gnb,
LOG_D(PDCP, "added srb %d to UE ID %ld\n", srb_id, UEid);
}
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
if (!alreadyLocked)
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void add_drb(int is_gnb,
......@@ -846,7 +890,8 @@ void add_drb(int is_gnb,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key)
unsigned char *integrity_key,
bool alreadyLocked)
{
nr_pdcp_entity_t *pdcp_drb;
nr_pdcp_ue_t *ue;
......@@ -910,8 +955,8 @@ void add_drb(int is_gnb,
exit(1);
}
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
if (!alreadyLocked)
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, UEid);
if (nr_pdcp_get_rb(ue, drb_id, false) != NULL) {
LOG_W(PDCP, "warning DRB %d already exist for UE ID %ld, do nothing\n", drb_id, UEid);
......@@ -940,7 +985,8 @@ void add_drb(int is_gnb,
mappedQFIs2Add,
mappedQFIs2AddCount);
}
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
if (!alreadyLocked)
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
void nr_pdcp_add_srbs(eNB_flag_t enb_flag,
......@@ -952,7 +998,14 @@ void nr_pdcp_add_srbs(eNB_flag_t enb_flag,
{
if (srb2add_list != NULL) {
for (int i = 0; i < srb2add_list->list.count; i++) {
add_srb(enb_flag, UEid, srb2add_list->list.array[i], security_modeP & 0x0f, (security_modeP >> 4) & 0x0f, kRRCenc, kRRCint);
add_srb(enb_flag,
UEid,
srb2add_list->list.array[i],
security_modeP & 0x0f,
(security_modeP >> 4) & 0x0f,
kRRCenc,
kRRCint,
false);
}
} else
LOG_W(PDCP, "nr_pdcp_add_srbs() with void list\n");
......@@ -973,7 +1026,8 @@ void nr_pdcp_add_drbs(eNB_flag_t enb_flag,
security_modeP & 0x0f,
(security_modeP >> 4) & 0x0f,
kUPenc,
kUPint);
kUPint,
false);
}
} else
LOG_W(PDCP, "nr_pdcp_add_drbs() with void list\n");
......@@ -1059,34 +1113,6 @@ void nr_pdcp_config_set_security(ue_id_t ue_id,
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
}
bool nr_pdcp_check_integrity_srb(ue_id_t ue_id,
int srb_id,
const uint8_t *msg,
int msg_size,
const nr_pdcp_integrity_data_t *msg_integrity)
{
nr_pdcp_ue_t *ue;
nr_pdcp_entity_t *rb;
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, ue_id);
rb = nr_pdcp_get_rb(ue, srb_id, true);
if (rb == NULL) {
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
LOG_E(PDCP, "no SRB found (ue_id %ld, rb_id %d)\n", ue_id, srb_id);
return false;
}
bool ret = rb->check_integrity(rb, msg, msg_size, msg_integrity);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
return ret;
}
bool nr_pdcp_data_req_srb(ue_id_t ue_id,
const rb_id_t rb_id,
const mui_t muiP,
......
......@@ -59,7 +59,8 @@ void add_drb(int is_gnb,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key);
unsigned char *integrity_key,
bool alreadyLocked);
void nr_pdcp_remove_UE(ue_id_t ue_id);
void nr_pdcp_reestablishment(ue_id_t ue_id, int rb_id, bool srb_flag);
......@@ -71,14 +72,14 @@ void nr_pdcp_reconfigure_drb(ue_id_t ue_id, int drb_id, NR_PDCP_Config_t *pdcp_c
void nr_pdcp_release_srb(ue_id_t ue_id, int srb_id);
void nr_pdcp_release_drb(ue_id_t ue_id, int drb_id);
void add_srb(int is_gnb,
ue_id_t UEid,
struct NR_SRB_ToAddMod *s,
int ciphering_algorithm,
int integrity_algorithm,
unsigned char *ciphering_key,
unsigned char *integrity_key);
unsigned char *integrity_key,
bool alreadyLocked);
void nr_pdcp_config_set_security(ue_id_t ue_id,
const rb_id_t rb_id,
......@@ -87,12 +88,6 @@ void nr_pdcp_config_set_security(ue_id_t ue_id,
uint8_t *const kRRCint_pP,
uint8_t *const kUPenc_pP);
bool nr_pdcp_check_integrity_srb(ue_id_t ue_id,
int srb_id,
const uint8_t *msg,
int msg_size,
const nr_pdcp_integrity_data_t *msg_integrity);
bool cu_f1u_data_req(protocol_ctxt_t *ctxt_pP,
const srb_flag_t srb_flagP,
const rb_id_t rb_id,
......
......@@ -24,7 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#define NR_RRC_HEADER_SIZE_MAX 64
#define NR_RRC_BUFFER_SIZE_MAX 1024
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment