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
f11d241c
Commit
f11d241c
authored
Feb 03, 2022
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Check NSSAI function
parent
97ccc2ed
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
116 additions
and
53 deletions
+116
-53
src/amf-app/amf_config.cpp
src/amf-app/amf_config.cpp
+12
-5
src/amf-app/amf_config.hpp
src/amf-app/amf_config.hpp
+7
-7
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+75
-32
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+9
-9
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+1
-0
src/nas/ies/struct.hpp
src/nas/ies/struct.hpp
+1
-0
src/ngap/ngapIEs/S-NSSAI.cpp
src/ngap/ngapIEs/S-NSSAI.cpp
+9
-0
src/ngap/ngapIEs/S-NSSAI.hpp
src/ngap/ngapIEs/S-NSSAI.hpp
+2
-0
No files found.
src/amf-app/amf_config.cpp
View file @
f11d241c
...
...
@@ -215,8 +215,16 @@ int amf_config::load(const std::string& config_file) {
for
(
int
j
=
0
;
j
<
numOfSlice
;
j
++
)
{
slice_t
slice
;
const
Setting
&
slice_item
=
slice_list_cfg
[
j
];
slice_item
.
lookupValue
(
AMF_CONFIG_STRING_SST
,
slice
.
sST
);
slice_item
.
lookupValue
(
AMF_CONFIG_STRING_SD
,
slice
.
sD
);
std
::
string
sst
=
{};
std
::
string
sd
=
{};
slice_item
.
lookupValue
(
AMF_CONFIG_STRING_SST
,
sst
);
slice_item
.
lookupValue
(
AMF_CONFIG_STRING_SD
,
sd
);
try
{
slice
.
sst
=
std
::
stoi
(
sst
);
slice
.
sd
=
std
::
stoi
(
sd
);
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
amf_app
().
error
(
"Invalid SST/SD"
);
}
plmn_item
.
slice_list
.
push_back
(
slice
);
}
plmn_list
.
push_back
(
plmn_item
);
...
...
@@ -627,9 +635,8 @@ void amf_config::display() {
Logger
::
config
().
info
(
" Slice Support ......:"
);
for
(
int
j
=
0
;
j
<
plmn_list
[
i
].
slice_list
.
size
();
j
++
)
{
Logger
::
config
().
info
(
" SST, SD ........: %s, %s"
,
plmn_list
[
i
].
slice_list
[
j
].
sST
.
c_str
(),
plmn_list
[
i
].
slice_list
[
j
].
sD
.
c_str
());
" SST, SD ........: %d, %d"
,
plmn_list
[
i
].
slice_list
[
j
].
sst
,
plmn_list
[
i
].
slice_list
[
j
].
sd
);
}
}
Logger
::
config
().
info
(
...
...
src/amf-app/amf_config.hpp
View file @
f11d241c
...
...
@@ -153,20 +153,20 @@ typedef struct guami_s {
}
guami_t
;
typedef
struct
slice_s
{
std
::
string
sST
;
std
::
string
sD
;
uint8_t
sst
;
uint32_t
sd
;
bool
operator
==
(
const
struct
slice_s
&
s
)
const
{
if
((
s
.
s
ST
==
this
->
sST
)
&&
(
s
.
sD
.
compare
(
this
->
sD
)
==
0
))
{
if
((
s
.
s
st
==
this
->
sst
)
&&
(
s
.
sd
==
this
->
sd
))
{
return
true
;
}
else
{
return
false
;
}
}
bool
operator
>
(
const
struct
slice_s
&
s
)
const
{
if
(
this
->
s
ST
.
compare
(
s
.
sST
)
>
0
)
return
true
;
if
(
this
->
s
ST
.
compare
(
s
.
sST
)
==
0
)
{
if
(
this
->
s
D
.
compare
(
s
.
sD
)
>
0
)
return
true
;
if
(
this
->
s
D
.
compare
(
s
.
sD
)
<
0
)
return
false
;
if
(
this
->
s
st
>
s
.
sst
)
return
true
;
if
(
this
->
s
st
==
s
.
sst
)
{
if
(
this
->
s
d
>
s
.
sd
)
return
true
;
if
(
this
->
s
d
<=
s
.
sd
)
return
false
;
}
}
}
slice_t
;
...
...
src/amf-app/amf_n1.cpp
View file @
f11d241c
...
...
@@ -3462,13 +3462,8 @@ void amf_n1::initialize_registration_accept(
for
(
auto
p
:
amf_cfg
.
plmn_list
)
{
for
(
auto
s
:
p
.
slice_list
)
{
SNSSAI_t
snssai
=
{};
try
{
snssai
.
sst
=
std
::
stoi
(
s
.
sST
);
snssai
.
sd
=
std
::
stoi
(
s
.
sD
);
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
amf_n1
().
warn
(
"Invalid SST/SD"
);
return
;
}
snssai
.
sst
=
s
.
sst
;
snssai
.
sd
=
s
.
sd
;
nssai
.
push_back
(
snssai
);
}
}
...
...
@@ -3514,13 +3509,8 @@ void amf_n1::initialize_registration_accept(
(
p
.
tac
==
uc
.
get
()
->
tai
.
tac
))
{
for
(
auto
s
:
p
.
slice_list
)
{
SNSSAI_t
snssai
=
{};
try
{
snssai
.
sst
=
std
::
stoi
(
s
.
sST
);
snssai
.
sd
=
std
::
stoi
(
s
.
sD
);
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
amf_n1
().
warn
(
"Invalid SST/SD"
);
return
;
}
snssai
.
sst
=
s
.
sst
;
snssai
.
sd
=
s
.
sd
;
nssai
.
push_back
(
snssai
);
// TODO: Check with the requested NSSAI from UE
/* for (auto rn : nc.get()->requestedNssai) {
...
...
@@ -3720,6 +3710,8 @@ bool amf_n1::reroute_registration_request(std::shared_ptr<nas_context>& nc) {
return
false
;
}
// Update subscribed NSSAIs
// Check that AMF can process the Requested NSSAIs or not
if
(
check_requested_nssai
(
nc
,
nssai
))
{
Logger
::
amf_n1
().
debug
(
...
...
@@ -3792,32 +3784,83 @@ bool amf_n1::check_requested_nssai(
result
=
true
;
// Each S-NSSAI in the Default Single NSSAIs must be in the AMF's Slice List
for
(
auto
n
:
nssai
.
getDefaultSingleNssais
())
{
bool
found_nssai
=
false
;
for
(
auto
s
:
p
.
slice_list
)
{
uint8_t
sst
=
0
;
try
{
sst
=
std
::
stoi
(
s
.
sST
);
}
catch
(
const
std
::
exception
&
err
)
{
Logger
::
amf_n1
().
warn
(
"Invalid SST"
);
continue
;
// Find the common NSSAIs between Requested NSSAIs and Subscribed NSSAIs
std
::
vector
<
oai
::
amf
::
model
::
Snssai
>
common_snssais
;
for
(
auto
s
:
nc
->
requestedNssai
)
{
std
::
string
sd
=
std
::
to_string
(
s
.
sd
);
// Check with default subscribed NSSAIs
for
(
auto
n
:
nssai
.
getDefaultSingleNssais
())
{
if
(
s
.
sst
==
n
.
getSst
())
{
if
((
n
.
sdIsSet
()
and
(
n
.
getSd
().
compare
(
sd
)
==
0
))
or
(
!
n
.
sdIsSet
()
and
sd
.
empty
()))
{
common_snssais
.
push_back
(
n
);
Logger
::
amf_n1
().
debug
(
"Found S-NSSAI (SST %d, SD %s)"
,
s
.
sst
,
sd
.
c_str
());
break
;
}
}
}
if
(
sst
==
n
.
getSst
())
{
if
((
n
.
sdIsSet
()
and
(
n
.
getSd
().
compare
(
s
.
sD
)
==
0
))
or
(
!
n
.
sdIsSet
()
and
s
.
sD
.
empty
()))
{
found_nssai
=
true
;
// check with other subscribed NSSAIs
for
(
auto
n
:
nssai
.
getSingleNssais
())
{
if
(
s
.
sst
==
n
.
getSst
())
{
if
((
n
.
sdIsSet
()
and
(
n
.
getSd
().
compare
(
sd
)
==
0
))
or
(
!
n
.
sdIsSet
()
and
sd
.
empty
()))
{
common_snssais
.
push_back
(
n
);
Logger
::
amf_n1
().
debug
(
"Found S-NSSAI (SST %d, SD %s)"
,
s
st
,
n
.
getSd
()
.
c_str
());
"Found S-NSSAI (SST %d, SD %s)"
,
s
.
sst
,
sd
.
c_str
());
break
;
}
}
}
}
if
(
!
found_nssai
)
{
result
=
false
;
break
;
// If there no requested NSSAIs or no common NSSAIs between requested NSSAIs
// and Subscribed NSSAIs
if
((
nc
->
requestedNssai
.
size
()
==
0
)
or
(
common_snssais
.
size
()
==
0
))
{
// Each S-NSSAI in the Default Single NSSAIs must be in the AMF's Slice
// List
for
(
auto
n
:
nssai
.
getDefaultSingleNssais
())
{
bool
found_nssai
=
false
;
for
(
auto
s
:
p
.
slice_list
)
{
std
::
string
sd
=
std
::
to_string
(
s
.
sd
);
if
(
s
.
sst
==
n
.
getSst
())
{
if
((
n
.
sdIsSet
()
and
(
n
.
getSd
().
compare
(
sd
)
==
0
))
or
(
!
n
.
sdIsSet
()
and
sd
.
empty
()))
{
found_nssai
=
true
;
Logger
::
amf_n1
().
debug
(
"Found S-NSSAI (SST %d, SD %s)"
,
s
.
sst
,
n
.
getSd
().
c_str
());
break
;
}
}
}
if
(
!
found_nssai
)
{
result
=
false
;
break
;
}
}
}
else
{
// check if AMF can serve all the common NSSAIs
for
(
auto
n
:
common_snssais
)
{
bool
found_nssai
=
false
;
for
(
auto
s
:
p
.
slice_list
)
{
std
::
string
sd
=
std
::
to_string
(
s
.
sd
);
if
(
s
.
sst
==
n
.
getSst
())
{
if
((
n
.
sdIsSet
()
and
(
n
.
getSd
().
compare
(
sd
)
==
0
))
or
(
!
n
.
sdIsSet
()
and
sd
.
empty
()))
{
found_nssai
=
true
;
Logger
::
amf_n1
().
debug
(
"Found S-NSSAI (SST %d, SD %s)"
,
s
.
sst
,
n
.
getSd
().
c_str
());
break
;
}
}
}
if
(
!
found_nssai
)
{
result
=
false
;
break
;
}
}
}
}
...
...
src/amf-app/amf_n2.cpp
View file @
f11d241c
...
...
@@ -429,8 +429,8 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
tmp
.
mnc
=
amf_cfg
.
plmn_list
[
i
].
mnc
;
for
(
int
j
=
0
;
j
<
amf_cfg
.
plmn_list
[
i
].
slice_list
.
size
();
j
++
)
{
S_Nssai
s_tmp
;
s_tmp
.
sst
=
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
sST
;
s_tmp
.
sd
=
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
D
;
s_tmp
.
sst
=
std
::
to_string
(
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
sst
)
;
s_tmp
.
sd
=
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
d
;
tmp
.
slice_list
.
push_back
(
s_tmp
);
}
plmn_list
.
push_back
(
tmp
);
...
...
@@ -1464,8 +1464,8 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
for
(
int
j
=
0
;
j
<
amf_cfg
.
plmn_list
[
i
].
slice_list
.
size
();
j
++
)
{
S_Nssai
s_tmp
;
S_NSSAI
s_nssai
=
{};
s_nssai
.
setSst
(
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
ST
);
s_nssai
.
setSd
(
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
D
);
s_nssai
.
setSst
(
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
st
);
s_nssai
.
setSd
(
amf_cfg
.
plmn_list
[
i
].
slice_list
[
j
].
s
d
);
Allowed_Nssai
.
push_back
(
s_nssai
);
}
}
...
...
@@ -1601,11 +1601,11 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
supi
,
curl_responses
.
begin
()
->
first
,
psc
))
{
PDUSessionResourceSetupRequestItem_t
item
=
{};
item
.
pduSessionId
=
psc
.
get
()
->
pdu_session_id
;
item
.
s_nssai
.
sst
=
psc
.
get
()
->
snssai
.
sST
;
item
.
s_nssai
.
sd
=
psc
.
get
()
->
snssai
.
sD
;
item
.
pduSessionNAS_PDU
=
nullptr
;
unsigned
int
data_len
=
n2_sm
.
length
();
unsigned
char
*
data
=
(
unsigned
char
*
)
malloc
(
data_len
+
1
);
item
.
s_nssai
.
sst
=
std
::
to_string
(
psc
.
get
()
->
snssai
.
sST
)
;
item
.
s_nssai
.
sd
=
psc
.
get
()
->
snssai
.
sD
;
item
.
pduSessionNAS_PDU
=
nullptr
;
unsigned
int
data_len
=
n2_sm
.
length
();
unsigned
char
*
data
=
(
unsigned
char
*
)
malloc
(
data_len
+
1
);
memset
(
data
,
0
,
data_len
+
1
);
memcpy
((
void
*
)
data
,
(
void
*
)
n2_sm
.
c_str
(),
data_len
);
item
.
pduSessionResourceSetupRequestTransfer
.
buf
=
data
;
...
...
src/contexts/nas_context.hpp
View file @
f11d241c
...
...
@@ -93,6 +93,7 @@ class nas_context {
std
::
vector
<
nas
::
SNSSAI_t
>
requestedNssai
;
// TODO: update with naming convention
std
::
vector
<
nas
::
SNSSAI_t
>
allowed_nssai
;
// in Registration Accept
// Set to true if marked as default
std
::
vector
<
std
::
pair
<
bool
,
nas
::
SNSSAI_t
>>
subscribed_snssai
;
std
::
vector
<
nas
::
SNSSAI_t
>
configured_nssai
;
// std::vector<nas::SNSSAI_t> default_configured_nssai;
...
...
src/nas/ies/struct.hpp
View file @
f11d241c
...
...
@@ -53,6 +53,7 @@ typedef struct SNSSAI_s {
return
*
this
;
}
}
SNSSAI_t
;
typedef
struct
{
uint8_t
ie_type
;
uint8_t
ie_len
;
...
...
src/ngap/ngapIEs/S-NSSAI.cpp
View file @
f11d241c
...
...
@@ -85,6 +85,10 @@ void S_NSSAI::setSst(const std::string charSst) {
sst
=
fromString
<
int
>
(
charSst
);
}
//------------------------------------------------------------------------------
void
S_NSSAI
::
setSst
(
const
uint8_t
s
)
{
sst
=
s
;
}
//------------------------------------------------------------------------------
void
S_NSSAI
::
getSst
(
std
::
string
&
charSst
)
const
{
charSst
=
to_string
((
int
)
sst
);
...
...
@@ -101,6 +105,11 @@ void S_NSSAI::setSd(const std::string charSd) {
sd
=
fromString
<
int
>
(
charSd
);
}
//------------------------------------------------------------------------------
void
S_NSSAI
::
setSd
(
const
uint32_t
s
)
{
sdIsSet
=
true
;
sd
=
s
;
}
//------------------------------------------------------------------------------
bool
S_NSSAI
::
getSd
(
std
::
string
&
s_nssaiSd
)
const
{
if
(
sdIsSet
)
{
...
...
src/ngap/ngapIEs/S-NSSAI.hpp
View file @
f11d241c
...
...
@@ -48,9 +48,11 @@ class S_NSSAI {
bool
sDEncode2OctetString
(
Ngap_SD_t
*
);
bool
sDdecodefromOctetString
(
Ngap_SD_t
*
);
void
setSst
(
const
std
::
string
charSst
);
void
setSst
(
const
uint8_t
s
);
void
getSst
(
std
::
string
&
charSst
)
const
;
std
::
string
getSst
()
const
;
void
setSd
(
const
std
::
string
charSd
);
void
setSd
(
const
uint32_t
s
);
bool
getSd
(
std
::
string
&
s_nssaiSd
)
const
;
std
::
string
getSd
()
const
;
bool
encode2S_NSSAI
(
Ngap_S_NSSAI_t
*
);
...
...
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