Commit 5fbd15a9 authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 755898a7
......@@ -13,8 +13,6 @@
#include <ue/nas/sm/sm.hpp>
#include <ue/rrc/task.hpp>
#include <asn/rrc/ASN_RRC_EstablishmentCause.h>
namespace nr::ue
{
......@@ -168,19 +166,10 @@ void NasMm::sendNasMessage(const nas::PlainMmMessage &msg)
}
}
if (m_cmState == ECmState::CM_IDLE)
{
auto *nw = new NwUeNasToRrc(NwUeNasToRrc::INITIAL_NAS_DELIVERY);
nw->nasPdu = std::move(pdu);
nw->rrcEstablishmentCause = ASN_RRC_EstablishmentCause_mo_Data;
m_base->rrcTask->push(nw);
}
else
{
auto *nw = new NwUeNasToRrc(NwUeNasToRrc::UPLINK_NAS_DELIVERY);
nw->pduId = 0;
nw->nasPdu = std::move(pdu);
m_base->rrcTask->push(nw);
}
}
void NasMm::receiveNasMessage(const nas::NasMessage &msg)
......
......@@ -92,17 +92,13 @@ struct NwUeNasToRrc : NtsMessage
enum PR
{
LOCAL_RELEASE_CONNECTION,
INITIAL_NAS_DELIVERY,
UPLINK_NAS_DELIVERY,
RRC_NOTIFY,
} present;
// INITIAL_NAS_DELIVERY
// UPLINK_NAS_DELIVERY
OctetString nasPdu{};
// INITIAL_NAS_DELIVERY
long rrcEstablishmentCause{};
uint32_t pduId{};
OctetString nasPdu;
explicit NwUeNasToRrc(PR present) : NtsMessage(NtsMessageType::UE_NAS_TO_RRC), present(present)
{
......
......@@ -63,6 +63,11 @@ bool UeRrcTask::hasSignalToCell(int cellId)
return m_cellDesc.count(cellId);
}
bool UeRrcTask::isActiveCell(int cellId)
{
return m_base->shCtx.currentCell.get<int>([](auto &value) { return value.cellId; }) == cellId;
}
void UeRrcTask::updateAvailablePlmns()
{
m_base->shCtx.availablePlmns.mutate([this](std::unordered_set<Plmn> &value) {
......
......@@ -54,21 +54,27 @@ void UeRrcTask::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const Oct
break;
}
case rrc::RrcChannel::DL_DCCH: {
if (isActiveCell(cellId))
{
auto *pdu = rrc::encode::Decode<ASN_RRC_DL_DCCH_Message>(asn_DEF_ASN_RRC_DL_DCCH_Message, rrcPdu);
if (pdu == nullptr)
m_logger->err("RRC DL-DCCH PDU decoding failed.");
else
receiveRrcMessage(cellId, pdu);
receiveRrcMessage(pdu);
asn::Free(asn_DEF_ASN_RRC_DL_DCCH_Message, pdu);
}
break;
};
case rrc::RrcChannel::PCCH: {
if (isActiveCell(cellId))
{
auto *pdu = rrc::encode::Decode<ASN_RRC_PCCH_Message>(asn_DEF_ASN_RRC_PCCH_Message, rrcPdu);
if (pdu == nullptr)
m_logger->err("RRC PCCH PDU decoding failed.");
else
receiveRrcMessage(cellId, pdu);
receiveRrcMessage(pdu);
asn::Free(asn_DEF_ASN_RRC_PCCH_Message, pdu);
}
break;
}
case rrc::RrcChannel::UL_CCCH:
......@@ -78,7 +84,7 @@ void UeRrcTask::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const Oct
}
}
void UeRrcTask::sendRrcMessage(ASN_RRC_UL_CCCH_Message *msg)
void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg)
{
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH_Message, msg);
if (pdu.length() == 0)
......@@ -93,7 +99,7 @@ void UeRrcTask::sendRrcMessage(ASN_RRC_UL_CCCH_Message *msg)
m_base->rlsTask->push(nw);
}
void UeRrcTask::sendRrcMessage(ASN_RRC_UL_CCCH1_Message *msg)
void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg)
{
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH1_Message, msg);
if (pdu.length() == 0)
......@@ -164,7 +170,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg)
}
}
void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_DCCH_Message *msg)
void UeRrcTask::receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg)
{
if (msg->message.present != ASN_RRC_DL_DCCH_MessageType_PR_c1)
return;
......@@ -183,7 +189,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_DCCH_Message *msg)
}
}
void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_PCCH_Message *msg)
void UeRrcTask::receiveRrcMessage(ASN_RRC_PCCH_Message *msg)
{
if (msg->message.present != ASN_RRC_PCCH_MessageType_PR_c1)
return;
......
......@@ -34,7 +34,7 @@ namespace nr::ue
void UeRrcTask::deliverInitialNas(OctetString &&nasPdu, long establishmentCause)
{
if (m_state != ERrcState::RRC_IDLE)
/*if (m_state != ERrcState::RRC_IDLE)
{
m_logger->warn("Initial NAS delivery while not in RRC_IDLE, treating as uplink delivery");
deliverUplinkNas(std::move(nasPdu));
......@@ -60,7 +60,7 @@ void UeRrcTask::deliverInitialNas(OctetString &&nasPdu, long establishmentCause)
m_initialNasPdu = std::move(nasPdu);
m_lastSetupReq = ERrcLastSetupRequest::SETUP_REQUEST;
sendRrcMessage(pdu);
sendRrcMessage(pdu);*/
}
void UeRrcTask::deliverUplinkNas(OctetString &&nasPdu)
......
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "task.hpp"
#include <lib/rrc/encode.hpp>
#include <ue/nas/task.hpp>
#include <ue/nts.hpp>
namespace nr::ue
{
void UeRrcTask::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu)
{
if (!m_base->shCtx.currentCell.get<bool>([](auto &value) { return value.hasValue(); }))
{
m_logger->err("Uplink NAS delivery failed. No cell is active");
return;
}
if (m_state == ERrcState::RRC_CONNECTED)
{
}
else if (m_state == ERrcState::RRC_INACTIVE)
{
}
else if (m_state == ERrcState::RRC_IDLE)
{
}
}
} // namespace nr::ue
\ No newline at end of file
......@@ -33,14 +33,8 @@ void UeRrcTask::handleNasSapMessage(NwUeNasToRrc &msg)
{
switch (msg.present)
{
case NwUeNasToRrc::INITIAL_NAS_DELIVERY: {
// TODO
// deliverInitialNas(std::move(msg.nasPdu), msg.rrcEstablishmentCause);
break;
}
case NwUeNasToRrc::UPLINK_NAS_DELIVERY: {
// TODO
// deliverUplinkNas(std::move(msg.nasPdu));
deliverUplinkNas(msg.pduId, std::move(msg.nasPdu));
break;
}
case NwUeNasToRrc::LOCAL_RELEASE_CONNECTION: {
......
......@@ -87,14 +87,14 @@ class UeRrcTask : public NtsTask
void handleRadioLinkFailure();
/* RRC Message Transmission and Receive */
void sendRrcMessage(ASN_RRC_UL_CCCH_Message *msg);
void sendRrcMessage(ASN_RRC_UL_CCCH1_Message *msg);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg);
void sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_BCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg); // TODO
void receiveRrcMessage(int cellId, ASN_RRC_DL_DCCH_Message *msg); // ..
void receiveRrcMessage(int cellId, ASN_RRC_PCCH_Message *msg); // Broadcast vs için camped olmayanları ignore
void receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_PCCH_Message *msg);
/* Service Access Point */
void handleRlsSapMessage(NwUeRlsToRrc &msg);
......@@ -114,11 +114,15 @@ class UeRrcTask : public NtsTask
void notifyCellDetected(int cellId, int dbm);
void notifyCellLost(int cellId);
bool hasSignalToCell(int cellId);
bool isActiveCell(int cellId);
void updateAvailablePlmns();
/* System Information */
void receiveMib(int cellId, const ASN_RRC_MIB &msg);
void receiveSib1(int cellId, const ASN_RRC_SIB1 &msg);
/* NAS Transport */
void deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu);
};
} // namespace nr::ue
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