Commit af2e3ffa authored by aligungr's avatar aligungr

RRC developments

parent 8748cc21
......@@ -9,10 +9,19 @@
#include "task.hpp"
#include <gnb/ngap/task.hpp>
#include <lib/asn/rrc.hpp>
#include <lib/asn/utils.hpp>
#include <lib/rrc/encode.hpp>
#include <utils/common.hpp>
#include <asn/rrc/ASN_RRC_MIB.h>
#include <asn/rrc/ASN_RRC_PLMN-Identity.h>
#include <asn/rrc/ASN_RRC_PLMN-IdentityInfo.h>
#include <asn/rrc/ASN_RRC_PLMN-IdentityInfoList.h>
#include <asn/rrc/ASN_RRC_SIB1.h>
#include <asn/rrc/ASN_RRC_UAC-BarringInfoSet.h>
#include <asn/rrc/ASN_RRC_UAC-BarringInfoSetIndex.h>
#include <asn/rrc/ASN_RRC_UAC-BarringInfoSetList.h>
namespace nr::gnb
{
......@@ -38,6 +47,40 @@ static ASN_RRC_BCCH_BCH_Message *ConstructMibMessage(bool barred, bool intraFreq
return pdu;
}
static ASN_RRC_BCCH_DL_SCH_Message *ConstructSib1Message(bool cellReserved, int tac, int64_t nci, const Plmn &plmn)
{
auto *pdu = asn::New<ASN_RRC_BCCH_DL_SCH_Message>();
pdu->message.present = ASN_RRC_BCCH_DL_SCH_MessageType_PR_c1;
pdu->message.choice.c1 = asn::NewFor(pdu->message.choice.c1);
pdu->message.choice.c1->present = ASN_RRC_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
pdu->message.choice.c1->choice.systemInformationBlockType1 = asn::New<ASN_RRC_SIB1>();
auto &sib1 = *pdu->message.choice.c1->choice.systemInformationBlockType1;
if (cellReserved)
{
sib1.cellAccessRelatedInfo.cellReservedForOtherUse =
asn::NewFor(sib1.cellAccessRelatedInfo.cellReservedForOtherUse);
*sib1.cellAccessRelatedInfo.cellReservedForOtherUse =
ASN_RRC_CellAccessRelatedInfo__cellReservedForOtherUse_true;
}
auto *plmnId = asn::rrc::NewPlmnId(plmn);
auto *plmnInfo = asn::New<ASN_RRC_PLMN_IdentityInfo>();
plmnInfo->cellReservedForOperatorUse = cellReserved
? ASN_RRC_PLMN_IdentityInfo__cellReservedForOperatorUse_reserved
: ASN_RRC_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
plmnInfo->trackingAreaCode = asn::NewFor(plmnInfo->trackingAreaCode);
asn::SetBitStringInt<24>(tac, *plmnInfo->trackingAreaCode);
asn::SetBitStringLong<36>(nci, plmnInfo->cellIdentity);
asn::SequenceAdd(plmnInfo->plmn_IdentityList, plmnId);
asn::SequenceAdd(sib1.cellAccessRelatedInfo.plmn_IdentityList, plmnInfo);
return pdu;
}
void GnbRrcTask::onBroadcastTimerExpired()
{
triggerSysInfoBroadcast();
......@@ -45,11 +88,14 @@ void GnbRrcTask::onBroadcastTimerExpired()
void GnbRrcTask::triggerSysInfoBroadcast()
{
ASN_RRC_BCCH_BCH_Message *msg = ConstructMibMessage(m_isBarred, m_intraFreqReselectAllowed);
auto *mib = ConstructMibMessage(m_isBarred, m_intraFreqReselectAllowed);
auto *sib1 = ConstructSib1Message(m_cellReserved, m_config->tac, m_config->nci, m_config->plmn);
sendRrcMessage(msg);
sendRrcMessage(mib);
sendRrcMessage(sib1);
asn::Free(asn_DEF_ASN_RRC_BCCH_BCH_Message, msg);
asn::Free(asn_DEF_ASN_RRC_BCCH_BCH_Message, mib);
asn::Free(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, sib1);
}
} // namespace nr::gnb
\ No newline at end of file
......@@ -81,7 +81,7 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg)
m_base->rlsTask->push(w);
}
void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_BCCH_DL_SCH_Message *msg)
void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg)
{
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_BCCH_DL_SCH_Message, msg);
if (pdu.length() == 0)
......@@ -91,7 +91,7 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_BCCH_DL_SCH_Message *msg)
}
auto *w = new NwGnbRrcToRls(NwGnbRrcToRls::RRC_PDU_DELIVERY);
w->ueId = ueId;
w->ueId = 0;
w->channel = rrc::RrcChannel::BCCH_DL_SCH;
w->pdu = std::move(pdu);
m_base->rlsTask->push(w);
......
......@@ -24,6 +24,7 @@ namespace nr::gnb
GnbRrcTask::GnbRrcTask(TaskBase *base) : m_base{base}, m_ueCtx{}, m_tidCounter{}
{
m_logger = base->logBase->makeUniqueLogger("rrc");
m_config = m_base->config;
}
void GnbRrcTask::onStart()
......
......@@ -42,12 +42,14 @@ class GnbRrcTask : public NtsTask
{
private:
TaskBase *m_base;
GnbConfig *m_config;
std::unique_ptr<Logger> m_logger;
std::unordered_map<int, RrcUeContext *> m_ueCtx;
int m_tidCounter;
bool m_isBarred = true;
bool m_intraFreqReselectAllowed = true;
bool m_cellReserved = false;
friend class GnbCmdHandler;
......@@ -83,7 +85,7 @@ class GnbRrcTask : public NtsTask
/* RRC channel send message */
void sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg);
void sendRrcMessage(int ueId, ASN_RRC_BCCH_DL_SCH_Message *msg);
void sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg);
void sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg);
void sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg);
void sendRrcMessage(ASN_RRC_PCCH_Message *msg);
......
//
// 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 "rrc.hpp"
#include <lib/asn/utils.hpp>
#include <asn/rrc/ASN_RRC_MCC.h>
namespace asn::rrc
{
static int NthDigit(int number, int n)
{
for (int i = 0; i < n; i++)
number /= 10;
return number % 10;
}
void SetPlmnId(const Plmn &source, ASN_RRC_PLMN_Identity &target)
{
int mncDigits = source.isLongMnc ? 3 : 2;
for (int i = 0; i < mncDigits; i++)
asn::SequenceAdd(target.mnc, NewMccMncDigit(NthDigit(source.mnc, mncDigits - i - 1)));
target.mcc = asn::NewFor(target.mcc);
for (int i = 0; i < 3; i++)
asn::SequenceAdd(*target.mcc, NewMccMncDigit(NthDigit(source.mcc, 2 - i)));
}
ASN_RRC_PLMN_Identity *NewPlmnId(const Plmn &plmn)
{
auto *value = asn::New<ASN_RRC_PLMN_Identity>();
SetPlmnId(plmn, *value);
return value;
}
ASN_RRC_MCC_MNC_Digit_t *NewMccMncDigit(int digit)
{
auto *value = asn::New<ASN_RRC_MCC_MNC_Digit_t>();
*value = digit;
return value;
}
} // namespace asn::rrc
//
// 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 <asn/rrc/ASN_RRC_PLMN-Identity.h>
#include <utils/common.hpp>
namespace asn::rrc
{
void SetPlmnId(const Plmn &source, ASN_RRC_PLMN_Identity &target);
ASN_RRC_PLMN_Identity *NewPlmnId(const Plmn &plmn);
ASN_RRC_MCC_MNC_Digit_t *NewMccMncDigit(int digit);
} // namespace asn::rrc
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