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

Resolve SMF IP addr when sending PDU session request

parent deeb33ba
...@@ -342,6 +342,8 @@ int amf_config::load(const std::string& config_file) { ...@@ -342,6 +342,8 @@ int amf_config::load(const std::string& config_file) {
} else { } else {
std::string smf_fqdn = {}; std::string smf_fqdn = {};
smf_addr_item.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, smf_fqdn); smf_addr_item.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, smf_fqdn);
smf_inst.fqdn = smf_fqdn;
/*
uint8_t addr_type = 0; uint8_t addr_type = 0;
fqdn::resolve(smf_fqdn, smf_inst.ipv4, smf_port, addr_type); fqdn::resolve(smf_fqdn, smf_inst.ipv4, smf_port, addr_type);
if (addr_type != 0) { // IPv6: TODO if (addr_type != 0) { // IPv6: TODO
...@@ -353,6 +355,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -353,6 +355,7 @@ int amf_config::load(const std::string& config_file) {
smf_inst.port = std::to_string(smf_port); smf_inst.port = std::to_string(smf_port);
smf_inst.version = "v1"; // TODO: get API version smf_inst.version = "v1"; // TODO: get API version
} }
*/
} }
smf_addr_item.lookupValue( smf_addr_item.lookupValue(
...@@ -595,14 +598,12 @@ void amf_config::display() { ...@@ -595,14 +598,12 @@ void amf_config::display() {
if (!enable_smf_selection) { if (!enable_smf_selection) {
Logger::config().info("- SMF Pool.........: "); Logger::config().info("- SMF Pool.........: ");
for (int i = 0; i < smf_pool.size(); i++) { for (int i = 0; i < smf_pool.size(); i++) {
std::string selected; std::string selected = smf_pool[i].selected ? "true" : "false";
if (smf_pool[i].selected) std::string smf_info =
selected = "true"; use_fqdn_dns ? smf_pool[i].fqdn : smf_pool[i].ipv4.c_str();
else
selected = "false";
Logger::config().info( Logger::config().info(
" SMF_INSTANCE_ID %d (%s:%s, version %s) is selected: %s", " SMF_INSTANCE_ID %d (%s:%s, version %s) is selected: %s",
smf_pool[i].id, smf_pool[i].ipv4.c_str(), smf_pool[i].port.c_str(), smf_pool[i].id, smf_info.c_str(), smf_pool[i].port.c_str(),
smf_pool[i].version.c_str(), selected.c_str()); smf_pool[i].version.c_str(), selected.c_str());
} }
} }
......
...@@ -168,6 +168,7 @@ typedef struct { ...@@ -168,6 +168,7 @@ typedef struct {
std::string port; std::string port;
std::string version; std::string version;
bool selected; bool selected;
std::string fqdn;
} smf_inst_t; } smf_inst_t;
class amf_config { class amf_config {
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "SmContextCreateData.h" #include "SmContextCreateData.h"
#include "mime_parser.hpp" #include "mime_parser.hpp"
#include "ue_context.hpp" #include "ue_context.hpp"
#include "fqdn.hpp"
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
...@@ -472,8 +473,26 @@ bool amf_n11::smf_selection_from_configuration( ...@@ -472,8 +473,26 @@ bool amf_n11::smf_selection_from_configuration(
std::string& smf_addr, std::string& smf_api_version) { std::string& smf_addr, std::string& smf_api_version) {
for (int i = 0; i < amf_cfg.smf_pool.size(); i++) { for (int i = 0; i < amf_cfg.smf_pool.size(); i++) {
if (amf_cfg.smf_pool[i].selected) { if (amf_cfg.smf_pool[i].selected) {
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port; if (!amf_cfg.use_fqdn_dns) {
smf_api_version = amf_cfg.smf_pool[i].version; smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + amf_cfg.smf_pool[i].port;
smf_api_version = amf_cfg.smf_pool[i].version;
return true;
} else {
// resolve IP addr from a FQDN/DNS name
uint8_t addr_type = 0;
uint32_t smf_port = 0;
fqdn::resolve(
amf_cfg.smf_pool[i].fqdn, amf_cfg.smf_pool[i].ipv4, smf_port,
addr_type);
if (addr_type != 0) { // IPv6: TODO
Logger::amf_n11().warn("Do not support IPv6 Addr for SMF");
return false;
} else { // IPv4
smf_addr = amf_cfg.smf_pool[i].ipv4 + ":" + std::to_string(smf_port);
smf_api_version = "v1"; // TODO: get API version
return true;
}
}
return true; return true;
} }
} }
......
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