Commit 4a0e1afd authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Fix issue for multi curl

parent 14dcfd4d
......@@ -79,6 +79,8 @@ typedef uint32_t evsub_id_t;
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NFM_NF_INSTANCE "/nf-instances/"
#define MAX_WAIT_MSECS 1000 //1 second
#define NF_CURL_TIMEOUT_MS 1000L
#define MAX_WAIT_MSECS 20000 //1 second
#endif
......@@ -80,6 +80,14 @@ nrf_app::nrf_app(const std::string &config_file, nrf_event &ev)
Logger::nrf_app().startup("Started");
}
nrf_app::~nrf_app() {
Logger::nrf_app().debug("Delete NRF_APP instance...");
for (auto i : connections) {
if (i.connected()) i.disconnect();
}
if (nrf_client_inst) delete nrf_client_inst;
}
//------------------------------------------------------------------------------
void nrf_app::generate_uuid() {
nrf_instance_id = to_string(boost::uuids::random_generator()());
......
......@@ -54,12 +54,7 @@ class nrf_app {
nrf_app(nrf_app const &) = delete;
void operator=(nrf_app const &) = delete;
virtual ~nrf_app() {
Logger::nrf_app().debug("Delete NRF_APP instance...");
for (auto i : connections) {
if (i.connected()) i.disconnect();
}
}
virtual ~nrf_app();
/*
* Generate a random UUID for NRF instance
......
This diff is collapsed.
......@@ -43,6 +43,7 @@ class nrf_client {
private:
CURLM *curl_multi;
std::vector<CURL *> handles;
struct curl_slist *headers;
nrf_event &m_event_sub;
bs2::connection
task_connection; // connection for performing curl_multi every 1ms
......@@ -50,6 +51,7 @@ class nrf_client {
public:
nrf_client(nrf_event &ev);
virtual ~nrf_client();
nrf_client(nrf_client const &) = delete;
void operator=(nrf_client const &) = delete;
......@@ -62,16 +64,17 @@ class nrf_client {
void notify_subscribed_event(const std::shared_ptr<nrf_profile> &profile,
const std::string &uri);
/*
* Send Notification for the associated event to the subscriber
* @param [const std::shared_ptr<nrf_profile> &] profile: NF profile
* @param [const std::string &] uri: URI of the subscribed NF
* @return void
*/
/* void notify_subscribed_event_with_curl_multi(
void notify_subscribed_event_multi(
const std::shared_ptr<nrf_profile> &profile, const uint8_t &event_type,
const std::vector<std::string> &uris);
*/
/*
* Send Notification for the associated event to the subscribers
......@@ -92,7 +95,7 @@ class nrf_client {
* @return pointer to the created curl
*/
CURL *curl_create_handle(const std::string &uri, const std::string &data,
std::string &response_data);
std::string &response_data);
/*
* Prepare to send a request using curl multi
......@@ -102,7 +105,7 @@ class nrf_client {
* @return void
*/
void send_curl_multi(const std::string &uri, const std::string &data,
std::string &response_data);
std::string &response_data);
/*
* Perform curl multi to actually process the available data
......
......@@ -9,17 +9,18 @@ curl -X GET "http://192.168.1.23/nnrf-nfm/v1/nf-instances/
#Update
curl -X PATCH -H "Content-Type: application/json" http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d -d '[{"op":"replace","path":"/nfInstanceName", "value": "NEW NAME"}]'
curl -X POST http://192.168.1.23/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"NfTypeCond": {"nfType":"AMF"} } }'
curl -X POST http://192.168.1.23:8080/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23:8080/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"NfTypeCond": {"nfType":"SMF"} } }'
curl -X POST http://192.168.1.23/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"NfInstanceIdCond": {"nfInstanceId":"AMF"} } }'
curl -X POST http://192.168.1.23/nnrf-nfm/v1/subscriptions -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"NfTypeCond": {"nfType":"AMF"} } }'
curl -X POST -H "Content-Type: application/json" "http://192.168.1.23/nnrf-nfm/v1/subscriptions" -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-nfm/v1/nf-instances/343a924e-6494-4927-860b-d45692c95c2d", "subscrCond": {"NfTypeCond": {"nfType":"AMF"}}, "reqNotifEvents":["NF_REGISTERED", "NF_DEREGISTERED"], "validityTime":"20020131T235959" }'
#Suscription
curl -X POST -H "Content-Type: application/json" "http://192.168.1.23:8080/nnrf-nfm/v1/subscriptions" -d '{"nfStatusNotificationUri":"http://192.168.1.23/nnrf-disc/v1/nf-instances?target-nf-type=SMF&requester-nf-type=AMF", "subscrCond": {"NfTypeCond": {"nfType":"SMF"}}, "reqNotifEvents":["NF_REGISTERED", "NF_DEREGISTERED"], "validityTime":"20210531T235959" }'
curl -X PATCH -H "Content-Type: application/json" http://192.168.1.23/nnrf-nfm/v1/subscriptions/1 -d '[{"op":"replace","path":"/validityTime", "value": "20201231T235959"}]'
#Discovery
curl -X GET "http://192.168.1.23/nnrf-disc/v1/nf-instances?target-nf-type="SMF"&requester-nf-type="AMF""
curl -X GET "http://192.168.1.23/nnrf-disc/v1/nf-instances?target-nf-type=SMF&requester-nf-type=AMF"
#Access Token
curl -d "grant_type=client_credentials&nfInstanceId=343a924e-6494-4927-860b-d45692c95c2d&scope=nsmf-pdusession" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://192.168.1.23/oauth2/token
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