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

First version for Get Network Slice Selection from NSSF

parent 182acb4d
......@@ -114,6 +114,7 @@ AMF =
SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF = "@EXTERNAL_AUSF@"; # Set to yes if AMF works with an external AUSF
EXTERNAL_UDM = "@EXTERNAL_UDM@"; # Set to yes if AMF works with an external UDM
EXTERNAL_NSSF = "no"; # Set to yes if AMF works with an external NSSF
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN
USE_HTTP2 = "no"; # Set to yes to enable HTTP2 for AMF server
}
......
......@@ -82,6 +82,7 @@ amf_config::amf_config() {
support_features.enable_smf_selection = false;
support_features.enable_external_ausf = false;
support_features.enable_external_udm = false;
support_features.enable_external_nssf = false;
support_features.use_fqdn_dns = false;
support_features.use_http2 = false;
// TODO:
......@@ -270,6 +271,14 @@ int amf_config::load(const std::string& config_file) {
support_features.enable_external_udm = false;
}
support_features_cfg.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_NSSF, opt);
if (boost::iequals(opt, "yes")) {
support_features.enable_external_nssf = true;
} else {
support_features.enable_external_nssf = false;
}
support_features_cfg.lookupValue(
AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS, opt);
if (boost::iequals(opt, "yes")) {
......@@ -706,6 +715,9 @@ void amf_config::display() {
Logger::config().info(
" External UDM ..........: %s",
support_features.enable_external_udm ? "Yes" : "No");
Logger::config().info(
" External NSSF .........: %s",
support_features.enable_external_nssf ? "Yes" : "No");
Logger::config().info(
" Use FQDN ..............: %s",
support_features.use_fqdn_dns ? "Yes" : "No");
......
......@@ -108,6 +108,7 @@
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_SMF_SELECTION "SMF_SELECTION"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_AUSF "EXTERNAL_AUSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_UDM "EXTERNAL_UDM"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_EXTERNAL_NSSF "EXTERNAL_NSSF"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define AMF_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2 "USE_HTTP2"
......@@ -231,6 +232,7 @@ class amf_config {
bool enable_smf_selection;
bool enable_external_ausf;
bool enable_external_udm;
bool enable_external_nssf;
bool use_fqdn_dns;
bool use_http2;
} support_features;
......
......@@ -1583,8 +1583,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
Logger::amf_n1().debug("_5g_aka_confirmation_from_ausf");
std::string remoteUri = nc.get()->Href;
std::string msgBody = {};
std::string response = {};
std::string msgBody = {};
// std::string response = {};
nlohmann::json response = {};
std::string resStar_string = {};
std::map<std::string, std::string>::iterator iter;
......@@ -1619,7 +1620,8 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
free_wrapper((void**) &resStar_s);
try {
ConfirmationDataResponse confirmationdataresponse;
nlohmann::json::parse(response.c_str()).get_to(confirmationdataresponse);
// nlohmann::json::parse(response.c_str()).get_to(confirmationdataresponse);
response.get_to(confirmationdataresponse);
unsigned char* kseaf_hex =
conv::format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32);
......@@ -3707,8 +3709,8 @@ bool amf_n1::reroute_registration_request(std::shared_ptr<nas_context>& nc) {
"Registration with AMF re-allocation, Reroute Registration Request to "
"the target AMF");
nssai_t nssai = {};
if (!get_slice_selection_subscription_data(nc, nssai)) { // Get NSSAI from
// UDM
// Get NSSAI from UDM
if (!get_slice_selection_subscription_data(nc, nssai)) {
return false;
}
// Check that AMF can process the Requested NSSAIs or not
......@@ -3772,7 +3774,7 @@ bool amf_n1::get_slice_selection_subscription_data(
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N2",
"Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name());
}
......@@ -3784,10 +3786,10 @@ bool amf_n1::get_slice_selection_subscription_data(
assert(f.is_ready());
assert(f.has_value());
assert(!f.has_exception());
// Wait for the result from APP and send reply to AMF
// Wait for the result from UDM
nlohmann::json nssai = f.get();
if (!nssai.empty()) {
Logger::ngap().debug("Got NSSAI from UDM", nssai.dump().c_str());
Logger::ngap().debug("Got NSSAI from UDM: %s", nssai.dump().c_str());
} else {
return false;
}
......@@ -3809,17 +3811,80 @@ bool amf_n1::get_slice_selection_subscription_data_from_conf_file(
// TODO:
return true;
}
//------------------------------------------------------------------------------
bool amf_n1::get_network_slice_selection(
const std::string& nf_instance_id,
slice_info_for_registration_t& slice_info,
authorized_network_slice_info_t& authorized_network_slice_info) const {
// TODO: UDM selection (from NRF or configuration file)
if (amf_cfg.support_features.enable_external_udm) {
if (amf_cfg.support_features.enable_external_nssf) {
// Get Authorized Network Slice Info from an external NSSF
std::shared_ptr<itti_n11_network_slice_selection_information> itti_msg =
std::make_shared<itti_n11_network_slice_selection_information>(
TASK_AMF_N1, TASK_AMF_N11);
// Generate a promise and associate this promise to the ITTI message
uint32_t promise_id = amf_app_inst->generate_promise_id();
Logger::amf_n1().debug("Promise ID generated %d", promise_id);
boost::shared_ptr<boost::promise<nlohmann::json>> p =
boost::make_shared<boost::promise<nlohmann::json>>();
boost::shared_future<nlohmann::json> f = p->get_future();
amf_app_inst->add_promise(promise_id, p);
itti_msg->http_version = 1;
itti_msg->nf_instance_id = nf_instance_id;
itti_msg->slice_info = slice_info;
itti_msg->promise_id = promise_id;
int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
itti_msg->get_msg_name());
}
bool result = false;
boost::future_status status;
// wait for timeout or ready
status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
assert(f.is_ready());
assert(f.has_value());
assert(!f.has_exception());
// Wait for the result from NSSF
nlohmann::json network_slice_info = f.get();
if (!network_slice_info.empty()) {
Logger::ngap().debug(
"Got Authorized Network Slice Info from NSSF: %s",
network_slice_info.dump().c_str());
} else {
return false;
}
} else {
return false;
}
} else {
// TODO: Get Authorized Network Slice Info from local configuration file
return get_network_slice_selection_from_conf_file(
nf_instance_id, slice_info, authorized_network_slice_info);
}
return true;
}
//------------------------------------------------------------------------------
bool amf_n1::get_network_slice_selection_from_conf_file(
const std::string& nf_instance_id,
slice_info_for_registration_t& slice_info,
authorized_network_slice_info_t& authorized_network_slice_info) const {
// TODO: Get Authorized Network Slice Info from local configuration file
return true;
}
//------------------------------------------------------------------------------
void amf_n1::send_n1_message_notity(
const std::shared_ptr<nas_context>& nc,
......
......@@ -230,6 +230,11 @@ class amf_n1 {
const std::string& nf_instance_id,
slice_info_for_registration_t& slice_info,
authorized_network_slice_info_t& authorized_network_slice_info) const;
bool get_network_slice_selection_from_conf_file(
const std::string& nf_instance_id,
slice_info_for_registration_t& slice_info,
authorized_network_slice_info_t& authorized_network_slice_info) const;
void send_n1_message_notity(
const std::shared_ptr<nas_context>& nc,
const std::string& target_amf) const;
......
This diff is collapsed.
......@@ -61,6 +61,8 @@ class amf_n11 {
void handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg);
void handle_itti_message(
itti_n11_slice_selection_subscription_data& itti_msg);
void handle_itti_message(
itti_n11_network_slice_selection_information& itti_msg);
void send_pdu_session_update_sm_context_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
......@@ -79,8 +81,8 @@ class amf_n11 {
uint8_t http_version = 1, uint32_t promise_id = 0);
void curl_http_client(
std::string remoteUri, std::string Method, std::string msgBody,
std::string& response, uint8_t http_version = 1);
std::string remote_uri, std::string method, std::string msg_body,
nlohmann::json& response_json, uint8_t http_version = 1);
bool discover_smf_from_nsi_info(
std::string& smf_addr, std::string& smf_api_version,
......
......@@ -28,7 +28,7 @@ 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_204_NO_CONTENT = 204,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
......
......@@ -87,6 +87,7 @@ typedef enum {
N11_UPDATE_NF_INSTANCE_RESPONSE,
N11_DEREGISTER_NF_INSTANCE,
N11_SLICE_SELECTION_SUBSCRIPTION_DATA,
N11_NETWORK_SLICE_SELECTION_INFORMATION,
SBI_EVENT_EXPOSURE_REQUEST,
SBI_NOTIFICATION_DATA,
SBI_NOTIFY_SUBSCRIBED_EVENT,
......
......@@ -28,6 +28,7 @@
#include "amf_profile.hpp"
#include "bstrlib.h"
#include "itti_msg.hpp"
#include "3gpp_29.531.h"
class itti_msg_n11 : public itti_msg {
public:
......@@ -208,4 +209,21 @@ class itti_n11_slice_selection_subscription_data : public itti_msg_n11 {
uint32_t promise_id;
};
//-----------------------------------------------------------------------------
class itti_n11_network_slice_selection_information : public itti_msg_n11 {
public:
itti_n11_network_slice_selection_information(
const task_id_t orig, const task_id_t dest)
: itti_msg_n11(N11_NETWORK_SLICE_SELECTION_INFORMATION, orig, dest),
http_version(1) {}
const char* get_msg_name() {
return "N11_NETWORK_SLICE_SELECTION_INFORMATION";
};
uint8_t http_version;
std::string nf_instance_id;
slice_info_for_registration_t slice_info;
uint32_t promise_id;
};
#endif
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