mirror of https://github.com/PentHertz/srsLTE.git
nr,gnb,rrc: add rrc nr message handler and send functions to establish an SA RRC connection
This commit is contained in:
parent
02f261c0a9
commit
83c1fb65d7
|
@ -154,6 +154,12 @@ inline void copy_msg_to_buffer(unique_byte_buffer_t& pdu, const_byte_span msg)
|
|||
pdu->N_bytes = msg.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delimits beginning/ending of a test with the following console output:
|
||||
* ============= [Test <Name of the Test>] ===============
|
||||
* <test log>
|
||||
* =======================================================
|
||||
*/
|
||||
class test_delimit_logger
|
||||
{
|
||||
const size_t delimiter_length = 128;
|
||||
|
|
|
@ -31,8 +31,6 @@ public:
|
|||
ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg, bool start_msg3_timer = true);
|
||||
~ue();
|
||||
|
||||
void send_dl_ccch(const asn1::rrc_nr::dl_ccch_msg_s& dl_dcch_msg);
|
||||
|
||||
int handle_sgnb_addition_request(uint16_t eutra_rnti, const sgnb_addition_req_params_t& params);
|
||||
void crnti_ce_received();
|
||||
|
||||
|
@ -58,14 +56,32 @@ public:
|
|||
void handle_rrc_setup_request(const asn1::rrc_nr::rrc_setup_request_s& msg);
|
||||
void handle_rrc_setup_complete(const asn1::rrc_nr::rrc_setup_complete_s& msg);
|
||||
|
||||
/* TS 38.331 - 5.3.4 Initial AS security activation */
|
||||
void handle_security_mode_complete(const asn1::rrc_nr::security_mode_complete_s& msg);
|
||||
|
||||
/* TS 38.331 - 5.3.5 RRC reconfiguration */
|
||||
void handle_rrc_reconfiguration_complete(const asn1::rrc_nr::rrc_recfg_complete_s& msg);
|
||||
|
||||
/* TS 38.331 - 5.7.2 UL information transfer */
|
||||
void handle_ul_information_transfer(const asn1::rrc_nr::ul_info_transfer_s& msg);
|
||||
|
||||
private:
|
||||
rrc_nr* parent = nullptr;
|
||||
uint16_t rnti = SRSRAN_INVALID_RNTI;
|
||||
|
||||
void send_dl_ccch(const asn1::rrc_nr::dl_ccch_msg_s& dl_ccch_msg);
|
||||
void send_dl_dcch(srsran::nr_srb srb, const asn1::rrc_nr::dl_dcch_msg_s& dl_dcch_msg);
|
||||
|
||||
/* TS 38.331 - 5.3.3 RRC connection establishment */
|
||||
void send_rrc_setup();
|
||||
void send_rrc_reject(uint8_t reject_wait_time_secs);
|
||||
|
||||
/* TS 38.331 - 5.3.4 Initial AS security activation */
|
||||
void send_security_mode_command();
|
||||
|
||||
/* TS 38.331 - 5.3.5 RRC reconfiguration */
|
||||
void send_rrc_reconfiguration();
|
||||
|
||||
int pack_rrc_reconfiguration(asn1::dyn_octstring& packed_rrc_reconfig);
|
||||
int pack_secondary_cell_group_cfg(asn1::dyn_octstring& packed_secondary_cell_config);
|
||||
|
||||
|
|
|
@ -145,6 +145,11 @@ template void rrc_nr::log_rrc_message<dl_ccch_msg_s>(const char* sou
|
|||
srsran::const_byte_span pdu,
|
||||
const dl_ccch_msg_s& msg,
|
||||
const char* msg_type);
|
||||
template void rrc_nr::log_rrc_message<dl_dcch_msg_s>(const char* source,
|
||||
const direction_t dir,
|
||||
srsran::const_byte_span pdu,
|
||||
const dl_dcch_msg_s& msg,
|
||||
const char* msg_type);
|
||||
template void rrc_nr::log_rrc_message<cell_group_cfg_s>(const char* source,
|
||||
const direction_t dir,
|
||||
srsran::const_byte_span pdu,
|
||||
|
@ -509,6 +514,12 @@ void rrc_nr::handle_ul_dcch(uint16_t rnti, uint32_t lcid, srsran::const_byte_spa
|
|||
case ul_dcch_msg_type_c::c1_c_::types_opts::rrc_setup_complete:
|
||||
u.handle_rrc_setup_complete(ul_dcch_msg.msg.c1().rrc_setup_complete());
|
||||
break;
|
||||
case ul_dcch_msg_type_c::c1_c_::types_opts::security_mode_complete:
|
||||
u.handle_security_mode_complete(ul_dcch_msg.msg.c1().security_mode_complete());
|
||||
case ul_dcch_msg_type_c::c1_c_::types_opts::rrc_recfg_complete:
|
||||
u.handle_rrc_reconfiguration_complete(ul_dcch_msg.msg.c1().rrc_recfg_complete());
|
||||
case ul_dcch_msg_type_c::c1_c_::types_opts::ul_info_transfer:
|
||||
u.handle_ul_information_transfer(ul_dcch_msg.msg.c1().ul_info_transfer());
|
||||
default:
|
||||
log_rx_pdu_fail(rnti, srb_to_lcid(lte_srb::srb0), pdu, "Unsupported UL-CCCH message type", false);
|
||||
// TODO Remove user
|
||||
|
@ -659,5 +670,6 @@ srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu(const T& msg)
|
|||
return pdu;
|
||||
}
|
||||
template srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu<dl_ccch_msg_s>(const dl_ccch_msg_s& msg);
|
||||
template srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu<dl_dcch_msg_s>(const dl_dcch_msg_s& msg);
|
||||
|
||||
} // namespace srsenb
|
||||
|
|
|
@ -126,6 +126,20 @@ void rrc_nr::ue::send_dl_ccch(const dl_ccch_msg_s& dl_ccch_msg)
|
|||
parent->rlc->write_sdu(rnti, srsran::srb_to_lcid(srsran::nr_srb::srb0), std::move(pdu));
|
||||
}
|
||||
|
||||
void rrc_nr::ue::send_dl_dcch(srsran::nr_srb srb, const asn1::rrc_nr::dl_dcch_msg_s& dl_dcch_msg)
|
||||
{
|
||||
// Allocate a new PDU buffer, pack the message and send to PDCP
|
||||
srsran::unique_byte_buffer_t pdu = parent->pack_into_pdu(dl_dcch_msg);
|
||||
if (pdu == nullptr) {
|
||||
parent->logger.error("Failed to send DL-DCCH");
|
||||
return;
|
||||
}
|
||||
fmt::memory_buffer fmtbuf;
|
||||
fmt::format_to(fmtbuf, "DL-DCCH.{}", dl_dcch_msg.msg.c1().type().to_string());
|
||||
log_rrc_message(srb, Tx, *pdu.get(), dl_dcch_msg, srsran::to_c_str(fmtbuf));
|
||||
parent->pdcp->write_sdu(rnti, srsran::srb_to_lcid(srb), std::move(pdu));
|
||||
}
|
||||
|
||||
int rrc_nr::ue::pack_secondary_cell_group_rlc_cfg(asn1::rrc_nr::cell_group_cfg_s& cell_group_cfg_pack)
|
||||
{
|
||||
// RLC for DRB1 (with fixed LCID)
|
||||
|
@ -927,6 +941,54 @@ void rrc_nr::ue::send_rrc_setup()
|
|||
void rrc_nr::ue::handle_rrc_setup_complete(const asn1::rrc_nr::rrc_setup_complete_s& msg)
|
||||
{
|
||||
// TODO: handle RRCSetupComplete
|
||||
|
||||
send_security_mode_command();
|
||||
}
|
||||
|
||||
/// TS 38.331, SecurityModeCommand
|
||||
void rrc_nr::ue::send_security_mode_command()
|
||||
{
|
||||
asn1::rrc_nr::dl_dcch_msg_s dl_dcch_msg;
|
||||
dl_dcch_msg.msg.set_c1().set_security_mode_cmd().rrc_transaction_id = (uint8_t)((transaction_id++) % 4);
|
||||
security_mode_cmd_ies_s& ies = dl_dcch_msg.msg.c1().security_mode_cmd().crit_exts.set_security_mode_cmd();
|
||||
|
||||
ies.security_cfg_smc.security_algorithm_cfg.integrity_prot_algorithm_present = true;
|
||||
ies.security_cfg_smc.security_algorithm_cfg.integrity_prot_algorithm.value = integrity_prot_algorithm_opts::nia0;
|
||||
ies.security_cfg_smc.security_algorithm_cfg.ciphering_algorithm.value = ciphering_algorithm_opts::nea0;
|
||||
|
||||
send_dl_dcch(srsran::nr_srb::srb1, dl_dcch_msg);
|
||||
}
|
||||
|
||||
/// TS 38.331, SecurityModeComplete
|
||||
void rrc_nr::ue::handle_security_mode_complete(const asn1::rrc_nr::security_mode_complete_s& msg)
|
||||
{
|
||||
// TODO: handle SecurityModeComplete
|
||||
|
||||
send_rrc_reconfiguration();
|
||||
}
|
||||
|
||||
void rrc_nr::ue::send_rrc_reconfiguration()
|
||||
{
|
||||
asn1::rrc_nr::dl_dcch_msg_s dl_dcch_msg;
|
||||
dl_dcch_msg.msg.set_c1().set_rrc_recfg().rrc_transaction_id = (uint8_t)((transaction_id++) % 4);
|
||||
rrc_recfg_ies_s& ies = dl_dcch_msg.msg.c1().rrc_recfg().crit_exts.set_rrc_recfg();
|
||||
|
||||
ies.non_crit_ext_present = true;
|
||||
ies.non_crit_ext.master_cell_group_present = false; // TODO
|
||||
|
||||
// Update lower layers
|
||||
|
||||
send_dl_dcch(srsran::nr_srb::srb1, dl_dcch_msg);
|
||||
}
|
||||
|
||||
void rrc_nr::ue::handle_rrc_reconfiguration_complete(const asn1::rrc_nr::rrc_recfg_complete_s& msg)
|
||||
{
|
||||
// TODO: handle RRCReconfComplete
|
||||
}
|
||||
|
||||
void rrc_nr::ue::handle_ul_information_transfer(const asn1::rrc_nr::ul_info_transfer_s& msg)
|
||||
{
|
||||
// TODO: handle UL information transfer
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue