Commit 54b1f5c4 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add NF Services info

parent f8572110
......@@ -12,8 +12,8 @@ SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='ens3'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='ens3'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='wlo1'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='wlo1'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80'
SMF_CONF[@SMF_INTERFACE_HTTP2_PORT_FOR_SBI@]='9090'
......@@ -29,6 +29,10 @@ SMF_CONF[@AMF_API_VERSION@]='v1'
SMF_CONF[@UPF_IPV4_ADDRESS@]='192.168.122.151'
SMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
SMF_CONF[@NRF_PORT@]='8080'
SMF_CONF[@NRF_API_VERSION@]='v1'
SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]='8.8.8.8'
SMF_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]='4.4.4.4'
......
......@@ -40,7 +40,7 @@ SMF =
IPV4_ADDRESS = "read";
PORT = @SMF_INTERFACE_PORT_FOR_SBI@; # YOUR NETWORK CONFIG HERE (default: 80)
HTTP2_PORT = @SMF_INTERFACE_HTTP2_PORT_FOR_SBI@; # YOUR NETWORK CONFIG HERE
API_VERSION = "@SMF_API_VERSION@"; # YOUR SMF API VERSION CONFIG HERE
API_VERSION = "@SMF_API_VERSION@"; # YOUR SMF API VERSION CONFIG HERE
};
};
......@@ -87,14 +87,14 @@ SMF =
{
IPV4_ADDRESS = "@AMF_IPV4_ADDRESS@"; # YOUR AMF CONFIG HERE
PORT = @AMF_PORT@; # YOUR AMF CONFIG HERE (default: 80)
API_VERSION = "@AMF_API_VERSION@"; # YOUR AMF API VERSION FOR SBI CONFIG HERE
API_VERSION = "@AMF_API_VERSION@"; # YOUR AMF API VERSION FOR SBI CONFIG HERE
};
UDM :
{
IPV4_ADDRESS = "@UDM_IPV4_ADDRESS@"; # YOUR UDM CONFIG HERE
PORT = @UDM_PORT@; # YOUR UDM CONFIG HERE (default: 80)
API_VERSION = "@UDM_API_VERSION@"; # YOUR UDM API VERSION FOR SBI CONFIG HERE
PORT = @UDM_PORT@; # YOUR UDM CONFIG HERE (default: 80)
API_VERSION = "@UDM_API_VERSION@"; # YOUR UDM API VERSION FOR SBI CONFIG HERE
};
UPF_LIST = (
......@@ -105,7 +105,7 @@ SMF =
{
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
};
LOCAL_CONFIGURATION :
......
......@@ -238,4 +238,49 @@ typedef struct smf_info_s {
std::vector<snssai_smf_info_item_t> snssai_smf_info_list;
} smf_info_t;
typedef struct nf_service_version_s {
std::string api_version_in_uri; // apiVersionInUri
std::string api_full_version; // apiFullVersion
nf_service_version_s &operator=(const nf_service_version_s &s) {
api_version_in_uri = s.api_version_in_uri;
api_full_version = s.api_full_version;
}
std::string to_string() const {
std::string s = {};
s.append(", Version (");
s.append("apiVersionInUri: ");
s.append(api_version_in_uri);
s.append(", apiFullVersion: ");
s.append(api_full_version);
s.append(" )");
return s;
}
} nf_service_version_t;
typedef struct nf_service_s {
std::string service_instance_id;
std::string service_name;
std::vector<nf_service_version_t> versions;
std::string scheme;
std::string nf_service_status;
std::string to_string() const {
std::string s = {};
s.append("Service Instance ID: ");
s.append(service_instance_id);
s.append(", Service name: ");
s.append(service_name);
for (auto v : versions) {
s.append(v.to_string());
}
s.append(", Scheme: ");
s.append(scheme);
s.append(", Service status: ");
s.append(nf_service_status);
return s;
}
} nf_service_t;
#endif
......@@ -281,7 +281,7 @@ void smf_app_task(void *) {
break;
case TASK_SMF_APP_TIMEOUT_NRF_DEREGISTRATION:
smf_app_inst->timer_nrf_deregistration(to->timer_id,
to->arg2_user);
to->arg2_user);
break;
default:;
}
......@@ -587,11 +587,11 @@ void smf_app::handle_itti_msg(itti_n11_register_nf_instance_response &r) {
TASK_SMF_APP, TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
//Set timer to send NF Deregistration (for testing purpose)
/* itti_inst->timer_setup(50, 0,
TASK_SMF_APP, TASK_SMF_APP_TIMEOUT_NRF_DEREGISTRATION,
0); // TODO arg2_user
*/
/* //Set timer to send NF Deregistration (for testing purpose)
itti_inst->timer_setup(50, 0,
TASK_SMF_APP,
TASK_SMF_APP_TIMEOUT_NRF_DEREGISTRATION, 0); // TODO arg2_user
*/
}
//------------------------------------------------------------------------------
......@@ -796,7 +796,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
request_type.c_str());
//"Existing PDU Session", AMF should use PDUSession_UpdateSMContext instead
//(see step 3, section 4.3.2.2.1 @ 3GPP TS 23.502 v16.0.0) ignore the
//message
// message
return;
}
......@@ -1460,11 +1460,11 @@ void smf_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id,
}
}
//---------------------------------------------------------------------------------------------
void smf_app::timer_nrf_deregistration(timer_id_t timer_id,
uint64_t arg2_user) {
Logger::smf_app().debug("Send ITTI msg to N11 task to trigger NRF Deregistratino");
uint64_t arg2_user) {
Logger::smf_app().debug(
"Send ITTI msg to N11 task to trigger NRF Deregistratino");
trigger_nf_deregistration();
}
......@@ -1786,6 +1786,19 @@ void smf_app::generate_smf_profile() {
nf_profile.set_nf_priority(1);
nf_profile.set_nf_capacity(100);
nf_profile.add_nf_ipv4_addresses(smf_cfg.sbi.addr4);
// NF services
nf_service_t nf_service = {};
nf_service.service_instance_id = smf_instance_id;
nf_service.service_name = "nsmf-pdusession";
nf_service_version_t version = {};
version.api_version_in_uri = "v1";
version.api_version_in_uri = "1.0.0"; // TODO: to be updated
nf_service.versions.push_back(version);
nf_service.scheme = "http";
nf_service.nf_service_status = "REGISTERED";
nf_profile.add_nf_service(nf_service);
// TODO: custom info
int i = 0;
......@@ -1851,7 +1864,7 @@ void smf_app::trigger_nf_deregistration() {
std::shared_ptr<itti_n11_deregister_nf_instance> itti_msg =
std::make_shared<itti_n11_deregister_nf_instance>(TASK_SMF_APP,
TASK_SMF_N11);
TASK_SMF_N11);
itti_msg->smf_instance_id = smf_instance_id;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
......@@ -1860,4 +1873,3 @@ void smf_app::trigger_nf_deregistration() {
itti_msg->get_msg_name());
}
}
......@@ -140,6 +140,21 @@ void smf_profile::get_nf_ipv4_addresses(std::vector<struct in_addr> &a) const {
a = ipv4_addresses;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_services(const std::vector<nf_service_t> &n) {
nf_services = n;
}
//------------------------------------------------------------------------------
void smf_profile::add_nf_service(const nf_service_t &n) {
nf_services.push_back(n);
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_services(std::vector<nf_service_t> &n) const {
n = nf_services;
}
//------------------------------------------------------------------------------
void smf_profile::set_custom_info(const nlohmann::json &c) { custom_info = c; }
......@@ -185,6 +200,14 @@ void smf_profile::display() {
Logger::smf_app().debug("\t\t %s", inet_ntoa(address));
}
// NF services
if (nf_services.size() > 0) {
Logger::smf_app().debug("\tNF Service");
}
for (auto service : nf_services) {
Logger::smf_app().debug("\t\t%s", service.to_string().c_str());
}
if (!custom_info.empty()) {
Logger::smf_app().debug("\tCustom info: %s", custom_info.dump().c_str());
}
......@@ -228,6 +251,25 @@ void smf_profile::to_json(nlohmann::json &data) const {
data["priority"] = priority;
data["capacity"] = capacity;
// NF services
data["nfServices"] = nlohmann::json::array();
for (auto service : nf_services) {
nlohmann::json srv_tmp = {};
srv_tmp["serviceInstanceId"] = service.service_instance_id;
srv_tmp["serviceName"] = service.service_name;
srv_tmp["versions"] = nlohmann::json::array();
for (auto v : service.versions) {
nlohmann::json v_tmp = {};
v_tmp["apiVersionInUri"] = v.api_version_in_uri;
v_tmp["apiFullVersion"] = v.api_full_version;
srv_tmp["versions"].push_back(v_tmp);
}
srv_tmp["scheme"] = service.scheme;
srv_tmp["nfServiceStatus"] = service.nf_service_status;
data["nfServices"].push_back(srv_tmp);
}
data["custom_info"] = custom_info;
// SMF info
......
......@@ -54,8 +54,7 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
snssais(),
ipv4_addresses(),
priority(0),
capacity(0)
{
capacity(0) {
nf_instance_name = "";
nf_status = "";
custom_info = {};
......@@ -68,8 +67,7 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
ipv4_addresses(),
priority(0),
capacity(0),
nf_type("NF_TYPE_UNKNOWN")
{
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = "";
nf_status = "";
custom_info = {};
......@@ -275,6 +273,27 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
*/
void get_nf_ipv4_addresses(std::vector<struct in_addr> &a) const;
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
* @return void
*/
void set_nf_services(const std::vector<nf_service_t> &n);
/*
* Add nf service
* @param [snssai_t &] n: nf service
* @return void
*/
void add_nf_service(const nf_service_t &n);
/*
* Get NF services
* @param [std::vector<snssai_t> &] n: store instance's nf services
* @return void:
*/
void get_nf_services(std::vector<nf_service_t> &n) const;
/*
* Set custom info
* @param [const nlohmann::json &] c: custom info to be set
......@@ -349,6 +368,7 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
std::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
std::vector<nf_service_t> nf_services;
nlohmann::json custom_info; // store extra json data
smf_info_t smf_info;
};
......
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