Commit 7953b27f authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent bcf1af2d
......@@ -118,6 +118,7 @@ struct NwUeRrcToRls : NtsMessage
// RRC_PDU_DELIVERY
rrc::RrcChannel channel{};
uint32_t pduId{};
OctetString pdu{};
explicit NwUeRrcToRls(PR present) : NtsMessage(NtsMessageType::UE_RRC_TO_RLS), present(present)
......
......@@ -91,6 +91,12 @@ void UeRlsTask::onLoop()
break;
}
case NwUeRrcToRls::RRC_PDU_DELIVERY: {
auto *m = new NwUeRlsToRls(NwUeRlsToRls::UPLINK_RRC);
m->cellId = w->cellId;
m->rrcChannel = w->channel;
m->pduId = w->pduId;
m->data = std::move(w->pdu);
m_ctlTask->push(m);
break;
}
}
......
......@@ -94,6 +94,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg)
}
auto *nw = new NwUeRrcToRls(NwUeRrcToRls::RRC_PDU_DELIVERY);
nw->cellId = cellId;
nw->channel = rrc::RrcChannel::UL_CCCH;
nw->pdu = std::move(pdu);
m_base->rlsTask->push(nw);
......@@ -109,6 +110,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg)
}
auto *nw = new NwUeRrcToRls(NwUeRrcToRls::RRC_PDU_DELIVERY);
nw->cellId = cellId;
nw->channel = rrc::RrcChannel::UL_CCCH1;
nw->pdu = std::move(pdu);
m_base->rlsTask->push(nw);
......
//
// 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>
#include <asn/rrc/ASN_RRC_RRCSetupRequest-IEs.h>
#include <asn/rrc/ASN_RRC_RRCSetupRequest.h>
namespace nr::ue
{
static ASN_RRC_UL_CCCH_Message *ConstructSetupRequest(ASN_RRC_InitialUE_Identity_t initialUeId,
ASN_RRC_EstablishmentCause_t establishmentCause)
{
auto *pdu = asn::New<ASN_RRC_UL_CCCH_Message>();
pdu->message.present = ASN_RRC_UL_CCCH_MessageType_PR_c1;
pdu->message.choice.c1 = asn::NewFor(pdu->message.choice.c1);
pdu->message.choice.c1->present = ASN_RRC_UL_CCCH_MessageType__c1_PR_rrcSetupRequest;
auto &r = pdu->message.choice.c1->choice.rrcSetupRequest = asn::New<ASN_RRC_RRCSetupRequest>();
asn::DeepCopy(asn_DEF_ASN_RRC_InitialUE_Identity, initialUeId, &r->rrcSetupRequest.ue_Identity);
r->rrcSetupRequest.establishmentCause = establishmentCause;
asn::SetSpareBits<1>(r->rrcSetupRequest.spare);
return pdu;
}
void UeRrcTask::startConnectionSetup(OctetString &&nasPdu)
{
// TODO: if it's already in progress
if (m_initialId.present == ASN_RRC_InitialUE_Identity_PR_NOTHING)
{
m_initialId.present = ASN_RRC_InitialUE_Identity_PR_randomValue;
asn::SetBitStringLong<39>(static_cast<int64_t>(utils::Random64()), m_initialId.choice.randomValue);
}
m_initialNasPdu = std::move(nasPdu);
int activeCell = m_base->shCtx.currentCell.get<int>([](auto &item) { return item.cellId; });
m_logger->debug("Sending RRC Setup Request");
auto *rrcSetupRequest = ConstructSetupRequest(m_initialId, ASN_RRC_EstablishmentCause_mo_Data);
sendRrcMessage(activeCell, rrcSetupRequest);
asn::Free(asn_DEF_ASN_RRC_UL_CCCH_Message, rrcSetupRequest);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -32,37 +32,6 @@
namespace nr::ue
{
void UeRrcTask::deliverInitialNas(OctetString &&nasPdu, long establishmentCause)
{
/*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));
return;
}
m_logger->debug("Sending RRC Setup Request");
auto *pdu = asn::New<ASN_RRC_UL_CCCH_Message>();
pdu->message.present = ASN_RRC_UL_CCCH_MessageType_PR_c1;
pdu->message.choice.c1 = asn::NewFor(pdu->message.choice.c1);
pdu->message.choice.c1->present = ASN_RRC_UL_CCCH_MessageType__c1_PR_rrcSetupRequest;
m_initialId.present = ASN_RRC_InitialUE_Identity_PR_randomValue;
asn::SetBitStringLong<39>(utils::Random64(), m_initialId.choice.randomValue);
auto &r = pdu->message.choice.c1->choice.rrcSetupRequest = asn::New<ASN_RRC_RRCSetupRequest>();
r->rrcSetupRequest.establishmentCause = establishmentCause;
asn::SetSpareBits<1>(r->rrcSetupRequest.spare);
asn::DeepCopy(asn_DEF_ASN_RRC_InitialUE_Identity, m_initialId, &r->rrcSetupRequest.ue_Identity);
// TODO: Start T300
m_initialNasPdu = std::move(nasPdu);
m_lastSetupReq = ERrcLastSetupRequest::SETUP_REQUEST;
sendRrcMessage(pdu);*/
}
void UeRrcTask::deliverUplinkNas(OctetString &&nasPdu)
{
auto *pdu = asn::New<ASN_RRC_UL_DCCH_Message>();
......
......@@ -7,6 +7,7 @@
//
#include "task.hpp"
#include <lib/rrc/encode.hpp>
#include <ue/nas/task.hpp>
#include <ue/nts.hpp>
......@@ -32,7 +33,7 @@ void UeRrcTask::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu)
}
else if (m_state == ERrcState::RRC_IDLE)
{
// TODO
startConnectionSetup(std::move(nasPdu));
}
}
......
......@@ -7,6 +7,7 @@
//
#include "task.hpp"
#include <lib/rrc/encode.hpp>
#include <ue/nas/task.hpp>
#include <ue/nts.hpp>
......
......@@ -75,7 +75,6 @@ class UeRrcTask : public NtsTask
private:
/* Handlers */
void handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const OctetString &pdu);
void deliverInitialNas(OctetString &&nasPdu, long establishmentCause);
void deliverUplinkNas(OctetString &&nasPdu);
void receiveRrcSetup(const ASN_RRC_RRCSetup &msg);
......@@ -123,6 +122,9 @@ class UeRrcTask : public NtsTask
/* NAS Transport */
void deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu);
/* Connection Control */
void startConnectionSetup(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