Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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-AMF
Commits
0392777b
Commit
0392777b
authored
Aug 18, 2022
by
Tien-Thinh Nguyen
Committed by
sagar arora
Aug 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ngap message callback
parent
98e4efa5
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
672 additions
and
481 deletions
+672
-481
src/amf-app/amf_config.cpp
src/amf-app/amf_config.cpp
+23
-19
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+72
-88
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+9
-0
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+95
-215
src/amf-app/amf_n2.hpp
src/amf-app/amf_n2.hpp
+22
-0
src/amf-app/amf_sbi.cpp
src/amf-app/amf_sbi.cpp
+3
-4
src/common/amf.hpp
src/common/amf.hpp
+3
-0
src/ngap/ngapMsgs/InitialContextSetupResponse.cpp
src/ngap/ngapMsgs/InitialContextSetupResponse.cpp
+0
-2
src/ngap/ngap_app/ngap_app.cpp
src/ngap/ngap_app/ngap_app.cpp
+33
-14
src/ngap/ngap_app/ngap_app.hpp
src/ngap/ngap_app/ngap_app.hpp
+64
-4
src/ngap/ngap_app/ngap_message_callback.hpp
src/ngap/ngap_app/ngap_message_callback.hpp
+345
-134
src/sctp/sctp_server.cpp
src/sctp/sctp_server.cpp
+3
-1
No files found.
src/amf-app/amf_config.cpp
View file @
0392777b
...
...
@@ -54,22 +54,22 @@ namespace config {
//------------------------------------------------------------------------------
amf_config
::
amf_config
()
{
nrf_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
nrf_addr
.
port
=
80
;
nrf_addr
.
api_version
=
"v1"
;
nrf_addr
.
port
=
DEFAULT_HTTP1_PORT
;
nrf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
ausf_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
ausf_addr
.
port
=
80
;
ausf_addr
.
api_version
=
"v1"
;
ausf_addr
.
port
=
DEFAULT_HTTP1_PORT
;
ausf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
udm_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
udm_addr
.
port
=
80
;
udm_addr
.
api_version
=
"v1"
;
udm_addr
.
port
=
DEFAULT_HTTP1_PORT
;
udm_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
nssf_addr
.
ipv4_addr
.
s_addr
=
INADDR_ANY
;
nssf_addr
.
port
=
80
;
nssf_addr
.
api_version
=
"v1"
;
nssf_addr
.
port
=
DEFAULT_HTTP1_PORT
;
nssf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
instance
=
0
;
n2
=
{};
sbi
=
{};
sbi_api_version
=
"v1"
;
sbi_http2_port
=
8080
;
sbi_api_version
=
DEFAULT_SBI_API_VERSION
;
sbi_http2_port
=
DEFAULT_HTTP2_PORT
;
statistics_interval
=
0
;
guami
=
{};
guami_list
=
{};
...
...
@@ -460,7 +460,8 @@ int amf_config::load(const std::string& config_file) {
}
nrf_addr
.
port
=
nrf_port
;
//
nrf_addr
.
api_version
=
"v1"
;
// TODO: get API version
nrf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
// TODO: get API version
}
}
...
...
@@ -508,8 +509,9 @@ int amf_config::load(const std::string& config_file) {
Logger
::
amf_app
().
error
(
AMF_CONFIG_STRING_PORT
"failed"
);
throw
(
AMF_CONFIG_STRING_PORT
"failed"
);
}
ausf_addr
.
port
=
ausf_port
;
ausf_addr
.
api_version
=
"v1"
;
// TODO: get API version
ausf_addr
.
port
=
ausf_port
;
ausf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
// TODO: get API version
}
}
}
...
...
@@ -552,9 +554,10 @@ int amf_config::load(const std::string& config_file) {
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
udm_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR UDM !"
);
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
udm_addr
.
port
=
udm_port
;
udm_addr
.
api_version
=
"v1"
;
// TODO: get API version
udm_addr
.
ipv4_addr
=
udm_ipv4_addr
;
udm_addr
.
port
=
udm_port
;
udm_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
// TODO: get API version
}
}
}
...
...
@@ -596,9 +599,10 @@ int amf_config::load(const std::string& config_file) {
IPV4_STR_ADDR_TO_INADDR
(
util
::
trim
(
address
).
c_str
(),
nssf_ipv4_addr
,
"BAD IPv4 ADDRESS FORMAT FOR NSSF !"
);
nssf_addr
.
ipv4_addr
=
nssf_ipv4_addr
;
nssf_addr
.
port
=
nssf_port
;
nssf_addr
.
api_version
=
"v1"
;
// TODO: get API version
nssf_addr
.
ipv4_addr
=
nssf_ipv4_addr
;
nssf_addr
.
port
=
nssf_port
;
nssf_addr
.
api_version
=
DEFAULT_SBI_API_VERSION
;
// TODO: get API version
}
}
}
...
...
src/amf-app/amf_n1.cpp
View file @
0392777b
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n1.hpp
View file @
0392777b
...
...
@@ -145,6 +145,15 @@ class amf_n1 {
*/
bool
is_amf_ue_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
)
const
;
/*
* Verify if a UE NAS context associated with an AMF UE NGAP ID exist
* @param [const long& ] amf_ue_ngap_id: AMF UE NGAP ID
* @param [std::shared_ptr<nas_context>&] nc: pointer to UE NAS context
* @return true if UE NAS context exist, otherwise false
*/
bool
is_amf_ue_id_2_nas_context
(
const
long
&
amf_ue_ngap_id
,
std
::
shared_ptr
<
nas_context
>&
nc
)
const
;
/*
* Get UE NAS context associated with an AMF UE NGAP ID
* @param [const long& ] amf_ue_ngap_id: AMF UE NGAP ID
...
...
src/amf-app/amf_n2.cpp
View file @
0392777b
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n2.hpp
View file @
0392777b
...
...
@@ -221,6 +221,17 @@ class amf_n2 : public ngap::ngap_app {
*/
bool
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
)
const
;
/*
* Verify whether a UE NGAP context associated with a RAN UE NGAP ID exist
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: shared pointer to the UE
* NGAP context
* @return true if exist, otherwise return false
*/
bool
is_ran_ue_id_2_ue_ngap_context
(
const
uint32_t
&
ran_ue_ngap_id
,
std
::
shared_ptr
<
ue_ngap_context
>&
unc
)
const
;
/*
* Store UE NGAP context associated with a RAN UE NGAP ID
* @param [const uint32_t&] ran_ue_ngap_id: RAN UE NGAP ID
...
...
@@ -262,6 +273,17 @@ class amf_n2 : public ngap::ngap_app {
bool
is_amf_ue_id_2_ue_ngap_context
(
const
unsigned
long
&
amf_ue_ngap_id
)
const
;
/*
* Verify whether a UE NGAP context associated with a AMF UE NGAP ID exist
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
* @param [std::shared_ptr<ue_ngap_context>&] unc: store the pointer to UE
* NGAP context
* @return true if exist, otherwise return false
*/
bool
is_amf_ue_id_2_ue_ngap_context
(
const
unsigned
long
&
amf_ue_ngap_id
,
std
::
shared_ptr
<
ue_ngap_context
>&
unc
)
const
;
/*
* Store UE NGAP context associated with a AMF UE NGAP ID
* @param [const unsigned long&] amf_ue_ngap_id: AMF UE NGAP ID
...
...
src/amf-app/amf_sbi.cpp
View file @
0392777b
...
...
@@ -278,16 +278,15 @@ void amf_sbi::handle_itti_message(
void
amf_sbi
::
handle_itti_message
(
itti_nsmf_pdusession_create_sm_context
&
smf
)
{
Logger
::
amf_sbi
().
debug
(
"Handle ITTI SMF_PDU_SESSION_CREATE_SM_CTX"
);
if
(
!
amf_n1_inst
->
is_amf_ue_id_2_nas_context
(
smf
.
amf_ue_ngap_id
))
{
std
::
shared_ptr
<
nas_context
>
nc
=
{};
if
(
!
amf_n1_inst
->
is_amf_ue_id_2_nas_context
(
smf
.
amf_ue_ngap_id
,
nc
))
{
Logger
::
amf_sbi
().
error
(
"No UE NAS context with amf_ue_ngap_id ("
AMF_UE_NGAP_ID_FMT
")"
,
smf
.
amf_ue_ngap_id
);
return
;
}
std
::
shared_ptr
<
nas_context
>
nc
=
{};
nc
=
amf_n1_inst
->
amf_ue_id_2_nas_context
(
smf
.
amf_ue_ngap_id
);
std
::
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
std
::
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
nc
.
get
()
->
ran_ue_ngap_id
)
+
":amfid_"
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
);
...
...
src/common/amf.hpp
View file @
0392777b
...
...
@@ -73,4 +73,7 @@ typedef enum {
IntegrityProtectedAndCipheredWithNew5GNASSecurityContext
=
0x4
,
}
SecurityHeaderType_t
;
constexpr
uint32_t
DEFAULT_HTTP1_PORT
=
80
;
constexpr
uint32_t
DEFAULT_HTTP2_PORT
=
8080
;
constexpr
auto
DEFAULT_SBI_API_VERSION
=
"v1"
;
#endif
src/ngap/ngapMsgs/InitialContextSetupResponse.cpp
View file @
0392777b
...
...
@@ -201,12 +201,10 @@ bool InitialContextSetupResponseMsg::decodeFromPdu(
.
choice
.
InitialContextSetupResponse
;
}
else
{
Logger
::
ngap
().
error
(
"Check InitialContextSetupResponse message error"
);
return
false
;
}
}
else
{
Logger
::
ngap
().
error
(
"MessageType error"
);
return
false
;
}
for
(
int
i
=
0
;
i
<
initialContextSetupResponseIEs
->
protocolIEs
.
list
.
count
;
...
...
src/ngap/ngap_app/ngap_app.cpp
View file @
0392777b
...
...
@@ -64,6 +64,16 @@ void ngap_app::handle_receive(
ngap_msg_pdu
->
present
);
asn_fprint
(
stderr
,
&
asn_DEF_Ngap_NGAP_PDU
,
ngap_msg_pdu
);
if
((
ngap_msg_pdu
->
choice
.
initiatingMessage
->
procedureCode
>
(
NGAP_PROCEDURE_CODE_MAX_VALUE
-
1
))
or
(
ngap_msg_pdu
->
present
>
NGAP_PRESENT_MAX_VALUE
))
{
Logger
::
ngap
().
error
(
"Invalid procedure code %d or present %d"
,
ngap_msg_pdu
->
choice
.
initiatingMessage
->
procedureCode
,
ngap_msg_pdu
->
present
);
return
;
}
// Handle the message
(
*
messages_callback
[
ngap_msg_pdu
->
choice
.
initiatingMessage
->
procedureCode
]
[
ngap_msg_pdu
->
present
-
1
])(
...
...
@@ -76,18 +86,14 @@ void ngap_app::handle_sctp_new_association(
sctp_stream_id_t
outstreams
)
{
Logger
::
ngap
().
debug
(
"Ready to handle new NGAP SCTP association request (id %d)"
,
assoc_id
);
std
::
shared_ptr
<
gnb_context
>
gc
=
{};
if
(
!
is_assoc_id_2_gnb_context
(
assoc_id
))
{
if
(
!
is_assoc_id_2_gnb_context
(
assoc_id
,
gc
))
{
Logger
::
ngap
().
debug
(
"Create a new gNB context with assoc_id (%d)"
,
assoc_id
);
gc
=
std
::
shared_ptr
<
gnb_context
>
(
new
gnb_context
());
set_assoc_id_2_gnb_context
(
assoc_id
,
gc
);
}
else
{
gc
=
assoc_id_2_gnb_context
(
assoc_id
);
if
(
gc
.
get
()
==
nullptr
)
{
Logger
::
amf_n2
().
error
(
"Illegal gNB with assoc id (0x%x)"
,
assoc_id
);
return
;
}
if
(
gc
.
get
()
->
ng_state
==
NGAP_RESETING
||
gc
.
get
()
->
ng_state
==
NGAP_SHUTDOWN
)
{
Logger
::
ngap
().
warn
(
...
...
@@ -98,16 +104,18 @@ void ngap_app::handle_sctp_new_association(
Logger
::
ngap
().
debug
(
"Update gNB context with assoc id (%d)"
,
assoc_id
);
}
}
if
(
gc
.
get
()
==
nullptr
)
{
Logger
::
ngap
().
error
(
"Failed to create gNB context for assoc_id (%d)"
,
assoc_id
);
}
else
{
gc
.
get
()
->
sctp_assoc_id
=
assoc_id
;
gc
.
get
()
->
instreams
=
instreams
;
gc
.
get
()
->
outstreams
=
outstreams
;
gc
.
get
()
->
next_sctp_stream
=
1
;
gc
.
get
()
->
ng_state
=
NGAP_INIT
;
}
return
;
};
gc
.
get
()
->
sctp_assoc_id
=
assoc_id
;
gc
.
get
()
->
instreams
=
instreams
;
gc
.
get
()
->
outstreams
=
outstreams
;
gc
.
get
()
->
next_sctp_stream
=
1
;
gc
.
get
()
->
ng_state
=
NGAP_INIT
;
}
//------------------------------------------------------------------------------
...
...
@@ -138,6 +146,17 @@ std::shared_ptr<gnb_context> ngap_app::assoc_id_2_gnb_context(
return
assoc2gnbContext
.
at
(
assoc_id
);
}
//------------------------------------------------------------------------------
bool
ngap_app
::
is_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>&
gc
)
{
std
::
shared_lock
lock
(
m_assoc2gnbContext
);
if
(
assoc2gnbContext
.
count
(
assoc_id
)
>
0
)
{
gc
=
assoc2gnbContext
.
at
(
assoc_id
);
if
(
gc
.
get
()
!=
nullptr
)
return
true
;
}
return
false
;
}
//------------------------------------------------------------------------------
void
ngap_app
::
set_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>
gc
)
{
...
...
@@ -161,7 +180,7 @@ std::shared_ptr<gnb_context> ngap_app::gnb_id_2_gnb_context(
//------------------------------------------------------------------------------
void
ngap_app
::
set_gnb_id_2_gnb_context
(
const
long
&
gnb_id
,
std
::
shared_ptr
<
gnb_context
>
gc
)
{
const
long
&
gnb_id
,
const
std
::
shared_ptr
<
gnb_context
>&
gc
)
{
std
::
unique_lock
lock
(
m_gnbid2gnbContext
);
gnbid2gnbContext
[
gnb_id
]
=
gc
;
return
;
...
...
src/ngap/ngap_app/ngap_app.hpp
View file @
0392777b
...
...
@@ -39,8 +39,13 @@ static const std::vector<std::string> ng_gnb_state_str = {
class
ngap_app
:
public
sctp_application
{
public:
ngap_app
(
const
std
::
string
&
address
,
const
uint16_t
port_num
);
~
ngap_app
();
virtual
~
ngap_app
();
/*
* Get Payload protocol ID
* @param void
* @return PP ID in Uint32_t:
*/
uint32_t
getPpid
();
/*
...
...
@@ -67,19 +72,74 @@ class ngap_app : public sctp_application {
sctp_assoc_id_t
assoc_id
,
sctp_stream_id_t
instreams
,
sctp_stream_id_t
outstreams
);
/*
* Handle SCTP Shutdown message
* @param [sctp_assoc_id_t] assoc_id: gNB association ID
* @return void:
*/
void
handle_sctp_shutdown
(
sctp_assoc_id_t
assoc_id
);
/*
* Verify whether an association id associated with a GNB context exist
* @param [const sctp_assoc_id_t&] assoc_id: gNB association ID
* @return true if exist, otherwise return false
*/
bool
is_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
)
const
;
void
set_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>
gc
);
/*
* Verify whether an association id associated with a GNB context exist
* @param [const sctp_assoc_id_t&] assoc_id: gNB association ID
* @param [std::shared_ptr<gnb_context>&] gc: store the gNB context if exist
* @return true if exist, otherwise return false
*/
bool
is_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>&
gc
);
/*
* Get the gNB Context associated with an association id
* @param [const sctp_assoc_id_t&] assoc_id: gNB association ID
* @return the pointer to the gNB context
*/
std
::
shared_ptr
<
gnb_context
>
assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
)
const
;
/*
* Store gNB Context associated with an association id
* @param [const sctp_assoc_id_t&] assoc_id: gNB association ID
* @param [std::shared_ptr<gnb_context>&] gc: pointer to the gNB context
* @return void
*/
void
set_assoc_id_2_gnb_context
(
const
sctp_assoc_id_t
&
assoc_id
,
std
::
shared_ptr
<
gnb_context
>
gc
);
/*
* Verify whether a GNB context associated with a gNB ID exist
* @param [const long&] gnb_id: gNB ID
* @return true if exist, otherwise return false
*/
bool
is_gnb_id_2_gnb_context
(
const
long
&
gnb_id
)
const
;
/*
* Store gNB Context associated with an association id
* @param [const long&] gnb_id: gNB ID
* @param [const std::shared_ptr<gnb_context>&] gc: pointer to the gNB context
* @return void
*/
void
set_gnb_id_2_gnb_context
(
const
long
&
gnb_id
,
std
::
shared_ptr
<
gnb_context
>
gc
);
const
long
&
gnb_id
,
const
std
::
shared_ptr
<
gnb_context
>&
gc
);
/*
* Get the gNB Context associated with a gNB id
* @param [const long& ] gnb_id: gNB ID
* @return the pointer to the gNB context
*/
std
::
shared_ptr
<
gnb_context
>
gnb_id_2_gnb_context
(
const
long
&
gnb_id
)
const
;
/*
* Remove the gNB Context associated with a gNB id
* @param [const long& ] gnb_id: gNB ID
* @return void
*/
void
remove_gnb_context
(
const
long
&
gnb_id
);
protected:
...
...
src/ngap/ngap_app/ngap_message_callback.hpp
View file @
0392777b
This diff is collapsed.
Click to expand it.
src/sctp/sctp_server.cpp
View file @
0392777b
...
...
@@ -410,10 +410,12 @@ int sctp_server::sctp_send_msg(
"with ppid %d"
,
assoc_desc
->
sd
,
sctp_assoc_id
,
bdata
(
*
payload
),
blength
(
*
payload
),
stream
,
assoc_desc
->
ppid
);
// Set timetolive to 100ms
if
(
sctp_sendmsg
(
assoc_desc
->
sd
,
(
const
void
*
)
bdata
(
*
payload
),
(
size_t
)
blength
(
*
payload
),
NULL
,
0
,
htonl
(
assoc_desc
->
ppid
),
0
,
stream
,
0
,
0
)
<
0
)
{
stream
,
10
0
,
0
)
<
0
)
{
Logger
::
sctp
().
error
(
"[Socket %d] Send stream %u, ppid %u, len %u failed (%s, %d)"
,
assoc_desc
->
sd
,
stream
,
htonl
(
assoc_desc
->
ppid
),
blength
(
*
payload
),
...
...
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