Commit 8374ce73 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup

parent d04c26e4
......@@ -181,10 +181,14 @@ void conv::plmnToMccMnc(
//------------------------------------------------------------------------------
struct in_addr conv::fromString(const std::string addr4) {
unsigned char buf[sizeof(struct in6_addr)] = {};
int s = inet_pton(AF_INET, addr4.c_str(), buf);
struct in_addr* ia = (struct in_addr*) buf;
return *ia;
struct in_addr ipv4_addr;
ipv4_addr.s_addr = INADDR_ANY;
if (inet_pton(AF_INET, addr4.c_str(), buf) == 1) {
memcpy(&ipv4_addr, buf, sizeof(struct in_addr));
}
return ipv4_addr;
}
//------------------------------------------------------------------------------
std::string conv::toString(const struct in_addr& inaddr) {
std::string s = {};
......
......@@ -97,11 +97,7 @@ bool fqdn::resolve(pfcp::node_id_t& node_id) {
}
switch (addr_type) {
case 0: {
if (inet_aton(util::trim(ip_addr_str).c_str(), &ipv4_addr) == 0) {
Logger::smf_app().debug("Bad IPv4 Addr format for UPF");
return false;
}
node_id.u1.ipv4_address.s_addr = ipv4_addr.s_addr;
node_id.u1.ipv4_address.s_addr = conv::fromString(ip_addr_str).s_addr;
Logger::smf_app().debug(
"Resolve FQDN %s, IP Addr %s", node_id.fqdn.c_str(),
ip_addr_str.c_str());
......
......@@ -331,7 +331,7 @@ struct edge {
if (!snssai_dnns.empty()) {
output.append("S-NSSAI UPF info list: { ");
for (const auto& s : snssai_dnns) {
output.append(" " + s.to_string() + ", ");
output.append(" ").append(s.to_string()).append(", ");
}
output.append("}");
}
......
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