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
10c9bccf
Commit
10c9bccf
authored
Jan 12, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup/polish
parent
709b6f4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
29 deletions
+31
-29
etc/nrf.conf
etc/nrf.conf
+1
-1
src/oai-nrf/main.cpp
src/oai-nrf/main.cpp
+26
-24
test/subscription/create_subscription.cpp
test/subscription/create_subscription.cpp
+4
-4
No files found.
etc/nrf.conf
View file @
10c9bccf
...
...
@@ -32,7 +32,7 @@ NRF =
IPV4_ADDRESS
=
"read"
;
PORT
= @
NRF_INTERFACE_PORT_FOR_SBI
@;
# YOUR NETWORK CONFIG HERE (default: 80)
HTTP2_PORT
= @
NRF_INTERFACE_HTTP2_PORT_FOR_SBI
@;
# YOUR NETWORK CONFIG HERE
API_VERSION
=
"@NRF_API_VERSION@"
;
# YOUR NRF API VERSION CONFIG HERE
API_VERSION
=
"@NRF_API_VERSION@"
;
# YOUR NRF API VERSION CONFIG HERE
};
};
...
...
src/oai-nrf/main.cpp
View file @
10c9bccf
...
...
@@ -14,23 +14,23 @@
* limitations under the License.
*/
#include "
nrf_app
.hpp"
#include "
logger
.hpp"
#include "nrf-api-server.h"
#include "nrf_app.hpp"
#include "nrf_client.hpp"
#include "options.hpp"
#include "pid_file.hpp"
#include "logger.hpp"
#include "nrf_client.hpp"
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
#include <iostream>
#include <thread>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <stdlib.h> // srand
#include <unistd.h> // get_pid(), pause()
#include <iostream>
#include <thread>
using
namespace
oai
::
nrf
::
app
;
using
namespace
util
;
...
...
@@ -42,7 +42,6 @@ NRFApiServer *api_server = nullptr;
//------------------------------------------------------------------------------
void
my_app_signal_handler
(
int
s
)
{
std
::
cout
<<
"Caught signal "
<<
s
<<
std
::
endl
;
Logger
::
system
().
startup
(
"exiting"
);
std
::
cout
<<
"Freeing Allocated memory..."
<<
std
::
endl
;
...
...
@@ -51,12 +50,14 @@ void my_app_signal_handler(int s) {
delete
api_server
;
api_server
=
nullptr
;
}
std
::
cout
<<
"NRF API Server memory done"
<<
std
::
endl
;
std
::
cout
<<
"NRF API Server memory done."
<<
std
::
endl
;
if
(
nrf_app_inst
)
if
(
nrf_app_inst
)
{
delete
nrf_app_inst
;
nrf_app_inst
=
nullptr
;
std
::
cout
<<
"NRF APP memory done."
<<
std
::
endl
;
nrf_app_inst
=
nullptr
;
}
std
::
cout
<<
"NRF APP memory done"
<<
std
::
endl
;
std
::
cout
<<
"Freeing allocated memory done"
<<
std
::
endl
;
exit
(
0
);
...
...
@@ -64,18 +65,17 @@ void my_app_signal_handler(int s) {
//------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
srand
(
time
(
NULL
));
srand
(
time
(
NULL
));
// Command line options
if
(
!
Options
::
parse
(
argc
,
argv
)
)
{
if
(
!
Options
::
parse
(
argc
,
argv
))
{
std
::
cout
<<
"Options::parse() failed"
<<
std
::
endl
;
return
1
;
}
// Logger
Logger
::
init
(
"nrf"
,
Options
::
getlogStdout
()
,
Options
::
getlogRotFilelog
());
Logger
::
nrf_app
().
startup
(
"Options parsed"
);
Logger
::
init
(
"nrf"
,
Options
::
getlogStdout
()
,
Options
::
getlogRotFilelog
());
Logger
::
nrf_app
().
startup
(
"Options parsed"
);
struct
sigaction
sigIntHandler
;
sigIntHandler
.
sa_handler
=
my_app_signal_handler
;
...
...
@@ -87,26 +87,28 @@ if ( !Options::parse( argc, argv ) )
nrf_cfg
.
load
(
Options
::
getlibconfigConfig
());
nrf_cfg
.
display
();
//Event subsystem
//
Event subsystem
nrf_event
ev
;
// NRF application layer
nrf_app_inst
=
new
nrf_app
(
Options
::
getlibconfigConfig
(),
ev
);
//Task Manager
//
Task Manager
task_manager
tm
(
ev
);
std
::
thread
task_manager_thread
(
&
task_manager
::
run
,
&
tm
);
// PID file
// Currently hard-coded value. TODO: add as config option.
string
pid_file_name
=
get_exe_absolute_path
(
"/var/run"
,
nrf_cfg
.
instance
);
if
(
!
is_pid_file_lock_success
(
pid_file_name
.
c_str
()))
{
Logger
::
nrf_app
().
error
(
"Lock PID file %s failed
\n
"
,
pid_file_name
.
c_str
());
exit
(
-
EDEADLK
);
if
(
!
is_pid_file_lock_success
(
pid_file_name
.
c_str
()))
{
Logger
::
nrf_app
().
error
(
"Lock PID file %s failed
\n
"
,
pid_file_name
.
c_str
());
exit
(
-
EDEADLK
);
}
//NRF Pistache API server (HTTP1)
Pistache
::
Address
addr
(
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
nrf_cfg
.
sbi
.
addr4
)))
,
Pistache
::
Port
(
nrf_cfg
.
sbi
.
port
));
// NRF Pistache API server (HTTP1)
Pistache
::
Address
addr
(
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
nrf_cfg
.
sbi
.
addr4
))),
Pistache
::
Port
(
nrf_cfg
.
sbi
.
port
));
api_server
=
new
NRFApiServer
(
addr
,
nrf_app_inst
);
api_server
->
init
(
2
);
std
::
thread
nrf_manager
(
&
NRFApiServer
::
start
,
api_server
);
...
...
test/subscription/create_subscription.cpp
View file @
10c9bccf
...
...
@@ -42,6 +42,7 @@ static std::size_t callback(const char *in, std::size_t size, std::size_t num,
out
->
append
(
in
,
totalBytes
);
return
totalBytes
;
}
//------------------------------------------------------------------------------
bool
send_curl
(
std
::
string
url
)
{
long
httpCode
=
{
0
};
...
...
@@ -74,15 +75,12 @@ bool send_curl(std::string url) {
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
NF_CURL_TIMEOUT_MS
);
std
::
unique_ptr
<
std
::
string
>
httpData
(
new
std
::
string
());
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
&
callback
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
httpData
.
get
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
body
.
length
());
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body
.
c_str
());
res
=
curl_easy_perform
(
curl
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
httpCode
);
curl_easy_cleanup
(
curl
);
...
...
@@ -90,6 +88,7 @@ bool send_curl(std::string url) {
curl_global_cleanup
();
}
//------------------------------------------------------------------------------
void
send_curl_multi
(
std
::
string
url
,
uint32_t
n
)
{
int
still_running
=
0
,
numfds
=
0
,
res
=
0
,
msgs_left
=
0
;
CURLMsg
*
curl_msg
=
nullptr
;
...
...
@@ -199,6 +198,7 @@ void send_curl_multi(std::string url, uint32_t n) {
curl_global_cleanup
();
curl_slist_free_all
(
headers
);
}
//------------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
bool
cont
=
false
;
...
...
@@ -208,7 +208,7 @@ int main(int argc, char *argv[]) {
std
::
string
type
=
"Content-Type: application/json"
;
std
::
string
url
=
"http://192.168.1.23:8080/nnrf-nfm/v1/subscriptions"
;
// send_curl(url);
uint32_t
number_subscriptions
=
2
00
;
uint32_t
number_subscriptions
=
1
00
;
std
::
cout
<<
"Number of subscriptions: "
<<
number_subscriptions
<<
std
::
endl
;
std
::
cout
<<
"Sending..."
<<
std
::
endl
;
send_curl_multi
(
url
,
number_subscriptions
);
...
...
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