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
fac48136
Commit
fac48136
authored
Nov 18, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get requested NSSAI from UE
parent
6653e38a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
25 deletions
+106
-25
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+91
-14
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+4
-0
src/nas/msgs/SecurityModeComplete.cpp
src/nas/msgs/SecurityModeComplete.cpp
+11
-11
No files found.
src/amf-app/amf_n1.cpp
View file @
fac48136
...
...
@@ -47,6 +47,7 @@
#include "RegistrationRequest.hpp"
#include "SecurityModeCommand.hpp"
#include "ServiceAccept.hpp"
#include "SecurityModeComplete.hpp"
#include "ServiceRequest.hpp"
#include "String2Value.hpp"
#include "UEAuthenticationCtx.h"
...
...
@@ -2149,9 +2150,44 @@ void amf_n1::security_mode_complete_handle(
return
;
}
std
::
shared_ptr
<
nas_context
>
nc
;
if
(
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
else
{
Logger
::
amf_n1
().
warn
(
"No existed nas_context with amf_ue_ngap_id (0x%x)"
,
amf_ue_ngap_id
);
return
;
}
// Decode Security Mode Complete
auto
security_mode_complete
=
std
::
make_unique
<
SecurityModeComplete
>
();
security_mode_complete
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas_msg
),
blength
(
nas_msg
));
bstring
nas_msg_container
;
if
(
security_mode_complete
->
getNasMessageContainer
(
nas_msg_container
))
{
uint8_t
*
buf_nas
=
(
uint8_t
*
)
bdata
(
nas_msg_container
);
uint8_t
message_type
=
*
(
buf_nas
+
2
);
if
(
message_type
==
REGISTRATION_REQUEST
)
{
Logger
::
amf_n1
().
debug
(
"Registration Request in NAS Message Container"
);
// Decode registration request message
std
::
unique_ptr
<
RegistrationRequest
>
registration_request
=
std
::
make_unique
<
RegistrationRequest
>
();
registration_request
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
nas_msg_container
),
blength
(
nas_msg_container
));
bdestroy
(
nas_msg_container
);
// free buffer
// Get Requested NSSAI (Optional IE), if provided
std
::
vector
<
SNSSAI_t
>
requested_nssai
=
{};
if
(
registration_request
->
getRequestedNssai
(
requested_nssai
))
{
nc
.
get
()
->
requestedNssai
=
requested_nssai
;
}
}
}
// Encoding REGISTRATION ACCEPT
auto
reg
A
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
initialize_registration_accept
(
reg
Accept
);
auto
reg
istration_a
ccept
=
std
::
make_unique
<
RegistrationAccept
>
();
initialize_registration_accept
(
reg
istration_accept
,
nc
);
std
::
string
mcc
=
{};
std
::
string
mnc
=
{};
...
...
@@ -2162,7 +2198,7 @@ void amf_n1::security_mode_complete_handle(
// TODO:
return
;
}
reg
A
ccept
->
set5G_GUTI
(
reg
istration_a
ccept
->
set5G_GUTI
(
mcc
,
mnc
,
amf_cfg
.
guami
.
regionID
,
amf_cfg
.
guami
.
AmfSetID
,
amf_cfg
.
guami
.
AmfPointer
,
tmsi
);
...
...
@@ -2172,10 +2208,11 @@ void amf_n1::security_mode_complete_handle(
Logger
::
amf_n1
().
debug
(
"Allocated GUTI %s"
,
guti
.
c_str
());
// TODO: remove hardcoded values
reg
A
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
reg
A
ccept
->
setT3512_Value
(
0x5
,
T3512_TIMER_VALUE_MIN
);
reg
istration_a
ccept
->
set_5GS_Network_Feature_Support
(
0x01
,
0x00
);
reg
istration_a
ccept
->
setT3512_Value
(
0x5
,
T3512_TIMER_VALUE_MIN
);
uint8_t
buffer
[
BUFFER_SIZE_1024
]
=
{
0
};
int
encoded_size
=
regAccept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
int
encoded_size
=
registration_accept
->
encode2buffer
(
buffer
,
BUFFER_SIZE_1024
);
comUt
::
print_buffer
(
"amf_n1"
,
"Registration-Accept message buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
...
...
@@ -2183,14 +2220,6 @@ void amf_n1::security_mode_complete_handle(
return
;
}
if
(
!
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
{
Logger
::
amf_n2
().
error
(
"No UE NAS context with amf_ue_ngap_id (0x%x)"
,
amf_ue_ngap_id
);
return
;
}
std
::
shared_ptr
<
nas_context
>
nc
=
{};
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
Logger
::
amf_n1
().
info
(
"UE (IMSI %s, GUTI %s, current RAN ID %d, current AMF ID %d) has been "
"registered to the network"
,
...
...
@@ -3136,6 +3165,54 @@ void amf_n1::initialize_registration_accept(
return
;
}
//------------------------------------------------------------------------------
void
amf_n1
::
initialize_registration_accept
(
std
::
unique_ptr
<
nas
::
RegistrationAccept
>&
registration_accept
,
std
::
shared_ptr
<
nas_context
>&
nc
)
{
registration_accept
->
setHeader
(
PLAIN_5GS_MSG
);
registration_accept
->
set_5GS_Registration_Result
(
false
,
false
,
false
,
0x01
);
// 3GPP Access
registration_accept
->
setT3512_Value
(
0x5
,
T3512_TIMER_VALUE_MIN
);
std
::
vector
<
p_tai_t
>
tai_list
;
for
(
auto
p
:
amf_cfg
.
plmn_list
)
{
p_tai_t
item
=
{};
item
.
type
=
0x00
;
nas_plmn_t
plmn
=
{};
plmn
.
mcc
=
p
.
mcc
;
plmn
.
mnc
=
p
.
mnc
;
item
.
plmn_list
.
push_back
(
plmn
);
item
.
tac_list
.
push_back
(
p
.
tac
);
tai_list
.
push_back
(
item
);
}
registration_accept
->
setTaiList
(
tai_list
);
// TODO: get the list of common SST, SD between UE/gNB and AMF
std
::
vector
<
struct
SNSSAI_s
>
nssai
;
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
;
}
// Check with the requested NSSAI from UE
for
(
auto
rn
:
nc
.
get
()
->
requestedNssai
)
{
if
((
rn
.
sst
==
snssai
.
sst
)
and
(
rn
.
sd
==
snssai
.
sd
))
{
nssai
.
push_back
(
snssai
);
break
;
}
}
}
}
registration_accept
->
setALLOWED_NSSAI
(
nssai
);
return
;
}
//------------------------------------------------------------------------------
bool
amf_n1
::
find_ue_context
(
const
std
::
shared_ptr
<
nas_context
>&
nc
,
std
::
shared_ptr
<
ue_context
>&
uc
)
{
...
...
src/amf-app/amf_n1.hpp
View file @
fac48136
...
...
@@ -182,6 +182,10 @@ class amf_n1 {
void
initialize_registration_accept
(
std
::
unique_ptr
<
nas
::
RegistrationAccept
>&
registration_accept
);
void
initialize_registration_accept
(
std
::
unique_ptr
<
nas
::
RegistrationAccept
>&
registration_accept
,
std
::
shared_ptr
<
nas_context
>&
nc
);
bool
find_ue_context
(
const
std
::
shared_ptr
<
nas_context
>&
nc
,
std
::
shared_ptr
<
ue_context
>&
uc
);
...
...
src/nas/msgs/SecurityModeComplete.cpp
View file @
fac48136
...
...
@@ -36,10 +36,10 @@ using namespace nas;
//------------------------------------------------------------------------------
SecurityModeComplete
::
SecurityModeComplete
()
{
Logger
::
nas_mm
().
debug
(
"initiating class SecurityModeComplete"
);
plain_header
=
NULL
;
ie_imeisv
=
NULL
;
ie_nas_message_container
=
NULL
;
ie_non_imeisvpei
=
NULL
;
plain_header
=
nullptr
;
ie_imeisv
=
nullptr
;
ie_nas_message_container
=
nullptr
;
ie_non_imeisvpei
=
nullptr
;
};
//------------------------------------------------------------------------------
...
...
@@ -75,9 +75,9 @@ void SecurityModeComplete::setNON_IMEISV(IMEISV_t imeisv) {
bool
SecurityModeComplete
::
getIMEISV
(
IMEISV_t
&
imeisv
)
{
if
(
ie_imeisv
)
{
ie_imeisv
->
getIMEISV
(
imeisv
);
return
0
;
return
true
;
}
else
{
return
-
1
;
return
false
;
}
}
...
...
@@ -85,9 +85,9 @@ bool SecurityModeComplete::getIMEISV(IMEISV_t& imeisv) {
bool
SecurityModeComplete
::
getNasMessageContainer
(
bstring
&
nas
)
{
if
(
ie_nas_message_container
)
{
ie_nas_message_container
->
getValue
(
nas
);
return
0
;
return
true
;
}
else
{
return
-
1
;
return
false
;
}
}
...
...
@@ -95,9 +95,9 @@ bool SecurityModeComplete::getNasMessageContainer(bstring& nas) {
bool
SecurityModeComplete
::
getNON_IMEISV
(
IMEISV_t
&
imeisv
)
{
if
(
ie_non_imeisvpei
)
{
ie_non_imeisvpei
->
getIMEISV
(
imeisv
);
return
0
;
return
true
;
}
else
{
return
-
1
;
return
false
;
}
}
...
...
@@ -155,7 +155,7 @@ int SecurityModeComplete::decodefrombuffer(
Logger
::
nas_mm
().
debug
(
"Decoding SecurityModeComplete message"
);
int
decoded_size
=
3
;
plain_header
=
header
;
Logger
::
nas_mm
().
debug
(
"
decoded_size
(%d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"
Decoded_size
(%d)"
,
decoded_size
);
uint8_t
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"First option IEI (0x%x)"
,
octet
);
while
((
octet
!=
0x0
))
{
...
...
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