Unverified Commit 5a94d11f authored by kharade's avatar kharade

use common SBI flag for http version

parent a9b5db1e
......@@ -89,6 +89,7 @@ SMF =
# but you may need to set to yes for UE that do not explicitly request a PDN address through NAS signalling
USE_LOCAL_SUBSCRIPTION_INFO = "yes"; # Set to yes if SMF uses local subscription information instead of from an UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF/UDM/NRF/UPF will relying on a DNS to resolve FQDN
HTTP_VERSION = @HTTP_VERSION@; # YOUR NRF CONFIG HERE (default: 1)
}
AMF :
......@@ -111,7 +112,6 @@ SMF =
{
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
HTTP_VERSION = @HTTP_VERSION@; # YOUR NRF CONFIG HERE (default: 1)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
FQDN = "@NRF_FQDN@" # YOUR NRF FQDN CONFIG HERE
};
......
......@@ -561,7 +561,7 @@ void smf_http2_server::nf_status_notify_handler(
smf::data_notification_msg notification_msg = {};
nlohmann::json json_data = {};
std::string content_type = "application/json";
std::string content_type = "application/problem+json";
// convert from NotificationData to data_notification_msg
xgpp_conv::data_notification_from_openapi(notificationData, notification_msg);
......@@ -570,23 +570,22 @@ void smf_http2_server::nf_status_notify_handler(
std::shared_ptr<itti_sbi_notification_data> itti_msg =
std::make_shared<itti_sbi_notification_data>(TASK_SMF_SBI, TASK_SMF_APP);
itti_msg->notification_msg = notification_msg;
itti_msg->http_version = 1;
itti_msg->http_version = 2;
ProblemDetails problem_details = {};
uint8_t http_code = 0;
header_map h;
h.emplace(
"location",
header_value{m_address + "/nsmf-nfstatus-notify/v1/subscriptions"});
h.emplace("content-type", header_value{content_type});
response.write_head(http_code, h);
response.end(json_data.dump().c_str());
if (m_smf_app->handle_nf_status_notification(
itti_msg, problem_details, http_code))
itti_msg, problem_details, http_code)) {
http_code = 204;
response.write_head(http_code, h);
response.end();
else
} else {
to_json(json_data, problem_details);
h.emplace("content-type", header_value{content_type});
response.end(json_data.dump().c_str());
}
}
//------------------------------------------------------------------------------
void smf_http2_server::stop() {
......
......@@ -1625,7 +1625,7 @@ void smf_app::timer_nrf_heartbeat_timeout(
patch_item.setValue("REGISTERED");
itti_msg->patch_items.push_back(patch_item);
itti_msg->smf_instance_id = smf_instance_id;
itti_msg->http_version = smf_cfg.nrf_addr.http_version;
itti_msg->http_version = smf_cfg.http_version;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
......@@ -2072,7 +2072,7 @@ void smf_app::trigger_nf_registration_request() {
std::make_shared<itti_n11_register_nf_instance_request>(
TASK_SMF_APP, TASK_SMF_SBI);
itti_msg->profile = nf_instance_profile;
itti_msg->http_version = smf_cfg.nrf_addr.http_version;
itti_msg->http_version = smf_cfg.http_version;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
......@@ -2090,7 +2090,7 @@ void smf_app::trigger_nf_deregistration() {
std::make_shared<itti_n11_deregister_nf_instance>(
TASK_SMF_APP, TASK_SMF_SBI);
itti_msg->smf_instance_id = smf_instance_id;
itti_msg->http_version = smf_cfg.nrf_addr.http_version;
itti_msg->http_version = smf_cfg.http_version;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
......@@ -2111,7 +2111,7 @@ void smf_app::trigger_upf_status_notification_subscribe() {
nlohmann::json json_data = {};
unsigned int port = smf_cfg.sbi.port;
if (smf_cfg.nrf_addr.http_version == 2) port = smf_cfg.sbi_http2_port;
if (smf_cfg.http_version == 2) port = smf_cfg.sbi_http2_port;
// TODO: remove hardcoded values
json_data["nfStatusNotificationUri"] =
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.sbi.addr4))) + ":" +
......@@ -2131,7 +2131,7 @@ void smf_app::trigger_upf_status_notification_subscribe() {
itti_msg->url = url;
itti_msg->json_data = json_data;
itti_msg->http_version = smf_cfg.nrf_addr.http_version;
itti_msg->http_version = smf_cfg.http_version;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
......
......@@ -560,6 +560,7 @@ int smf_config::load(const string& config_file) {
const Setting& support_features =
smf_cfg[SMF_CONFIG_STRING_SUPPORT_FEATURES];
string opt;
unsigned int httpVersion = {0};
support_features.lookupValue(
SMF_CONFIG_STRING_SUPPORT_FEATURES_REGISTER_NRF, opt);
if (boost::iequals(opt, "yes")) {
......@@ -599,6 +600,10 @@ int smf_config::load(const string& config_file) {
use_fqdn_dns = false;
}
support_features.lookupValue(
SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION, httpVersion);
http_version = httpVersion;
} catch (const SettingNotFoundException& nfex) {
Logger::smf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
......@@ -760,16 +765,8 @@ int smf_config::load(const string& config_file) {
const Setting& nrf_cfg = smf_cfg[SMF_CONFIG_STRING_NRF];
struct in_addr nrf_ipv4_addr = {};
unsigned int nrf_port = {0};
unsigned int httpVersion = {0};
std::string nrf_api_version = {};
if (!(nrf_cfg.lookupValue(
SMF_CONFIG_STRING_NRF_HTTP_VERSION, httpVersion))) {
Logger::smf_app().error(SMF_CONFIG_STRING_NRF_HTTP_VERSION "failed");
throw(SMF_CONFIG_STRING_NRF_HTTP_VERSION "failed");
}
nrf_addr.http_version = httpVersion;
if (!use_fqdn_dns) {
nrf_cfg.lookupValue(SMF_CONFIG_STRING_NRF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
......
......@@ -110,7 +110,6 @@
#define SMF_CONFIG_STRING_NRF "NRF"
#define SMF_CONFIG_STRING_NRF_IPV4_ADDRESS "IPV4_ADDRESS"
#define SMF_CONFIG_STRING_NRF_PORT "PORT"
#define SMF_CONFIG_STRING_NRF_HTTP_VERSION "HTTP_VERSION"
#define SMF_CONFIG_STRING_LOCAL_CONFIGURATION "LOCAL_CONFIGURATION"
#define SMF_CONFIG_STRING_SESSION_MANAGEMENT_SUBSCRIPTION_LIST \
......@@ -140,6 +139,7 @@
#define SMF_CONFIG_STRING_NAS_FORCE_PUSH_PCO \
"FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION "HTTP_VERSION"
#define SMF_MAX_ALLOCATED_PDN_ADDRESSES 1024
......@@ -222,6 +222,7 @@ class smf_config {
bool discover_upf;
bool use_local_subscription_info;
bool use_fqdn_dns;
unsigned int http_version;
struct {
struct in_addr ipv4_addr;
......
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