Verified Commit 53b348bd authored by Rohan's avatar Rohan
Browse files

fix for ipv6

parent 6b57e049
Pipeline #25994 passed with stage
in 0 seconds
......@@ -87,21 +87,40 @@ bool api_conv::profile_api_to_nrf_profile(
profile.get()->set_fqdn(api_profile.getFqdn());
Logger::nrf_app().debug("\tFQDN: %s", api_profile.getFqdn().c_str());
}
std::vector<std::string> ipv4_addr_str = api_profile.getIpv4Addresses();
for (auto address : ipv4_addr_str) {
struct in_addr addr4 = {};
unsigned char buf_in_addr[sizeof(struct in_addr)];
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::nrf_app().warn(
"Address conversion: Bad value %s", util::trim(address).c_str());
}
if (api_profile.ipv4AddressesIsSet()) {
std::vector<std::string> ipv4_addr_str = api_profile.getIpv4Addresses();
for (auto address : ipv4_addr_str) {
struct in_addr addr4 = {};
unsigned char buf_in_addr[sizeof(struct in_addr)];
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::nrf_app().warn(
"Address conversion: Bad value %s", util::trim(address).c_str());
}
Logger::nrf_app().debug("\tIPv4 Addr: %s", address.c_str());
profile.get()->add_nf_ipv4_addresses(addr4);
Logger::nrf_app().debug("\tIPv4 Addr: %s", address.c_str());
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());
......
......@@ -229,12 +229,14 @@ void nrf_profile::display() {
for (auto s : snssais) {
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
for (auto address : ipv4_addresses) {
Logger::nrf_app().debug("\tIPv4 Addr: %s", inet_ntoa(address));
}
// ToDo : For ipv6 addresses
if (!json_data.empty()) {
Logger::nrf_app().debug("\tJson Data: %s", json_data.dump().c_str());
}
......@@ -405,7 +407,7 @@ bool nrf_profile::add_profile_info(
std::string address = value;
struct in6_addr addr6 = {};
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));
} else {
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