Commit b67b2482 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

code cleanup

parent 96352e3c
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/*! \file amf_n1.cpp /*! \file amf_n1.cpp
\brief \brief
\author Keliang DU, BUPT \author Keliang DU, BUPT, Tien-Thinh NGUYEN, EURECOM
\date 2020 \date 2020
\email: contact@openairinterface.org \email: contact@openairinterface.org
*/ */
...@@ -86,7 +86,7 @@ void amf_n1_task(void*) { ...@@ -86,7 +86,7 @@ void amf_n1_task(void*) {
} }
break; break;
default: default:
Logger::amf_n1().error("no handler for msg type %d", msg->msg_type); Logger::amf_n1().error("No handler for msg type %d", msg->msg_type);
} }
} while (true); } while (true);
} }
...@@ -98,7 +98,7 @@ amf_n1::amf_n1() { ...@@ -98,7 +98,7 @@ amf_n1::amf_n1() {
throw std::runtime_error("Cannot create task TASK_AMF_N1"); throw std::runtime_error("Cannot create task TASK_AMF_N1");
} }
Logger::amf_n1().startup("Started"); Logger::amf_n1().startup("Started");
Logger::amf_n1().debug("construct amf_n1 successfully"); Logger::amf_n1().debug("Construct amf_n1 successfully");
} }
amf_n1::~amf_n1() { amf_n1::~amf_n1() {
} }
...@@ -236,12 +236,12 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) { ...@@ -236,12 +236,12 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
break; break;
} }
if (nas_data_ind.is_nas_signalling_estab_req) { if (nas_data_ind.is_nas_signalling_estab_req) {
Logger::amf_n1().debug("Received NAS signalling establishment request ..."); Logger::amf_n1().debug("Received NAS signalling establishment request...");
//dump_nas_message((uint8_t*)bdata(decoded_plain_msg), blength(decoded_plain_msg)); //dump_nas_message((uint8_t*)bdata(decoded_plain_msg), blength(decoded_plain_msg));
print_buffer("amf_n1", "Decoded plain NAS Message buffer", (uint8_t*) bdata(decoded_plain_msg), blength(decoded_plain_msg)); print_buffer("amf_n1", "Decoded plain NAS Message buffer", (uint8_t*) bdata(decoded_plain_msg), blength(decoded_plain_msg));
nas_signalling_establishment_request_handle(type, nc, nas_data_ind.ran_ue_ngap_id, nas_data_ind.amf_ue_ngap_id, decoded_plain_msg, snn, ulCount); nas_signalling_establishment_request_handle(type, nc, nas_data_ind.ran_ue_ngap_id, nas_data_ind.amf_ue_ngap_id, decoded_plain_msg, snn, ulCount);
} else { } else {
Logger::amf_n1().debug("Received uplink NAS message ..."); Logger::amf_n1().debug("Received uplink NAS message...");
print_buffer("amf_n1", "Decoded NAS message buffer", (uint8_t*) bdata(decoded_plain_msg), blength(decoded_plain_msg)); print_buffer("amf_n1", "Decoded NAS message buffer", (uint8_t*) bdata(decoded_plain_msg), blength(decoded_plain_msg));
uplink_nas_msg_handle(nas_data_ind.ran_ue_ngap_id, nas_data_ind.amf_ue_ngap_id, decoded_plain_msg, plmn); uplink_nas_msg_handle(nas_data_ind.ran_ue_ngap_id, nas_data_ind.amf_ue_ngap_id, decoded_plain_msg, plmn);
} }
...@@ -317,7 +317,7 @@ void amf_n1::uplink_nas_msg_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, ...@@ -317,7 +317,7 @@ void amf_n1::uplink_nas_msg_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id,
} }
break; break;
case UL_NAS_TRANSPORT: { case UL_NAS_TRANSPORT: {
Logger::amf_n1().debug("Received ul NAS transport message, handling..."); Logger::amf_n1().debug("Received UL NAS transport message, handling...");
ul_nas_transport_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg); ul_nas_transport_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} }
break; break;
...@@ -381,9 +381,7 @@ void amf_n1::uplink_nas_msg_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, ...@@ -381,9 +381,7 @@ void amf_n1::uplink_nas_msg_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id,
default: { default: {
//TODO: //TODO:
} }
} }
} }
// nas message decode // nas message decode
...@@ -434,7 +432,7 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context> ...@@ -434,7 +432,7 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context>
uint8_t *kamf = nc.get()->kamf[secu->vector_pointer]; uint8_t *kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n1().debug("Uplink count(%d)", secu->ul_count.seq_num); Logger::amf_n1().debug("Uplink count (%d)", secu->ul_count.seq_num);
print_buffer("amf_n1", "kamf", kamf, 32); print_buffer("amf_n1", "kamf", kamf, 32);
Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb); Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32); bstring kgnb_bs = blk2bstr(kgnb, 32);
...@@ -565,7 +563,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont ...@@ -565,7 +563,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
uint8_t reg_type; uint8_t reg_type;
bool is_follow_on_req_pending; bool is_follow_on_req_pending;
if (!regReq->get5GSRegistrationType(is_follow_on_req_pending, reg_type)) { if (!regReq->get5GSRegistrationType(is_follow_on_req_pending, reg_type)) {
Logger::amf_n1().error("Missing Mandatory IE 5GS Registration type ..."); Logger::amf_n1().error("Missing Mandatory IE 5GS Registration type...");
response_registration_reject_msg(_5GMM_CAUSE_INVALID_MANDATORY_INFO, ran_ue_ngap_id, amf_ue_ngap_id); response_registration_reject_msg(_5GMM_CAUSE_INVALID_MANDATORY_INFO, ran_ue_ngap_id, amf_ue_ngap_id);
return; return;
} }
...@@ -575,7 +573,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont ...@@ -575,7 +573,7 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
//Check ngKSI (Mandatory IE) //Check ngKSI (Mandatory IE)
uint8_t ngKSI = regReq->getngKSI(); uint8_t ngKSI = regReq->getngKSI();
if (ngKSI == -1) { if (ngKSI == -1) {
Logger::amf_n1().error("Missing Mandatory IE ngKSI ..."); Logger::amf_n1().error("Missing Mandatory IE ngKSI...");
response_registration_reject_msg(_5GMM_CAUSE_INVALID_MANDATORY_INFO, ran_ue_ngap_id, amf_ue_ngap_id); response_registration_reject_msg(_5GMM_CAUSE_INVALID_MANDATORY_INFO, ran_ue_ngap_id, amf_ue_ngap_id);
return; return;
} }
...@@ -704,9 +702,9 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value, uint32_t ran_ ...@@ -704,9 +702,9 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value, uint32_t ran_
uint8_t buffer[1024] = { 0 }; uint8_t buffer[1024] = { 0 };
int encoded_size = registrationRej->encode2buffer(buffer, 1024); int encoded_size = registrationRej->encode2buffer(buffer, 1024);
//dump_nas_message(buffer, encoded_size); //dump_nas_message(buffer, encoded_size);
print_buffer("amf_n1", "Registration-Reject Message Buffer", buffer, encoded_size); print_buffer("amf_n1", "Registration-Reject message buffer", buffer, encoded_size);
if (!encoded_size) { if (!encoded_size) {
Logger::nas_mm().error("Encode RegistrationRej message error"); Logger::nas_mm().error("Encode Registration-Reject message error");
return; return;
} else { } else {
delete registrationRej; delete registrationRej;
...@@ -744,7 +742,7 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) { ...@@ -744,7 +742,7 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) {
ngksi_t ngksi = 0; ngksi_t ngksi = 0;
if (nc.get()->security_ctx && nc.get()->ngKsi != NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE) { if (nc.get()->security_ctx && nc.get()->ngKsi != NAS_KEY_SET_IDENTIFIER_NOT_AVAILABLE) {
ngksi = (nc.get()->ngKsi + 1) % (NGKSI_MAX_VALUE + 1); ngksi = (nc.get()->ngKsi + 1) % (NGKSI_MAX_VALUE + 1);
Logger::amf_n1().debug("New ngKsi(%d)", ngksi); Logger::amf_n1().debug("New ngKsi (%d)", ngksi);
// ... how to handle? // ... how to handle?
} }
nc.get()->ngKsi = ngksi; nc.get()->ngKsi = ngksi;
...@@ -1083,7 +1081,7 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue ...@@ -1083,7 +1081,7 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue
bool isAuthOk = true; bool isAuthOk = true;
//Get response RES* //Get response RES*
if (!auth->getAuthenticationResponseParameter(resStar)) { if (!auth->getAuthenticationResponseParameter(resStar)) {
Logger::amf_n1().warn("Cannot receive AuthenticationResponseParameter(RES*)"); Logger::amf_n1().warn("Cannot receive AuthenticationResponseParameter (RES*)");
} else { } else {
//Get stored XRES* //Get stored XRES*
int secu_index = nc.get()->security_ctx->vector_pointer; int secu_index = nc.get()->security_ctx->vector_pointer;
...@@ -1150,10 +1148,10 @@ void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id, long amf_ue_ ...@@ -1150,10 +1148,10 @@ void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id, long amf_ue_
Logger::amf_n1().debug("Initial new authentication procedure"); Logger::amf_n1().debug("Initial new authentication procedure");
bstring auts; bstring auts;
if (!authFail->getAutsInAuthFailPara(auts)) { if (!authFail->getAutsInAuthFailPara(auts)) {
Logger::amf_n1().warn("IE Authentication Failure Parameter(auts) not received"); Logger::amf_n1().warn("IE Authentication Failure Parameter (auts) not received");
} }
nc.get()->auts = auts; nc.get()->auts = auts;
printf("received auts: 0x "); printf("Received auts: 0x ");
for (int i = 0; i < blength(auts); i++) for (int i = 0; i < blength(auts); i++)
printf("%x ", ((uint8_t*) bdata(auts))[i]); printf("%x ", ((uint8_t*) bdata(auts))[i]);
printf("\n"); printf("\n");
...@@ -1720,12 +1718,12 @@ void amf_n1::run_mobility_registration_update_procedure(std::shared_ptr<nas_cont ...@@ -1720,12 +1718,12 @@ void amf_n1::run_mobility_registration_update_procedure(std::shared_ptr<nas_cont
encode_nas_message_protected(secu, false, INTEGRITY_PROTECTED_AND_CIPHERED, NAS_MESSAGE_DOWNLINK, buffer, encoded_size, protectedNas); encode_nas_message_protected(secu, false, INTEGRITY_PROTECTED_AND_CIPHERED, NAS_MESSAGE_DOWNLINK, buffer, encoded_size, protectedNas);
string supi = "imsi-" + nc.get()->imsi; string supi = "imsi-" + nc.get()->imsi;
Logger::amf_n1().debug("Key for pdu session context: supi(%s)", supi.c_str()); Logger::amf_n1().debug("Key for pdu session context SUPI (%s)", supi.c_str());
std::shared_ptr<pdu_session_context> psc; std::shared_ptr<pdu_session_context> psc;
if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) { if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
psc = amf_n11_inst->supi_to_pdu_ctx(supi); psc = amf_n11_inst->supi_to_pdu_ctx(supi);
} else { } else {
Logger::amf_n1().error("Cannot get pdu_session_context with supi(%s)", supi.c_str()); Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
} }
uint8_t *kamf = nc.get()->kamf[secu->vector_pointer]; uint8_t *kamf = nc.get()->kamf[secu->vector_pointer];
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/*! \file amf_n11.cpp /*! \file amf_n11.cpp
\brief \brief
\author Keliang DU, BUPT \author Keliang DU, BUPT, Tien-Thinh NGUYEN, EURECOM
\date 2020 \date 2020
\email: contact@openairinterface.org \email: contact@openairinterface.org
*/ */
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "itti_msg_amf_app.hpp" #include "itti_msg_amf_app.hpp"
#include "amf_config.hpp" #include "amf_config.hpp"
#include "nas_context.hpp" #include "nas_context.hpp"
#include "amf.hpp"
#include <curl/curl.h> #include <curl/curl.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
...@@ -105,13 +106,13 @@ void amf_n11_task(void*) { ...@@ -105,13 +106,13 @@ void amf_n11_task(void*) {
} }
break; break;
case NSMF_PDU_SESS_UPDATE_SMCTX: { case NSMF_PDU_SESS_UPDATE_SMCTX: {
Logger::amf_n1().info("Receive NSMF_PDU_SESS_UPDATE_SMCTX, handling ..."); Logger::amf_n1().info("Receive Nsmf_PDUSessionUpdateSMContext, handling ...");
itti_nsmf_pdusession_update_sm_context *m = dynamic_cast<itti_nsmf_pdusession_update_sm_context*>(msg); itti_nsmf_pdusession_update_sm_context *m = dynamic_cast<itti_nsmf_pdusession_update_sm_context*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} }
break; break;
case PDU_SESS_RES_SET_RESP: { case PDU_SESS_RES_SET_RESP: {
Logger::amf_n1().info("Receive PDU_SESS_RES_SET_RESP, handling ..."); Logger::amf_n1().info("Receive PDU Session Resource Setup Response, handling ...");
itti_pdu_session_resource_setup_response *m = dynamic_cast<itti_pdu_session_resource_setup_response*>(msg); itti_pdu_session_resource_setup_response *m = dynamic_cast<itti_pdu_session_resource_setup_response*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} }
...@@ -142,27 +143,26 @@ void amf_n11::handle_itti_message(itti_pdu_session_resource_setup_response &itti ...@@ -142,27 +143,26 @@ void amf_n11::handle_itti_message(itti_pdu_session_resource_setup_response &itti
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n11::handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg) { void amf_n11::handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg) {
std::string supi = pduid2supi.at(itti_msg.pdu_session_id); std::string supi = pduid2supi.at(itti_msg.pdu_session_id);
Logger::amf_n11().debug("Try to find supi(%s) from pdusession_id(%d)", supi.c_str(), itti_msg.pdu_session_id); Logger::amf_n11().debug("Found SUPI %s with PDU Session ID %d", supi.c_str(), itti_msg.pdu_session_id);
std::shared_ptr<pdu_session_context> psc; std::shared_ptr<pdu_session_context> psc;
if (is_supi_to_pdu_ctx(supi)) { if (is_supi_to_pdu_ctx(supi)) {
psc = supi_to_pdu_ctx(supi); psc = supi_to_pdu_ctx(supi);
} else { } else {
Logger::amf_n11().error("Trying to find psu_session_context with supi(%s), Failed", supi.c_str()); Logger::amf_n11().error("Could not find psu_session_context with SUPI %s, Failed", supi.c_str());
return; return;
} }
std::string smf_addr; std::string smf_addr;
if (!psc.get()->smf_available) { if (!psc.get()->smf_available) {
if (!smf_selection_from_configuration(smf_addr)) { if (!smf_selection_from_configuration(smf_addr)) {
Logger::amf_n11().error("No candidate SMF is available"); Logger::amf_n11().error("No SMF candidate is available");
return; return;
} }
} else { } else {
smf_selection_from_context(smf_addr); smf_selection_from_context(smf_addr);
} }
//TODO:Remove hardcoded value (1 - SCID)
//std::string remote_uri = smf_addr + "/nsmf-pdusession/v1/sm-contexts/" + "imsi-208950000000031-1" + "/modify"; //scid //std::string remote_uri = smf_addr + "/nsmf-pdusession/v1/sm-contexts/" + "imsi-208950000000031-1" + "/modify"; //scid
std::string remote_uri = smf_addr + psc.get()->smf_context_location + "/modify"; //scid std::string remote_uri = smf_addr + psc.get()->smf_context_location + "/modify"; //scid
nlohmann::json pdu_session_update_request; nlohmann::json pdu_session_update_request;
pdu_session_update_request["n2SmInfoType"] = "PDU_RES_SETUP_RSP"; pdu_session_update_request["n2SmInfoType"] = "PDU_RES_SETUP_RSP";
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2SmMsg"; pdu_session_update_request["n2SmInfo"]["contentId"] = "n2SmMsg";
...@@ -225,9 +225,11 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer &smf) { ...@@ -225,9 +225,11 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer &smf) {
} }
break; break;
case EXISTING_PDU_SESSION: { case EXISTING_PDU_SESSION: {
//TODO:
} }
break; break;
case PDU_SESSION_MODIFICATION_REQUEST: { case PDU_SESSION_MODIFICATION_REQUEST: {
//TODO:
} }
break; break;
} }
...@@ -368,7 +370,6 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std: ...@@ -368,7 +370,6 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
} }
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
//res = curl_easy_perform(curl);
// Response information. // Response information.
long httpCode(0); long httpCode(0);
...@@ -392,7 +393,10 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std: ...@@ -392,7 +393,10 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
Logger::amf_n11().debug("Get response with httpcode (%d)", httpCode); Logger::amf_n11().debug("Get response with httpcode (%d)", httpCode);
if (httpCode == 0) { if (httpCode == 0) {
Logger::amf_n11().error("Cannot get response when calling %s", remoteUri.c_str()); Logger::amf_n11().error("Cannot get response when calling %s", remoteUri.c_str());
//TODO: free curl before returning //free curl before returning
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_mime_free(mime);
return; return;
} }
if (httpCode != 200 && httpCode != 201 && httpCode != 204) { if (httpCode != 200 && httpCode != 201 && httpCode != 204) {
...@@ -402,15 +406,14 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std: ...@@ -402,15 +406,14 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
Logger::amf_n11().error("Could not get the cause from the response"); Logger::amf_n11().error("Could not get the cause from the response");
} }
} else { } else {
//TODO: store location of created context //store location of created context
std::string header_response = *httpHeaderData.get(); std::string header_response = *httpHeaderData.get();
std::string CRLF = "\r\n"; std::string CRLF = "\r\n";
std::size_t location_pos = header_response.find("Location"); std::size_t location_pos = header_response.find("Location");
std::size_t crlf_pos = header_response.find(CRLF, location_pos); std::size_t crlf_pos = header_response.find(CRLF, location_pos);
std::string location = header_response.substr(location_pos + 10, crlf_pos - (location_pos + 10)); std::string location = header_response.substr(location_pos + 10, crlf_pos - (location_pos + 10));
Logger::amf_n11().info("Location: %s", location.c_str()); Logger::amf_n11().info("Location of the SMF context created: %s", location.c_str());
psc.get()->smf_context_location = location; psc.get()->smf_context_location = location;
} }
nlohmann::json response_data; nlohmann::json response_data;
bstring n1sm_hex; bstring n1sm_hex;
...@@ -422,7 +425,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std: ...@@ -422,7 +425,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
print_buffer("amf_n11", "Get response with n1sm:", (uint8_t*) bdata(n1sm_hex), blength(n1sm_hex)); print_buffer("amf_n11", "Get response with n1sm:", (uint8_t*) bdata(n1sm_hex), blength(n1sm_hex));
std::string cause = response_data["error"]["cause"]; std::string cause = response_data["error"]["cause"];
Logger::amf_n11().error("Call Network Function services failure "); Logger::amf_n11().error("Call Network Function services failure");
Logger::amf_n11().info("Cause value: %s", cause.c_str()); Logger::amf_n11().info("Cause value: %s", cause.c_str());
if (!cause.compare("DNN_DENIED")) if (!cause.compare("DNN_DENIED"))
handle_post_sm_context_response_error(httpCode, cause, n1sm_hex, supi, pdu_session_id); handle_post_sm_context_response_error(httpCode, cause, n1sm_hex, supi, pdu_session_id);
......
...@@ -276,7 +276,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) { ...@@ -276,7 +276,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) { void amf_n2::handle_itti_message(itti_initial_ue_message &init_ue_msg) {
//create ngap-ue context and store in gNB context to store UE information in gNB, for example, here RAN UE NGAP ID and location information and RRC Establishment Cause //create ngap-ue context and store in gNB context to store UE information in gNB, for example, here RAN UE NGAP ID and location information and RRC Establishment Cause
//send NAS-PDU to NAS layer //send NAS-PDU to NAS layer
/*get INITIAL_UE_MESSAGE IEs*/ //Get INITIAL_UE_MESSAGE IEs
//check the gNB context on which this UE is attached with assoc_id //check the gNB context on which this UE is attached with assoc_id
itti_nas_signalling_establishment_request *itti_msg = new itti_nas_signalling_establishment_request(TASK_AMF_N2, TASK_AMF_APP); itti_nas_signalling_establishment_request *itti_msg = new itti_nas_signalling_establishment_request(TASK_AMF_N2, TASK_AMF_APP);
...@@ -384,16 +384,16 @@ void amf_n2::handle_itti_message(itti_ul_nas_transport &ul_nas_transport) { ...@@ -384,16 +384,16 @@ void amf_n2::handle_itti_message(itti_ul_nas_transport &ul_nas_transport) {
gc = assoc_id_2_gnb_context(ul_nas_transport.assoc_id); gc = assoc_id_2_gnb_context(ul_nas_transport.assoc_id);
std::shared_ptr<ue_ngap_context> unc; std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().error("UE with ran_ue_ngap_id(0x%x) is not attached to gnb with assoc_id(%d)", ran_ue_ngap_id, ul_nas_transport.assoc_id); Logger::amf_n2().error("UE with ran_ue_ngap_id(0x%x) is not attached to gnb with assoc_id (%d)", ran_ue_ngap_id, ul_nas_transport.assoc_id);
return; return;
} }
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().error("No UE NGAP context with ran_ue_ngap_id(%d)", ran_ue_ngap_id); Logger::amf_n2().error("No UE NGAP context with ran_ue_ngap_id (%d)", ran_ue_ngap_id);
return; return;
} }
unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id); unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) { if (unc.get()->amf_ue_ngap_id != 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)", amf_ue_ngap_id, unc.get()->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)", amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
} }
if (unc.get()->ng_ue_state != NGAP_UE_CONNECTED) { 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"); Logger::amf_n2().error("Received NGAP UPLINK_NAS_TRANSPORT while UE in state != NGAP_UE_CONNECTED");
...@@ -461,13 +461,13 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request &itti_msg) { ...@@ -461,13 +461,13 @@ 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); unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get() == nullptr) { if (unc.get() == nullptr) {
Logger::amf_n2().error("Illegal UE with ran_ue_ngap_id(0x%x)", itti_msg.ran_ue_ngap_id); Logger::amf_n2().error("Illegal UE with ran_ue_ngap_id (0x%x)", itti_msg.ran_ue_ngap_id);
return; return;
} }
std::shared_ptr<gnb_context> gc; std::shared_ptr<gnb_context> gc;
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id); gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) { if (gc.get() == nullptr) {
Logger::amf_n2().error("Illegal gNB with assoc id(0x%x)", unc.get()->gnb_assoc_id); Logger::amf_n2().error("Illegal gNB with assoc id (0x%x)", unc.get()->gnb_assoc_id);
return; return;
} }
InitialContextSetupRequestMsg *msg = new InitialContextSetupRequestMsg(); InitialContextSetupRequestMsg *msg = new InitialContextSetupRequestMsg();
...@@ -521,13 +521,13 @@ void amf_n2::handle_itti_message(itti_pdu_session_resource_setup_request &itti_m ...@@ -521,13 +521,13 @@ void amf_n2::handle_itti_message(itti_pdu_session_resource_setup_request &itti_m
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); unc = ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
if (unc.get() == nullptr) { if (unc.get() == nullptr) {
Logger::amf_n2().error("Illegal UE with ran_ue_ngap_id(0x%x)", itti_msg.ran_ue_ngap_id); Logger::amf_n2().error("Illegal UE with ran_ue_ngap_id (0x%x)", itti_msg.ran_ue_ngap_id);
return; return;
} }
std::shared_ptr<gnb_context> gc; std::shared_ptr<gnb_context> gc;
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id); gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) { if (gc.get() == nullptr) {
Logger::amf_n2().error("Illegal gNB with assoc id(0x%x)", unc.get()->gnb_assoc_id); Logger::amf_n2().error("Illegal gNB with assoc id (0x%x)", unc.get()->gnb_assoc_id);
return; return;
} }
PduSessionResourceSetupRequestMsg *psrsr = new PduSessionResourceSetupRequestMsg(); PduSessionResourceSetupRequestMsg *psrsr = new PduSessionResourceSetupRequestMsg();
...@@ -577,7 +577,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_request &itti_msg) { ...@@ -577,7 +577,7 @@ void amf_n2::handle_itti_message(itti_ue_context_release_request &itti_msg) {
void amf_n2::handle_itti_message(itti_ue_radio_capability_indication &itti_msg) { void amf_n2::handle_itti_message(itti_ue_radio_capability_indication &itti_msg) {
std::shared_ptr<gnb_context> gc; std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error("No existed gNB context with assoc_id(%d)", itti_msg.assoc_id); Logger::amf_n2().error("No existed gNB context with assoc_id (%d)", itti_msg.assoc_id);
return; return;
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
......
...@@ -66,6 +66,34 @@ typedef struct s_nssai // section 28.4, TS23.003 ...@@ -66,6 +66,34 @@ typedef struct s_nssai // section 28.4, TS23.003
} snssai_t; } snssai_t;
//SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
HTTP_RESPONSE_CODE_200_OK = 200,
HTTP_RESPONSE_CODE_201_CREATED = 201,
HTTP_RESPONSE_CODE_202_ACCEPTED = 202,
HTTP_RESPONSE_CODE_204_UPDATED = 204,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
HTTP_RESPONSE_CODE_NOT_FOUND = 404,
HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED = 405,
HTTP_RESPONSE_CODE_REQUEST_TIMEOUT = 408,
HTTP_RESPONSE_CODE_406_NOT_ACCEPTED = 406,
HTTP_RESPONSE_CODE_CONFLICT = 409,
HTTP_RESPONSE_CODE_GONE = 410,
HTTP_RESPONSE_CODE_LENGTH_REQUIRED = 411,
HTTP_RESPONSE_CODE_PRECONDITION_FAILED = 412,
HTTP_RESPONSE_CODE_PAYLOAD_TOO_LARGE = 413,
HTTP_RESPONSE_CODE_URI_TOO_LONG = 414,
HTTP_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429,
HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 500,
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
#endif #endif
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <unistd.h> #include <unistd.h>
#include "amf.hpp"
/* /*
* To read content of the response from UDM * To read content of the response from UDM
*/ */
......
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