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
16ea304a
Commit
16ea304a
authored
Sep 30, 2022
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Mobile Identity
parent
1b0cacb0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
134 deletions
+136
-134
src/nas/ies/5GSMobileIdentity.cpp
src/nas/ies/5GSMobileIdentity.cpp
+106
-118
src/nas/ies/5GSMobileIdentity.hpp
src/nas/ies/5GSMobileIdentity.hpp
+11
-5
src/nas/ies/5GSRegistrationType.cpp
src/nas/ies/5GSRegistrationType.cpp
+1
-1
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+8
-5
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+10
-5
No files found.
src/nas/ies/5GSMobileIdentity.cpp
View file @
16ea304a
...
@@ -33,7 +33,7 @@ using namespace nas;
...
@@ -33,7 +33,7 @@ using namespace nas;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
_5GSMobileIdentity
::
_5GSMobileIdentity
()
{
_5GSMobileIdentity
::
_5GSMobileIdentity
()
{
iei
=
0
;
iei
=
0
;
_5g_guti
=
nullptr
;
_5g_guti
=
std
::
nullopt
;
imei_imeisv
=
nullptr
;
imei_imeisv
=
nullptr
;
supi_format_imsi
=
nullptr
;
supi_format_imsi
=
nullptr
;
_5g_s_tmsi
=
nullptr
;
_5g_s_tmsi
=
nullptr
;
...
@@ -57,7 +57,7 @@ _5GSMobileIdentity::_5GSMobileIdentity(
...
@@ -57,7 +57,7 @@ _5GSMobileIdentity::_5GSMobileIdentity(
is_no_identity
=
false
;
is_no_identity
=
false
;
length
=
0
;
length
=
0
;
_5g_guti
=
nullptr
;
_5g_guti
=
std
::
nullopt
;
imei_imeisv
=
nullptr
;
imei_imeisv
=
nullptr
;
supi_format_imsi
=
nullptr
;
supi_format_imsi
=
nullptr
;
_IMEISV
=
{};
_IMEISV
=
{};
...
@@ -81,7 +81,7 @@ _5GSMobileIdentity::_5GSMobileIdentity(
...
@@ -81,7 +81,7 @@ _5GSMobileIdentity::_5GSMobileIdentity(
is_no_identity
=
false
;
is_no_identity
=
false
;
_5g_s_tmsi
=
nullptr
;
_5g_s_tmsi
=
nullptr
;
_5g_guti
=
nullptr
;
_5g_guti
=
std
::
nullopt
;
imei_imeisv
=
nullptr
;
imei_imeisv
=
nullptr
;
_IMEISV
=
{};
_IMEISV
=
{};
}
}
...
@@ -174,18 +174,24 @@ bool _5GSMobileIdentity::get5G_S_TMSI(
...
@@ -174,18 +174,24 @@ bool _5GSMobileIdentity::get5G_S_TMSI(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
_5GSMobileIdentity
::
set5GGUTI
(
void
_5GSMobileIdentity
::
set5GGUTI
(
const
string
mcc
,
const
string
mnc
,
uint8_t
amf_region_id
,
const
string
&
mcc
,
const
string
&
mnc
,
const
uint8_t
&
amf_region_id
,
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
const
uint32_t
_5g_tmsi
)
{
const
uint16_t
&
amf_set_id
,
const
uint8_t
&
amf_pointer
,
typeOfIdentity
=
_5G_GUTI
;
const
uint32_t
&
_5g_tmsi
)
{
if
(
_5g_guti
==
nullptr
)
typeOfIdentity
=
_5G_GUTI
;
_5g_guti
=
(
_5G_GUTI_t
*
)
calloc
(
1
,
sizeof
(
_5G_GUTI_t
));
_5G_GUTI_t
tmp
=
{};
_5g_guti
->
mcc
=
mcc
;
tmp
.
mcc
=
mcc
;
_5g_guti
->
mnc
=
mnc
;
tmp
.
mnc
=
mnc
;
_5g_guti
->
amf_region_id
=
amf_region_id
;
tmp
.
amf_region_id
=
amf_region_id
;
_5g_guti
->
amf_set_id
=
amf_set_id
;
tmp
.
amf_set_id
=
amf_set_id
;
_5g_guti
->
amf_pointer
=
amf_pointer
;
tmp
.
amf_pointer
=
amf_pointer
;
_5g_guti
->
_5g_tmsi
=
_5g_tmsi
;
tmp
.
_5g_tmsi
=
_5g_tmsi
;
length
=
14
;
_5g_guti
=
std
::
optional
<
_5G_GUTI_t
>
(
tmp
);
length
=
14
;
// TODO: define const
}
//------------------------------------------------------------------------------
void
_5GSMobileIdentity
::
get5GGUTI
(
std
::
optional
<
_5G_GUTI_t
>&
guti
)
const
{
guti
=
_5g_guti
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -219,17 +225,6 @@ void _5GSMobileIdentity::getSuciWithSupiImsi(SUCI_imsi_t& ptr) {
...
@@ -219,17 +225,6 @@ void _5GSMobileIdentity::getSuciWithSupiImsi(SUCI_imsi_t& ptr) {
ptr
=
*
supi_format_imsi
;
ptr
=
*
supi_format_imsi
;
}
}
//------------------------------------------------------------------------------
void
_5GSMobileIdentity
::
get5GGUTI
(
_5G_GUTI_t
&
ptr
)
{
// ptr = *_5g_guti;
ptr
.
mcc
=
_5g_guti
->
mcc
;
ptr
.
mnc
=
_5g_guti
->
mnc
;
ptr
.
amf_region_id
=
_5g_guti
->
amf_region_id
;
ptr
.
amf_set_id
=
_5g_guti
->
amf_set_id
;
ptr
.
amf_pointer
=
_5g_guti
->
amf_pointer
;
ptr
.
_5g_tmsi
=
_5g_guti
->
_5g_tmsi
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
_5GSMobileIdentity
::
setIMEISV
(
IMEISV_t
imeisv
)
{
void
_5GSMobileIdentity
::
setIMEISV
(
IMEISV_t
imeisv
)
{
typeOfIdentity
=
IMEISV
;
typeOfIdentity
=
IMEISV
;
...
@@ -320,85 +315,77 @@ int _5GSMobileIdentity::_5g_guti_encode2buffer(uint8_t* buf, int len) {
...
@@ -320,85 +315,77 @@ int _5GSMobileIdentity::_5g_guti_encode2buffer(uint8_t* buf, int len) {
if
(
iei
)
{
if
(
iei
)
{
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"Encoding 5GSMobilityIdentity type 0x%x"
,
typeOfIdentity
);
"Encoding 5GSMobilityIdentity type 0x%x"
,
typeOfIdentity
);
*
(
buf
)
=
iei
;
ENCODE_U8
(
buf
+
encoded_size
,
iei
,
encoded_size
);
encoded_size
++
;
encoded_size
+=
2
;
*
(
buf
+
encoded_size
)
=
0xf0
|
_5G_GUTI
;
encoded_size
+=
1
;
encoded_size
+=
encodeMssMnc2buffer
(
_5g_guti
->
mcc
,
_5g_guti
->
mnc
,
buf
+
encoded_size
);
*
(
buf
+
encoded_size
)
=
_5g_guti
->
amf_region_id
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
((
_5g_guti
->
amf_set_id
&
0x03fc
)
>>
2
);
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
((
_5g_guti
->
amf_pointer
&
0x3f
)
|
((
_5g_guti
->
amf_set_id
&
0x0003
)
<<
6
));
encoded_size
+=
1
;
uint32_t
tmsi
=
_5g_guti
->
_5g_tmsi
;
*
(
buf
+
encoded_size
)
=
(
tmsi
&
0xff000000
)
>>
24
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
(
tmsi
&
0x00ff0000
)
>>
16
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
(
tmsi
&
0x0000ff00
)
>>
8
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
tmsi
&
0x000000ff
;
encoded_size
+=
1
;
}
else
{
encoded_size
+=
2
;
*
(
buf
+
encoded_size
)
=
0x00
|
(
SUPI_FORMAT_IMSI
<<
4
)
|
SUCI
;
encoded_size
+=
1
;
encoded_size
+=
encodeMssMnc2buffer
(
supi_format_imsi
->
mcc
,
supi_format_imsi
->
mnc
,
buf
+
encoded_size
);
encoded_size
+=
encodeRoutid2buffer
(
supi_format_imsi
->
routingIndicator
,
buf
+
encoded_size
);
*
(
buf
+
encoded_size
)
=
0x00
|
supi_format_imsi
->
protectionSchemeId
;
encoded_size
+=
1
;
*
(
buf
+
encoded_size
)
=
0x00
|
supi_format_imsi
->
homeNetworkPKI
;
encoded_size
+=
1
;
// encoded_size += encodeMSIN2buffer(supi_format_imsi->msin,
// buf+encoded_size);
}
}
encoded_size
+=
2
;
// store length, do it later
ENCODE_U8
(
buf
+
encoded_size
,
0xf0
|
_5G_GUTI
,
encoded_size
);
// Type of Identity
encoded_size
+=
encodeMssMnc2buffer
(
_5g_guti
.
value
().
mcc
,
_5g_guti
.
value
().
mnc
,
buf
+
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
_5g_guti
.
value
().
amf_region_id
,
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
((
_5g_guti
.
value
().
amf_set_id
&
0x03fc
)
>>
2
),
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
((
_5g_guti
.
value
().
amf_pointer
&
0x3f
)
|
((
_5g_guti
.
value
().
amf_set_id
&
0x0003
)
<<
6
)),
encoded_size
);
// TMSI: 4 octets
uint32_t
tmsi
=
_5g_guti
.
value
().
_5g_tmsi
;
ENCODE_U32
(
buf
+
encoded_size
,
tmsi
,
encoded_size
);
// Encode Len
uint8_t
ie_len
=
0
;
uint8_t
encoded_size_tmp
=
0
;
if
(
!
iei
)
{
if
(
!
iei
)
{
*
(
uint16_t
*
)
buf
=
encoded_size
-
2
;
ie_len
=
encoded_size
-
2
;
encoded_size_tmp
=
0
;
}
else
{
}
else
{
//*(uint16_t *)(buf + 1) = encoded_size - 3;
ie_len
=
encoded_size
-
3
;
buf
[
1
]
=
((
encoded_size
-
3
)
&
0xff00
)
>>
8
;
encoded_size_tmp
=
1
;
buf
[
2
]
=
(
encoded_size
-
3
)
&
0x00ff
;
}
}
ENCODE_U16
(
buf
+
encoded_size_tmp
,
ie_len
,
encoded_size_tmp
);
Logger
::
nas_mm
().
debug
(
"Encoded 5G-GUTI IE (len %d octets)"
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded 5G-GUTI IE (len %d octets)"
,
encoded_size
);
return
encoded_size
;
return
encoded_size
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
_5GSMobileIdentity
::
encodeMssMnc2buffer
(
int
_5GSMobileIdentity
::
encodeMssMnc2buffer
(
string
mccstr
,
string
mnc
str
,
uint8_t
*
buf
)
{
const
std
::
string
&
mcc_str
,
const
std
::
string
&
mnc_
str
,
uint8_t
*
buf
)
{
int
encoded_size
=
0
;
int
encoded_size
=
0
;
int
mcc
=
fromString
<
int
>
(
mccstr
);
uint8_t
value
=
0
;
int
mnc
=
fromString
<
int
>
(
mncstr
);
int
mcc
=
fromString
<
int
>
(
mcc_str
);
*
(
buf
+
encoded_size
)
=
int
mnc
=
fromString
<
int
>
(
mnc_str
);
(
0x0f
&
(
mcc
/
100
))
|
((
0x0f
&
((
mcc
%
100
)
/
10
))
<<
4
);
encoded_size
+=
1
;
value
=
(
0x0f
&
(
mcc
/
100
))
|
((
0x0f
&
((
mcc
%
100
)
/
10
))
<<
4
);
ENCODE_U8
(
buf
+
encoded_size
,
value
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"MNC digit 1: %d"
,
mnc
/
100
);
Logger
::
nas_mm
().
debug
(
"MNC digit 1: %d"
,
mnc
/
100
);
if
(
!
(
mnc
/
100
))
{
if
(
!
(
mnc
/
100
))
{
Logger
::
nas_mm
().
debug
(
"Encoding MNC 2 digits"
);
Logger
::
nas_mm
().
debug
(
"Encoding MNC 2 digits"
);
*
(
buf
+
encoded_size
)
=
(
0x0f
&
(
mcc
%
10
))
|
0xf0
;
value
=
(
0x0f
&
(
mcc
%
10
))
|
0xf0
;
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
*
(
buf
+
encoded_size
));
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
value
);
encoded_size
+=
1
;
ENCODE_U8
(
buf
+
encoded_size
,
value
,
encoded_size
);
*
(
buf
+
encoded_size
)
=
(
0x0f
&
((
mnc
%
100
)
/
10
))
|
((
0x0f
&
(
mnc
%
10
))
<<
4
);
value
=
(
0x0f
&
((
mnc
%
100
)
/
10
))
|
((
0x0f
&
(
mnc
%
10
))
<<
4
);
encoded_size
+=
1
;
ENCODE_U8
(
buf
+
encoded_size
,
value
,
encoded_size
);
}
else
{
}
else
{
Logger
::
nas_mm
().
debug
(
"Encoding MNC 3 digits"
);
Logger
::
nas_mm
().
debug
(
"Encoding MNC 3 digits"
);
*
(
buf
+
encoded_size
)
=
(
0x0f
&
(
mcc
%
10
))
|
((
0x0f
&
(
mnc
%
10
))
<<
4
);
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
*
(
buf
+
encoded_size
));
value
=
(
0x0f
&
(
mcc
%
10
))
|
((
0x0f
&
(
mnc
%
10
))
<<
4
);
encoded_size
+=
1
;
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
value
);
*
(
buf
+
encoded_size
)
=
ENCODE_U8
(
buf
+
encoded_size
,
value
,
encoded_size
);
((
0x0f
&
((
mnc
%
100
)
/
10
))
<<
4
)
|
(
0x0f
&
(
mnc
/
100
));
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
*
(
buf
+
encoded_size
));
value
=
((
0x0f
&
((
mnc
%
100
)
/
10
))
<<
4
)
|
(
0x0f
&
(
mnc
/
100
));
encoded_size
+=
1
;
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
value
);
ENCODE_U8
(
buf
+
encoded_size
,
value
,
encoded_size
);
}
}
Logger
::
nas_mm
().
debug
(
"MCC %s, MNC %s"
,
mcc
str
.
c_str
(),
mnc
str
.
c_str
());
Logger
::
nas_mm
().
debug
(
"MCC %s, MNC %s"
,
mcc
_str
.
c_str
(),
mnc_
str
.
c_str
());
return
encoded_size
;
return
encoded_size
;
}
}
...
@@ -484,18 +471,19 @@ int _5GSMobileIdentity::decodeFromBuffer(
...
@@ -484,18 +471,19 @@ int _5GSMobileIdentity::decodeFromBuffer(
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity"
);
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity"
);
int
decoded_size
=
0
;
int
decoded_size
=
0
;
if
(
is_option
)
{
if
(
is_option
)
{
iei
=
*
buf
;
DECODE_U8
(
buf
+
decoded_size
,
iei
,
decoded_size
);
decoded_size
+=
1
;
}
}
uint8_t
len1
=
0
,
len2
=
0
;
len1
=
*
(
buf
+
decoded_size
);
DECODE_U16
(
buf
+
decoded_size
,
length
,
decoded_size
);
decoded_size
++
;
len2
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
length
=
(
0x0000
)
|
(
len1
<<
8
)
|
len2
;
Logger
::
amf_n1
().
debug
(
"Decoded 5GSMobilityIdentity IE length %d"
,
length
);
Logger
::
amf_n1
().
debug
(
"Decoded 5GSMobilityIdentity IE length %d"
,
length
);
int
decoded_size_tmp
=
0
;
uint8_t
octet
=
0
;
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size_tmp
);
// Decode but don't increase decoded_size
switch
(
*
(
buf
+
decoded_size
)
&
0x07
)
{
switch
(
octet
&
0x07
)
{
case
SUCI
:
{
case
SUCI
:
{
typeOfIdentity
=
SUCI
;
typeOfIdentity
=
SUCI
;
decoded_size
+=
decoded_size
+=
...
@@ -520,6 +508,9 @@ int _5GSMobileIdentity::decodeFromBuffer(
...
@@ -520,6 +508,9 @@ int _5GSMobileIdentity::decodeFromBuffer(
_5g_s_tmsi_decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
);
_5g_s_tmsi_decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
);
return
decoded_size
;
return
decoded_size
;
}
break
;
}
break
;
default:
{
// TODO:
}
}
}
return
0
;
return
0
;
}
}
...
@@ -634,31 +625,30 @@ int _5GSMobileIdentity::suci_decodefrombuffer(
...
@@ -634,31 +625,30 @@ int _5GSMobileIdentity::suci_decodefrombuffer(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
_5GSMobileIdentity
::
_5g_guti_decodefrombuffer
(
uint8_t
*
buf
,
int
len
)
{
int
_5GSMobileIdentity
::
_5g_guti_decodefrombuffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity 5G-GUTI"
);
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity 5G-GUTI"
);
// Starting from Octet 3 (Type of Identity)
int
decoded_size
=
0
;
int
decoded_size
=
0
;
uint8_t
octet
=
0
;
uint8_t
octet
=
0
;
octet
=
*
buf
;
decoded_size
++
;
_5g_guti
=
(
_5G_GUTI_t
*
)
calloc
(
1
,
sizeof
(
_5G_GUTI_t
));
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
// Type of Identity
octet
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
_5G_GUTI_t
tmp
=
{};
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
int
mcc
=
0
,
mnc
=
0
;
int
mcc
=
0
,
mnc
=
0
;
mcc
+=
((
octet
&
0x0f
)
*
100
+
((
octet
&
0xf0
)
>>
4
)
*
10
);
mcc
+=
((
octet
&
0x0f
)
*
100
+
((
octet
&
0xf0
)
>>
4
)
*
10
);
octet
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
)
;
mcc
+=
(
octet
&
0x0f
);
mcc
+=
(
octet
&
0x0f
);
Logger
::
nas_mm
().
debug
(
"MCC %s"
,
std
::
to_string
(
mcc
).
c_str
());
Logger
::
nas_mm
().
debug
(
"MCC %s"
,
std
::
to_string
(
mcc
).
c_str
());
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
octet
);
if
((
octet
&
0xf0
)
==
0xf0
)
{
if
((
octet
&
0xf0
)
==
0xf0
)
{
octet
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
decoded_size
++
;
mnc
+=
((
octet
&
0x0f
)
*
10
+
((
octet
&
0xf0
)
>>
4
));
mnc
+=
((
octet
&
0x0f
)
*
10
+
((
octet
&
0xf0
)
>>
4
));
Logger
::
nas_mm
().
debug
(
"MNC (2 digits): %s"
,
std
::
to_string
(
mnc
).
c_str
());
Logger
::
nas_mm
().
debug
(
"MNC (2 digits): %s"
,
std
::
to_string
(
mnc
).
c_str
());
}
else
{
}
else
{
mnc
+=
((
octet
&
0xf0
)
>>
4
);
mnc
+=
((
octet
&
0xf0
)
>>
4
);
octet
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Buffer 0x%x"
,
octet
);
decoded_size
++
;
mnc
+=
((
octet
&
0x0f
)
*
100
+
((
octet
&
0xf0
)
>>
4
)
*
10
);
mnc
+=
((
octet
&
0x0f
)
*
100
+
((
octet
&
0xf0
)
>>
4
)
*
10
);
Logger
::
nas_mm
().
debug
(
"MNC (3 digits): %s"
,
std
::
to_string
(
mnc
).
c_str
());
Logger
::
nas_mm
().
debug
(
"MNC (3 digits): %s"
,
std
::
to_string
(
mnc
).
c_str
());
}
}
...
@@ -670,20 +660,18 @@ int _5GSMobileIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
...
@@ -670,20 +660,18 @@ int _5GSMobileIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"MCC %s, MNC %s"
,
std
::
to_string
(
mcc
).
c_str
(),
mnc_str
.
c_str
());
"MCC %s, MNC %s"
,
std
::
to_string
(
mcc
).
c_str
(),
mnc_str
.
c_str
());
_5g_guti
->
mcc
=
(
const
string
)(
std
::
to_string
(
mcc
));
tmp
.
mcc
=
(
const
string
)(
std
::
to_string
(
mcc
));
_5g_guti
->
mnc
=
(
const
string
)(
mnc_str
);
tmp
.
mnc
=
(
const
string
)(
mnc_str
);
_5g_guti
->
amf_region_id
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
tmp
.
amf_region_id
,
decoded_size
);
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
tmp
.
amf_set_id
,
decoded_size
);
_5g_guti
->
amf_set_id
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
tmp
.
amf_pointer
,
decoded_size
);
decoded_size
++
;
_5g_guti
->
amf_pointer
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
// TMSI, 4 octets
// TMSI, 4 octets
DECODE_U32
(
buf
+
decoded_size
,
_5g_guti
->
_5g_tmsi
,
decoded_size
);
DECODE_U32
(
buf
+
decoded_size
,
tmp
.
_5g_tmsi
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"TMSI 0x%x"
,
_5g_guti
->
_5g_tmsi
);
Logger
::
nas_mm
().
debug
(
"TMSI 0x%x"
,
tmp
.
_5g_tmsi
);
_5g_guti
=
std
::
optional
<
_5G_GUTI_t
>
(
tmp
);
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity 5G-GUTI"
);
Logger
::
nas_mm
().
debug
(
"Decoding 5GSMobilityIdentity 5G-GUTI"
);
return
decoded_size
;
return
decoded_size
;
}
}
...
...
src/nas/ies/5GSMobileIdentity.hpp
View file @
16ea304a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#define _5GS_MOBILE_IDENTITY_H_
#define _5GS_MOBILE_IDENTITY_H_
#include <stdint.h>
#include <stdint.h>
#include <optional>
#include "struct.hpp"
#include "struct.hpp"
extern
"C"
{
extern
"C"
{
...
@@ -95,7 +96,10 @@ class _5GSMobileIdentity {
...
@@ -95,7 +96,10 @@ class _5GSMobileIdentity {
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
suci_encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
suci_encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
_5g_guti_encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
_5g_guti_encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
encodeMssMnc2buffer
(
string
mcc
,
string
mnc
,
uint8_t
*
buf
);
int
encodeMssMnc2buffer
(
const
std
::
string
&
mcc_str
,
const
std
::
string
&
mnc_str
,
uint8_t
*
buf
);
int
encodeRoutid2buffer
(
string
routid
,
uint8_t
*
buf
);
int
encodeRoutid2buffer
(
string
routid
,
uint8_t
*
buf
);
int
encodeMSIN2buffer
(
string
msinstr
,
uint8_t
*
buf
);
int
encodeMSIN2buffer
(
string
msinstr
,
uint8_t
*
buf
);
int
_5g_s_tmsi_encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
_5g_s_tmsi_encode2buffer
(
uint8_t
*
buf
,
int
len
);
...
@@ -105,13 +109,15 @@ class _5GSMobileIdentity {
...
@@ -105,13 +109,15 @@ class _5GSMobileIdentity {
int
imeisv_decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
int
imeisv_decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
);
int
suci_decodefrombuffer
(
uint8_t
*
buf
,
int
len
,
int
length
);
int
suci_decodefrombuffer
(
uint8_t
*
buf
,
int
len
,
int
length
);
int
_5g_guti_decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
int
_5g_guti_decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
void
set5GGUTI
(
void
set5GGUTI
(
const
string
mcc
,
const
string
mnc
,
uint8_t
amf_region_id
,
const
string
&
mcc
,
const
string
&
mnc
,
const
uint8_t
&
amf_region_id
,
uint16_t
amf_set_id
,
uint8_t
amf_pointer
,
const
uint32_t
_5g_tmsi
);
const
uint16_t
&
amf_set_id
,
const
uint8_t
&
amf_pointer
,
void
get5GGUTI
(
_5G_GUTI_t
&
);
const
uint32_t
&
_5g_tmsi
);
void
get5GGUTI
(
std
::
optional
<
_5G_GUTI_t
>&
)
const
;
void
setSuciWithSupiImsi
(
void
setSuciWithSupiImsi
(
const
string
&
mcc
,
const
string
&
mnc
,
const
string
&
routingInd
,
const
string
&
mcc
,
const
string
&
mnc
,
const
string
&
routingInd
,
...
@@ -131,7 +137,7 @@ class _5GSMobileIdentity {
...
@@ -131,7 +137,7 @@ class _5GSMobileIdentity {
uint16_t
length
;
uint16_t
length
;
uint8_t
typeOfIdentity
:
3
;
uint8_t
typeOfIdentity
:
3
;
_5G_GUTI_t
*
_5g_guti
;
std
::
optional
<
_5G_GUTI_t
>
_5g_guti
;
IMEI_IMEISV_t
*
imei_imeisv
;
IMEI_IMEISV_t
*
imei_imeisv
;
SUCI_imsi_t
*
supi_format_imsi
;
SUCI_imsi_t
*
supi_format_imsi
;
_5G_S_TMSI_t
*
_5g_s_tmsi
;
_5G_S_TMSI_t
*
_5g_s_tmsi
;
...
...
src/nas/ies/5GSRegistrationType.cpp
View file @
16ea304a
...
@@ -104,7 +104,7 @@ int _5GSRegistrationType::decodeFromBuffer(
...
@@ -104,7 +104,7 @@ int _5GSRegistrationType::decodeFromBuffer(
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"Decoded 5GSRegistrationType IE (%d octet)"
,
decoded_size
);
"Decoded 5GSRegistrationType IE (%d octet)"
,
decoded_size
);
return
decoded_size
;
return
0
;
// to read NAS Key Set Identifier (1/2 octet)
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
src/nas/msgs/DeregistrationRequest.cpp
View file @
16ea304a
...
@@ -132,12 +132,15 @@ bool DeregistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
...
@@ -132,12 +132,15 @@ bool DeregistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
std
::
string
DeregistrationRequest
::
get_5g_guti
()
{
std
::
string
DeregistrationRequest
::
get_5g_guti
()
{
if
(
ie_5gs_mobility_id
)
{
if
(
ie_5gs_mobility_id
)
{
nas
::
_5G_GUTI_t
guti
;
std
::
optional
<
nas
::
_5G_GUTI_t
>
guti
=
std
::
nullopt
;
ie_5gs_mobility_id
->
get5GGUTI
(
guti
);
ie_5gs_mobility_id
->
get5GGUTI
(
guti
);
std
::
string
guti_str
=
if
(
!
guti
.
has_value
())
return
{};
guti
.
mcc
+
guti
.
mnc
+
std
::
to_string
(
guti
.
amf_region_id
)
+
std
::
to_string
(
guti
.
amf_set_id
)
+
std
::
to_string
(
guti
.
amf_pointer
)
+
std
::
string
guti_str
=
guti
.
value
().
mcc
+
guti
.
value
().
mnc
+
conv
::
tmsi_to_string
(
guti
.
_5g_tmsi
);
std
::
to_string
(
guti
.
value
().
amf_region_id
)
+
std
::
to_string
(
guti
.
value
().
amf_set_id
)
+
std
::
to_string
(
guti
.
value
().
amf_pointer
)
+
conv
::
tmsi_to_string
(
guti
.
value
().
_5g_tmsi
);
Logger
::
nas_mm
().
debug
(
"5G GUTI %s"
,
guti_str
.
c_str
());
Logger
::
nas_mm
().
debug
(
"5G GUTI %s"
,
guti_str
.
c_str
());
return
guti_str
;
return
guti_str
;
}
else
{
}
else
{
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
16ea304a
...
@@ -138,12 +138,15 @@ bool RegistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
...
@@ -138,12 +138,15 @@ bool RegistrationRequest::getSuciSupiFormatImsi(nas::SUCI_imsi_t& imsi) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
std
::
string
RegistrationRequest
::
get_5g_guti
()
{
std
::
string
RegistrationRequest
::
get_5g_guti
()
{
if
(
ie_5gs_mobility_id
)
{
if
(
ie_5gs_mobility_id
)
{
nas
::
_5G_GUTI_t
guti
;
std
::
optional
<
nas
::
_5G_GUTI_t
>
guti
=
std
::
nullopt
;
ie_5gs_mobility_id
->
get5GGUTI
(
guti
);
ie_5gs_mobility_id
->
get5GGUTI
(
guti
);
std
::
string
guti_str
=
if
(
!
guti
.
has_value
())
return
{};
guti
.
mcc
+
guti
.
mnc
+
std
::
to_string
(
guti
.
amf_region_id
)
+
std
::
to_string
(
guti
.
amf_set_id
)
+
std
::
to_string
(
guti
.
amf_pointer
)
+
std
::
string
guti_str
=
guti
.
value
().
mcc
+
guti
.
value
().
mnc
+
conv
::
tmsi_to_string
(
guti
.
_5g_tmsi
);
std
::
to_string
(
guti
.
value
().
amf_region_id
)
+
std
::
to_string
(
guti
.
value
().
amf_set_id
)
+
std
::
to_string
(
guti
.
value
().
amf_pointer
)
+
conv
::
tmsi_to_string
(
guti
.
value
().
_5g_tmsi
);
Logger
::
nas_mm
().
debug
(
"5G GUTI %s"
,
guti_str
.
c_str
());
Logger
::
nas_mm
().
debug
(
"5G GUTI %s"
,
guti_str
.
c_str
());
return
guti_str
;
return
guti_str
;
}
else
{
}
else
{
...
@@ -172,7 +175,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
...
@@ -172,7 +175,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
RegistrationRequest
::
getAdditionalGuti
(
nas
::
_5G_GUTI_t
&
guti
)
{
bool
RegistrationRequest
::
getAdditionalGuti
(
nas
::
_5G_GUTI_t
&
guti
)
{
if
(
ie_additional_guti
)
{
if
(
ie_additional_guti
)
{
std
::
optional
<
nas
::
_5G_GUTI_t
>
guti
=
std
::
nullopt
;
ie_additional_guti
->
get5GGUTI
(
guti
);
ie_additional_guti
->
get5GGUTI
(
guti
);
if
(
!
guti
.
has_value
())
return
false
;
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
...
...
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