Unverified Commit 53b348bd authored by kharade's avatar kharade

fix for ipv6

parent 6b57e049
...@@ -87,21 +87,40 @@ bool api_conv::profile_api_to_nrf_profile( ...@@ -87,21 +87,40 @@ bool api_conv::profile_api_to_nrf_profile(
profile.get()->set_fqdn(api_profile.getFqdn()); profile.get()->set_fqdn(api_profile.getFqdn());
Logger::nrf_app().debug("\tFQDN: %s", api_profile.getFqdn().c_str()); Logger::nrf_app().debug("\tFQDN: %s", api_profile.getFqdn().c_str());
} }
std::vector<std::string> ipv4_addr_str = api_profile.getIpv4Addresses(); if (api_profile.ipv4AddressesIsSet()) {
for (auto address : ipv4_addr_str) { std::vector<std::string> ipv4_addr_str = api_profile.getIpv4Addresses();
struct in_addr addr4 = {}; for (auto address : ipv4_addr_str) {
unsigned char buf_in_addr[sizeof(struct in_addr)]; struct in_addr addr4 = {};
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) { unsigned char buf_in_addr[sizeof(struct in_addr)];
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr)); if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
} else { memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
Logger::nrf_app().warn( } else {
"Address conversion: Bad value %s", util::trim(address).c_str()); Logger::nrf_app().warn(
} "Address conversion: Bad value %s", util::trim(address).c_str());
}
Logger::nrf_app().debug("\tIPv4 Addr: %s", address.c_str()); Logger::nrf_app().debug("\tIPv4 Addr: %s", address.c_str());
profile.get()->add_nf_ipv4_addresses(addr4); profile.get()->add_nf_ipv4_addresses(addr4);
}
} }
// ToDo: Check if ipv6 addr present // ToDo: For ipv6
// if (api_profile.ipv6AddressesIsSet()) {
// std::vector<Ipv6Addr> ipv6_addr = api_profile.getIpv6Addresses();
// for (auto address : ipv6_addr) {
// struct in6_addr addr6 = {};
// unsigned char buf_in_addr[sizeof(struct in6_addr)];
// if (inet_pton(AF_INET6, util::trim(address).c_str(), buf_in_addr) == 1)
// {
// memcpy(&addr6, buf_in_addr, sizeof(struct in6_addr));
// } else {
// Logger::nrf_app().warn(
// "Address conversion: Bad value %s", util::trim(address).c_str());
// }
// Logger::nrf_app().debug("\tIPv6 Addr: %s", address.c_str());
// profile.get()->add_nf_ipv6_addresses(addr6);
// }
// }
nf_type_t nf_type = string_to_nf_type(api_profile.getNfType()); nf_type_t nf_type = string_to_nf_type(api_profile.getNfType());
......
...@@ -229,12 +229,14 @@ void nrf_profile::display() { ...@@ -229,12 +229,14 @@ void nrf_profile::display() {
for (auto s : snssais) { for (auto s : snssais) {
Logger::nrf_app().debug("\tNNSSAI(SST, SD): %d, %s", s.sST, s.sD.c_str()); Logger::nrf_app().debug("\tNNSSAI(SST, SD): %d, %s", s.sST, s.sD.c_str());
} }
if (!fqdn.empty()) {
Logger::nrf_app().debug("\tFQDN: %s", fqdn.c_str());
}
// IPv4 Addresses // IPv4 Addresses
for (auto address : ipv4_addresses) { for (auto address : ipv4_addresses) {
Logger::nrf_app().debug("\tIPv4 Addr: %s", inet_ntoa(address)); Logger::nrf_app().debug("\tIPv4 Addr: %s", inet_ntoa(address));
} }
// ToDo : For ipv6 addresses
if (!json_data.empty()) { if (!json_data.empty()) {
Logger::nrf_app().debug("\tJson Data: %s", json_data.dump().c_str()); Logger::nrf_app().debug("\tJson Data: %s", json_data.dump().c_str());
} }
...@@ -405,7 +407,7 @@ bool nrf_profile::add_profile_info( ...@@ -405,7 +407,7 @@ bool nrf_profile::add_profile_info(
std::string address = value; std::string address = value;
struct in6_addr addr6 = {}; struct in6_addr addr6 = {};
unsigned char buf_in_addr[sizeof(struct in6_addr)]; unsigned char buf_in_addr[sizeof(struct in6_addr)];
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) { if (inet_pton(AF_INET6, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr6, buf_in_addr, sizeof(struct in6_addr)); memcpy(&addr6, buf_in_addr, sizeof(struct in6_addr));
} else { } else {
Logger::nrf_app().warn( Logger::nrf_app().warn(
......
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