Commit 3817de0c authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'develop' into 'more-verbosity-in-release'

# Conflicts:
#   src/amf-app/amf_app.cpp
parents 7b333cd4 689fb352
......@@ -36,16 +36,17 @@ try:
result = re.search('(?:\/.+?\/)(.+?)(?:\/.+)', str(line))
if result:
result1 = re.search('^(.*/)([^/]*)$', str(result.group(0)))
subprocess.check_output(f'cp {result1.group(1)}* DS-TEST-RESULTS/', stderr=subprocess.STDOUT, shell=True, universal_newlines=True)
filename = re.search('[^/]*$', str(result1.group(0)))
subprocess.check_output(f'cp -r {result1.group(1)}* DS-TEST-RESULTS/', shell=True, universal_newlines=True)
locexist = True
except IOError:
sys.exit("File not accessible to check DSTester Summary: DS-TEST-RESULTS/dsTester_Summary.txt")
if locexist:
try:
with open(cwd + '/DS-TEST-RESULTS/dcamf.yaml') as f:
data = yaml.load(f)
with open(cwd + f'/DS-TEST-RESULTS/{filename.group(0)}') as f:
data = yaml.full_load(f)
if data["final-result"] == 'fail':
sys.exit('DsTester final result FAILED')
except IOError:
sys.exit("File not accessible to check DSTester result: DS-TEST-RESULTS/dcamf.yaml")
sys.exit(f'File not accessible to check DSTester result: DS-TEST-RESULTS/{filename.group(0)}')
......@@ -238,7 +238,19 @@ bool amf_app::get_pdu_sessions_context(
//------------------------------------------------------------------------------
void amf_app::handle_itti_message(
itti_n1n2_message_transfer_request& itti_msg) {
Logger::amf_app().error("Handle ITTI N1N2 Message Transfer Request");
if (itti_msg.is_ppi_set) { // Paging procedure
std::shared_ptr<itti_paging> i =
std::make_shared<itti_paging>(TASK_AMF_APP, TASK_AMF_N2);
i.get()->amf_ue_ngap_id = amf_n1_inst->supi2amfId.at(itti_msg.supi);
i.get()->ran_ue_ngap_id = amf_n1_inst->supi2ranId.at(itti_msg.supi);
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());
}
} else {
// Encode DL NAS TRANSPORT message(NAS message)
DLNASTransport* dl = new DLNASTransport();
dl->setHeader(PLAIN_5GS_MSG);
......@@ -247,8 +259,8 @@ void amf_app::handle_itti_message(
(uint8_t*) bdata(itti_msg.n1sm), blength(itti_msg.n1sm));
dl->setPDUSessionId(itti_msg.pdu_session_id);
uint8_t nas[1024];
int encoded_size = dl->encode2buffer(nas, 1024);
uint8_t nas[BUFFER_SIZE_1024];
int encoded_size = dl->encode2buffer(nas, BUFFER_SIZE_1024);
print_buffer("amf_app", "n1n2 transfer", nas, encoded_size);
bstring dl_nas = blk2bstr(nas, encoded_size);
......@@ -273,6 +285,7 @@ void amf_app::handle_itti_message(
"Could not send ITTI message %s to task TASK_AMF_N1",
i->get_msg_name());
}
}
}
//------------------------------------------------------------------------------
......
......@@ -412,7 +412,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED";
nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn;
......@@ -582,7 +582,7 @@ void amf_n1::identity_response_handle(
nc.get()->ctx_avaliability_ind = false;
}
nc.get()->ctx_avaliability_ind = true;
nc.get()->nas_status = "CM-CONNECTED";
nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->is_imsi_present = true;
......@@ -847,7 +847,7 @@ void amf_n1::registration_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED";
nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn;
......@@ -925,7 +925,7 @@ void amf_n1::registration_request_handle(
set_amf_ue_ngap_id_2_nas_context(amf_ue_ngap_id, nc);
nc.get()->ctx_avaliability_ind = false;
// change UE connection status CM-IDLE -> CM-CONNECTED
nc.get()->nas_status = "CM-CONNECTED";
nc.get()->nas_status = CM_CONNECTED;
nc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
nc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
nc.get()->serving_network = snn;
......@@ -1052,6 +1052,9 @@ void amf_n1::registration_request_handle(
// Get pdu session status(OPtional IE), associated and active pdu sessions
// available in UE
bstring nas_msg;
bool is_messagecontainer = regReq->getNasMessageContainer(nas_msg);
// Store NAS information into nas_context
// Run different registration procedure
switch (reg_type) {
......@@ -1069,8 +1072,12 @@ void amf_n1::registration_request_handle(
} break;
case PERIODIC_REGISTRATION_UPDATING: {
Logger::amf_n1().error(
"Network does not support periodic registration, reject ...");
Logger::amf_n1().debug("Network handling periodic registration...");
if (is_messagecontainer)
run_periodic_registration_update_procedure(nc, nas_msg);
else
run_periodic_registration_update_procedure(
nc, regReq->getPduSessionStatus());
} break;
case EMERGENCY_REGISTRATION: {
......@@ -2777,6 +2784,178 @@ void amf_n1::run_mobility_registration_update_procedure(
}
}
//------------------------------------------------------------------------------
void amf_n1::run_periodic_registration_update_procedure(
std::shared_ptr<nas_context> nc, uint16_t pdu_session_status) {
// Experimental procedure
// encoding REGISTRATION ACCEPT
std::unique_ptr<RegistrationAccept> regAccept =
std::make_unique<RegistrationAccept>();
regAccept->setHeader(PLAIN_5GS_MSG);
regAccept->set_5GS_Registration_Result(false, false, false, 0x01);
regAccept->set5G_GUTI(
amf_cfg.guami.mcc, amf_cfg.guami.mnc, amf_cfg.guami.regionID,
amf_cfg.guami.AmfSetID, amf_cfg.guami.AmfPointer, 0x264a34c0);
regAccept->setT3512_Value(0x5, 0x1e);
std::vector<p_tai_t> tai_list;
p_tai_t item0 = {};
item0.type = 0x00;
nas_plmn_t plmn = {};
plmn.mcc = amf_cfg.plmn_list[0].mcc;
plmn.mnc = amf_cfg.plmn_list[0].mnc;
item0.plmn_list.push_back(plmn);
item0.tac_list.push_back(amf_cfg.plmn_list[0].tac);
tai_list.push_back(item0);
regAccept->setTaiList(tai_list);
//
// std::vector<struct SNSSAI_s> nssai;
// SNSSAI_t snssai;
// snssai.sst = 0;
// snssai.sd = -1;
// snssai.mHplmnSst = -1;
// snssai.mHplmnSd = -1;
// nssai.push_back(snssai);
// regAccept->setALLOWED_NSSAI(nssai);
if (pdu_session_status == 0x0000) {
regAccept->setPDU_session_status(0x0000);
} else {
regAccept->setPDU_session_status(pdu_session_status);
Logger::amf_n1().debug(
"Setting PDU Session Status 0x%02x", htonl(pdu_session_status));
// serApt->setPDU_session_status(0x2000);
}
regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
uint8_t buffer[BUFFER_SIZE_1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, BUFFER_SIZE_1024);
print_buffer(
"amf_n1", "Registration-Accept Message Buffer", buffer, encoded_size);
if (!encoded_size) {
Logger::nas_mm().error("Encode Registration-Accept message error");
return;
}
nas_secu_ctx* secu = nc.get()->security_ctx;
// protect nas message
bstring protectedNas;
encode_nas_message_protected(
secu, false, INTEGRITY_PROTECTED_AND_CIPHERED, NAS_MESSAGE_DOWNLINK,
buffer, encoded_size, protectedNas);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug("Key for pdu session context SUPI (%s)", supi.c_str());
itti_dl_nas_transport* itti_msg =
new itti_dl_nas_transport(TASK_AMF_N1, TASK_AMF_N2);
itti_msg->ran_ue_ngap_id = nc.get()->ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = nc.get()->amf_ue_ngap_id;
itti_msg->nas = protectedNas;
std::shared_ptr<itti_dl_nas_transport> i =
std::shared_ptr<itti_dl_nas_transport>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void amf_n1::run_periodic_registration_update_procedure(
std::shared_ptr<nas_context> nc, bstring& nas_msg) {
// Experimental procedure
// decoding REGISTRATION request
std::unique_ptr<RegistrationRequest> regReq =
std::make_unique<RegistrationRequest>();
regReq->decodefrombuffer(
nullptr, (uint8_t*) bdata(nas_msg), blength(nas_msg));
bdestroy(nas_msg); // free buffer
// encoding REGISTRATION ACCEPT
std::unique_ptr<RegistrationAccept> regAccept =
std::make_unique<RegistrationAccept>();
regAccept->setHeader(PLAIN_5GS_MSG);
regAccept->set_5GS_Registration_Result(false, false, false, 0x01);
regAccept->set5G_GUTI(
amf_cfg.guami.mcc, amf_cfg.guami.mnc, amf_cfg.guami.regionID,
amf_cfg.guami.AmfSetID, amf_cfg.guami.AmfPointer, 0x264a34c0);
regAccept->setT3512_Value(0x5, 0x1e);
std::vector<p_tai_t> tai_list;
p_tai_t item0 = {};
item0.type = 0x00;
nas_plmn_t plmn = {};
plmn.mcc = amf_cfg.plmn_list[0].mcc;
plmn.mnc = amf_cfg.plmn_list[0].mnc;
item0.plmn_list.push_back(plmn);
item0.tac_list.push_back(amf_cfg.plmn_list[0].tac);
tai_list.push_back(item0);
regAccept->setTaiList(tai_list);
//
// std::vector<struct SNSSAI_s> nssai;
// SNSSAI_t snssai;
// snssai.sst = 0;
// snssai.sd = -1;
// snssai.mHplmnSst = -1;
// snssai.mHplmnSd = -1;
// nssai.push_back(snssai);
// regAccept->setALLOWED_NSSAI(nssai);
uint16_t pdu_session_status = 0xffff;
pdu_session_status = regReq->getPduSessionStatus();
if (pdu_session_status == 0x0000) {
regAccept->setPDU_session_status(0x0000);
} else {
regAccept->setPDU_session_status(pdu_session_status);
Logger::amf_n1().debug(
"setting pdu session status 0x%02x", htonl(pdu_session_status));
// serApt->setPDU_session_status(0x2000);
}
regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
uint8_t buffer[BUFFER_SIZE_1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, BUFFER_SIZE_1024);
print_buffer(
"amf_n1", "Registration-Accept Message Buffer", buffer, encoded_size);
if (!encoded_size) {
Logger::nas_mm().error("Encode Registration-Accept message error");
return;
}
nas_secu_ctx* secu = nc.get()->security_ctx;
// protect nas message
bstring protectedNas;
encode_nas_message_protected(
secu, false, INTEGRITY_PROTECTED_AND_CIPHERED, NAS_MESSAGE_DOWNLINK,
buffer, encoded_size, protectedNas);
string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().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);
} else {
Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)",
supi.c_str());
}
*/
itti_dl_nas_transport* itti_msg =
new itti_dl_nas_transport(TASK_AMF_N1, TASK_AMF_N2);
itti_msg->ran_ue_ngap_id = nc.get()->ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = nc.get()->amf_ue_ngap_id;
itti_msg->nas = protectedNas;
std::shared_ptr<itti_dl_nas_transport> i =
std::shared_ptr<itti_dl_nas_transport>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
i->get_msg_name());
}
}
//------------------------------------------------------------------------------
void amf_n1::set_5gmm_state(
std::shared_ptr<nas_context> nc, _5gmm_state_t state) {
......
......@@ -105,6 +105,12 @@ class amf_n1 {
void run_mobility_registration_update_procedure(
std::shared_ptr<nas_context> nc, uint16_t uplink_data_status,
uint16_t pdu_session_status);
void run_periodic_registration_update_procedure(
std::shared_ptr<nas_context> nc, uint16_t);
void run_periodic_registration_update_procedure(
std::shared_ptr<nas_context> nc, bstring& nas_msg);
// authentication
bool auth_vectors_generator(std::shared_ptr<nas_context>& nc);
......
......@@ -494,6 +494,7 @@ void amf_n11::handle_post_sm_context_response_error(
itti_msg->is_n2sm_set = false;
itti_msg->supi = supi;
itti_msg->pdu_session_id = pdu_session_id;
itti_msg->is_ppi_set = false;
std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i);
......@@ -586,8 +587,8 @@ void amf_n11::curl_http_client(
nlohmann::json response_data = {};
bstring n1sm_hex, n2sm_hex;
Logger::amf_n11().debug("Get response with HTTP code (%d)", httpCode);
Logger::amf_n11().debug("response body %s", response.c_str());
Logger::amf_n11().info("Get response with HTTP code (%d)", httpCode);
Logger::amf_n11().info("Response body %s", response.c_str());
if (static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_0) {
......@@ -610,6 +611,8 @@ void amf_n11::curl_http_client(
json_data_response = response;
}
Logger::amf_n11().info("Json part %s", json_data_response.c_str());
if ((static_cast<http_response_codes_e>(httpCode) !=
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) &&
(static_cast<http_response_codes_e>(httpCode) !=
......@@ -716,6 +719,8 @@ void amf_n11::curl_http_client(
itti_msg->is_n1sm_set = false;
itti_msg->is_n2sm_set = false;
itti_msg->is_ppi_set = false;
if (n1sm.size() > 0) {
msg_str_2_msg_hex(n1sm, n1sm_hex);
print_buffer(
......@@ -1106,10 +1111,6 @@ void amf_n11::curl_http_client(
return;
}
else {
response = *httpData.get();
}
if (!is_response_ok) {
try {
response_data = nlohmann::json::parse(json_data_response);
......
......@@ -42,6 +42,7 @@
#include "PduSessionResourceSetupRequest.hpp"
#include "UEContextReleaseCommand.hpp"
#include "HandoverPreparationFailure.hpp"
#include "Paging.hpp"
#include "amf_app.hpp"
#include "amf_config.hpp"
#include "amf_n1.hpp"
......@@ -198,6 +199,11 @@ void amf_n2_task(void* args_p) {
dynamic_cast<itti_uplink_ran_status_transfer*>(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);
}
......@@ -217,12 +223,56 @@ amf_n2::amf_n2(const std::string& address, const uint16_t port_num)
//------------------------------------------------------------------------------
amf_n2::~amf_n2() {}
// NGAP Messages Handlers
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_new_sctp_association& new_assoc) {
} // handled in class ngap_app
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);
}
// TODO: check UE reachability status
PagingMsg paging_msg = {};
paging_msg.setMessageType();
Logger::amf_n2().debug(
" UE NGAP Context, s_setid (%d), s_pointer (%d), s_tmsi (%d)",
unc.get()->s_setid, unc.get()->s_pointer, unc.get()->s_tmsi);
paging_msg.setUEPagingIdentity(
unc.get()->s_setid, unc.get()->s_pointer, unc.get()->s_tmsi);
std ::vector<struct Tai_s> list;
Tai_t tai = {};
tai.mcc = unc.get()->tai.mcc;
tai.mnc = unc.get()->tai.mnc;
tai.tac = unc.get()->tai.tac;
list.push_back(tai);
paging_msg.setTAIListForPaging(list);
uint8_t buffer[BUFFER_SIZE_512];
int encoded_size = paging_msg.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) {}
// NG_SETUP_REQUEST Handler
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
Logger::amf_n2().debug(
......@@ -491,6 +541,8 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
return;
}
if (!init_ue_msg.initUeMsg) return;
// UE NGAP Context
uint32_t ran_ue_ngap_id;
if ((ran_ue_ngap_id = init_ue_msg.initUeMsg->getRanUENgapID()) == -1) {
......@@ -527,6 +579,7 @@ void amf_n2::handle_itti_message(itti_initial_ue_message& init_ue_msg) {
if (init_ue_msg.initUeMsg->getUserLocationInfoNR(cgi, tai)) {
itti_msg->cgi = cgi;
itti_msg->tai = tai;
unc.get()->tai = tai;
} else {
Logger::amf_n2().error("Missing Mandatory IE UserLocationInfoNR");
return;
......@@ -554,6 +607,9 @@ 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;
......@@ -687,7 +743,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
//------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
std::shared_ptr<ue_ngap_context> unc;
std::shared_ptr<ue_ngap_context> unc = {};
unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get() == nullptr) {
Logger::amf_n2().error(
......@@ -695,7 +751,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
return;
}
unc.get()->ncc = 1;
std::shared_ptr<gnb_context> gc;
std::shared_ptr<gnb_context> gc = {};
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) {
Logger::amf_n2().error(
......@@ -807,8 +863,8 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
}
}
uint8_t buffer[20000]; // TODO: remove hardcoded value
int encoded_size = msg->encode2buffer(buffer, 10000);
uint8_t buffer[BUFFER_SIZE_2048];
int encoded_size = msg->encode2buffer(buffer, BUFFER_SIZE_2048);
bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(
gc.get()->sctp_assoc_id, unc.get()->sctp_stream_send, &b);
......
......@@ -65,6 +65,7 @@ class amf_n2 : public ngap::ngap_app {
void send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id);
void handle_itti_message(itti_paging& itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn(
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_29_518_SEEN
#define FILE_3GPP_29_518_SEEN
#include <vector>
enum n1_n2_message_transfer_cause_e {
ATTEMPTING_TO_REACH_UE = 1,
N1_N2_TRANSFER_INITIATED = 2,
WAITING_FOR_ASYNCHRONOUS_TRANSFER = 3,
UE_NOT_RESPONDING = 4,
N1_MSG_NOT_TRANSFERRED = 5,
UE_NOT_REACHABLE_FOR_SESSION = 6
};
static const std::vector<std::string> n1_n2_message_transfer_cause_e2str = {
"UNKNOWN ERROR",
"ATTEMPTING_TO_REACH_UE",
"N1_N2_TRANSFER_INITIATED",
"WAITING_FOR_ASYNCHRONOUS_TRANSFER",
"UE_NOT_RESPONDING",
"N1_MSG_NOT_TRANSFERRED",
"UE_NOT_REACHABLE_FOR_SESSION"};
#endif
......@@ -29,6 +29,8 @@
#define __AMF_HPP
#include "3gpp_23.003.h"
#include "3gpp_29.518.h"
/*
typedef struct {
std::string mcc;
......
......@@ -37,7 +37,6 @@ include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
add_library (CONTEXTS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/gNB_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nas_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pdu_session_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ue_context.cpp
......
......@@ -45,10 +45,15 @@ extern "C" {
using namespace sctp;
using namespace ngap;
enum amf_ng_gnb_state_s { NGAP_INIT, NGAP_RESETING, NGAP_READY, NGAP_SHUTDOWN };
typedef enum {
NGAP_INIT,
NGAP_RESETING,
NGAP_READY,
NGAP_SHUTDOWN
} amf_ng_gnb_state_t;
class gnb_context {
public:
enum amf_ng_gnb_state_s ng_state;
amf_ng_gnb_state_t ng_state;
std::string gnb_name;
long globalRanNodeId;
......
......@@ -56,6 +56,11 @@ static const std::vector<std::string> _5gmm_state_e2str = {
"_5GMM_COMMON_PROCEDURE_INITIATED",
"_5GMM_STATE_MAX"};
typedef enum { CM_IDLE = 0, CM_CONNECTED } cm_state_t;
static const std::vector<std::string> cm_state_e2str = {"CM_IDLE",
"CM_CONNECTED"};
class nas_context {
public:
nas_context();
......@@ -64,7 +69,7 @@ class nas_context {
bool is_stacs_available;
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
std::string nas_status;
cm_state_t nas_status;
_5gmm_state_t _5gmm_state;
// parameters from Registration request
......
......@@ -59,6 +59,12 @@ class ue_ngap_context {
bool ueContextRequest;
uint32_t s_tmsi_5g;
std ::string s_setid;
std ::string s_pointer;
std ::string s_tmsi;
Tai_t tai;
// state management, ue status over the air
ng_ue_state_t ng_ue_state;
uint8_t ncc; // Next Hop Chaining Counter
......
......@@ -91,6 +91,7 @@ typedef enum {
HANDOVER_NOTIFY,
UPLINK_RAN_STATUS_TRANSFER,
PDU_SESSION_RESOURCE_SETUP_RESPONSE,
PAGING,
TIME_OUT,
HEALTH_PING,
TERMINATE,
......
......@@ -66,7 +66,11 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
public:
itti_n1n2_message_transfer_request(
const task_id_t origin, const task_id_t destination)
: itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination) {}
: itti_msg_amf_app(N1N2_MESSAGE_TRANSFER_REQ, origin, destination) {
is_n2sm_set = false;
is_n1sm_set = false;
is_ppi_set = false;
}
itti_n1n2_message_transfer_request(
const itti_n1n2_message_transfer_request& i)
: itti_msg_amf_app(i) {}
......@@ -78,6 +82,8 @@ class itti_n1n2_message_transfer_request : public itti_msg_amf_app {
bool is_n1sm_set;
uint8_t pdu_session_id;
std::string n2sm_info_type;
bool is_ppi_set;
uint8_t ppi;
// other parameters
};
......
......@@ -34,6 +34,7 @@ class itti_msg_n1 : public itti_msg {
itti_msg_n1(const itti_msg_n1& i) : itti_msg(i) {
is_nas_signalling_estab_req = i.is_nas_signalling_estab_req;
ran_ue_ngap_id = i.ran_ue_ngap_id;
amf_ue_ngap_id = i.amf_ue_ngap_id;
}
public:
......
......@@ -94,7 +94,6 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
is_n2sm_set = i.is_n2sm_set;
n2sm_info_type = i.n2sm_info_type;
promise_id = i.promise_id;
;
}
public:
......@@ -114,8 +113,10 @@ class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESSION_RELEASE_SM_CTX, origin, destination) {}
itti_nsmf_pdusession_release_sm_context(
const itti_nsmf_pdusession_update_sm_context& i)
: itti_msg_n11(i) {}
const itti_nsmf_pdusession_release_sm_context& i)
: itti_msg_n11(i) {
supi = i.supi;
}
public:
std::string supi;
......
......@@ -61,7 +61,9 @@ class itti_new_sctp_association : public itti_msg_n2 {
class itti_ng_setup_request : public itti_msg_n2 {
public:
itti_ng_setup_request(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(NG_SETUP_REQ, origin, destination) {}
: itti_msg_n2(NG_SETUP_REQ, origin, destination) {
ngSetupReq = nullptr;
}
itti_ng_setup_request(const itti_ng_setup_request& i) : itti_msg_n2(i) {}
public:
......@@ -71,7 +73,9 @@ class itti_ng_setup_request : public itti_msg_n2 {
class itti_ng_reset : public itti_msg_n2 {
public:
itti_ng_reset(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(NG_RESET, origin, destination) {}
: itti_msg_n2(NG_RESET, origin, destination) {
ngReset = nullptr;
}
itti_ng_reset(const itti_ng_reset& i) : itti_msg_n2(i) {}
public:
......@@ -88,7 +92,9 @@ class itti_ng_shutdown : public itti_msg_n2 {
class itti_initial_ue_message : public itti_msg_n2 {
public:
itti_initial_ue_message(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(INITIAL_UE_MSG, origin, destination) {}
: itti_msg_n2(INITIAL_UE_MSG, origin, destination) {
initUeMsg = nullptr;
}
itti_initial_ue_message(const itti_initial_ue_message& i) : itti_msg_n2(i) {}
InitialUEMessageMsg* initUeMsg;
......@@ -97,7 +103,9 @@ class itti_initial_ue_message : public itti_msg_n2 {
class itti_ul_nas_transport : public itti_msg_n2 {
public:
itti_ul_nas_transport(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(ITTI_UL_NAS_TRANSPORT, origin, destination) {}
: itti_msg_n2(ITTI_UL_NAS_TRANSPORT, origin, destination) {
ulNas = nullptr;
}
itti_ul_nas_transport(const itti_ul_nas_transport& i) : itti_msg_n2(i) {}
UplinkNASTransportMsg* ulNas;
......@@ -172,7 +180,9 @@ class itti_ue_context_release_request : public itti_msg_n2 {
public:
itti_ue_context_release_request(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UE_CONTEXT_RELEASE_REQUEST, origin, destination) {}
: itti_msg_n2(UE_CONTEXT_RELEASE_REQUEST, origin, destination) {
ueCtxRel = nullptr;
}
itti_ue_context_release_request(const itti_ue_context_release_request& i)
: itti_msg_n2(i) {}
UEContextReleaseRequestMsg* ueCtxRel;
......@@ -183,7 +193,7 @@ class itti_ue_context_release_command : public itti_msg_n2 {
itti_ue_context_release_command(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UE_CONTEXT_RELEASE_COMMAND, origin, destination) {}
itti_ue_context_release_command(const itti_dl_nas_transport& i)
itti_ue_context_release_command(const itti_ue_context_release_command& i)
: itti_msg_n2(i) {}
public:
......@@ -196,7 +206,9 @@ class itti_ue_context_release_complete : public itti_msg_n2 {
public:
itti_ue_context_release_complete(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UE_CONTEXT_RELEASE_COMPLETE, origin, destination) {}
: itti_msg_n2(UE_CONTEXT_RELEASE_COMPLETE, origin, destination) {
ueCtxRelCmpl = nullptr;
}
itti_ue_context_release_complete(const itti_ue_context_release_complete& i)
: itti_msg_n2(i) {}
UEContextReleaseCompleteMsg* ueCtxRelCmpl;
......@@ -206,7 +218,9 @@ class itti_ue_radio_capability_indication : public itti_msg_n2 {
public:
itti_ue_radio_capability_indication(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UE_RADIO_CAP_IND, origin, destination) {}
: itti_msg_n2(UE_RADIO_CAP_IND, origin, destination) {
ueRadioCap = nullptr;
}
itti_ue_radio_capability_indication(
const itti_ue_radio_capability_indication& i)
: itti_msg_n2(i) {}
......@@ -216,15 +230,30 @@ class itti_ue_radio_capability_indication : public itti_msg_n2 {
class itti_handover_required : public itti_msg_n2 {
public:
itti_handover_required(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {}
: itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {
handoverReq = nullptr;
}
itti_handover_required(const itti_handover_required& i) : itti_msg_n2(i) {}
HandoverRequiredMsg* handoverReq;
};
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;
};
class itti_handover_request_Ack : public itti_msg_n2 {
public:
itti_handover_request_Ack(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(HANDOVER_REQUEST_ACK, origin, destination) {}
: itti_msg_n2(HANDOVER_REQUEST_ACK, origin, destination) {
handoverrequestAck = nullptr;
}
itti_handover_request_Ack(const itti_handover_request_Ack& i)
: itti_msg_n2(i) {}
HandoverRequestAck* handoverrequestAck;
......@@ -233,7 +262,9 @@ class itti_handover_request_Ack : public itti_msg_n2 {
class itti_handover_notify : public itti_msg_n2 {
public:
itti_handover_notify(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(HANDOVER_NOTIFY, origin, destination) {}
: itti_msg_n2(HANDOVER_NOTIFY, origin, destination) {
handovernotify = nullptr;
}
itti_handover_notify(const itti_handover_notify& i) : itti_msg_n2(i) {}
HandoverNotifyMsg* handovernotify;
};
......@@ -242,7 +273,9 @@ class itti_uplink_ran_status_transfer : public itti_msg_n2 {
public:
itti_uplink_ran_status_transfer(
const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UPLINK_RAN_STATUS_TRANSFER, origin, destination) {}
: itti_msg_n2(UPLINK_RAN_STATUS_TRANSFER, origin, destination) {
uplinkrantransfer = nullptr;
}
itti_uplink_ran_status_transfer(const itti_uplink_ran_status_transfer& i)
: itti_msg_n2(i) {}
UplinkRANStatusTransfer* uplinkrantransfer;
......
......@@ -243,7 +243,6 @@ asn_dec_rval_t NativeEnumerated_decode_aper(
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
// printf("test0515 Decoding %s as NativeEnumerated\n", td->name);
if (ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
......
......@@ -321,7 +321,6 @@ asn_dec_rval_t NativeInteger_decode_aper(
(void) opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
// printf("test0515 Decoding NativeInteger %s (APER)\n", td->name);
if (!native) {
native = (long*) (*sptr = CALLOC(1, sizeof(*native)));
......
......@@ -1033,8 +1033,6 @@ asn_dec_rval_t CHOICE_decode_aper(
if (value < 0) ASN__DECODE_STARVED;
ASN_DEBUG(
"CHOICE %s got index %d in range %d", td->name, value, ct->range_bits);
// printf("test0515 CHOICE %s got index %d in range %d\n", td->name, value,
// ct->range_bits);
if (value > ct->upper_bound) ASN__DECODE_FAILED;
} else {
if (specs->ext_start == -1) ASN__DECODE_FAILED;
......@@ -1059,7 +1057,6 @@ asn_dec_rval_t CHOICE_decode_aper(
memb_ptr2 = &memb_ptr;
}
ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
// printf("test0515 Discovered CHOICE %s encodes %s\n", td->name, elm->name);
if (ct && ct->range_bits >= 0) {
rv = elm->type->op->aper_decoder(
......@@ -1074,8 +1071,6 @@ asn_dec_rval_t CHOICE_decode_aper(
if (rv.code != RC_OK) {
ASN_DEBUG(
"Failed to decode %s in %s (CHOICE) %d", elm->name, td->name, rv.code);
// printf("test0515 Failed to decode %s in %s (CHOICE) %d\n", elm->name,
// td->name, rv.code);
}
return rv;
}
......
......@@ -1493,7 +1493,6 @@ asn_dec_rval_t SEQUENCE_decode_aper(
}
ASN_DEBUG("Decoding %s as SEQUENCE (APER)", td->name);
// printf("test0515 Decoding %s as SEQUENCE (APER)\n", td->name);
/* Handle extensions */
if (specs->first_extension < 0) {
......@@ -1566,9 +1565,6 @@ asn_dec_rval_t SEQUENCE_decode_aper(
ASN_DEBUG(
"Member %s->%s is optional, p=%d (%d->%d)", td->name, elm->name,
present, (int) opmd.nboff, (int) opmd.nbits);
// printf("test0515 Member %s->%s is optional, p=%d (%d->%d)\n",
// td->name, elm->name, present,
// (int)opmd.nboff, (int)opmd.nbits);
if (present == 0) {
/* This element is not present */
if (elm->default_value_set) {
......@@ -1587,7 +1583,6 @@ asn_dec_rval_t SEQUENCE_decode_aper(
/* Fetch the member from the stream */
ASN_DEBUG("Decoding member \"%s\" in %s", elm->name, td->name);
// printf("test0515 Decoding member \"%s\" in %s\n", elm->name, td->name);
if (elm->flags & ATF_OPEN_TYPE) {
rv = OPEN_TYPE_aper_get(opt_codec_ctx, td, st, elm, pd);
......
......@@ -406,7 +406,6 @@ static asn_dec_rval_t aper_open_type_get_simple(
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
// printf("test0515 Getting open type %s...\n", td->name);
do {
chunk_bytes = aper_get_length(pd, -1, -1, &repeat);
......@@ -433,8 +432,6 @@ static asn_dec_rval_t aper_open_type_get_simple(
ASN_DEBUG(
"Getting open type %s encoded in %ld bytes", td->name, (long) bufLen);
// printf("test0515 Getting open type %s encoded in %ld bytes\n", td->name,
//(long)bufLen);
memset(&spd, 0, sizeof(spd));
spd.buffer = buf;
......
......@@ -46,6 +46,7 @@ bool FiveGSTmsi::decodefrompdu(Ngap_FiveG_S_TMSI_t pdu) {
amfSetid.getAMFSetID(setId);
amfPointer.getAMFPointer(pointer);
_5g_s_tmsi = setId + pointer + std::to_string(tmsi);
tmsi_value = std::to_string(tmsi);
return true;
}
......@@ -53,3 +54,33 @@ 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 = tmsi_value;
}
//------------------------------------------------------------------------------
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;
}
......@@ -47,9 +47,13 @@ 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;
std::string tmsi_value;
AMFSetID amfSetid;
AMFPointer amfPointer;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "TAIListforPaging.hpp"
extern "C" {
#include "Ngap_TAIListForPagingItem.h"
}
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
TAIListForPaging::TAIListForPaging() {
tai = nullptr;
numOftai = 0;
}
//------------------------------------------------------------------------------
TAIListForPaging::~TAIListForPaging() {
if (!tai) delete[] tai;
}
//------------------------------------------------------------------------------
bool TAIListForPaging::encode2TAIListForPaging(Ngap_TAIListForPaging_t* pdu) {
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;
if (numOftai < 0) return false;
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
......@@ -19,11 +19,32 @@
* contact@openairinterface.org
*/
/*! \file gNB_context.cpp
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#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
#include "gNB_context.hpp"
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#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;
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#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
......@@ -454,4 +454,14 @@ 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
......@@ -67,6 +67,8 @@ 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;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "Paging.hpp"
#include <iostream>
using namespace std;
namespace ngap {
//------------------------------------------------------------------------------
PagingMsg::PagingMsg() {
pagingPdu = nullptr;
pagingIEs = nullptr;
uePagingIdentity = nullptr;
taIListForPaging = nullptr;
}
//------------------------------------------------------------------------------
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) {
if (uePagingIdentity) uePagingIdentity->getUEPagingIdentity(_5g_s_tmsi);
}
//------------------------------------------------------------------------------
void PagingMsg::getUEPagingIdentity(
std::string& setid, std::string& pointer, std::string& tmsi) {
if (uePagingIdentity)
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 = nullptr;
int sizeoftailist = 0;
taIListForPaging->getTAIListForPaging(tailist, sizeoftailist);
for (int i = 0; i < sizeoftailist; i++) {
Tai_t tai = {};
PlmnId* plmnid = nullptr;
TAC* tac = nullptr;
tailist[i].getTAI(plmnid, tac);
plmnid->getMcc(tai.mcc);
plmnid->getMnc(tai.mnc);
tai.tac = tac->getTac();
list.push_back(tai);
}
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#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;
// Paging DRX
// Paging Priority
// UE Radio Capability for Paging
// Paging Origin
// Assistance Data for Paging
};
} // namespace ngap
#endif
......@@ -72,7 +72,11 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Pistache::Http::ResponseWriter& response) {
Logger::amf_server().debug(
"Receive N1N2MessageTransfer Request, handling...");
response.send(Pistache::Http::Code::Ok, "OK");
nlohmann::json response_json = {};
response_json["cause"] =
n1_n2_message_transfer_cause_e2str[N1_N2_TRANSFER_INITIATED];
Pistache::Http::Code code = Pistache::Http::Code::Ok;
std::string supi = ueContextId;
Logger::amf_server().debug(
......@@ -108,6 +112,22 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
itti_msg->is_n2sm_set = true;
itti_msg->pdu_session_id =
(uint8_t) n1N2MessageTransferReqData.getPduSessionId();
// For Paging
if (n1N2MessageTransferReqData.ppiIsSet()) {
itti_msg->is_ppi_set = true;
itti_msg->ppi = n1N2MessageTransferReqData.getPpi();
response_json["cause"] =
n1_n2_message_transfer_cause_e2str[ATTEMPTING_TO_REACH_UE];
code = Pistache::Http::Code::Accepted;
} else {
itti_msg->is_ppi_set = false;
}
// Send response to the NF Service Consumer (e.g., SMF)
response.send(code, response_json.dump().c_str());
// Process N1N2 Message Transfer Request
std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i);
......
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