Commit 558a4917 authored by yangjian's avatar yangjian

add paging function

parent 9e0cbaff
......@@ -111,6 +111,13 @@ void amf_app_task(void*) {
amf_app_inst->handle_itti_message(ref(*m));
} break;
case PAGING_N1N2_MESSAGE_TRANSFER: {
Logger::amf_app().debug("Received PAGING_N1N2_MESSAGE_TRANSFER");
itti_paging_n1n2_message_transfer* m =
dynamic_cast<itti_paging_n1n2_message_transfer*>(msg);
amf_app_inst->handle_itti_message(ref(*m));
} break;
case TIME_OUT:
if (itti_msg_timeout* to = dynamic_cast<itti_msg_timeout*>(msg)) {
switch (to->arg1_user) {
......@@ -181,6 +188,27 @@ void amf_app::set_ran_amf_id_2_ue_context(
}
// ITTI handlers
//------------------------------------------------------------------------------
void amf_app::handle_itti_message(
itti_paging_n1n2_message_transfer& itti_msg) {
itti_paging* paging_msg = new itti_paging(TASK_AMF_APP, TASK_AMF_N2);
paging_msg->ran_ue_ngap_id = itti_msg.ran_ue_ngap_id;
paging_msg->amf_ue_ngap_id = itti_msg.amf_ue_ngap_id;
paging_msg->plmn = itti_msg.plmn;
std::shared_ptr<itti_paging> i =
std::shared_ptr<itti_paging>(paging_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_app().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void amf_app::handle_itti_message(
itti_n1n2_message_transfer_request& itti_msg) {
......
......@@ -55,6 +55,7 @@ class amf_app {
// itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg);
void handle_itti_message(itti_paging_n1n2_message_transfer& itti_msg);
// context management
std::map<long, std::shared_ptr<ue_context>> amf_ue_ngap_id2ue_ctx;
mutable std::shared_mutex m_amf_ue_ngap_id2ue_ctx;
......
......@@ -41,6 +41,7 @@
#include "PduSessionResourceReleaseCommand.hpp"
#include "PduSessionResourceSetupRequest.hpp"
#include "UEContextReleaseCommand.hpp"
#include "Paging.hpp"
#include "amf_app.hpp"
#include "amf_config.hpp"
#include "amf_n1.hpp"
......@@ -177,6 +178,11 @@ void amf_n2_task(void* args_p) {
itti_uplinkranstatsutransfer* m =
dynamic_cast<itti_uplinkranstatsutransfer*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
} break;
case PAGING: {
Logger::amf_n2().info("Received Paging message,handling");
itti_paging* m = dynamic_cast<itti_paging*>(msg);
amf_n2_inst->handle_itti_message(ref(*m));
} break;
default:
Logger::amf_n2().info("No handler for msg type %d", msg->msg_type);
......@@ -201,6 +207,55 @@ amf_n2::~amf_n2() {}
// NGAP Messages Handlers
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_paging& itti_msg) {
Logger::amf_n2().debug("Handling Paging message...");
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id)) {
Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id (%d)", itti_msg.ran_ue_ngap_id);
return;
}
unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != itti_msg.amf_ue_ngap_id) {
Logger::amf_n2().error(
"The requested UE (amf_ue_ngap_id: 0x%x) is not valid, existed UE "
"which's amf_ue_ngap_id (0x%x)",
itti_msg.amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
}
if (unc.get()->ng_ue_state != NGAP_UE_CONNECTED) {
Logger::amf_n2().error(
"Received NGAP UPLINK_NAS_TRANSPORT while UE in state != "
"NGAP_UE_CONNECTED");
// return;
}
PagingMsg Paging_test;
Paging_test.setMessageType();
Logger::amf_n2().warn(" unc.get()->s_setid (%d)",unc.get()->s_setid);
Logger::amf_n2().warn(" unc.get()->s_pointer (%d)",unc.get()->s_pointer);
Logger::amf_n2().warn(" unc.get()->s_tmsi (%d)",unc.get()->s_tmsi);
Paging_test.setUEPagingIdentity(unc.get()->s_setid, unc.get()->s_pointer, unc.get()->s_tmsi);
Logger::amf_n2().warn("==========================================");
std :: vector < struct Tai_s > list;
Tai_t tai_test;
tai_test.mcc = itti_msg.plmn.mcc;
tai_test.mnc = itti_msg.plmn.mnc;
tai_test.tac = itti_msg.plmn.tac;
list.push_back(tai_test);
Paging_test.setTAIListForPaging(list);
uint8_t buffer[BUFFER_SIZE_512];
int encoded_size = Paging_test.encode2buffer(buffer, BUFFER_SIZE_512);
bstring b = blk2bstr(buffer, encoded_size);
amf_n2_inst->sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, unc.get()->sctp_stream_send, &b);
}
void amf_n2::handle_itti_message(itti_new_sctp_association& new_assoc) {
} // handled in class ngap_app
......@@ -435,6 +490,8 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
itti_msg->is_5g_s_tmsi_present = true;
itti_msg->_5g_s_tmsi = _5g_s_tmsi;
Logger::amf_n2().debug("5g_s_tmsi present");
init_ue_msg.initUeMsg->get5GS_TMSI(unc.get()->s_setid, unc.get()->s_pointer, unc.get()->s_tmsi);
}
uint8_t* nas_buf;
......
......@@ -60,6 +60,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_handover_request_Ack& itti_msg);
void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer& itti_msg);
void handle_itti_message(itti_paging& itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn(
......
......@@ -56,6 +56,10 @@ class ue_ngap_context {
bool ueContextRequest;
uint32_t s_tmsi_5g;
std :: string s_setid = "1";
std :: string s_pointer = "1";
std :: string s_tmsi = "1";
// state management, ue status over the air
ng_ue_state_t ng_ue_state;
};
......
......@@ -82,6 +82,8 @@ typedef enum {
HANDOVER_NOTIFY,
UPLINKRANSTATUSTRANSFER,
PDU_SESS_RES_SET_RESP,
PAGING_N1N2_MESSAGE_TRANSFER,
PAGING,
TIME_OUT,
HEALTH_PING,
TERMINATE,
......
#ifndef _AMF_APP_ITTI_H_
#define _AMF_APP_ITTI_H_
#include "amf.hpp"
#include "itti_msg.hpp"
#include "NgapIEsStruct.hpp"
#include <string>
......@@ -59,4 +60,17 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
// other parameters
};
class itti_paging_n1n2_message_transfer : public itti_msg_amf_app {
public:
itti_paging_n1n2_message_transfer(const task_id_t origin, const task_id_t destination)
: itti_msg_amf_app(PAGING_N1N2_MESSAGE_TRANSFER, origin, destination) {}
itti_paging_n1n2_message_transfer(const itti_paging_n1n2_message_transfer& i) : itti_msg_amf_app(i) {}
public:
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
plmn_t plmn;
};
#endif
#ifndef _ITTI_MSG_N2_H_
#define _ITTI_MSG_N2_H_
#include "amf.hpp"
#include "itti_msg.hpp"
#include "NGSetupRequest.hpp"
#include "InitialUEMessage.hpp"
......@@ -171,6 +172,19 @@ class itti_handover_required : public itti_msg_n2 {
HandoverRequiredMsg* handvoerRequ;
};
class itti_paging : public itti_msg_n2 {
public:
itti_paging(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(PAGING, origin, destination) {}
itti_paging(const itti_paging& i) : itti_msg_n2(i) {}
public:
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
plmn_t plmn;
};
class itti_handover_request_Ack : public itti_msg_n2 {
public:
itti_handover_request_Ack(const task_id_t origin, const task_id_t destination)
......
......@@ -53,3 +53,36 @@ bool FiveGSTmsi::decodefrompdu(Ngap_FiveG_S_TMSI_t pdu) {
void FiveGSTmsi::getValue(std::string& tmsi) {
tmsi = _5g_s_tmsi;
}
//------------------------------------------------------------------------------
void FiveGSTmsi::getValue(std::string& setid,std::string& pointer,std::string& tmsi)
{
amfSetid.getAMFSetID(setid);
amfPointer.getAMFPointer(pointer);
tmsi = _5g_s_tmsi;
}
//------------------------------------------------------------------------------
void FiveGSTmsi::setValue(std::string& setid,std::string& pointer,std::string& tmsi)
{
amfSetid.setAMFSetID(setid);
amfPointer.setAMFPointer(pointer);
_5g_s_tmsi = tmsi;
}
//------------------------------------------------------------------------------
bool FiveGSTmsi::encode2pdu(Ngap_FiveG_S_TMSI_t* pdu)
{
amfSetid.encode2bitstring(pdu->aMFSetID);
amfPointer.encode2bitstring(pdu->aMFPointer);
uint32_t tmsi = (uint32_t)std::stol(_5g_s_tmsi);
uint8_t *buf = (uint8_t *)malloc(sizeof(uint32_t));
*(uint32_t *)buf = htonl(tmsi);
pdu->fiveG_TMSI.buf = buf;
pdu->fiveG_TMSI.size = sizeof(uint32_t);
return true;
}
......@@ -46,6 +46,9 @@ class FiveGSTmsi {
public:
bool decodefrompdu(Ngap_FiveG_S_TMSI_t pdu);
void getValue(std::string& value);
void getValue(std::string& setid,std::string& pointer,std::string& tmsi);
void setValue(std::string& setid,std::string& pointer,std::string& tmsi);
bool encode2pdu(Ngap_FiveG_S_TMSI_t* pdu);
private:
std::string _5g_s_tmsi;
......
#include "TAIListforPaging.hpp"
extern "C" {
#include "Ngap_TAIListForPagingItem.h"
}
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
TAIListForPaging::TAIListForPaging() {
tai = NULL;
numOftai = 0;
}
//------------------------------------------------------------------------------
TAIListForPaging::~TAIListForPaging() {
if(!tai) delete [] tai;
}
//------------------------------------------------------------------------------
bool TAIListForPaging::encode2TAIListForPaging(Ngap_TAIListForPaging_t* pdu) {
cout << "TAIListForPaging::numberOfItem "<< numOftai << endl;
for (int i = 0; i < numOftai; i++) {
Ngap_TAIListForPagingItem_t* ta =
(Ngap_TAIListForPagingItem_t*) calloc(1, sizeof(Ngap_TAIListForPagingItem_t));
if (!tai[i].encode2TAI(&ta->tAI)) return false;
if (ASN_SEQUENCE_ADD(&pdu->list, ta) != 0) return false;
}
return true;
}
//------------------------------------------------------------------------------
bool TAIListForPaging::decodefromTAIListForPaging(Ngap_TAIListForPaging_t *pdu) {
numOftai = pdu->list.count;
tai = new TAI[numOftai];
for (int i = 0; i < numOftai; i++) {
if (!tai[i].decodefromTAI(&pdu->list.array[i]->tAI))
return false;
}
return true;
}
//------------------------------------------------------------------------------
void TAIListForPaging::setTAIListForPaging(TAI* m_tai, int numOfItem) {
tai = m_tai;
numOftai = numOfItem;
}
//------------------------------------------------------------------------------
void TAIListForPaging::getTAIListForPaging(TAI*& m_tai, int& numOfItem) {
m_tai = tai;
numOfItem = numOftai;
}
} // namespace ngap
#ifndef _TAILISTFORPAGING_H_
#define _TAILISTFORPAGING_H_
#include "TAI.hpp"
extern "C" {
#include "Ngap_TAIListForPaging.h"
}
namespace ngap {
class TAIListForPaging {
public:
TAIListForPaging();
virtual ~TAIListForPaging();
void setTAIListForPaging(TAI* m_tai, int numOfItem);
void getTAIListForPaging(TAI*& m_tai, int& numOfItem);
bool encode2TAIListForPaging(Ngap_TAIListForPaging_t* pdu);
bool decodefromTAIListForPaging(Ngap_TAIListForPaging_t *pdu);
private:
TAI *tai;
int numOftai;
};
} // namespace ngap
#endif
#include "UEPagingIdentity.hpp"
namespace ngap {
UEPagingIdentity::UEPagingIdentity(){}
UEPagingIdentity::~UEPagingIdentity(){}
void UEPagingIdentity::setUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi)
{
fiveGSTmsi.setValue(setid, pointer, tmsi);
}
void UEPagingIdentity::getUEPagingIdentity(std::string& _5g_s_tmsi)
{
fiveGSTmsi.getValue(_5g_s_tmsi);
}
void UEPagingIdentity::getUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi)
{
fiveGSTmsi.getValue(setid, pointer, tmsi);
}
bool UEPagingIdentity::encode2pdu(Ngap_UEPagingIdentity_t* pdu)
{
pdu->present = Ngap_UEPagingIdentity_PR_fiveG_S_TMSI;
Ngap_FiveG_S_TMSI_t* ie = (Ngap_FiveG_S_TMSI_t *)calloc(1,sizeof(Ngap_FiveG_S_TMSI_t));
pdu->choice.fiveG_S_TMSI = ie;
if(!fiveGSTmsi.encode2pdu(pdu->choice.fiveG_S_TMSI)) return false;
return true;
}
bool UEPagingIdentity::decodefrompdu(Ngap_UEPagingIdentity_t pdu)
{
if(pdu.present != Ngap_UEPagingIdentity_PR_fiveG_S_TMSI) return false;
if(!fiveGSTmsi.decodefrompdu(*pdu.choice.fiveG_S_TMSI)) return false;
return true;
}
}
#ifndef _UEPAGINGIDENTITY_H_
#define _UEPAGINGIDENTITY_H_
#include "FiveGSTmsi.hpp"
extern "C" {
#include "Ngap_UEPagingIdentity.h"
}
namespace ngap {
class UEPagingIdentity {
public:
UEPagingIdentity();
virtual ~UEPagingIdentity();
void setUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi);
void getUEPagingIdentity(std::string& _5g_s_tmsi);
void getUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi);
bool encode2pdu(Ngap_UEPagingIdentity_t* pdu);
bool decodefrompdu(Ngap_UEPagingIdentity_t pdu);
private:
FiveGSTmsi fiveGSTmsi;
};
} // namespace ngap
#endif
......@@ -431,4 +431,13 @@ bool InitialUEMessageMsg::get5GS_TMSI(string& _5g_s_tmsi) {
return false;
}
bool InitialUEMessageMsg::get5GS_TMSI(std :: string & setid,std :: string & pointer,std :: string & tmsi) {
if (fivegSTmsi) {
fivegSTmsi->getValue(setid, pointer, tmsi);
return true;
} else
return false;
}
} // namespace ngap
......@@ -68,6 +68,7 @@ class InitialUEMessageMsg {
int getRRCEstablishmentCause();
int getUeContextRequest();
bool get5GS_TMSI(std::string& _5g_s_tmsi);
bool get5GS_TMSI(std :: string & setid,std :: string & pointer,std :: string & tmsi);
private:
Ngap_NGAP_PDU_t* initialUEMessagePdu;
......
#include "Paging.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PagingMsg::PagingMsg() {
pagingPdu = NULL;
pagingIEs = NULL;
uePagingIdentity = NULL;
taIListForPaging = NULL;
}
//------------------------------------------------------------------------------
PagingMsg::~PagingMsg() {
if(!uePagingIdentity) delete uePagingIdentity;
if(!taIListForPaging) delete taIListForPaging;
}
//------------------------------------------------------------------------------
void PagingMsg::setMessageType() {
if (!pagingPdu)
pagingPdu = (Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType PagingTypeIE;
PagingTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_Paging);
PagingTypeIE.setTypeOfMessage(
Ngap_NGAP_PDU_PR_initiatingMessage);
PagingTypeIE.setCriticality(Ngap_Criticality_ignore);
PagingTypeIE.setValuePresent(
Ngap_InitiatingMessage__value_PR_Paging);
if (PagingTypeIE.getProcedureCode() ==
Ngap_ProcedureCode_id_Paging &&
PagingTypeIE.getTypeOfMessage() ==
Ngap_NGAP_PDU_PR_initiatingMessage &&
PagingTypeIE.getCriticality() ==
Ngap_Criticality_ignore) {
PagingTypeIE.encode2pdu(pagingPdu);
pagingIEs = &(pagingPdu->choice.initiatingMessage->value
.choice.Paging);
} else {
cout << "[warning] This information doesn't refer to Paging "
"Message!!!"
<< endl;
}
}
//------------------------------------------------------------------------------
int PagingMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, pagingPdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, pagingPdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
//------------------------------------------------------------------------------
bool PagingMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
pagingPdu = ngap_msg_pdu;
if (pagingPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
if (pagingPdu->choice.initiatingMessage &&
pagingPdu->choice.initiatingMessage->procedureCode ==
Ngap_ProcedureCode_id_Paging &&
pagingPdu->choice.initiatingMessage->criticality ==
Ngap_Criticality_ignore &&
pagingPdu->choice.initiatingMessage->value.present ==
Ngap_InitiatingMessage__value_PR_Paging) {
pagingIEs = &pagingPdu->choice.initiatingMessage
->value.choice.Paging;
} else {
cout << "Check Paging message error!!!" << endl;
return false;
}
} else {
cout << "MessageType error!!!" << endl;
return false;
}
for (int i = 0; i < pagingIEs->protocolIEs.list.count; i++) {
switch (pagingIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_UEPagingIdentity: {
if (pagingIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
pagingIEs->protocolIEs.list.array[i]->value.present ==
Ngap_PagingIEs__value_PR_UEPagingIdentity) {
uePagingIdentity = new UEPagingIdentity();
if (!uePagingIdentity->decodefrompdu(
pagingIEs->protocolIEs.list.array[i]
->value.choice.UEPagingIdentity)) {
cout << "Decoded NGAP UEPagingIdentity IE error" << endl;
return false;
}
cout << "[Paging] Received UEPagingIdentity " << endl;
} else {
cout << "Decoded NGAP UEPagingIdentity IE error" << endl;
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_TAIListForPaging: {
if (pagingIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
pagingIEs->protocolIEs.list.array[i]->value.present ==
Ngap_PagingIEs__value_PR_TAIListForPaging) {
taIListForPaging = new TAIListForPaging();
if (!taIListForPaging->decodefromTAIListForPaging(
&pagingIEs->protocolIEs.list.array[i]
->value.choice.TAIListForPaging)) {
cout << "Decoded NGAP TAIListForPaging IE error" << endl;
return false;
}
cout << "[Paging] Received TAIListForPaging " << endl;
} else {
cout << "Decoded NGAP TAIListForPaging IE error" << endl;
return false;
}
} break;
default: {
cout << "not decoded IE:"
<< pagingIEs->protocolIEs.list.array[i]->id << endl;
return true;
}
}
}
return true;
}
//------------------------------------------------------------------------------
void PagingMsg::setUEPagingIdentity(std::string SetId, std::string Pointer, std::string tmsi)
{
if (!uePagingIdentity) uePagingIdentity = new UEPagingIdentity();
uePagingIdentity->setUEPagingIdentity(SetId,Pointer,tmsi);
Ngap_PagingIEs_t* ie = (Ngap_PagingIEs_t*) calloc(
1, sizeof(Ngap_PagingIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_UEPagingIdentity;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_PagingIEs__value_PR_UEPagingIdentity;
int ret = uePagingIdentity->encode2pdu(&ie->value.choice.UEPagingIdentity);
if (!ret) {
cout << "encode UEPagingIdentity IE error" << endl;
return;
}
ret = ASN_SEQUENCE_ADD(&pagingIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UEPagingIdentity IE error" << endl;
}
void PagingMsg::getUEPagingIdentity(std::string& _5g_s_tmsi)
{
uePagingIdentity->getUEPagingIdentity(_5g_s_tmsi);
}
void PagingMsg::getUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi)
{
uePagingIdentity->getUEPagingIdentity(setid, pointer, tmsi);
}
//------------------------------------------------------------------------------
void PagingMsg::setTAIListForPaging(const std::vector<struct Tai_s> list)
{
if (list.size() == 0) {
cout << "[Warning] Setup failed, vector is empty!!!" << endl;
return;
}
if (!taIListForPaging) taIListForPaging = new TAIListForPaging();
TAI tai [list.size()];
PlmnId plmnid[list.size()];
TAC tac[list.size()];
for (int i = 0; i < list.size(); i++)
{
plmnid[i].setMccMnc(list[i].mcc, list[i].mnc);
tac[i].setTac(list[i].tac);
tai[i].setTAI(&plmnid[i], &tac[i]);
}
taIListForPaging->setTAIListForPaging(tai, list.size());
Ngap_PagingIEs_t* ie = (Ngap_PagingIEs_t*) calloc(
1, sizeof(Ngap_PagingIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_TAIListForPaging;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_PagingIEs__value_PR_TAIListForPaging;
int ret = taIListForPaging->encode2TAIListForPaging(&ie->value.choice.TAIListForPaging);
if (!ret) {
cout << "encode TAIListForPaging IE error" << endl;
return;
}
ret = ASN_SEQUENCE_ADD(&pagingIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode TAIListForPaging IE error" << endl;
}
void PagingMsg::getTAIListForPaging(std::vector<struct Tai_s>& list)
{
if (!taIListForPaging) return ;
TAI* tailist;
int sizeoftailist;
taIListForPaging->getTAIListForPaging(tailist, sizeoftailist);
for (int i = 0; i < sizeoftailist; i++)
{
Tai_t tai;
PlmnId* plmnid;
TAC* tac;
tailist[i].getTAI(plmnid, tac);
plmnid->getMcc(tai.mcc);
plmnid->getMnc(tai.mnc);
tai.tac = tac->getTac();
list.push_back(tai);
}
}
}
\ No newline at end of file
#ifndef _PAGING_H_
#define _PAGING_H_
#include "NgapIEsStruct.hpp"
#include "MessageType.hpp"
#include "UEPagingIdentity.hpp"
#include "TAIListforPaging.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_Paging.h"
}
namespace ngap {
class PagingMsg {
public:
PagingMsg();
virtual ~PagingMsg();
void setMessageType();
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void setUEPagingIdentity(std::string SetId, std::string Pointer, std::string tmsi);
void getUEPagingIdentity(std::string& _5g_s_tmsi);
void getUEPagingIdentity(std::string& setid,std::string& pointer,std::string& tmsi);
void setTAIListForPaging(const std::vector<struct Tai_s> list);
void getTAIListForPaging(std::vector<struct Tai_s>& list);
private:
Ngap_NGAP_PDU_t* pagingPdu;
Ngap_Paging_t* pagingIEs;
UEPagingIdentity* uePagingIdentity;
TAIListForPaging* taIListForPaging;
};
} // namespace ngap
#endif
\ No newline at end of file
......@@ -92,6 +92,11 @@ void N1N2MessageCollectionDocumentApi::n1_n2_message_transfer_handler(
try {
nlohmann::json::parse(parts[0].body.c_str())
.get_to(n1N2MessageTransferReqData);
if(n1N2MessageTransferReqData.ppiIsSet())
{
this->n1_n2_message_transfer(ueContextId, n1N2MessageTransferReqData, response);
}
else{
if (!is_ngap)
this->n1_n2_message_transfer(
ueContextId, n1N2MessageTransferReqData, parts[1].body, response);
......@@ -99,6 +104,7 @@ void N1N2MessageCollectionDocumentApi::n1_n2_message_transfer_handler(
this->n1_n2_message_transfer(
ueContextId, n1N2MessageTransferReqData, parts[1].body, parts[2].body,
response);
}
} catch (nlohmann::detail::exception& e) {
// send a 400 error
Logger::amf_server().error(
......
......@@ -13,15 +13,25 @@
#include "N1N2MessageCollectionDocumentApiImpl.h"
#include "itti.hpp"
//#include "itti_msg_n2.hpp"
#include "amf_n11.hpp"
//#include "amf_n2.hpp"
//#include "Paging.hpp"
#include "pdu_session_context.hpp"
using namespace amf_application;
using namespace ngap;
extern void msg_str_2_msg_hex(std::string msg, bstring& b);
extern void convert_string_2_hex(std::string& input, std::string& output);
extern itti_mw* itti_inst;
extern amf_n11* amf_n11_inst;
//extern amf_n2* amf_n2_inst;
extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len);
......@@ -45,8 +55,38 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Pistache::Http::Code::Ok,
"N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer API has "
"not been implemented yet!");
std::string supi = ueContextId;
Logger::amf_server().debug(
"Key for PDU Session context: SUPI (%s)", supi.c_str());
std::shared_ptr<pdu_session_context> psc;
if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
psc = amf_n11_inst->supi_to_pdu_ctx(supi);
itti_paging_n1n2_message_transfer* itti_msg =
new itti_paging_n1n2_message_transfer(AMF_SERVER, TASK_AMF_APP);
itti_msg->ran_ue_ngap_id = psc.get()->ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = psc.get()->amf_ue_ngap_id;
itti_msg->plmn = psc.get()->plmn;
std::shared_ptr<itti_paging_n1n2_message_transfer> i =
std::shared_ptr<itti_paging_n1n2_message_transfer>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_server().error(
"Could not send ITTI message %s to task TASK_AMF_APP",
i->get_msg_name());
}
} else {
Logger::amf_server().error(
"Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
}
}
void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
const std::string& ueContextId,
const N1N2MessageTransferReqData& n1N2MessageTransferReqData,
......
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