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; ...@@ -79,6 +79,8 @@ typedef uint32_t evsub_id_t;
#define NNRF_NFM_BASE "/nnrf-nfm/" #define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NFM_NF_INSTANCE "/nf-instances/" #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 #endif
...@@ -80,6 +80,14 @@ nrf_app::nrf_app(const std::string &config_file, nrf_event &ev) ...@@ -80,6 +80,14 @@ nrf_app::nrf_app(const std::string &config_file, nrf_event &ev)
Logger::nrf_app().startup("Started"); 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() { void nrf_app::generate_uuid() {
nrf_instance_id = to_string(boost::uuids::random_generator()()); nrf_instance_id = to_string(boost::uuids::random_generator()());
......
...@@ -54,12 +54,7 @@ class nrf_app { ...@@ -54,12 +54,7 @@ class nrf_app {
nrf_app(nrf_app const &) = delete; nrf_app(nrf_app const &) = delete;
void operator=(nrf_app const &) = delete; void operator=(nrf_app const &) = delete;
virtual ~nrf_app() { virtual ~nrf_app();
Logger::nrf_app().debug("Delete NRF_APP instance...");
for (auto i : connections) {
if (i.connected()) i.disconnect();
}
}
/* /*
* Generate a random UUID for NRF instance * Generate a random UUID for NRF instance
......
This diff is collapsed.
...@@ -43,6 +43,7 @@ class nrf_client { ...@@ -43,6 +43,7 @@ class nrf_client {
private: private:
CURLM *curl_multi; CURLM *curl_multi;
std::vector<CURL *> handles; std::vector<CURL *> handles;
struct curl_slist *headers;
nrf_event &m_event_sub; nrf_event &m_event_sub;
bs2::connection bs2::connection
task_connection; // connection for performing curl_multi every 1ms task_connection; // connection for performing curl_multi every 1ms
...@@ -50,6 +51,7 @@ class nrf_client { ...@@ -50,6 +51,7 @@ class nrf_client {
public: public:
nrf_client(nrf_event &ev); nrf_client(nrf_event &ev);
virtual ~nrf_client(); virtual ~nrf_client();
nrf_client(nrf_client const &) = delete; nrf_client(nrf_client const &) = delete;
void operator=(nrf_client const &) = delete; void operator=(nrf_client const &) = delete;
...@@ -62,16 +64,17 @@ class nrf_client { ...@@ -62,16 +64,17 @@ class nrf_client {
void notify_subscribed_event(const std::shared_ptr<nrf_profile> &profile, void notify_subscribed_event(const std::shared_ptr<nrf_profile> &profile,
const std::string &uri); const std::string &uri);
/* /*
* Send Notification for the associated event to the subscriber * Send Notification for the associated event to the subscriber
* @param [const std::shared_ptr<nrf_profile> &] profile: NF profile * @param [const std::shared_ptr<nrf_profile> &] profile: NF profile
* @param [const std::string &] uri: URI of the subscribed NF * @param [const std::string &] uri: URI of the subscribed NF
* @return void * @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::shared_ptr<nrf_profile> &profile, const uint8_t &event_type,
const std::vector<std::string> &uris); const std::vector<std::string> &uris);
*/
/* /*
* Send Notification for the associated event to the subscribers * Send Notification for the associated event to the subscribers
......
...@@ -9,17 +9,18 @@ curl -X GET "http://192.168.1.23/nnrf-nfm/v1/nf-instances/ ...@@ -9,17 +9,18 @@ curl -X GET "http://192.168.1.23/nnrf-nfm/v1/nf-instances/
#Update #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 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": {"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 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"}]' 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 #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 #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 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