Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AUSF
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-AUSF
Commits
7a0439d6
Commit
7a0439d6
authored
Jul 15, 2021
by
Niuhaiwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some bug of heart-beat
parent
b274d6d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
1 deletion
+106
-1
src/ausf_app/ausf_app.cpp
src/ausf_app/ausf_app.cpp
+91
-1
src/ausf_app/ausf_app.hpp
src/ausf_app/ausf_app.hpp
+1
-0
src/itti/itti_msg.hpp
src/itti/itti_msg.hpp
+1
-0
src/itti/itti_msg_sbi.hpp
src/itti/itti_msg_sbi.hpp
+13
-0
No files found.
src/ausf_app/ausf_app.cpp
View file @
7a0439d6
...
...
@@ -53,6 +53,10 @@ void ausf_app_task(void*){
ausf_app_inst
->
handle_itti_msg
(
std
::
ref
(
*
m
));
}
break
;
case
SBI_UPDATE_NF_INSTANCE_REQUEST
:
Logger
::
ausf_app
().
debug
(
"send update request"
);
ausf_app_inst
->
update_nf_instance
(
std
::
static_pointer_cast
<
itti_n11_update_nf_instance_request
>
(
shared_msg
));
break
;
case
TIME_OUT
:
if
(
itti_msg_timeout
*
to
=
dynamic_cast
<
itti_msg_timeout
*>
(
msg
))
{
...
...
@@ -278,3 +282,89 @@ void ausf_app::handle_itti_msg(itti_sbi_register_nf_instance_response& r) {
TASK_AUSF_APP_TIMEOUT_NRF_HEARTBEAT,
0);*/
// TODO arg2_user
}
void
ausf_app
::
update_nf_instance
(
std
::
shared_ptr
<
itti_n11_update_nf_instance_request
>
msg
)
{
Logger
::
ausf_app
().
debug
(
"Send NF Update to NRF (HTTP version %d)"
,
msg
->
http_version
);
nlohmann
::
json
json_data
=
nlohmann
::
json
::
array
();
for
(
auto
i
:
msg
->
patch_items
)
{
nlohmann
::
json
item
=
{};
to_json
(
item
,
i
);
json_data
.
push_back
(
item
);
}
std
::
string
body
=
json_data
.
dump
();
Logger
::
ausf_app
().
debug
(
"Send NF Update to NRF, Msg body %s"
,
body
.
c_str
());
std
::
string
url
=
std
::
string
(
inet_ntoa
(
*
((
struct
in_addr
*
)
&
ausf_cfg
.
nnrf
.
addr4
)))
+
":"
+
std
::
to_string
(
ausf_cfg
.
nnrf
.
port
)
+
"/nnrf-nfm/"
+
ausf_cfg
.
nnrf
.
api_version
+
"/nf-instances/"
+
msg
->
ausf_instance_id
;
Logger
::
ausf_app
().
debug
(
"Send NF Update to NRF, NRF URL %s"
,
url
.
c_str
());
curl_global_init
(
CURL_GLOBAL_ALL
);
CURL
*
curl
=
curl
=
curl_easy_init
();
if
(
curl
)
{
CURLcode
res
=
{};
struct
curl_slist
*
headers
=
nullptr
;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers
=
curl_slist_append
(
headers
,
"content-type: application/json"
);
// TODO: json-patch+json
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
headers
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_HTTPGET
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"PATCH"
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT_MS
,
100L
);
if
(
msg
->
http_version
==
2
)
{
curl_easy_setopt
(
curl
,
CURLOPT_VERBOSE
,
1L
);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYPEER
,
0L
);
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYHOST
,
0L
);
curl_easy_setopt
(
curl
,
CURLOPT_HTTP_VERSION
,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE
);
}
// Response information.
long
httpCode
=
{
0
};
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
);
Logger
::
ausf_app
().
debug
(
"NF Update, response from NRF, HTTP Code: %d"
,
httpCode
);
if
(
httpCode
==
200
||
httpCode
==
204
)
{
Logger
::
ausf_app
().
debug
(
"NF Update, got successful response from NRF"
);
// TODO: in case of response containing NF profile
// send response to APP to process
std
::
shared_ptr
<
itti_sbi_update_nf_instance_response
>
itti_msg
=
std
::
make_shared
<
itti_sbi_update_nf_instance_response
>
(
TASK_AUSF_APP
,
TASK_AUSF_APP
);
itti_msg
->
http_response_code
=
httpCode
;
itti_msg
->
http_version
=
msg
->
http_version
;
itti_msg
->
ausf_instance_id
=
msg
->
ausf_instance_id
;
/*int ret = itti_inst->send_msg(itti_msg);
if (0 != ret) {
Logger::ausf_app().error(
"Could not send ITTI message %s to task TASK_AUSF_APP",
itti_msg->get_msg_name());
}*/
}
else
{
Logger
::
ausf_app
().
warn
(
"NF Update, could not get response from NRF"
);
}
curl_slist_free_all
(
headers
);
curl_easy_cleanup
(
curl
);
}
curl_global_cleanup
();
}
\ No newline at end of file
src/ausf_app/ausf_app.hpp
View file @
7a0439d6
...
...
@@ -25,6 +25,7 @@ namespace ausf_application{
void
timer_nrf_heartbeat_timeout
(
timer_id_t
timer_id
,
uint64_t
arg2_user
);
void
register_nf_instance
(
std
::
shared_ptr
<
itti_sbi_register_nf_instance_request
>
msg
);
void
handle_itti_msg
(
itti_sbi_register_nf_instance_response
&
r
);
void
update_nf_instance
(
std
::
static_pointer_cast
<
itti_n11_update_nf_instance_request
>
msg
);
private:
std
::
string
ausf_instance_id
;
...
...
src/itti/itti_msg.hpp
View file @
7a0439d6
...
...
@@ -56,6 +56,7 @@ typedef enum {
SBI_REGISTER_NF_INSTANCE_REQUEST
,
SBI_REGISTER_NF_INSTANCE_RESPONSE
,
SBI_UPDATE_NF_INSTANCE_REQUEST
,
SBI_UPDATE_NF_INSTANCE_RESPONSE
,
TIME_OUT
,
HEALTH_PING
,
TERMINATE
,
...
...
src/itti/itti_msg_sbi.hpp
View file @
7a0439d6
...
...
@@ -58,4 +58,17 @@ class itti_sbi_update_nf_instance_request : public itti_sbi_msg {
uint8_t
http_version
;
std
::
string
ausf_instance_id
;
};
class
itti_sbi_update_nf_instance_response
:
public
itti_sbi_msg
{
public:
itti_sbi_update_nf_instance_response
(
const
task_id_t
orig
,
const
task_id_t
dest
)
:
itti_sbi_msg
(
SBI_UPDATE_NF_INSTANCE_RESPONSE
,
orig
,
dest
),
http_version
(
1
)
{}
const
char
*
get_msg_name
()
{
return
"SBI_UPDATE_NF_INSTANCE_RESPONSE"
;
};
uint8_t
http_version
;
std
::
string
ausf_instance_id
;
uint8_t
http_response_code
;
};
#endif
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