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

Merge branch 'validate_smf_info' into 'develop'

Check nssai during SMF selection

See merge request oai/cn5g/oai-cn5g-amf!69
parents 6653e38a 849ee9df
......@@ -61,6 +61,7 @@ using namespace oai::smf::model;
using namespace oai::smf::api;
using namespace web;
using namespace web::http;
// Common features like URIs.
using namespace web::http::client;
using namespace config;
using namespace amf_application;
......@@ -1104,14 +1105,35 @@ bool amf_n11::discover_smf(
nlohmann::json instance_json = it.value();
// TODO: convert instance_json to SMF profile
// TODO: add SMF to the list of available SMF
// TODO: check with sNSSAI and DNN
// check with sNSSAI
if (instance_json.find("sNssais") != instance_json.end()) {
for (auto& s : instance_json["sNssais"].items()) {
nlohmann::json Snssai = s.value();
if (Snssai["sst"] == snssai.sST) {
// Match SD (optional) only if it is provided
if (!Snssai["sd"].empty() & Snssai["sd"] != snssai.sD) {
Logger::amf_n11().debug("SD is not matched");
result = false;
}
Logger::amf_n11().debug(
"Snssai [SST- %s, SD -%s] is matched for SMF profile",
Snssai["sst"].dump().c_str(), Snssai["sd"].dump().c_str());
result = true;
break;
} else {
Logger::amf_n11().debug(
"Snssai is not matched for SMF profile");
result = false;
}
}
}
// TODO: check DNN
// TODO: PLMN (need to add plmnList into NRF profile, SMF profile)
// for now, just IP addr of SMF of the first NF instance
if (instance_json.find("ipv4Addresses") != instance_json.end()) {
if (instance_json["ipv4Addresses"].size() > 0)
smf_addr =
instance_json["ipv4Addresses"].at(0).get<std::string>();
// break;
}
if (instance_json.find("nfServices") != instance_json.end()) {
if (instance_json["nfServices"].size() > 0) {
......@@ -1124,19 +1146,19 @@ bool amf_n11::discover_smf(
}
}
}
break;
}
// Break after first matching SMF instance for requested S-NSSAI
if (result) break;
}
}
Logger::amf_n11().debug(
"NFDiscovery, SMF Addr: %s, SMF Api Version: %s", smf_addr.c_str(),
smf_api_version.c_str());
} else {
Logger::amf_n11().warn("NFDiscovery, could not get response from NRF");
result = false;
}
Logger::amf_n11().debug(
"NFDiscovery, SMF Addr: %s, SMF Api Version: %s", smf_addr.c_str(),
smf_api_version.c_str());
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
......
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