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

Get AMF IP addr from _sm_context_status_uri

parent f52bfe4c
...@@ -219,8 +219,9 @@ void xgpp_conv::sm_context_create_from_openapi( ...@@ -219,8 +219,9 @@ void xgpp_conv::sm_context_create_from_openapi(
Logger::smf_app().debug( Logger::smf_app().debug(
"PDU Session ID %d", context_data.getPduSessionId()); "PDU Session ID %d", context_data.getPduSessionId());
pcr.set_pdu_session_id(context_data.getPduSessionId()); pcr.set_pdu_session_id(context_data.getPduSessionId());
} else {
Logger::smf_app().warn("No PDU Session ID available");
} }
{ Logger::smf_app().warn("No PDU Session ID available"); }
// AMF ID (ServingNFId/NfInstanceId) // AMF ID (ServingNFId/NfInstanceId)
Logger::smf_app().debug( Logger::smf_app().debug(
......
...@@ -88,6 +88,7 @@ class smf_context_ref { ...@@ -88,6 +88,7 @@ class smf_context_ref {
dnn = ""; dnn = "";
pdu_session_id = 0; pdu_session_id = 0;
amf_status_uri = ""; amf_status_uri = "";
amf_addr = "";
} }
supi_t supi; supi_t supi;
...@@ -95,6 +96,7 @@ class smf_context_ref { ...@@ -95,6 +96,7 @@ class smf_context_ref {
pdu_session_id_t pdu_session_id; pdu_session_id_t pdu_session_id;
snssai_t nssai; snssai_t nssai;
std::string amf_status_uri; std::string amf_status_uri;
std::string amf_addr;
}; };
class smf_app { class smf_app {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "smf_context.hpp" #include "smf_context.hpp"
#include <algorithm> #include <algorithm>
#include <boost/algorithm/string.hpp>
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include "3gpp_29.500.h" #include "3gpp_29.500.h"
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
#include "smf_pfcp_association.hpp" #include "smf_pfcp_association.hpp"
#include "smf_procedure.hpp" #include "smf_procedure.hpp"
#include "3gpp_conversions.hpp" #include "3gpp_conversions.hpp"
#include "string.hpp"
extern "C" { extern "C" {
#include "Ngap_AssociatedQosFlowItem.h" #include "Ngap_AssociatedQosFlowItem.h"
...@@ -570,6 +572,16 @@ void smf_pdu_session::add_qos_rule(const QOSRulesIE& qos_rule) { ...@@ -570,6 +572,16 @@ void smf_pdu_session::add_qos_rule(const QOSRulesIE& qos_rule) {
} }
} }
//------------------------------------------------------------------------------
void smf_pdu_session::set_amf_addr(const std::string& addr) {
amf_addr = addr;
}
//------------------------------------------------------------------------------
void smf_pdu_session::get_amf_addr(std::string& addr) const {
addr = amf_addr;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void session_management_subscription::insert_dnn_configuration( void session_management_subscription::insert_dnn_configuration(
const std::string& dnn, const std::string& dnn,
...@@ -1422,6 +1434,21 @@ void smf_context::handle_pdu_session_create_sm_context_request( ...@@ -1422,6 +1434,21 @@ void smf_context::handle_pdu_session_create_sm_context_request(
} }
scf.get()->amf_status_uri = smreq->req.get_sm_context_status_uri(); scf.get()->amf_status_uri = smreq->req.get_sm_context_status_uri();
// Get and Store AMF Addr
std::vector<std::string> split_result;
boost::split(
split_result, scf.get()->amf_status_uri, boost::is_any_of("/"));
if (split_result.size() >= 3) {
std::string amf_addr_str = split_result[2];
struct in_addr amf_ipv4_addr;
if (inet_aton(util::trim(amf_addr_str).c_str(), &amf_ipv4_addr) == 0) {
Logger::smf_api_server().warn("Bad IPv4 for AMF");
} else {
scf.get()->amf_addr = amf_addr_str;
sp.get()->set_amf_addr(amf_addr_str);
}
}
// Trigger SMF APP to send response to SMF-HTTP-API-SERVER (Step // Trigger SMF APP to send response to SMF-HTTP-API-SERVER (Step
// 5, 4.3.2.2.1 TS 23.502) // 5, 4.3.2.2.1 TS 23.502)
Logger::smf_app().debug( Logger::smf_app().debug(
...@@ -3125,6 +3152,16 @@ void smf_context::update_qos_info( ...@@ -3125,6 +3152,16 @@ void smf_context::update_qos_info(
} }
} }
//------------------------------------------------------------------------------
void smf_context::set_amf_addr(const std::string& addr) {
amf_addr = addr;
}
//------------------------------------------------------------------------------
void smf_context::get_amf_addr(std::string& addr) const {
addr = amf_addr;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool dnn_context::find_pdu_session( bool dnn_context::find_pdu_session(
const uint32_t pdu_session_id, const uint32_t pdu_session_id,
......
...@@ -390,6 +390,20 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { ...@@ -390,6 +390,20 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
*/ */
pdu_session_type_t get_pdu_session_type() const; pdu_session_type_t get_pdu_session_type() const;
/*
* Set AMF Addr of the serving AMF
* @param [const std::string&] addr: AMF Addr in string representation
* @return void
*/
void set_amf_addr(const std::string& addr);
/*
* Get AMF Addr of the serving AMF (in string representation)
* @param [const std::string&] addr: store AMF IP Addr
* @return void
*/
void get_amf_addr(std::string& addr) const;
bool ipv4; // IP Address(es): IPv4 address and/or IPv6 prefix bool ipv4; // IP Address(es): IPv4 address and/or IPv6 prefix
bool ipv6; // IP Address(es): IPv4 address and/or IPv6 prefix bool ipv6; // IP Address(es): IPv4 address and/or IPv6 prefix
struct in_addr struct in_addr
...@@ -412,6 +426,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { ...@@ -412,6 +426,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
uint32_t pdu_session_id; uint32_t pdu_session_id;
std::string amf_id; std::string amf_id;
std::string amf_addr;
pdu_session_status_e pdu_session_status; pdu_session_status_e pdu_session_status;
upCnx_state_e upCnx_state_e
upCnx_state; // N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING) upCnx_state; // N3 tunnel status (ACTIVATED, DEACTIVATED, ACTIVATING)
...@@ -1014,6 +1029,20 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -1014,6 +1029,20 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
smf::pdu_session_update_sm_context_response& res, smf::pdu_session_update_sm_context_response& res,
const nas_message_t& nas_msg); const nas_message_t& nas_msg);
/*
* Set AMF Addr of the serving AMF
* @param [const std::string&] addr: AMF Addr in string representation
* @return void
*/
void set_amf_addr(const std::string& addr);
/*
* Get AMF Addr of the serving AMF (in string representation)
* @param [const std::string&] addr: store AMF IP Addr
* @return void
*/
void get_amf_addr(std::string& addr) const;
private: private:
std::vector<std::shared_ptr<dnn_context>> dnns; std::vector<std::shared_ptr<dnn_context>> dnns;
std::vector<std::shared_ptr<smf_procedure>> pending_procedures; std::vector<std::shared_ptr<smf_procedure>> pending_procedures;
...@@ -1023,6 +1052,9 @@ class smf_context : public std::enable_shared_from_this<smf_context> { ...@@ -1023,6 +1052,9 @@ class smf_context : public std::enable_shared_from_this<smf_context> {
supi_t supi; supi_t supi;
std::string supi_prefix; std::string supi_prefix;
scid_t scid; // SM Context ID scid_t scid; // SM Context ID
//AMF IP addr
string amf_addr;
// Big recursive lock // Big recursive lock
mutable std::recursive_mutex m_context; mutable std::recursive_mutex m_context;
......
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