Commit 336a7f03 authored by kharade's avatar kharade

profile update for attribute Ip Endpoint

parent b8df9909
......@@ -23,6 +23,8 @@
#define FILE_3GPP_29_510_NRF_SEEN
#include <vector>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "3gpp_23.003.h"
enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 };
......@@ -304,12 +306,30 @@ typedef struct nf_service_version_s {
}
} nf_service_version_t;
typedef struct ip_endpoint_s {
// struct in6_addr ipv6_address;
struct in_addr ipv4_address;
std::string transport; // TCP
unsigned int port;
std::string to_string() const {
std::string s = {};
s.append("Ipv4 Address: ");
s.append(inet_ntoa(ipv4_address));
s.append(", TransportProtocol: ");
s.append(transport);
s.append(", Port: ");
s.append(std::to_string(port));
return s;
}
} ip_endpoint_t;
typedef struct nf_service_s {
std::string service_instance_id;
std::string service_name;
std::vector<nf_service_version_t> versions;
std::string scheme;
std::string nf_service_status;
std::vector<ip_endpoint_t> ip_endpoints;
std::string to_string() const {
std::string s = {};
......@@ -324,6 +344,10 @@ typedef struct nf_service_s {
s.append(scheme);
s.append(", Service status: ");
s.append(nf_service_status);
s.append(", IpEndPoints: ");
for (auto endpoint : ip_endpoints) {
s.append(endpoint.to_string());
}
return s;
}
} nf_service_t;
......
......@@ -46,6 +46,7 @@
#include "logger.hpp"
#include "nrf.h"
#include "string.hpp"
#include "common_defs.h"
using namespace oai::nrf::model;
using namespace oai::nrf::app;
......@@ -332,6 +333,16 @@ bool api_conv::profile_api_to_nrf_profile(
ns.versions.push_back(version);
}
ns.nf_service_status = service.getNfServiceStatus();
if (service.ipEndPointsIsSet()) {
for (auto v : service.getIpEndPoints()) {
ip_endpoint_t ip_end;
IPV4_STR_ADDR_TO_INADDR(
v.getIpv4Address().c_str(), ip_end.ipv4_address, "");
ip_end.port = v.getPort();
//ip_end.transport = v.getTransport();
ns.ip_endpoints.push_back(ip_end);
}
}
profile.get()->add_nf_service(ns);
}
}
......
......@@ -608,6 +608,17 @@ void nrf_profile::to_json(nlohmann::json& data) const {
}
srv_tmp["scheme"] = service.scheme;
srv_tmp["nfServiceStatus"] = service.nf_service_status;
if (!service.ip_endpoints.empty()) {
// IP endpoints
srv_tmp["ipEndPoints"] = nlohmann::json::array();
for (auto endpoint : service.ip_endpoints) {
nlohmann::json ep_tmp = {};
ep_tmp["ipv4Address"] = inet_ntoa(endpoint.ipv4_address);
ep_tmp["transport"] = endpoint.transport;
ep_tmp["port"] = endpoint.port;
srv_tmp["ipEndPoints"].push_back(ep_tmp);
}
}
data["nfServices"].push_back(srv_tmp);
}
data["json_data"] = json_data;
......
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