Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-Spgwu-Tiny-Simple
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
CommunityXG
OpenXG-Spgwu-Tiny-Simple
Commits
db6b092a
Commit
db6b092a
authored
Jan 14, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to send NF register/update to NRF
parent
ed7b3bb2
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
403 additions
and
105 deletions
+403
-105
etc/spgw_u.conf
etc/spgw_u.conf
+7
-0
src/common/3gpp_29.510.h
src/common/3gpp_29.510.h
+17
-0
src/spgwu/spgwu_app.cpp
src/spgwu/spgwu_app.cpp
+4
-0
src/spgwu/spgwu_app.hpp
src/spgwu/spgwu_app.hpp
+1
-0
src/spgwu/spgwu_config.cpp
src/spgwu/spgwu_config.cpp
+25
-0
src/spgwu/spgwu_config.hpp
src/spgwu/spgwu_config.hpp
+14
-0
src/spgwu/spgwu_nrf.cpp
src/spgwu/spgwu_nrf.cpp
+274
-102
src/spgwu/spgwu_nrf.hpp
src/spgwu/spgwu_nrf.hpp
+61
-3
No files found.
etc/spgw_u.conf
View file @
db6b092a
...
...
@@ -100,5 +100,12 @@ SPGW-U =
SPGW
-
C_LIST
= (
{
IPV4_ADDRESS
=
"@SPGWC0_IP_ADDRESS@"
;}
);
NRF
:
{
IPV4_ADDRESS
=
"@NRF_IPV4_ADDRESS@"
;
# YOUR NRF CONFIG HERE
PORT
= @
NRF_PORT
@;
# YOUR NRF CONFIG HERE (default: 80)
API_VERSION
=
"@NRF_API_VERSION@"
;
# YOUR NRF API VERSION FOR SBI CONFIG HERE
};
};
src/common/3gpp_29.510.h
View file @
db6b092a
...
...
@@ -23,6 +23,7 @@
#define FILE_3GPP_29_510_NRF_SEEN
#include <vector>
#include <nlohmann/json.hpp>
typedef
struct
s_nssai
// section 28.4, TS23.003
{
...
...
@@ -59,7 +60,23 @@ typedef struct upf_info_s {
std
::
vector
<
snssai_upf_info_item_t
>
snssai_upf_info_list
;
}
upf_info_t
;
typedef
struct
patch_item_s
{
std
::
string
op
;
std
::
string
path
;
// std::string from;
std
::
string
value
;
nlohmann
::
json
to_json
()
const
{
nlohmann
::
json
json_data
=
{};
json_data
[
"op"
]
=
op
;
json_data
[
"path"
]
=
path
;
json_data
[
"value"
]
=
value
;
return
json_data
;
}
}
patch_item_t
;
#define NRF_CURL_TIMEOUT_MS 100L
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NF_REGISTER_URL "/nf-instances/"
#endif
src/spgwu/spgwu_app.cpp
View file @
db6b092a
...
...
@@ -35,6 +35,8 @@
#include "spgwu_sx.hpp"
#include "spgwu_nrf.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <stdexcept>
using
namespace
pfcp
;
...
...
@@ -271,3 +273,5 @@ void spgwu_app::handle_itti_msg(
Logger
::
spgwu_app
().
info
(
"Received SXAB_SESSION_REPORT_RESPONSE seid "
SEID_FMT
" "
,
m
->
seid
);
}
src/spgwu/spgwu_app.hpp
View file @
db6b092a
...
...
@@ -80,6 +80,7 @@ class spgwu_app {
// void handle_itti_msg (itti_sxab_session_deletion_response& m);
// void handle_itti_msg (itti_sxab_session_report_request& m);
void
handle_itti_msg
(
std
::
shared_ptr
<
itti_sxab_session_report_response
>
m
);
};
}
// namespace spgwu
#endif
/* FILE_SPGWU_APP_HPP_SEEN */
src/spgwu/spgwu_config.cpp
View file @
db6b092a
...
...
@@ -453,6 +453,31 @@ int spgwu_config::load(const string& config_file) {
SPGWU_CONFIG_STRING_SPGWC_LIST
,
i
,
config_file
.
c_str
());
}
}
// NRF
const
Setting
&
nrf_cfg
=
spgwu_cfg
[
SPGWU_CONFIG_STRING_NRF
];
struct
in_addr
nrf_ipv4_addr
;
unsigned
int
nrf_port
=
0
;
std
::
string
nrf_api_version
;
string
nrf_address
=
{};
nrf_cfg
.
lookupValue
(
SPGWU_CONFIG_STRING_NRF_IPV4_ADDRESS
,
nrf_address
);
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
nrf_address
).
c_str
(),
nrf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NRF !"
);
nrf_addr
.
ipv4_addr
=
nrf_ipv4_addr
;
if
(
!
(
nrf_cfg
.
lookupValue
(
SPGWU_CONFIG_STRING_NRF_PORT
,
nrf_port
)))
{
Logger
::
spgwu_app
().
error
(
SPGWU_CONFIG_STRING_NRF_PORT
"failed"
);
throw
(
SPGWU_CONFIG_STRING_NRF_PORT
"failed"
);
}
nrf_addr
.
port
=
nrf_port
;
if
(
!
(
nrf_cfg
.
lookupValue
(
SPGWU_CONFIG_STRING_API_VERSION
,
nrf_api_version
)))
{
Logger
::
spgwu_app
().
error
(
SPGWU_CONFIG_STRING_API_VERSION
"failed"
);
throw
(
SPGWU_CONFIG_STRING_API_VERSION
"failed"
);
}
nrf_addr
.
api_version
=
nrf_api_version
;
}
catch
(
const
SettingNotFoundException
&
nfex
)
{
Logger
::
spgwu_app
().
error
(
"%s : %s"
,
nfex
.
what
(),
nfex
.
getPath
());
return
RETURNerror
;
...
...
src/spgwu/spgwu_config.hpp
View file @
db6b092a
...
...
@@ -63,6 +63,10 @@ namespace spgwu {
#define SPGWU_CONFIG_STRING_SNAT "SNAT"
#define SPGWU_CONFIG_STRING_MAX_PFCP_SESSIONS "MAX_PFCP_SESSIONS"
#define SPGWU_CONFIG_STRING_SPGWC_LIST "SPGW-C_LIST"
#define SPGWU_CONFIG_STRING_NRF "NRF"
#define SPGWU_CONFIG_STRING_NRF_IPV4_ADDRESS "IPV4_ADDRESS"
#define SPGWU_CONFIG_STRING_NRF_PORT "PORT"
#define SPGWU_CONFIG_STRING_API_VERSION "API_VERSION"
#define SPGWU_CONFIG_STRING_ITTI_TASKS "ITTI_TASKS"
#define SPGWU_CONFIG_STRING_ITTI_TIMER_SCHED_PARAMS "ITTI_TIMER_SCHED_PARAMS"
#define SPGWU_CONFIG_STRING_S1U_SCHED_PARAMS "S1U_SCHED_PARAMS"
...
...
@@ -124,6 +128,12 @@ class spgwu_config {
std
::
vector
<
pdn_cfg_t
>
pdns
;
std
::
vector
<
pfcp
::
node_id_t
>
spgwcs
;
struct
{
struct
in_addr
ipv4_addr
;
unsigned
int
port
;
std
::
string
api_version
;
}
nrf_addr
;
spgwu_config
()
:
m_rw_lock
(),
pid_dir
(),
...
...
@@ -149,6 +159,10 @@ class spgwu_config {
sx
.
thread_rd_sched_params
.
sched_priority
=
95
;
sx
.
port
=
pfcp
::
default_port
;
nrf_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
nrf_addr
.
port
=
80
;
nrf_addr
.
api_version
=
"v1"
;
};
void
lock
()
{
m_rw_lock
.
lock
();
};
void
unlock
()
{
m_rw_lock
.
unlock
();
};
...
...
src/spgwu/spgwu_nrf.cpp
View file @
db6b092a
This diff is collapsed.
Click to expand it.
src/spgwu/spgwu_nrf.hpp
View file @
db6b092a
...
...
@@ -32,19 +32,27 @@
#include <map>
#include <thread>
#include "itti.hpp"
#include <curl/curl.h>
#include "3gpp_29.510.h"
#include "itti_msg_nrf.hpp"
#include "spgwu_profile.hpp"
namespace
spgwu
{
#define TASK_SPGWU_NRF_TIMEOUT_NRF_HEARTBEAT_REQUEST 1
#define TASK_SPGWU_NRF_TIMEOUT_NRF_HEARTBEAT (1)
#define TASK_SPGWU_NRF_TIMEOUT_NRF_DEREGISTRATION (2)
class
spgwu_nrf
{
private:
std
::
thread
::
id
thread_id
;
std
::
thread
thread
;
spgwu_profile
upf_profile
;
// UPF profile
std
::
string
upf_instance_id
;
// UPF instance id
timer_id_t
timer_nrf_heartbeat
;
public:
spgwu_nrf
();
spgwu_nrf
(
spgwu_nrf
const
&
)
=
delete
;
...
...
@@ -59,14 +67,18 @@ class spgwu_nrf {
void
register_nf_instance
(
std
::
shared_ptr
<
itti_nrf_register_nf_instance_request
>
msg
);
void
send_register_nf_instance
(
std
::
string
&
url
);
void
send_update_nf_instance
(
std
::
string
&
url
,
nlohmann
::
json
&
data
);
/*
* Send NF instance update to NRF
* @param [std::shared_ptr<itti_nrf_update_nf_instance_request>] msg: Content
* of message to be sent
* @return void
*/
void
update_nf_instance
(
std
::
shared_ptr
<
itti_nrf_update_nf_instance_request
>
msg
);
/*
* Send NF deregister to NRF
...
...
@@ -76,6 +88,52 @@ class spgwu_nrf {
*/
void
deregister_nf_instance
(
std
::
shared_ptr
<
itti_nrf_deregister_nf_instance
>
msg
);
/*
* Trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void
register_to_nrf
();
/*
* Generate a random UUID for SMF instance
* @param [void]
* @return void
*/
void
generate_uuid
();
/*
* Generate a SMF profile for this instance
* @param [void]
* @return void
*/
void
generate_upf_profile
();
/*
* Send request to N11 task to trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void
trigger_nf_registration_request
();
/*
* Send request to N11 task to trigger NF instance deregistration to NRF
* @param [void]
* @return void
*/
void
trigger_nf_deregistration
();
/*
* will be executed when NRF Heartbeat timer expires
* @param [timer_id_t] timer_id
* @param [uint64_t] arg2_user
* @return void
*/
void
timer_nrf_heartbeat_timeout
(
timer_id_t
timer_id
,
uint64_t
arg2_user
);
void
timer_nrf_deregistration
(
timer_id_t
timer_id
,
uint64_t
arg2_user
);
};
}
// namespace smf
#endif
/* FILE_SPGWU_NRF_HPP_SEEN */
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