Commit b9e6a565 authored by lfq's avatar lfq

srb_sdu

parent d7ebca91
......@@ -194,6 +194,85 @@ int V(int semid,int idx){
entity->rx_reord = entity->rx_next;
entity->t_reordering_start = entity->t_current;
}
}
int nr_pdcp_entity_process_srb_sdu(nr_pdcp_entity_t *entity,
char *buffer,
int size,
int sdu_id,
char *pdu_buffer,
int pdu_max_size)
{
uint32_t count;
int sn;
int header_size;
int integrity_size;
char *buf = pdu_buffer;
DevAssert(size + 3 + 4 <= pdu_max_size);
int dc_bit;
entity->stats.rxsdu_pkts++;
entity->stats.rxsdu_bytes += size;
count = entity->tx_next;
sn = entity->tx_next & entity->sn_max;
/* D/C bit is only to be set for DRBs */
if (entity->type == NR_PDCP_DRB_AM || entity->type == NR_PDCP_DRB_UM) {
dc_bit = 0x80;
} else {
dc_bit = 0;
}
if (entity->sn_size == 12) {
buf[0] = dc_bit | ((sn >> 8) & 0xf);
buf[1] = sn & 0xff;
header_size = 2;
} else {
buf[0] = dc_bit | ((sn >> 16) & 0x3);
buf[1] = (sn >> 8) & 0xff;
buf[2] = sn & 0xff;
header_size = 3;
}
/* SRBs always have MAC-I, even if integrity is not active */
if (entity->has_integrity || entity->type == NR_PDCP_SRB) {
integrity_size = 4;
} else {
integrity_size = 0;
}
memcpy(buf + header_size, buffer, size);
if (entity->has_integrity){
uint8_t integrity[4] = {0};
entity->integrity(entity->integrity_context,
integrity,
(unsigned char *)buf, header_size + size,
entity->rb_id, count, entity->is_gnb ? 1 : 0);
memcpy((unsigned char *)buf + header_size + size, integrity, 4);
}
// set MAC-I to 0 for SRBs with integrity not active
else if (integrity_size == 4)
memset(buf + header_size + size, 0, 4);
if (entity->has_ciphering && (entity->is_gnb || entity->security_mode_completed)){
entity->cipher(entity->security_context,
(unsigned char *)buf + header_size, size + integrity_size,
entity->rb_id, count, entity->is_gnb ? 1 : 0);
} else {
entity->security_mode_completed = true;
}
entity->tx_next++;
entity->stats.txpdu_pkts++;
entity->stats.txpdu_bytes += header_size + size + integrity_size;
entity->stats.txpdu_sn = sn;
return header_size + size + integrity_size;
}
int nr_pdcp_entity_process_sdu(nr_pdcp_entity_t *entity,
......
......@@ -182,14 +182,11 @@ typedef struct nr_pdcp_entity_t {
bool security_mode_completed;
int has_ciphering_algorithm;
int has_integrity_algorithm;
char has_ciphering_key;
char has_integrity_key;
ngran_node_t node_type;
ue_id_t rntiMaybeUEid;
int drb_id;
} nr_pdcp_entity_t;
nr_pdcp_entity_t *new_nr_pdcp_entity(
......@@ -220,6 +217,12 @@ int nr_pdcp_entity_process_sdu(nr_pdcp_entity_t *entity,
int sdu_id,
char *pdu_buffer,
int pdu_max_size);
int nr_pdcp_entity_process_srb_sdu(nr_pdcp_entity_t *entity,
char *buffer,
int size,
int sdu_id,
char *pdu_buffer,
int pdu_max_size);
void nr_pdcp_entity_set_security(nr_pdcp_entity_t *entity,
int integrity_algorithm,
char *integrity_key,
......
......@@ -404,7 +404,7 @@ static void do_pdcp_data_ind(
for(int i=0;i<*(pdcp_num);i++){
uint8_t *pdcp_shm = pdcp_ctxt + sizeof(int64_t) + i * sizeof(nr_pdcp_entity_t);
nr_pdcp_entity_t *stu = (struct nr_pdcp_entity_t*)pdcp_shm;
if(stu->rntiMaybeUEid == rntiMaybeUEid && stu->drb_id == (rb_id - 1)){
if(stu->rntiMaybeUEid == rntiMaybeUEid && stu->rb_id == rb_id){
if (rb_id < 1 || rb_id > MAX_DRBS_PER_UE)
{
rb = NULL;
......@@ -442,8 +442,8 @@ static void do_pdcp_data_ind(
// rb->deliver_sdu = deliver_sdu_drb;
// rb->deliver_pdu = deliver_pdu_drb;
nr_pdcp_entity_set_security(rb,
rb->has_integrity_algorithm, &rb->has_integrity_key,
rb->has_ciphering_algorithm, &rb->has_ciphering_key);
rb->integrity_algorithm, NULL,
rb->ciphering_algorithm, NULL);
// LOG_I(PDCP,"recv buffer[0]:%x-------buffer[1]:%x--------buffer[2]:%x\n",((char *)sdu_buffer->data)[0],((char *)sdu_buffer->data)[1],((char *)sdu_buffer->data)[2]);
rb->recv_pdu(rb, (char *)sdu_buffer->data, sdu_buffer_size,shm_offset_cu);
} else {
......@@ -1105,21 +1105,8 @@ void add_drb_am(int is_gnb, ue_id_t rntiMaybeUEid, ue_id_t reestablish_ue_id, st
has_integrity ? integrity_algorithm : 0,
has_ciphering ? ciphering_key : NULL,
has_integrity ? integrity_key : NULL);
pdcp_drb->has_ciphering_algorithm = has_ciphering ? ciphering_algorithm : 0;
pdcp_drb->has_integrity_algorithm = has_integrity ? integrity_algorithm : 0;
if(has_ciphering){
pdcp_drb->has_ciphering_key = *ciphering_key;
}else{
pdcp_drb->has_ciphering_key = 0;
}
if(has_integrity){
pdcp_drb->has_integrity_key = *integrity_key;
}else{
pdcp_drb->has_integrity_key = 0;
}
nr_pdcp_ue_add_drb_pdcp_entity(ue, drb_id, pdcp_drb);
pdcp_drb->drb_id = drb_id - 1;
if (reestablish_ue_id > 0) {
nr_pdcp_ue_t *reestablish_ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, reestablish_ue_id);
......@@ -1322,15 +1309,15 @@ bool nr_pdcp_data_req_srb(ue_id_t ue_id,
}
int max_size = sdu_buffer_size + 3 + 4; // 3: max header, 4: max integrity
char *pdu_buf = NULL;
int pdu_size = rb->process_sdu(rb, (char *)sdu_buffer, sdu_buffer_size, muiP, pdu_buf, max_size);
char pdu_buf[max_size];
int pdu_size = nr_pdcp_entity_process_srb_sdu(rb, (char *)sdu_buffer, sdu_buffer_size, muiP, pdu_buf, max_size);
AssertFatal(rb->deliver_pdu == NULL, "SRB callback should be NULL, to be provided on every invocation\n");
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
int shm_offset = 0;
deliver_pdu_cb(data, ue_id, rb_id, (sdu_buffer - 2), pdu_size, muiP,shm_offset);
deliver_pdu_cb(data, ue_id, rb_id, pdu_buf, pdu_size, muiP,shm_offset);
return 1;
}
bool enqueue_nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
......@@ -1436,7 +1423,7 @@ bool nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
for(int i=0;i<*(pdcp_num);i++){
uint8_t *pdcp_shm = pdcp_ctxt + sizeof(int64_t) + i * sizeof(nr_pdcp_entity_t);
nr_pdcp_entity_t *stu = (struct nr_pdcp_entity_t*)pdcp_shm;
if(stu->rntiMaybeUEid == ue_id && stu->drb_id == (rb_id - 1)){
if(stu->rntiMaybeUEid == ue_id && stu->rb_id == rb_id){
if (rb_id < 1 || rb_id > MAX_DRBS_PER_UE)
{
rb = NULL;
......@@ -1467,8 +1454,8 @@ bool nr_pdcp_data_req_drb(protocol_ctxt_t *ctxt_pP,
rb->get_stats = nr_pdcp_entity_get_stats;
rb->deliver_pdu = deliver_pdu_drb;
nr_pdcp_entity_set_security(rb,
rb->has_integrity_algorithm, &rb->has_integrity_key,
rb->has_ciphering_algorithm, &rb->has_ciphering_key);
rb->integrity_algorithm, NULL,
rb->ciphering_algorithm, NULL);
}
int max_size = sdu_buffer_size + 3 + 4; // 3: max header, 4: max integrity
......
......@@ -216,7 +216,7 @@ void nr_pdcp_ue_add_drb_pdcp_entity(nr_pdcp_ue_t *ue, int drb_id, nr_pdcp_entity
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}
entity->drb_id = drb_id;
// entity->drb_id = drb_id;
ue->drb[drb_id] = entity;
}
......
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