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-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-AMF-Simple
Commits
63c70695
Commit
63c70695
authored
Mar 28, 2021
by
luhan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://git.opensource5g.org/openxg/amf
parents
e595da59
b44be750
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
191 additions
and
135 deletions
+191
-135
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+27
-5
src/contexts/nas_context.cpp
src/contexts/nas_context.cpp
+1
-0
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+1
-0
src/nas/ies/UESecurityCapability.cpp
src/nas/ies/UESecurityCapability.cpp
+46
-28
src/nas/ies/UESecurityCapability.hpp
src/nas/ies/UESecurityCapability.hpp
+9
-7
src/nas/msgs/ULNASTransport.cpp
src/nas/msgs/ULNASTransport.cpp
+107
-95
No files found.
src/amf-app/amf_n1.cpp
View file @
63c70695
...
@@ -950,6 +950,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
...
@@ -950,6 +950,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
}
}
nc
.
get
()
->
ueSecurityCapEnc
=
encrypt_alg
;
nc
.
get
()
->
ueSecurityCapEnc
=
encrypt_alg
;
nc
.
get
()
->
ueSecurityCapInt
=
integrity_alg
;
nc
.
get
()
->
ueSecurityCapInt
=
integrity_alg
;
nc
.
get
()
->
ueSecurityCaplen
=
regReq
->
ie_ue_security_capability
->
getLenght
();
// Get Requested NSSAI (Optional IE), if provided
// Get Requested NSSAI (Optional IE), if provided
std
::
vector
<
SNSSAI_t
>
requestedNssai
=
{};
std
::
vector
<
SNSSAI_t
>
requestedNssai
=
{};
...
@@ -2001,6 +2002,12 @@ bool amf_n1::start_security_mode_control_procedure(
...
@@ -2001,6 +2002,12 @@ bool amf_n1::start_security_mode_control_procedure(
smc
->
setngKSI
(
NAS_KEY_SET_IDENTIFIER_NATIVE
,
nc
.
get
()
->
ngKsi
&
0x07
);
smc
->
setngKSI
(
NAS_KEY_SET_IDENTIFIER_NATIVE
,
nc
.
get
()
->
ngKsi
&
0x07
);
smc
->
setUE_Security_Capability
(
nc
.
get
()
->
ueSecurityCapEnc
,
smc
->
setUE_Security_Capability
(
nc
.
get
()
->
ueSecurityCapEnc
,
nc
.
get
()
->
ueSecurityCapInt
);
nc
.
get
()
->
ueSecurityCapInt
);
if
(
smc
->
ie_ue_security_capability
!=
NULL
)
{
smc
->
ie_ue_security_capability
->
setLenght
(
nc
.
get
()
->
ueSecurityCaplen
);
}
else
{
Logger
::
amf_n1
().
error
(
"smc->ie_ue_security_capability is NULL"
);
}
smc
->
setIMEISV_Request
(
0xe1
);
smc
->
setIMEISV_Request
(
0xe1
);
smc
->
setAdditional_5G_Security_Information
(
true
,
false
);
smc
->
setAdditional_5G_Security_Information
(
true
,
false
);
uint8_t
buffer
[
1024
];
uint8_t
buffer
[
1024
];
...
@@ -2309,12 +2316,14 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
...
@@ -2309,12 +2316,14 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
int
input_nas_len
,
int
input_nas_len
,
uint32_t
&
mac32
)
{
uint32_t
&
mac32
)
{
uint32_t
count
=
0x00000000
;
uint32_t
count
=
0x00000000
;
if
(
direction
)
if
(
direction
)
{
count
=
0x00000000
|
((
nsc
->
dl_count
.
overflow
&
0x0000ffff
)
<<
8
)
|
count
=
0x00000000
|
((
nsc
->
dl_count
.
overflow
&
0x0000ffff
)
<<
8
)
|
((
nsc
->
dl_count
.
seq_num
&
0x000000ff
));
((
nsc
->
dl_count
.
seq_num
&
0x000000ff
));
else
}
else
{
Logger
::
amf_n1
().
debug
(
"nsc->ul_count.overflow %x"
,
nsc
->
ul_count
.
overflow
);
count
=
0x00000000
|
((
nsc
->
ul_count
.
overflow
&
0x0000ffff
)
<<
8
)
|
count
=
0x00000000
|
((
nsc
->
ul_count
.
overflow
&
0x0000ffff
)
<<
8
)
|
((
nsc
->
ul_count
.
seq_num
&
0x000000ff
));
((
nsc
->
ul_count
.
seq_num
&
0x000000ff
));
}
nas_stream_cipher_t
stream_cipher
=
{
0
};
nas_stream_cipher_t
stream_cipher
=
{
0
};
uint8_t
mac
[
4
];
uint8_t
mac
[
4
];
stream_cipher
.
key
=
nsc
->
knas_int
;
stream_cipher
.
key
=
nsc
->
knas_int
;
...
@@ -2322,6 +2331,7 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
...
@@ -2322,6 +2331,7 @@ bool amf_n1::nas_message_integrity_protected(nas_secu_ctx *nsc,
AUTH_KNAS_INT_SIZE
);
AUTH_KNAS_INT_SIZE
);
stream_cipher
.
key_length
=
AUTH_KNAS_INT_SIZE
;
stream_cipher
.
key_length
=
AUTH_KNAS_INT_SIZE
;
stream_cipher
.
count
=
*
(
input_nas
);
stream_cipher
.
count
=
*
(
input_nas
);
stream_cipher
.
bearer
=
0x01
;
// stream_cipher.count = count;
// stream_cipher.count = count;
if
(
!
direction
)
{
if
(
!
direction
)
{
nsc
->
ul_count
.
seq_num
=
stream_cipher
.
count
;
nsc
->
ul_count
.
seq_num
=
stream_cipher
.
count
;
...
@@ -2391,8 +2401,19 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction,
...
@@ -2391,8 +2401,19 @@ bool amf_n1::nas_message_cipher_protected(nas_secu_ctx *nsc, uint8_t direction,
}
break
;
}
break
;
case
EA1_128_5G
:
{
case
EA1_128_5G
:
{
Logger
::
amf_n1
().
debug
(
"Cipher protected with EA1_128_5G"
);
Logger
::
amf_n1
().
debug
(
"Cipher protected with EA1_128_5G"
);
nas_algorithms
::
nas_stream_encrypt_nea1
(
&
stream_cipher
,
Logger
::
amf_n1
().
debug
(
"stream_cipher.blength %d"
,
stream_cipher
.
blength
);
(
uint8_t
*
)
bdata
(
output_nas
));
Logger
::
amf_n1
().
debug
(
"stream_cipher.message %x"
,
stream_cipher
.
message
[
0
]);
print_buffer
(
"amf_n1"
,
"stream_cipher.key "
,
stream_cipher
.
key
,
16
);
Logger
::
amf_n1
().
debug
(
"stream_cipher.count %x"
,
stream_cipher
.
count
);
uint8_t
*
ciphered
=
(
uint8_t
*
)
malloc
(((
stream_cipher
.
blength
+
31
)
/
32
)
*
4
);
nas_algorithms
::
nas_stream_encrypt_nea1
(
&
stream_cipher
,
ciphered
);
output_nas
=
blk2bstr
(
ciphered
,
((
stream_cipher
.
blength
+
31
)
/
32
)
*
4
);
// output_nas = blk2bstr(ciphered, blength(input_nas));
free
(
ciphered
);
}
break
;
}
break
;
case
EA2_128_5G
:
{
case
EA2_128_5G
:
{
Logger
::
amf_n1
().
debug
(
"Cipher protected with EA2_128_5G"
);
Logger
::
amf_n1
().
debug
(
"Cipher protected with EA2_128_5G"
);
...
@@ -2471,7 +2492,8 @@ void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id,
...
@@ -2471,7 +2492,8 @@ void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id,
Logger
::
amf_n1
().
debug
(
"5G Mobile Identity, GUTI %s"
,
Logger
::
amf_n1
().
debug
(
"5G Mobile Identity, GUTI %s"
,
deregReq
->
get_5g_guti
().
c_str
());
deregReq
->
get_5g_guti
().
c_str
());
}
break
;
}
break
;
default:
{}
default:
{
}
}
}
// Prepare DeregistrationAccept
// Prepare DeregistrationAccept
...
...
src/contexts/nas_context.cpp
View file @
63c70695
...
@@ -42,6 +42,7 @@ nas_context::nas_context() {
...
@@ -42,6 +42,7 @@ nas_context::nas_context() {
is_common_procedure_for_security_mode_control_running
=
false
;
is_common_procedure_for_security_mode_control_running
=
false
;
is_common_procedure_for_nas_transport_running
=
false
;
is_common_procedure_for_nas_transport_running
=
false
;
auts
=
NULL
;
auts
=
NULL
;
ueSecurityCaplen
=
0
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
src/contexts/nas_context.hpp
View file @
63c70695
...
@@ -73,6 +73,7 @@ class nas_context {
...
@@ -73,6 +73,7 @@ class nas_context {
// mobility identity: imsi, supi, 5g-guti, etc
// mobility identity: imsi, supi, 5g-guti, etc
std
::
string
imsi
;
std
::
string
imsi
;
uint8_t
mmCapability
;
uint8_t
mmCapability
;
uint8_t
ueSecurityCaplen
;
uint8_t
ueSecurityCapEnc
;
uint8_t
ueSecurityCapEnc
;
uint8_t
ueSecurityCapInt
;
uint8_t
ueSecurityCapInt
;
std
::
vector
<
nas
::
SNSSAI_t
>
requestedNssai
;
std
::
vector
<
nas
::
SNSSAI_t
>
requestedNssai
;
...
...
src/nas/ies/UESecurityCapability.cpp
View file @
63c70695
...
@@ -31,9 +31,7 @@
...
@@ -31,9 +31,7 @@
using
namespace
nas
;
using
namespace
nas
;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UESecurityCapability
::
UESecurityCapability
(
uint8_t
iei
)
{
UESecurityCapability
::
UESecurityCapability
(
uint8_t
iei
)
{
_iei
=
iei
;
}
_iei
=
iei
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UESecurityCapability
::
UESecurityCapability
()
{}
UESecurityCapability
::
UESecurityCapability
()
{}
...
@@ -42,36 +40,43 @@ UESecurityCapability::UESecurityCapability() {}
...
@@ -42,36 +40,43 @@ UESecurityCapability::UESecurityCapability() {}
UESecurityCapability
::~
UESecurityCapability
()
{}
UESecurityCapability
::~
UESecurityCapability
()
{}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UESecurityCapability
::
UESecurityCapability
(
UESecurityCapability
::
UESecurityCapability
(
const
uint8_t
iei
,
const
uint8_t
iei
,
uint8_t
_5gg_EASel
,
uint8_t
_5gg_IASel
)
{
uint8_t
_5gg_EASel
,
_iei
=
iei
;
uint8_t
_5gg_IASel
)
{
_iei
=
iei
;
_5g_EASel
=
_5gg_EASel
;
_5g_EASel
=
_5gg_EASel
;
_5g_IASel
=
_5gg_IASel
;
_5g_IASel
=
_5gg_IASel
;
length
=
4
;
length
=
2
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
UESecurityCapability
::
setEASel
(
uint8_t
sel
)
{
void
UESecurityCapability
::
setEASel
(
uint8_t
sel
)
{
_5g_EASel
=
sel
;
}
_5g_EASel
=
sel
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
UESecurityCapability
::
setIASel
(
uint8_t
sel
)
{
void
UESecurityCapability
::
setIASel
(
uint8_t
sel
)
{
_5g_IASel
=
sel
;
}
_5g_IASel
=
sel
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
uint8_t
UESecurityCapability
::
getEASel
()
{
uint8_t
UESecurityCapability
::
getEASel
()
{
return
_5g_EASel
;
}
return
_5g_EASel
;
}
//------------------------------------------------------------------------------
uint8_t
UESecurityCapability
::
getIASel
()
{
return
_5g_IASel
;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
uint8_t
UESecurityCapability
::
getIASel
()
{
void
UESecurityCapability
::
setLenght
(
uint8_t
len
)
{
return
_5g_IASel
;
if
((
len
>
0
)
&&
(
len
<=
4
))
{
length
=
len
;
}
else
{
Logger
::
nas_mm
().
debug
(
"Set UESecurityCapability Lenght faile %d"
,
len
);
Logger
::
nas_mm
().
debug
(
"UESecurityCapability Lenght is set to the default value %d"
,
length
);
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
UESecurityCapability
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
uint8_t
UESecurityCapability
::
getLenght
()
{
return
length
;
}
//------------------------------------------------------------------------------
int
UESecurityCapability
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding UESecurityCapability IEI 0x%x"
,
_iei
);
Logger
::
nas_mm
().
debug
(
"Encoding UESecurityCapability IEI 0x%x"
,
_iei
);
if
(
len
<
length
)
{
if
(
len
<
length
)
{
Logger
::
nas_mm
().
error
(
"len is less than %d"
,
length
);
Logger
::
nas_mm
().
error
(
"len is less than %d"
,
length
);
...
@@ -81,27 +86,40 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) {
...
@@ -81,27 +86,40 @@ int UESecurityCapability::encode2buffer(uint8_t* buf, int len) {
if
(
_iei
)
{
if
(
_iei
)
{
*
(
buf
+
encoded_size
)
=
_iei
;
*
(
buf
+
encoded_size
)
=
_iei
;
encoded_size
++
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
length
-
2
;
*
(
buf
+
encoded_size
)
=
length
;
encoded_size
++
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
encoded_size
++
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
encoded_size
++
;
encoded_size
++
;
if
(
length
==
4
)
{
*
(
buf
+
encoded_size
)
=
0xf0
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
0xf0
;
encoded_size
++
;
}
}
else
{
}
else
{
*
(
buf
+
encoded_size
)
=
length
-
2
;
*
(
buf
+
encoded_size
)
=
length
;
encoded_size
++
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
encoded_size
++
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
encoded_size
++
;
encoded_size
++
;
if
(
length
==
4
)
{
*
(
buf
+
encoded_size
)
=
0xf0
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
0xf0
;
encoded_size
++
;
}
}
}
Logger
::
nas_mm
().
debug
(
"encoded UESecurityCapability (len %d)"
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"encoded UESecurityCapability (len %d)"
,
encoded_size
);
return
encoded_size
;
return
encoded_size
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
UESecurityCapability
::
decodefrombuffer
(
int
UESecurityCapability
::
decodefrombuffer
(
uint8_t
*
buf
,
int
len
,
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
bool
is_option
)
{
Logger
::
nas_mm
().
debug
(
"Decoding UESecurityCapability IEI 0x%x"
,
*
buf
);
Logger
::
nas_mm
().
debug
(
"Decoding UESecurityCapability IEI 0x%x"
,
*
buf
);
int
decoded_size
=
0
;
int
decoded_size
=
0
;
if
(
is_option
)
{
if
(
is_option
)
{
...
@@ -112,10 +130,10 @@ int UESecurityCapability::decodefrombuffer(
...
@@ -112,10 +130,10 @@ int UESecurityCapability::decodefrombuffer(
_5g_EASel
=
*
(
buf
+
decoded_size
);
_5g_EASel
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
decoded_size
++
;
_5g_IASel
=
*
(
buf
+
decoded_size
);
_5g_IASel
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
decoded_size
++
;
if
(
length
==
4
)
if
(
length
==
4
)
decoded_size
+=
2
;
//
to do: decoding EEA EIA
decoded_size
+=
2
;
//
to do: decoding EEA EIA
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"UESecurityCapability EA 0x%d,IA 0x%d"
,
_5g_EASel
,
"UESecurityCapability EA 0x%d,IA 0x%d"
,
_5g_EASel
,
_5g_IASel
);
_5g_IASel
);
return
decoded_size
;
return
decoded_size
;
}
}
src/nas/ies/UESecurityCapability.hpp
View file @
63c70695
...
@@ -34,26 +34,28 @@
...
@@ -34,26 +34,28 @@
namespace
nas
{
namespace
nas
{
class
UESecurityCapability
{
class
UESecurityCapability
{
public:
public:
UESecurityCapability
(
uint8_t
iei
);
UESecurityCapability
(
uint8_t
iei
);
UESecurityCapability
();
UESecurityCapability
();
~
UESecurityCapability
();
~
UESecurityCapability
();
UESecurityCapability
(
UESecurityCapability
(
const
uint8_t
iei
,
uint8_t
_5gg_EASel
,
const
uint8_t
iei
,
uint8_t
_5gg_EASel
,
uint8_t
_5gg_IASel
);
uint8_t
_5gg_IASel
);
void
setEASel
(
uint8_t
sel
);
void
setEASel
(
uint8_t
sel
);
void
setIASel
(
uint8_t
sel
);
void
setIASel
(
uint8_t
sel
);
uint8_t
getEASel
();
uint8_t
getEASel
();
uint8_t
getIASel
();
uint8_t
getIASel
();
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
void
setLenght
(
uint8_t
len
);
int
decodefrombuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
);
uint8_t
getLenght
();
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
decodefrombuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
);
private:
private:
uint8_t
_iei
;
uint8_t
_iei
;
uint8_t
length
;
uint8_t
length
;
uint8_t
_5g_EASel
;
uint8_t
_5g_EASel
;
uint8_t
_5g_IASel
;
uint8_t
_5g_IASel
;
};
};
}
// namespace nas
}
// namespace nas
#endif
#endif
src/nas/msgs/ULNASTransport.cpp
View file @
63c70695
...
@@ -34,16 +34,16 @@ using namespace nas;
...
@@ -34,16 +34,16 @@ using namespace nas;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ULNASTransport
::
ULNASTransport
()
{
ULNASTransport
::
ULNASTransport
()
{
plain_header
=
NULL
;
plain_header
=
NULL
;
ie_payload_container_type
=
NULL
;
ie_payload_container_type
=
NULL
;
ie_payload_container
=
NULL
;
ie_payload_container
=
NULL
;
ie_pdu_session_identity_2
=
NULL
;
ie_pdu_session_identity_2
=
NULL
;
ie_old_pdu_session_identity_2
=
NULL
;
ie_old_pdu_session_identity_2
=
NULL
;
ie_request_type
=
NULL
;
ie_request_type
=
NULL
;
ie_s_nssai
=
NULL
;
ie_s_nssai
=
NULL
;
ie_dnn
=
NULL
;
ie_dnn
=
NULL
;
ie_additional_information
=
NULL
;
ie_additional_information
=
NULL
;
ie_ma_pdu_session_information
=
NULL
;
ie_ma_pdu_session_information
=
NULL
;
ie_release_assistance_indication
=
NULL
;
ie_release_assistance_indication
=
NULL
;
}
}
...
@@ -53,8 +53,8 @@ ULNASTransport::~ULNASTransport() {}
...
@@ -53,8 +53,8 @@ ULNASTransport::~ULNASTransport() {}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
ULNASTransport
::
setHeader
(
uint8_t
security_header_type
)
{
void
ULNASTransport
::
setHeader
(
uint8_t
security_header_type
)
{
plain_header
=
new
NasMmPlainHeader
();
plain_header
=
new
NasMmPlainHeader
();
plain_header
->
setHeader
(
plain_header
->
setHeader
(
EPD_5GS_MM_MSG
,
security_header_type
,
EPD_5GS_MM_MSG
,
security_header_type
,
UL_NAS_TRANSPORT
);
UL_NAS_TRANSPORT
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -78,14 +78,14 @@ void ULNASTransport::setPayload_Container(
...
@@ -78,14 +78,14 @@ void ULNASTransport::setPayload_Container(
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
ULNASTransport
::
getPayloadContainer
(
bstring
&
content
)
{
bool
ULNASTransport
::
getPayloadContainer
(
bstring
&
content
)
{
ie_payload_container
->
getValue
(
content
);
ie_payload_container
->
getValue
(
content
);
return
true
;
return
true
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
ULNASTransport
::
getPayloadContainer
(
bool
ULNASTransport
::
getPayloadContainer
(
std
::
vector
<
PayloadContainerEntry
>
&
content
)
{
std
::
vector
<
PayloadContainerEntry
>
&
content
)
{
if
(
ie_payload_container
)
{
if
(
ie_payload_container
)
{
ie_payload_container
->
getValue
(
content
);
ie_payload_container
->
getValue
(
content
);
return
0
;
return
0
;
...
@@ -140,7 +140,7 @@ void ULNASTransport::setS_NSSAI(SNSSAI_s snssai) {
...
@@ -140,7 +140,7 @@ void ULNASTransport::setS_NSSAI(SNSSAI_s snssai) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
ULNASTransport
::
getSnssai
(
SNSSAI_s
&
snssai
)
{
bool
ULNASTransport
::
getSnssai
(
SNSSAI_s
&
snssai
)
{
if
(
ie_s_nssai
)
{
if
(
ie_s_nssai
)
{
ie_s_nssai
->
getValue
(
snssai
);
ie_s_nssai
->
getValue
(
snssai
);
return
0
;
return
0
;
...
@@ -150,12 +150,10 @@ bool ULNASTransport::getSnssai(SNSSAI_s& snssai) {
...
@@ -150,12 +150,10 @@ bool ULNASTransport::getSnssai(SNSSAI_s& snssai) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
ULNASTransport
::
setDNN
(
bstring
dnn
)
{
void
ULNASTransport
::
setDNN
(
bstring
dnn
)
{
ie_dnn
=
new
DNN
(
0x25
,
dnn
);
}
ie_dnn
=
new
DNN
(
0x25
,
dnn
);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
ULNASTransport
::
getDnn
(
bstring
&
dnn
)
{
bool
ULNASTransport
::
getDnn
(
bstring
&
dnn
)
{
if
(
ie_dnn
)
{
if
(
ie_dnn
)
{
ie_dnn
->
getValue
(
dnn
);
ie_dnn
->
getValue
(
dnn
);
return
true
;
return
true
;
...
@@ -181,14 +179,15 @@ void ULNASTransport::setRelease_Assistance_Indication(uint8_t value) {
...
@@ -181,14 +179,15 @@ void ULNASTransport::setRelease_Assistance_Indication(uint8_t value) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
ULNASTransport
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
int
ULNASTransport
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"encoding ULNASTransport message"
);
Logger
::
nas_mm
().
debug
(
"encoding ULNASTransport message"
);
int
encoded_size
=
0
;
int
encoded_size
=
0
;
if
(
!
plain_header
)
{
if
(
!
plain_header
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Header"
);
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Header"
);
return
0
;
return
0
;
}
}
if
(
!
(
plain_header
->
encode2buffer
(
buf
,
len
)))
return
0
;
if
(
!
(
plain_header
->
encode2buffer
(
buf
,
len
)))
return
0
;
encoded_size
+=
3
;
encoded_size
+=
3
;
if
(
!
ie_payload_container_type
)
{
if
(
!
ie_payload_container_type
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_payload_container_type is not available"
);
Logger
::
nas_mm
().
warn
(
"IE ie_payload_container_type is not available"
);
...
@@ -204,8 +203,8 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
...
@@ -204,8 +203,8 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
if
(
!
ie_payload_container
)
{
if
(
!
ie_payload_container
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_payload_container is not available"
);
Logger
::
nas_mm
().
warn
(
"IE ie_payload_container is not available"
);
}
else
{
}
else
{
if
(
int
size
=
ie_payload_container
->
encode2buffer
(
if
(
int
size
=
ie_payload_container
->
encode2buffer
(
buf
+
encoded_size
,
buf
+
encoded_size
,
len
-
encoded_size
))
{
len
-
encoded_size
))
{
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
"encoding ie_payload_container error"
);
Logger
::
nas_mm
().
error
(
"encoding ie_payload_container error"
);
...
@@ -238,8 +237,8 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
...
@@ -238,8 +237,8 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
if
(
!
ie_request_type
)
{
if
(
!
ie_request_type
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_request_type is not available"
);
Logger
::
nas_mm
().
warn
(
"IE ie_request_type is not available"
);
}
else
{
}
else
{
if
(
int
size
=
ie_request_type
->
encode2buffer
(
if
(
int
size
=
ie_request_type
->
encode2buffer
(
buf
+
encoded_size
,
buf
+
encoded_size
,
len
-
encoded_size
))
{
len
-
encoded_size
))
{
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
"encoding ie ie_request_type error"
);
Logger
::
nas_mm
().
error
(
"encoding ie ie_request_type error"
);
...
@@ -304,17 +303,17 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
...
@@ -304,17 +303,17 @@ int ULNASTransport::encode2buffer(uint8_t* buf, int len) {
return
0
;
return
0
;
}
}
}
}
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"encoded ULNASTransport message len(%d)"
,
"encoded ULNASTransport message len(%d)"
,
encoded_size
);
encoded_size
);
return
1
;
return
1
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
ULNASTransport
::
decodefrombuffer
(
int
ULNASTransport
::
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
)
{
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Decoding ULNASTransport message"
);
Logger
::
nas_mm
().
debug
(
"Decoding ULNASTransport message"
);
int
decoded_size
=
3
;
int
decoded_size
=
3
;
plain_header
=
header
;
plain_header
=
header
;
ie_payload_container_type
=
new
Payload_Container_Type
();
ie_payload_container_type
=
new
Payload_Container_Type
();
decoded_size
+=
ie_payload_container_type
->
decodefrombuffer
(
decoded_size
+=
ie_payload_container_type
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
...
@@ -325,76 +324,89 @@ int ULNASTransport::decodefrombuffer(
...
@@ -325,76 +324,89 @@ int ULNASTransport::decodefrombuffer(
Logger
::
nas_mm
().
debug
(
"Decoded_size (%d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded_size (%d)"
,
decoded_size
);
uint8_t
octet
=
*
(
buf
+
decoded_size
);
uint8_t
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"First option IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"First option IEI (0x%x)"
,
octet
);
bool
flag
=
false
;
while
((
octet
!=
0x0
))
{
while
((
octet
!=
0x0
))
{
switch
((
octet
&
0xf0
)
>>
4
)
{
switch
((
octet
&
0xf0
)
>>
4
)
{
case
0x8
:
{
case
0x8
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x8)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x8)"
);
ie_request_type
=
new
Request_Type
();
ie_request_type
=
new
Request_Type
();
decoded_size
+=
ie_request_type
->
decodefrombuffer
(
decoded_size
+=
ie_request_type
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
break
;
case
0xA
:
{
case
0xA
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0xA)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0xA)"
);
ie_ma_pdu_session_information
=
new
MA_PDU_Session_Information
();
ie_ma_pdu_session_information
=
new
MA_PDU_Session_Information
();
decoded_size
+=
ie_ma_pdu_session_information
->
decodefrombuffer
(
decoded_size
+=
ie_ma_pdu_session_information
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
break
;
case
0xF
:
{
case
0xF
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0xF)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0xF)"
);
ie_release_assistance_indication
=
new
Release_Assistance_Indication
();
ie_release_assistance_indication
=
new
Release_Assistance_Indication
();
decoded_size
+=
ie_release_assistance_indication
->
decodefrombuffer
(
decoded_size
+=
ie_release_assistance_indication
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
break
;
default:
{
flag
=
true
;
}
}
}
switch
(
octet
)
{
switch
(
octet
)
{
case
0x12
:
{
case
0x12
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x12)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x12)"
);
ie_pdu_session_identity_2
=
new
PDU_Session_Identity_2
();
ie_pdu_session_identity_2
=
new
PDU_Session_Identity_2
();
decoded_size
+=
ie_pdu_session_identity_2
->
decodefrombuffer
(
decoded_size
+=
ie_pdu_session_identity_2
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
break
;
case
0x59
:
{
case
0x59
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x59)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x59)"
);
ie_old_pdu_session_identity_2
=
new
PDU_Session_Identity_2
();
ie_old_pdu_session_identity_2
=
new
PDU_Session_Identity_2
();
decoded_size
+=
ie_old_pdu_session_identity_2
->
decodefrombuffer
(
decoded_size
+=
ie_old_pdu_session_identity_2
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
break
;
case
0x22
:
{
case
0x22
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x22)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x22)"
);
ie_s_nssai
=
new
S_NSSAI
();
ie_s_nssai
=
new
S_NSSAI
();
decoded_size
+=
ie_s_nssai
->
decodefrombuffer
(
decoded_size
+=
ie_s_nssai
->
decodefrombuffer
(
buf
+
decoded_size
,
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
case
0x25
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x25)"
);
ie_dnn
=
new
DNN
();
decoded_size
+=
ie_dnn
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
case
0x24
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x24)"
);
ie_additional_information
=
new
Additional_Information
();
decoded_size
+=
ie_additional_information
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
default:
{
if
(
flag
)
{
Logger
::
nas_mm
().
debug
(
"Unknown IEI (0x%x)"
,
octet
);
decoded_size
++
;
octet
=
*
(
buf
+
decoded_size
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
case
0x25
:
{
}
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x25)"
);
ie_dnn
=
new
DNN
();
decoded_size
+=
ie_dnn
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
case
0x24
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x24)"
);
ie_additional_information
=
new
Additional_Information
();
decoded_size
+=
ie_additional_information
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
);
octet
=
*
(
buf
+
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Next IEI (0x%x)"
,
octet
);
}
break
;
}
}
flag
=
false
;
}
}
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"decoded ULNASTransport message len(%d)"
,
"decoded ULNASTransport message len(%d)"
,
decoded_size
);
decoded_size
);
}
}
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