Commit 9086eece authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Tentative fix for OC

parent 74e79f24
...@@ -1011,6 +1011,7 @@ typedef struct fseid_s { ...@@ -1011,6 +1011,7 @@ typedef struct fseid_s {
// 8.2.38 Node ID // 8.2.38 Node ID
enum node_id_type_value_e { enum node_id_type_value_e {
/* Request / Initial message */ /* Request / Initial message */
NODE_ID_TYPE_UNKNOWN = -1,
NODE_ID_TYPE_IPV4_ADDRESS = 0, NODE_ID_TYPE_IPV4_ADDRESS = 0,
NODE_ID_TYPE_IPV6_ADDRESS = 1, NODE_ID_TYPE_IPV6_ADDRESS = 1,
NODE_ID_TYPE_FQDN = 2, NODE_ID_TYPE_FQDN = 2,
...@@ -1025,6 +1026,32 @@ struct node_id_s { ...@@ -1025,6 +1026,32 @@ struct node_id_s {
} u1; } u1;
std::string fqdn; // should be in union but problem with virtual ~ std::string fqdn; // should be in union but problem with virtual ~
bool operator==(const struct node_id_s& i) const { bool operator==(const struct node_id_s& i) const {
if (i.node_id_type != this->node_id_type) return false;
switch (i.node_id_type) {
case NODE_ID_TYPE_IPV4_ADDRESS: {
if (i.u1.ipv4_address.s_addr == this->u1.ipv4_address.s_addr)
return true;
} break;
case NODE_ID_TYPE_IPV6_ADDRESS: {
if ((i.u1.ipv6_address.s6_addr32[0] ==
this->u1.ipv6_address.s6_addr32[0]) &&
(i.u1.ipv6_address.s6_addr32[1] ==
this->u1.ipv6_address.s6_addr32[1]) &&
(i.u1.ipv6_address.s6_addr32[2] ==
this->u1.ipv6_address.s6_addr32[2]) &&
(i.u1.ipv6_address.s6_addr32[3] ==
this->u1.ipv6_address.s6_addr32[3]))
return true;
} break;
case NODE_ID_TYPE_FQDN: {
if (i.fqdn == this->fqdn) return true;
} break;
default: {
return false;
}
}
/*
if ((i.node_id_type == this->node_id_type) && if ((i.node_id_type == this->node_id_type) &&
(i.u1.ipv4_address.s_addr == this->u1.ipv4_address.s_addr) && (i.u1.ipv4_address.s_addr == this->u1.ipv4_address.s_addr) &&
(i.fqdn == this->fqdn) && (i.fqdn == this->fqdn) &&
...@@ -1040,6 +1067,7 @@ struct node_id_s { ...@@ -1040,6 +1067,7 @@ struct node_id_s {
} else { } else {
return false; return false;
} }
*/
}; };
bool operator==(const std::string& f) const { bool operator==(const std::string& f) const {
if ((NODE_ID_TYPE_FQDN == this->node_id_type) && (fqdn.compare(f) == 0)) { if ((NODE_ID_TYPE_FQDN == this->node_id_type) && (fqdn.compare(f) == 0)) {
......
...@@ -1323,6 +1323,9 @@ bool smf_app::handle_nf_status_notification( ...@@ -1323,6 +1323,9 @@ bool smf_app::handle_nf_status_notification(
std::vector<struct in_addr> ipv4_addrs = {}; std::vector<struct in_addr> ipv4_addrs = {};
profile.get()->get_nf_ipv4_addresses(ipv4_addrs); profile.get()->get_nf_ipv4_addresses(ipv4_addrs);
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_UNKNOWN;
// Use FQDN if available // Use FQDN if available
if (!upf_fqdn.empty()) { if (!upf_fqdn.empty()) {
uint8_t addr_type = {0}; uint8_t addr_type = {0};
...@@ -1336,7 +1339,6 @@ bool smf_app::handle_nf_status_notification( ...@@ -1336,7 +1339,6 @@ bool smf_app::handle_nf_status_notification(
Logger::smf_app().debug("Do not support IPv6 addr for UPF"); Logger::smf_app().debug("Do not support IPv6 addr for UPF");
return false; return false;
} else { // IPv4 } else { // IPv4
if (inet_aton(util::trim(address).c_str(), &upf_ipv4_addr) == 0) { if (inet_aton(util::trim(address).c_str(), &upf_ipv4_addr) == 0) {
Logger::smf_app().debug("Bad IPv4 Addr format for UPF"); Logger::smf_app().debug("Bad IPv4 Addr format for UPF");
return false; return false;
...@@ -1354,24 +1356,20 @@ bool smf_app::handle_nf_status_notification( ...@@ -1354,24 +1356,20 @@ bool smf_app::handle_nf_status_notification(
// Add a new UPF node // Add a new UPF node
Logger::smf_app().debug( Logger::smf_app().debug(
"Add a new UPF node, FQDN %s", upf_fqdn.c_str()); "Add a new UPF node, FQDN %s", upf_fqdn.c_str());
pfcp::node_id_t n = {}; // pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_FQDN; n.node_id_type = pfcp::NODE_ID_TYPE_FQDN;
n.fqdn = upf_fqdn; n.fqdn = upf_fqdn;
n.u1.ipv4_address.s_addr = n.u1.ipv4_address.s_addr =
upf_ipv4_addr upf_ipv4_addr
.s_addr; // Normally we should not do that, but ok since we .s_addr; // Normally we should not do that, but ok since we
// keep both fqdn and IPv4 at the same time // keep both fqdn and IPv4 at the same time
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
} else { } else {
Logger::smf_app().debug( Logger::smf_app().debug(
"UPF node already exist (%s)", address.c_str()); "UPF node already exist (%s)", address.c_str());
} }
} else if (ipv4_addrs.size() >= 1) { // If FQDN isn't available, check }
// IP address
if (ipv4_addrs.size() >= 1) { // Use IP address if it's available
bool found = false; bool found = false;
for (auto node : smf_cfg.upfs) { for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) { if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
...@@ -1383,18 +1381,26 @@ bool smf_app::handle_nf_status_notification( ...@@ -1383,18 +1381,26 @@ bool smf_app::handle_nf_status_notification(
// Add a new UPF node // Add a new UPF node
Logger::smf_app().debug( Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0])); "Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {}; // pfcp::node_id_t n = {};
if (n.node_id_type == pfcp::NODE_ID_TYPE_UNKNOWN)
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS; n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr; n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
smf_cfg.upfs.push_back(n); /*smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile = upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get()); dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile)); start_upf_association(n, std::ref(*upf_node_profile));
*/
} else { } else {
Logger::smf_app().debug( Logger::smf_app().debug(
"UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0])); "UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0]));
} }
}
if (n.node_id_type != pfcp::NODE_ID_TYPE_UNKNOWN) {
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
} else { } else {
Logger::smf_app().debug("No IP Addr/FQDN found"); Logger::smf_app().debug("No IP Addr/FQDN found");
return false; return false;
......
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