Commit 37470ff1 authored by aligungr's avatar aligungr

SRA dev.

parent 5d844b4a
......@@ -10,6 +10,7 @@
#include <asn/ngap/ASN_NGAP_QosFlowSetupRequestItem.h>
#include <gnb/gtp/proto.hpp>
#include <gnb/sra/task.hpp>
#include <utils/constants.hpp>
#include <utils/libc_error.hpp>
......@@ -75,17 +76,17 @@ void GtpTask::onLoop()
}
break;
}
//case NtsMessageType::GNB_MR_TO_GTP: {
// auto *w = dynamic_cast<NwGnbMrToGtp *>(msg);
// switch (w->present)
// {
// case NwGnbMrToGtp::UPLINK_DELIVERY: {
// handleUplinkData(w->ueId, w->pduSessionId, std::move(w->data));
// break;
// }
// }
// break;
//}
case NtsMessageType::GNB_SRA_TO_GTP: {
auto *w = dynamic_cast<NwGnbSraToGtp *>(msg);
switch (w->present)
{
case NwGnbSraToGtp::DATA_PDU_DELIVERY: {
handleUplinkData(w->ueId, w->psi, std::move(w->pdu));
break;
}
}
break;
}
case NtsMessageType::UDP_SERVER_RECEIVE:
handleUdpReceive(*dynamic_cast<udp::NwUdpServerReceive *>(msg));
break;
......@@ -238,11 +239,11 @@ void GtpTask::handleUdpReceive(const udp::NwUdpServerReceive &msg)
if (m_rateLimiter->allowDownlinkPacket(sessionInd, gtp->payload.length()))
{
//auto *w = new NwGnbGtpToMr(NwGnbGtpToMr::DATA_PDU_DELIVERY);
//w->ueId = GetUeId(sessionInd);
//w->pduSessionId = GetPsi(sessionInd);
//w->data = std::move(gtp->payload);
//m_base->mrTask->push(w);
auto *w = new NwGnbGtpToSra(NwGnbGtpToSra::DATA_PDU_DELIVERY);
w->ueId = GetUeId(sessionInd);
w->psi = GetPsi(sessionInd);
w->pdu = std::move(gtp->payload);
m_base->sraTask->push(w);
}
delete gtp;
......
......@@ -44,6 +44,40 @@ struct NwGnbSraToRrc : NtsMessage
}
};
struct NwGnbSraToGtp : NtsMessage
{
enum PR
{
DATA_PDU_DELIVERY,
} present;
// DATA_PDU_DELIVERY
int ueId{};
int psi{};
OctetString pdu{};
explicit NwGnbSraToGtp(PR present) : NtsMessage(NtsMessageType::GNB_SRA_TO_GTP), present(present)
{
}
};
struct NwGnbGtpToSra : NtsMessage
{
enum PR
{
DATA_PDU_DELIVERY,
} present;
// DATA_PDU_DELIVERY
int ueId{};
int psi{};
OctetString pdu{};
explicit NwGnbGtpToSra(PR present) : NtsMessage(NtsMessageType::GNB_GTP_TO_SRA), present(present)
{
}
};
struct NwGnbRrcToSra : NtsMessage
{
enum PR
......
......@@ -8,6 +8,7 @@
#include "task.hpp"
#include <cmath>
#include <gnb/gtp/task.hpp>
#include <gnb/rrc/task.hpp>
static int MIN_ALLOWED_DBM = -120;
......@@ -57,6 +58,14 @@ void GnbSraTask::handleUplinkPduDelivery(int ueId, sra::SraPduDelivery &msg)
nw->pdu = std::move(msg.pdu);
m_base->rrcTask->push(nw);
}
else if (msg.pduType == sra::EPduType::DATA)
{
auto *nw = new NwGnbSraToGtp(NwGnbSraToGtp::DATA_PDU_DELIVERY);
nw->ueId = ueId;
nw->psi = msg.payload.get4I(0);
nw->pdu = std::move(msg.pdu);
m_base->gtpTask->push(nw);
}
}
void GnbSraTask::handleDownlinkDelivery(int ueId, sra::EPduType pduType, OctetString &&pdu, OctetString &&payload)
......
......@@ -67,6 +67,18 @@ void GnbSraTask::onLoop()
}
break;
}
case NtsMessageType::GNB_GTP_TO_SRA: {
auto *w = dynamic_cast<NwGnbGtpToSra *>(msg);
switch (w->present)
{
case NwGnbGtpToSra::DATA_PDU_DELIVERY: {
handleDownlinkDelivery(w->ueId, sra::EPduType::DATA, std::move(w->pdu),
OctetString::FromOctet4(static_cast<int>(w->psi)));
break;
}
}
break;
}
case NtsMessageType::UDP_SERVER_RECEIVE: {
auto *w = dynamic_cast<udp::NwUdpServerReceive *>(msg);
auto sraMsg = sra::DecodeSraMessage(OctetView{w->packet});
......
......@@ -9,6 +9,7 @@
#include "task.hpp"
#include "cmd_handler.hpp"
#include <nas/utils.hpp>
#include <ue/sra/task.hpp>
#include <ue/tun/tun.hpp>
#include <utils/common.hpp>
#include <utils/constants.hpp>
......@@ -49,33 +50,30 @@ void UeAppTask::onLoop()
switch (msg->msgType)
{
// case NtsMessageType::UE_MR_TO_APP: {
// auto *w = dynamic_cast<NwUeMrToApp *>(msg);
// switch (w->present)
// {
// case NwUeMrToApp::DATA_PDU_DELIVERY: {
// auto *tunTask = m_tunTasks[w->psi];
// if (tunTask)
// {
// auto *nw = new NwAppToTun(NwAppToTun::DATA_PDU_DELIVERY);
// nw->psi = w->psi;
// nw->data = std::move(w->data);
// tunTask->push(nw);
// }
// break;
// }
// }
// break;
//}
case NtsMessageType::UE_SRA_TO_APP: {
auto *w = dynamic_cast<NwUeSraToApp *>(msg);
switch (w->present)
{
case NwUeSraToApp::DATA_PDU_DELIVERY: {
auto *tunTask = m_tunTasks[w->psi];
if (tunTask)
{
auto *nw = new NwAppToTun(NwAppToTun::DATA_PDU_DELIVERY);
nw->psi = w->psi;
nw->data = std::move(w->pdu);
tunTask->push(nw);
}
break;
}
}
break;
}
case NtsMessageType::UE_TUN_TO_APP: {
auto *w = dynamic_cast<NwUeTunToApp *>(msg);
switch (w->present)
{
case NwUeTunToApp::DATA_PDU_DELIVERY: {
// auto *nw = new NwAppToMr(NwAppToMr::DATA_PDU_DELIVERY);
// nw->psi = w->psi;
// nw->data = std::move(w->data);
// m_base->mrTask->push(nw);
handleUplinkDataRequest(w->psi, std::move(w->data));
break;
}
case NwUeTunToApp::TUN_ERROR: {
......@@ -157,6 +155,12 @@ void UeAppTask::receiveStatusUpdate(NwUeStatusUpdate &msg)
}
return;
}
if (msg.what == NwUeStatusUpdate::CM_STATE)
{
m_cmState = msg.cmState;
return;
}
}
void UeAppTask::setupTunInterface(const PduSession *pduSession)
......@@ -218,4 +222,20 @@ void UeAppTask::setupTunInterface(const PduSession *pduSession)
allocatedName.c_str(), ipAddress.c_str());
}
void UeAppTask::handleUplinkDataRequest(int psi, OctetString &&data)
{
if (m_cmState == ECmState::CM_CONNECTED)
{
auto *nw = new NwUeAppToSra(NwUeAppToSra::DATA_PDU_DELIVERY);
nw->psi = psi;
nw->pdu = std::move(data);
m_base->sraTask->push(nw);
}
else
{
// TODO
m_logger->err("Uplink data is pending");
}
}
} // namespace nr::ue
......@@ -202,6 +202,22 @@ struct NwUeAppToSra : NtsMessage
}
};
struct NwUeSraToApp : NtsMessage
{
enum PR
{
DATA_PDU_DELIVERY
} present;
// DATA_PDU_DELIVERY
int psi{};
OctetString pdu{};
explicit NwUeSraToApp(PR present) : NtsMessage(NtsMessageType::UE_SRA_TO_APP), present(present)
{
}
};
struct NwUeStatusUpdate : NtsMessage
{
static constexpr const int SESSION_ESTABLISHMENT = 1;
......
......@@ -7,6 +7,7 @@
//
#include "task.hpp"
#include <ue/app/task.hpp>
#include <ue/nts.hpp>
#include <ue/rrc/task.hpp>
#include <utils/constants.hpp>
......@@ -63,6 +64,13 @@ void UeSraTask::deliverDownlinkPdu(sra::SraPduDelivery &msg)
nw->pdu = std::move(msg.pdu);
m_base->rrcTask->push(nw);
}
else if (msg.pduType == sra::EPduType::DATA)
{
auto *nw = new NwUeSraToApp(NwUeSraToApp::DATA_PDU_DELIVERY);
nw->psi = msg.payload.get4I(0);
nw->pdu = std::move(msg.pdu);
m_base->appTask->push(nw);
}
}
} // namespace nr::ue
......@@ -36,6 +36,8 @@ enum class NtsMessageType
GNB_MR_TO_RRC,
GNB_SRA_TO_RRC,
GNB_SRA_TO_GTP,
GNB_GTP_TO_SRA,
GNB_RRC_TO_SRA,
GNB_NGAP_TO_RRC,
GNB_RRC_TO_NGAP,
......@@ -50,6 +52,7 @@ enum class NtsMessageType
UE_RRC_TO_SRA,
UE_NAS_TO_NAS,
UE_SRA_TO_RRC,
UE_SRA_TO_APP,
UE_NAS_TO_APP,
};
......
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