Commit c00a73a9 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Use SBI interface to communicate with NRF/UDM/NSSF

parent 5d86ed09
......@@ -68,7 +68,7 @@ AMF =
};
# AMF binded interface for SBI (N11 (SMF)/N12 (AUSF), etc.)
N11:
SBI:
{
INTERFACE_NAME = "@AMF_INTERFACE_NAME_FOR_N11@";
IPV4_ADDRESS = "read";
......
......@@ -1018,7 +1018,7 @@ void amf_app::generate_amf_profile() {
nf_instance_profile.set_nf_priority(1);
nf_instance_profile.set_nf_capacity(100);
nf_instance_profile.delete_nf_ipv4_addresses();
nf_instance_profile.add_nf_ipv4_addresses(amf_cfg.n11.addr4);
nf_instance_profile.add_nf_ipv4_addresses(amf_cfg.sbi.addr4);
// NF services
nf_service_t nf_service = {};
......@@ -1032,9 +1032,9 @@ void amf_app::generate_amf_profile() {
nf_service.nf_service_status = "REGISTERED";
// IP Endpoint
ip_endpoint_t endpoint = {};
endpoint.ipv4_address = amf_cfg.n11.addr4;
endpoint.ipv4_address = amf_cfg.sbi.addr4;
endpoint.transport = "TCP";
endpoint.port = amf_cfg.n11.port;
endpoint.port = amf_cfg.sbi.port;
nf_service.ip_endpoints.push_back(endpoint);
nf_instance_profile.delete_nf_services();
......@@ -1067,20 +1067,21 @@ std::string amf_app::get_nf_instance() const {
//---------------------------------------------------------------------------------------------
void amf_app::register_to_nrf() {
// send request to N11 to send NF registration to NRF
// send request to SBI to send NF registration to NRF
trigger_nf_registration_request();
}
//------------------------------------------------------------------------------
void amf_app::trigger_nf_registration_request() {
Logger::amf_app().debug(
"Send ITTI msg to N11 task to trigger the registration request to NRF");
"Send ITTI msg to SBI task to trigger the registration request to NRF");
std::shared_ptr<itti_sbi_register_nf_instance_request> itti_msg =
std::make_shared<itti_sbi_register_nf_instance_request>(
TASK_AMF_APP, TASK_AMF_SBI);
itti_msg->profile = nf_instance_profile;
// TODO: use ITTI to send message between N1 and SBI
amf_sbi_inst->register_nf_instance(itti_msg);
/*
......@@ -1096,7 +1097,7 @@ void amf_app::trigger_nf_registration_request() {
//------------------------------------------------------------------------------
void amf_app::trigger_nf_deregistration() const {
Logger::amf_app().debug(
"Send ITTI msg to N11 task to trigger the deregistration request to NRF");
"Send ITTI msg to SBI task to trigger the deregistration request to NRF");
std::shared_ptr<itti_sbi_deregister_nf_instance> itti_msg =
std::make_shared<itti_sbi_deregister_nf_instance>(
......@@ -1129,8 +1130,8 @@ void amf_app::add_promise(
void amf_app::add_promise(
const uint32_t pid,
const boost::shared_ptr<boost::promise<nlohmann::json>>& p) {
std::unique_lock lock(m_curl_handle_responses_n11);
curl_handle_responses_n11.emplace(pid, p);
std::unique_lock lock(m_curl_handle_responses_sbi);
curl_handle_responses_sbi.emplace(pid, p);
}
//---------------------------------------------------------------------------------------------
......@@ -1170,10 +1171,10 @@ void amf_app::trigger_process_response(
"Trigger process response: Set promise with ID %u "
"to ready",
pid);
std::unique_lock lock(m_curl_handle_responses_n11);
if (curl_handle_responses_n11.count(pid) > 0) {
curl_handle_responses_n11[pid]->set_value(json_data);
std::unique_lock lock(m_curl_handle_responses_sbi);
if (curl_handle_responses_sbi.count(pid) > 0) {
curl_handle_responses_sbi[pid]->set_value(json_data);
// Remove this promise from list
curl_handle_responses_n11.erase(pid);
curl_handle_responses_sbi.erase(pid);
}
}
......@@ -37,7 +37,7 @@
#include "amf_module_from_config.hpp"
#include "amf_profile.hpp"
#include "itti.hpp"
#include "itti_msg_n11.hpp"
#include "itti_msg_sbi.hpp"
#include "itti_msg_amf_app.hpp"
#include "ue_context.hpp"
#include "amf_subscription.hpp"
......@@ -92,9 +92,9 @@ class amf_app {
std::map<uint32_t, boost::shared_ptr<boost::promise<std::string>>>
curl_handle_responses_n2_sm;
mutable std::shared_mutex m_curl_handle_responses_n11;
mutable std::shared_mutex m_curl_handle_responses_sbi;
std::map<uint32_t, boost::shared_ptr<boost::promise<nlohmann::json>>>
curl_handle_responses_n11;
curl_handle_responses_sbi;
util::uint_generator<uint32_t> n1n2sub_id_generator;
std::map<
......@@ -458,14 +458,14 @@ class amf_app {
void generate_amf_profile();
/*
* Send request to N11 task to trigger NF instance registration to NRF
* Send request to SBI task to trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void trigger_nf_registration_request();
/*
* Send request to N11 task to trigger NF instance deregistration to NRF
* Send request to SBI task to trigger NF instance deregistration to NRF
* @param [void]
* @return void
*/
......
......@@ -73,7 +73,7 @@ amf_config::amf_config() {
nssf_addr.api_version = "v1";
instance = 0;
n2 = {};
n11 = {};
sbi = {};
sbi_api_version = "v1";
sbi_http2_port = 8080;
statistics_interval = 0;
......@@ -343,19 +343,19 @@ int amf_config::load(const std::string& config_file) {
new_if_cfg[AMF_CONFIG_STRING_INTERFACE_NGAP_AMF];
load_interface(n2_amf_cfg, n2);
// N11
const Setting& n11_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_N11];
load_interface(n11_cfg, n11);
// SBI
const Setting& sbi_cfg = new_if_cfg[AMF_CONFIG_STRING_INTERFACE_SBI];
load_interface(sbi_cfg, sbi);
// SBI API VERSION
if (!(n11_cfg.lookupValue(
if (!(sbi_cfg.lookupValue(
AMF_CONFIG_STRING_API_VERSION, sbi_api_version))) {
Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed");
throw(AMF_CONFIG_STRING_API_VERSION "failed");
}
// HTTP2 port
if (!(n11_cfg.lookupValue(
if (!(sbi_cfg.lookupValue(
AMF_CONFIG_STRING_SBI_HTTP2_PORT, sbi_http2_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_SBI_HTTP2_PORT "failed");
throw(AMF_CONFIG_STRING_SBI_HTTP2_PORT "failed");
......@@ -363,7 +363,7 @@ int amf_config::load(const std::string& config_file) {
// SMF
const Setting& smf_addr_pool =
n11_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL];
sbi_cfg[AMF_CONFIG_STRING_SMF_INSTANCES_POOL];
int count = smf_addr_pool.getLength();
for (int i = 0; i < count; i++) {
const Setting& smf_addr_item = smf_addr_pool[i];
......@@ -755,10 +755,10 @@ void amf_config::display() {
Logger::config().info(" Port ..................: %d", n2.port);
Logger::config().info("- SBI Networking:");
Logger::config().info(" Iface .................: %s", n11.if_name.c_str());
Logger::config().info(" Iface .................: %s", sbi.if_name.c_str());
Logger::config().info(
" IP Addr ...............: %s", inet_ntoa(n11.addr4));
Logger::config().info(" Port ..................: %d", n11.port);
" IP Addr ...............: %s", inet_ntoa(sbi.addr4));
Logger::config().info(" Port ..................: %d", sbi.port);
Logger::config().info(" HTTP2 port ............: %d", sbi_http2_port);
Logger::config().info(
" API version............: %s", sbi_api_version.c_str());
......@@ -916,9 +916,9 @@ std::string amf_config::get_amf_n1n2_message_subscribe_uri(
if (support_features.use_http2) {
sbi_port = sbi_http2_port;
} else {
sbi_port = n11.port;
sbi_port = sbi.port;
}
return std::string(inet_ntoa(*((struct in_addr*) &n11.addr4))) + ":" +
return std::string(inet_ntoa(*((struct in_addr*) &sbi.addr4))) + ":" +
std::to_string(sbi_port) + NAMF_COMMUNICATION_BASE + sbi_api_version +
"/ue-contexts/" + ue_cxt_id + "/n1-n2-messages/subscriptions";
}
......@@ -982,8 +982,8 @@ void amf_config::to_json(nlohmann::json& json_data) const {
json_data["auth_para"] = auth_para.to_json();
json_data["n2"] = n2.to_json();
json_data["n11"] = n11.to_json();
json_data["n11"]["sbi_http2_port"] = sbi_http2_port;
json_data["sbi"] = sbi.to_json();
json_data["sbi"]["sbi_http2_port"] = sbi_http2_port;
json_data["support_features"] = support_features.to_json();
......@@ -1060,8 +1060,8 @@ bool amf_config::from_json(nlohmann::json& json_data) {
if (json_data.find("n2") != json_data.end()) {
n2.from_json(json_data["n2"]);
}
if (json_data.find("n11") != json_data.end()) {
n11.from_json(json_data["n11"]);
if (json_data.find("sbi") != json_data.end()) {
sbi.from_json(json_data["sbi"]);
}
if (json_data.find("sbi_http2_port") != json_data.end()) {
......
......@@ -59,7 +59,7 @@
#define AMF_CONFIG_STRING_PPID "PPID"
#define AMF_CONFIG_STRING_SBI_HTTP2_PORT "HTTP2_PORT"
#define AMF_CONFIG_STRING_INTERFACE_N11 "N11"
#define AMF_CONFIG_STRING_INTERFACE_SBI "SBI"
#define AMF_CONFIG_STRING_SMF_INSTANCES_POOL "SMF_INSTANCES_POOL"
#define AMF_CONFIG_STRING_SMF_INSTANCE_ID "SMF_INSTANCE_ID"
#define AMF_CONFIG_STRING_SMF_INSTANCE_PORT "PORT"
......@@ -481,7 +481,7 @@ class amf_config {
unsigned int instance;
std::string pid_dir;
interface_cfg_t n2;
interface_cfg_t n11;
interface_cfg_t sbi;
itti_cfg_t itti;
std::string sbi_api_version;
unsigned int sbi_http2_port;
......
......@@ -58,7 +58,7 @@
#include "amf_n2.hpp"
#include "comUt.hpp"
#include "itti.hpp"
#include "itti_msg_n11.hpp"
#include "itti_msg_sbi.hpp"
#include "itti_msg_n2.hpp"
#include "logger.hpp"
#include "nas_algorithms.hpp"
......@@ -1772,7 +1772,7 @@ bool amf_n1::get_authentication_vectors_from_ausf(
uint8_t http_version = 1;
if (amf_cfg.support_features.use_http2) http_version = 2;
//TODO: use ITTI to send message between N1 and SBI
// TODO: use ITTI to send message between N1 and SBI
if (amf_sbi_inst->send_ue_authentication_request(
authenticationinfo, ueauthenticationctx, http_version)) {
unsigned char* r5gauthdata_rand = conv::format_string_as_hex(
......@@ -4657,7 +4657,7 @@ void amf_n1::send_n1_message_notity(
const std::shared_ptr<nas_context>& nc,
const std::string& target_amf) const {
Logger::amf_n1().debug(
"Send a request to N11 to send N1 Message Notify to the target AMF");
"Send a request to SBI to send N1 Message Notify to the target AMF");
std::shared_ptr<itti_sbi_n1_message_notify> itti_msg =
std::make_shared<itti_sbi_n1_message_notify>(TASK_AMF_N1, TASK_AMF_SBI);
......
......@@ -492,7 +492,7 @@ void amf_sbi::handle_pdu_session_initial_request(
else
smf_ip_addr = smf_addr;
// provide http2 port if enabled
std::string amf_port = to_string(amf_cfg.n11.port);
std::string amf_port = to_string(amf_cfg.sbi.port);
if (amf_cfg.support_features.use_http2)
amf_port = to_string(amf_cfg.sbi_http2_port);
......@@ -518,7 +518,7 @@ void amf_sbi::handle_pdu_session_initial_request(
pdu_session_establishment_request["anType"] = "3GPP_ACCESS"; // TODO
pdu_session_establishment_request["smContextStatusUri"] =
"http://" +
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))) + ":" +
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.sbi.addr4))) + ":" +
amf_port + "/nsmf-pdusession/callback/" + supi + "/" +
std::to_string(psc.get()->pdu_session_id);
......@@ -1107,7 +1107,7 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_URL, remote_uri.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
......@@ -1376,7 +1376,7 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_URL, remote_uri.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
......@@ -1520,7 +1520,7 @@ void amf_sbi::curl_http_client(
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.sbi.if_name.c_str());
if (http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
......
......@@ -35,7 +35,6 @@
#include "AuthenticationInfo.h"
#include "UEAuthenticationCtx.h"
#include "itti_msg_n11.hpp"
#include "itti_msg_sbi.hpp"
#include "pdu_session_context.hpp"
......
/*
* 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 _ITTI_N11_MSG_H_
#define _ITTI_N11_MSG_H_
#include <string>
#include "amf.hpp"
#include "amf_profile.hpp"
#include "bstrlib.h"
#include "itti_msg.hpp"
#include "SliceInfoForRegistration.h"
#endif
......@@ -34,7 +34,7 @@
#include "amf_n1.hpp"
#include "amf_sbi.hpp"
#include "itti.hpp"
#include "itti_msg_n11.hpp"
#include "itti_msg_sbi.hpp"
#include "itti_msg_n2.hpp"
#include "logger.hpp"
#include "nas_context.hpp"
......
......@@ -124,15 +124,15 @@ int main(int argc, char** argv) {
Logger::amf_app().debug("Initiating AMF server endpoints");
// AMF HTTP1 server
Pistache::Address addr(
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))),
Pistache::Port(amf_cfg.n11.port));
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.sbi.addr4))),
Pistache::Port(amf_cfg.sbi.port));
amf_api_server_1 = new AMFApiServer(addr, amf_app_inst);
amf_api_server_1->init(2);
// std::thread amf_http1_manager(&AMFApiServer::start, amf_api_server_1);
amf_api_server_1->start();
// AMF HTTP2 server
amf_api_server_2 = new amf_http2_server(
conv::toString(amf_cfg.n11.addr4), amf_cfg.sbi_http2_port, amf_app_inst);
conv::toString(amf_cfg.sbi.addr4), amf_cfg.sbi_http2_port, amf_app_inst);
amf_api_server_2->init(1);
// std::thread amf_http2_manager(&amf_http2_server::start, amf_api_server_2);
amf_api_server_2->start();
......
......@@ -66,8 +66,8 @@ void SubscriptionsCollectionDocumentApiImplEventExposure::create_subscription(
if (sub_id != -1) {
std::string location =
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.n11.addr4))) + ":" +
std::to_string(amf_cfg.n11.port) + base + amf_cfg.sbi_api_version +
std::string(inet_ntoa(*((struct in_addr*) &amf_cfg.sbi.addr4))) + ":" +
std::to_string(amf_cfg.sbi.port) + base + amf_cfg.sbi_api_version +
"/namf-evts/" + std::to_string(sub_id);
json_data["subscriptionId"] = location;
......
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