Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
4a0e1afd
Commit
4a0e1afd
authored
Jan 12, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue for multi curl
parent
14dcfd4d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
67 deletions
+85
-67
src/common/nrf.h
src/common/nrf.h
+3
-1
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+8
-0
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+1
-6
src/nrf_app/nrf_client.cpp
src/nrf_app/nrf_client.cpp
+62
-53
src/nrf_app/nrf_client.hpp
src/nrf_app/nrf_client.hpp
+7
-4
test/cmd.txt
test/cmd.txt
+4
-3
No files found.
src/common/nrf.h
View file @
4a0e1afd
...
...
@@ -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
src/nrf_app/nrf_app.cpp
View file @
4a0e1afd
...
...
@@ -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
()());
...
...
src/nrf_app/nrf_app.hpp
View file @
4a0e1afd
...
...
@@ -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
...
...
src/nrf_app/nrf_client.cpp
View file @
4a0e1afd
This diff is collapsed.
Click to expand it.
src/nrf_app/nrf_client.hpp
View file @
4a0e1afd
...
...
@@ -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
...
...
test/cmd.txt
View file @
4a0e1afd
...
...
@@ -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":"A
MF"} } }'
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":"S
MF"} } }'
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment