Commit 47da9a26 authored by Mohammed Ismail's avatar Mohammed Ismail

Merge branch 'fqdn_ausf' into 'develop'

Support FQDN for AUSF

See merge request oai/cn5g/oai-cn5g-amf!52
parents 4ed0fefa eedb57aa
...@@ -84,6 +84,7 @@ services: ...@@ -84,6 +84,7 @@ services:
- AUSF_IPV4_ADDRESS=0.0.0.0 - AUSF_IPV4_ADDRESS=0.0.0.0
- AUSF_PORT=80 - AUSF_PORT=80
- AUSF_API_VERSION=v1 - AUSF_API_VERSION=v1
- AUSF_FQDN=localhost
depends_on: depends_on:
- cicd_mysql - cicd_mysql
networks: networks:
......
...@@ -85,7 +85,7 @@ AMF = ...@@ -85,7 +85,7 @@ AMF =
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80) 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
FQDN = "@NRF_FQDN@" FQDN = "@NRF_FQDN@" # YOUR NRF FQDN CONFIG HERE
}; };
AUSF : AUSF :
...@@ -93,6 +93,7 @@ AMF = ...@@ -93,6 +93,7 @@ AMF =
IPV4_ADDRESS = "@AUSF_IPV4_ADDRESS@"; # YOUR AUSF CONFIG HERE IPV4_ADDRESS = "@AUSF_IPV4_ADDRESS@"; # YOUR AUSF CONFIG HERE
PORT = @AUSF_PORT@; # YOUR AUSF CONFIG HERE (default: 80) PORT = @AUSF_PORT@; # YOUR AUSF CONFIG HERE (default: 80)
API_VERSION = "@AUSF_API_VERSION@"; # YOUR AUSF API VERSION FOR SBI CONFIG HERE API_VERSION = "@AUSF_API_VERSION@"; # YOUR AUSF API VERSION FOR SBI CONFIG HERE
FQDN = "@AUSF_FQDN@" # YOUR AUSF FQDN CONFIG HERE
}; };
}; };
......
...@@ -132,7 +132,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -132,7 +132,7 @@ int amf_config::load(const std::string& config_file) {
const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG]; const Setting& amf_cfg = root[AMF_CONFIG_STRING_AMF_CONFIG];
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath()); Logger::amf_app().error("%s : %s", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
// Instance // Instance
...@@ -286,7 +286,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -286,7 +286,7 @@ int amf_config::load(const std::string& config_file) {
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
// Network interfaces // Network interfaces
...@@ -399,34 +399,52 @@ int amf_config::load(const std::string& config_file) { ...@@ -399,34 +399,52 @@ int amf_config::load(const std::string& config_file) {
} }
// AUSF // AUSF
// TODO: add FQDN option if (enable_external_ausf) {
const Setting& ausf_cfg = new_if_cfg[AMF_CONFIG_STRING_AUSF]; const Setting& ausf_cfg = new_if_cfg[AMF_CONFIG_STRING_AUSF];
struct in_addr ausf_ipv4_addr = {}; struct in_addr ausf_ipv4_addr = {};
unsigned int ausf_port = {}; unsigned int ausf_port = {};
std::string ausf_api_version = {}; std::string ausf_api_version = {};
ausf_cfg.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, address);
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), ausf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR AUSF !");
ausf_addr.ipv4_addr = ausf_ipv4_addr;
if (!(ausf_cfg.lookupValue(AMF_CONFIG_STRING_PORT, ausf_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_PORT "failed");
throw(AMF_CONFIG_STRING_PORT "failed");
}
ausf_addr.port = ausf_port;
if (!(ausf_cfg.lookupValue( if (!use_fqdn_dns) {
AMF_CONFIG_STRING_API_VERSION, ausf_api_version))) { ausf_cfg.lookupValue(AMF_CONFIG_STRING_IPV4_ADDRESS, address);
Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed"); IPV4_STR_ADDR_TO_INADDR(
throw(AMF_CONFIG_STRING_API_VERSION "failed"); util::trim(address).c_str(), ausf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR AUSF !");
ausf_addr.ipv4_addr = ausf_ipv4_addr;
if (!(ausf_cfg.lookupValue(AMF_CONFIG_STRING_PORT, ausf_port))) {
Logger::amf_app().error(AMF_CONFIG_STRING_PORT "failed");
throw(AMF_CONFIG_STRING_PORT "failed");
}
ausf_addr.port = ausf_port;
if (!(ausf_cfg.lookupValue(
AMF_CONFIG_STRING_API_VERSION, ausf_api_version))) {
Logger::amf_app().error(AMF_CONFIG_STRING_API_VERSION "failed");
throw(AMF_CONFIG_STRING_API_VERSION "failed");
}
ausf_addr.api_version = ausf_api_version;
} else {
std::string ausf_fqdn = {};
ausf_cfg.lookupValue(AMF_CONFIG_STRING_FQDN_DNS, ausf_fqdn);
uint8_t addr_type = {};
fqdn::resolve(ausf_fqdn, address, ausf_port, addr_type);
if (addr_type != 0) { // IPv6: TODO
throw("DO NOT SUPPORT IPV6 ADDR FOR AUSF!");
} else { // IPv4
IPV4_STR_ADDR_TO_INADDR(
util::trim(address).c_str(), ausf_ipv4_addr,
"BAD IPv4 ADDRESS FORMAT FOR AUSF !");
ausf_addr.ipv4_addr = ausf_ipv4_addr;
ausf_addr.port = ausf_port;
ausf_addr.api_version = "v1"; // TODO: get API version
}
}
} }
ausf_addr.api_version = ausf_api_version;
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
// Emergency support // Emergency support
...@@ -437,7 +455,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -437,7 +455,7 @@ int amf_config::load(const std::string& config_file) {
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
// Authentication Info // Authentication Info
...@@ -455,7 +473,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -455,7 +473,7 @@ int amf_config::load(const std::string& config_file) {
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
// Integrity/Ciphering algorithms (NAS) // Integrity/Ciphering algorithms (NAS)
...@@ -496,7 +514,7 @@ int amf_config::load(const std::string& config_file) { ...@@ -496,7 +514,7 @@ int amf_config::load(const std::string& config_file) {
} catch (const SettingNotFoundException& nfex) { } catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error( Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath()); "%s : %s, using defaults", nfex.what(), nfex.getPath());
return -1; return RETURNerror;
} }
return 1; return 1;
......
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