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
454e097a
Commit
454e097a
authored
Jan 06, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update NSSAI
parent
f9d806bd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
85 deletions
+67
-85
src/nas/common/Ie_Const.hpp
src/nas/common/Ie_Const.hpp
+1
-0
src/nas/ies/NSSAI.cpp
src/nas/ies/NSSAI.cpp
+32
-54
src/nas/ies/NSSAI.hpp
src/nas/ies/NSSAI.hpp
+12
-8
src/nas/ies/UESecurityCapability.cpp
src/nas/ies/UESecurityCapability.cpp
+11
-12
src/nas/ies/UESecurityCapability.hpp
src/nas/ies/UESecurityCapability.hpp
+5
-6
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+2
-2
src/nas/msgs/RegistrationRequest.hpp
src/nas/msgs/RegistrationRequest.hpp
+2
-1
src/nas/msgs/SecurityModeCommand.cpp
src/nas/msgs/SecurityModeCommand.cpp
+2
-2
No files found.
src/nas/common/Ie_Const.hpp
View file @
454e097a
...
...
@@ -58,6 +58,7 @@ constexpr uint8_t kIeiNbN1ModeDrxParameters = 0x29;
constexpr
uint8_t
kIeiNSSAIAllowed
=
0x15
;
constexpr
uint8_t
kIeiNSSAIConfigured
=
0x31
;
constexpr
uint8_t
kIeiNSSAIPending
=
0x39
;
constexpr
uint8_t
kIeiNSSAIRequested
=
0x2f
;
constexpr
uint8_t
kIeiOldPduSessionId
=
0x59
;
constexpr
uint8_t
kIeiPduAddress
=
0x29
;
constexpr
uint8_t
kIeiPduSessionId
=
0x12
;
...
...
src/nas/ies/NSSAI.cpp
View file @
454e097a
...
...
@@ -30,26 +30,27 @@
using
namespace
nas
;
//------------------------------------------------------------------------------
NSSAI
::
NSSAI
(
uint8_t
iei
)
{
_iei
=
iei
;
length
=
0
;
NSSAI
::
NSSAI
(
uint8_t
iei
)
:
Type4NasIe
(
iei
)
{
SetLengthIndicator
(
0
)
;
SetIeName
(
kNssaiIeName
)
;
}
//------------------------------------------------------------------------------
NSSAI
::
NSSAI
(
const
uint8_t
iei
,
const
std
::
vector
<
struct
SNSSAI_s
>&
nssai
)
{
_iei
=
iei
;
length
=
0
;
NSSAI
::
NSSAI
(
uint8_t
iei
,
const
std
::
vector
<
struct
SNSSAI_s
>&
nssai
)
:
Type4NasIe
(
iei
)
{
int
length
=
0
;
S_NSSAIs
.
assign
(
nssai
.
begin
(),
nssai
.
end
());
for
(
int
i
=
0
;
i
<
nssai
.
size
();
i
++
)
{
length
+=
(
1
+
nssai
[
i
].
length
);
// 1 for length of NSSAI[i]
// if (nssai[i].sd != SD_NO_VALUE) length += SD_LENGTH;
// if (nssai[i].mHplmnSst != -1) length += SST_LENGTH;
// if (nssai[i].mHplmnSd != SD_NO_VALUE) length += SD_LENGTH;
}
SetLengthIndicator
(
length
);
SetIeName
(
kNssaiIeName
);
}
//------------------------------------------------------------------------------
NSSAI
::
NSSAI
()
:
_iei
(),
length
(),
S_NSSAIs
()
{}
NSSAI
::
NSSAI
()
:
Type4NasIe
(),
S_NSSAIs
()
{
SetIeName
(
kNssaiIeName
);
}
//------------------------------------------------------------------------------
NSSAI
::~
NSSAI
()
{}
...
...
@@ -61,22 +62,18 @@ void NSSAI::getValue(std::vector<struct SNSSAI_s>& nssai) {
//------------------------------------------------------------------------------
int
NSSAI
::
encode2Buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding NSSAI IEI (0x%x)"
,
_iei
);
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
int
ie_len
=
GetIeLength
();
int
total_length
=
(
_iei
>
0
)
?
(
length
+
2
)
:
(
length
+
1
);
if
(
len
<
total_length
)
{
if
(
len
<
ie_len
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than the length of this IE (%d octet)"
,
total_length
);
"Buffer length is less than the length of this IE (%d octet)"
,
ie_len
);
return
KEncodeDecodeError
;
}
int
encoded_size
=
0
;
if
(
_iei
)
{
ENCODE_U8
(
buf
+
encoded_size
,
_iei
,
encoded_size
);
}
ENCODE_U8
(
buf
+
encoded_size
,
length
,
encoded_size
);
// IEI and Length
encoded_size
+=
Type4NasIe
::
Encode
(
buf
+
encoded_size
,
len
);
for
(
int
i
=
0
;
i
<
S_NSSAIs
.
size
();
i
++
)
{
// TODO: Define encode for SNSSAI_s
...
...
@@ -87,23 +84,8 @@ int NSSAI::encode2Buffer(uint8_t* buf, int len) {
if
(
S_NSSAIs
.
at
(
i
).
sd
!=
SD_NO_VALUE
)
{
len_s_nssai
+=
SD_LENGTH
;
ENCODE_U8
(
buf
+
encoded_size
,
(
S_NSSAIs
.
at
(
i
).
sd
&
0x00ff0000
)
>>
16
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded NSSAI SD first octet (0x%x)"
,
(
S_NSSAIs
.
at
(
i
).
sd
&
0x00ff0000
)
>>
16
);
ENCODE_U8
(
buf
+
encoded_size
,
(
S_NSSAIs
.
at
(
i
).
sd
&
0x0000ff00
)
>>
8
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded NSSAI SD second octet (%x)"
,
*
(
buf
+
encoded_size
-
1
));
ENCODE_U8
(
buf
+
encoded_size
,
S_NSSAIs
.
at
(
i
).
sd
&
0x000000ff
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded NSSAI SD third octet (%x)"
,
*
(
buf
+
encoded_size
-
1
));
ENCODE_U24
(
buf
+
encoded_size
,
S_NSSAIs
.
at
(
i
).
sd
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded NSSAI SD (0x%x)"
,
S_NSSAIs
.
at
(
i
).
sd
);
}
if
(
S_NSSAIs
.
at
(
i
).
length
>
(
SST_LENGTH
+
SD_LENGTH
))
{
if
(
S_NSSAIs
.
at
(
i
).
mHplmnSst
!=
-
1
)
{
...
...
@@ -113,16 +95,13 @@ int NSSAI::encode2Buffer(uint8_t* buf, int len) {
}
if
(
S_NSSAIs
.
at
(
i
).
mHplmnSd
!=
SD_NO_VALUE
)
{
len_s_nssai
+=
SD_LENGTH
;
*
(
buf
+
encoded_size
)
=
(
S_NSSAIs
.
at
(
i
).
mHplmnSd
&
0x00ff0000
)
>>
16
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
(
S_NSSAIs
.
at
(
i
).
mHplmnSd
&
0x0000ff00
)
>>
8
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
S_NSSAIs
.
at
(
i
).
mHplmnSd
&
0x000000ff
;
encoded_size
++
;
ENCODE_U24
(
buf
+
encoded_size
,
S_NSSAIs
.
at
(
i
).
mHplmnSd
,
encoded_size
);
}
}
*
(
buf
+
encoded_size
-
len_s_nssai
-
1
)
=
len_s_nssai
;
int
encoded_size_tmp
=
0
;
ENCODE_U8
(
buf
+
encoded_size
-
len_s_nssai
-
1
,
len_s_nssai
,
encoded_size_tmp
);
}
Logger
::
nas_mm
().
debug
(
"Encoded NSSAI len (%d)"
,
encoded_size
);
...
...
@@ -130,19 +109,16 @@ int NSSAI::encode2Buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int
NSSAI
::
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
Logger
::
nas_mm
().
debug
(
"Decoding NSSAI IEI (0x%x)"
,
*
buf
);
int
NSSAI
::
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
)
{
Logger
::
nas_mm
().
debug
(
"Decoding %s"
,
GetIeName
().
c_str
());
int
decoded_size
=
0
;
SNSSAI_s
a
=
{
0
,
0
,
0
,
0
};
if
(
is_option
)
{
// IEI
DECODE_U8
(
buf
+
decoded_size
,
_iei
,
decoded_size
);
}
// Length
DECODE_U8
(
buf
+
decoded_size
,
length
,
decoded_size
);
//
IEI and
Length
decoded_size
+=
Type4NasIe
::
Decode
(
buf
+
decoded_size
,
len
,
is_iei
);
int
length_tmp
=
length
;
int
length_tmp
=
GetLengthIndicator
()
;
while
(
length_tmp
)
{
switch
(
*
(
buf
+
decoded_size
))
{
// Length of SNSSAI
...
...
@@ -212,6 +188,8 @@ int NSSAI::decodeFromBuffer(uint8_t* buf, int len, bool is_option) {
Logger
::
nas_mm
().
debug
(
"Decoded NSSAI %s"
,
S_NSSAIs
.
at
(
i
).
ToString
().
c_str
());
}
Logger
::
nas_mm
().
debug
(
"Decoded NSSAI len (%d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded %s, len (%d)"
,
GetIeName
().
c_str
(),
decoded_size
);
return
decoded_size
;
}
src/nas/ies/NSSAI.hpp
View file @
454e097a
...
...
@@ -21,28 +21,32 @@
#ifndef _NSSAI_H_
#define _NSSAI_H_
#include <stdint.h>
#include "NasIeHeader.hpp"
#include "Type4NasIe.hpp"
#include <stdint.h>
#include <vector>
#include "NasIeHeader.hpp"
constexpr
uint8_t
kNssaiMinimumLength
=
4
;
constexpr
uint8_t
kNssaiMaximumLength
=
146
;
constexpr
auto
kNssaiIeName
=
"NSSAI"
;
namespace
nas
{
class
NSSAI
{
class
NSSAI
:
public
Type4NasIe
{
public:
NSSAI
();
NSSAI
(
uint8_t
iei
);
NSSAI
(
const
uint8_t
iei
,
const
std
::
vector
<
struct
SNSSAI_s
>&
nssai
);
NSSAI
(
uint8_t
iei
,
const
std
::
vector
<
struct
SNSSAI_s
>&
nssai
);
~
NSSAI
();
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_
option
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_
iei
);
void
getValue
(
std
::
vector
<
struct
SNSSAI_s
>&
nssai
);
private:
uint8_t
_iei
;
uint8_t
length
;
std
::
vector
<
struct
SNSSAI_s
>
S_NSSAIs
;
std
::
vector
<
struct
SNSSAI_s
>
S_NSSAIs
;
// TODO: use class S-NSSAI instead of struct SNSSAI_s
};
}
// namespace nas
...
...
src/nas/ies/UESecurityCapability.cpp
View file @
454e097a
...
...
@@ -34,7 +34,7 @@ UESecurityCapability::UESecurityCapability() : Type4NasIe() {
eea_
=
std
::
nullopt
;
eia_
=
std
::
nullopt
;
SetLengthIndicator
(
2
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
...
...
@@ -44,7 +44,7 @@ UESecurityCapability::UESecurityCapability(uint8_t iei) : Type4NasIe(iei) {
eea_
=
std
::
nullopt
;
eia_
=
std
::
nullopt
;
SetLengthIndicator
(
2
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
...
...
@@ -55,31 +55,31 @@ UESecurityCapability::UESecurityCapability(uint8_t _5g_ea, uint8_t _5g_ia)
eea_
=
std
::
nullopt
;
eia_
=
std
::
nullopt
;
SetLengthIndicator
(
2
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
UESecurityCapability
::
UESecurityCapability
(
const
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
)
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
)
:
Type4NasIe
(
iei
)
{
_5g_ea_
=
_5g_ea
;
_5g_ia_
=
_5g_ia
;
eea_
=
std
::
nullopt
;
eia_
=
std
::
nullopt
;
SetLengthIndicator
(
2
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
UESecurityCapability
::
UESecurityCapability
(
const
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
,
uint8_t
eea
,
uint8_t
eia
)
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
,
uint8_t
eea
,
uint8_t
eia
)
:
Type4NasIe
(
iei
)
{
_5g_ea_
=
_5g_ea
;
_5g_ia_
=
_5g_ia
;
eea_
=
std
::
optional
<
uint8_t
>
(
eea
);
eia_
=
std
::
optional
<
uint8_t
>
(
eia
);
SetLengthIndicator
(
4
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
...
...
@@ -91,7 +91,7 @@ UESecurityCapability::UESecurityCapability(
eea_
=
std
::
optional
<
uint8_t
>
(
eea
);
eia_
=
std
::
optional
<
uint8_t
>
(
eia
);
SetLengthIndicator
(
4
);
SetIeName
(
kUeSecurityCapability
);
SetIeName
(
kUeSecurityCapability
IeName
);
}
//------------------------------------------------------------------------------
...
...
@@ -146,7 +146,7 @@ bool UESecurityCapability::GetEia(uint8_t& value) const {
}
//------------------------------------------------------------------------------
int
UESecurityCapability
::
encode2Buffer
(
uint8_t
*
buf
,
int
len
)
{
int
UESecurityCapability
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
int
ie_len
=
GetIeLength
();
...
...
@@ -181,8 +181,7 @@ int UESecurityCapability::encode2Buffer(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int
UESecurityCapability
::
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
int
UESecurityCapability
::
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
)
{
Logger
::
nas_mm
().
debug
(
"Decoding %s"
,
GetIeName
().
c_str
());
if
(
len
<
kUeSecurityCapabilityMinimumLength
)
{
...
...
@@ -196,7 +195,7 @@ int UESecurityCapability::decodeFromBuffer(
uint8_t
octet
=
0
;
// IEI and Length
decoded_size
+=
Type4NasIe
::
Decode
(
buf
+
decoded_size
,
len
,
is_
option
);
decoded_size
+=
Type4NasIe
::
Decode
(
buf
+
decoded_size
,
len
,
is_
iei
);
// EA
DECODE_U8
(
buf
+
decoded_size
,
_5g_ea_
,
decoded_size
);
// IA
...
...
src/nas/ies/UESecurityCapability.hpp
View file @
454e097a
...
...
@@ -28,7 +28,7 @@
constexpr
uint8_t
kUeSecurityCapabilityMinimumLength
=
4
;
constexpr
uint8_t
kUeSecurityCapabilityMaximumLength
=
10
;
constexpr
auto
kUeSecurityCapability
=
"UE Security Capability"
;
constexpr
auto
kUeSecurityCapability
IeName
=
"UE Security Capability"
;
namespace
nas
{
...
...
@@ -37,10 +37,9 @@ class UESecurityCapability : public Type4NasIe {
UESecurityCapability
();
UESecurityCapability
(
uint8_t
iei
);
UESecurityCapability
(
uint8_t
_5g_ea
,
uint8_t
_5g_ia
);
UESecurityCapability
(
const
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
);
UESecurityCapability
(
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
);
UESecurityCapability
(
const
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
,
uint8_t
eea
,
uint8_t
eia
);
uint8_t
iei
,
uint8_t
_5g_ea
,
uint8_t
_5g_ia
,
uint8_t
eea
,
uint8_t
eia
);
UESecurityCapability
(
uint8_t
_5g_ea
,
uint8_t
_5g_ia
,
uint8_t
eea
,
uint8_t
eia
);
~
UESecurityCapability
();
...
...
@@ -57,8 +56,8 @@ class UESecurityCapability : public Type4NasIe {
void
SetEia
(
uint8_t
value
);
bool
GetEia
(
uint8_t
&
value
)
const
;
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
);
int
Encode
(
uint8_t
*
buf
,
int
len
);
int
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
);
private:
uint8_t
_5g_ea_
;
// 3rd octet, Mandatory
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
454e097a
...
...
@@ -599,7 +599,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
if
(
!
ie_ue_security_capability
.
has_value
())
{
Logger
::
nas_mm
().
warn
(
"IE UE security capability is not available"
);
}
else
{
if
((
encoded_ie_size
=
ie_ue_security_capability
.
value
().
encode2Buffer
(
if
((
encoded_ie_size
=
ie_ue_security_capability
.
value
().
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"encoding UE security capability error"
);
return
KEncodeDecodeError
;
...
...
@@ -912,7 +912,7 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
case
0x2E
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x2E)"
);
UESecurityCapability
ie_ue_security_capability_tmp
=
{};
if
((
decoded_size_ie
=
ie_ue_security_capability_tmp
.
decodeFromBuffer
(
if
((
decoded_size_ie
=
ie_ue_security_capability_tmp
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
))
==
KEncodeDecodeError
)
{
return
KEncodeDecodeError
;
...
...
src/nas/msgs/RegistrationRequest.hpp
View file @
454e097a
...
...
@@ -153,7 +153,8 @@ class RegistrationRequest : public NasMmPlainHeader {
std
::
optional
<
NasKeySetIdentifier
>
ie_non_current_native_nas_ksi
;
// Optional
std
::
optional
<
_5GMMCapability
>
ie_5g_mm_capability
;
// Optional
std
::
optional
<
UESecurityCapability
>
ie_ue_security_capability
;
// Optional
std
::
optional
<
NSSAI
>
ie_requested_NSSAI
;
// Optional
std
::
optional
<
NSSAI
>
ie_requested_NSSAI
;
// Optional
std
::
optional
<
_5GSTrackingAreaIdentity
>
ie_last_visited_registered_TAI
;
// Optional
std
::
optional
<
UENetworkCapability
>
ie_s1_ue_network_capability
;
// Optional
...
...
src/nas/msgs/SecurityModeCommand.cpp
View file @
454e097a
...
...
@@ -154,7 +154,7 @@ int SecurityModeCommand::encode2Buffer(uint8_t* buf, int len) {
if
(
!
ie_ue_security_capability
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_ue_security_capability is not available"
);
}
else
{
if
(
int
size
=
ie_ue_security_capability
->
encode2Buffer
(
if
(
int
size
=
ie_ue_security_capability
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
...
...
@@ -249,7 +249,7 @@ int SecurityModeCommand::decodeFromBuffer(
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Spare half octet
ie_ue_security_capability
=
new
UESecurityCapability
();
decoded_size
+=
ie_ue_security_capability
->
decodeFromBuffer
(
decoded_size
+=
ie_ue_security_capability
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
Logger
::
nas_mm
().
debug
(
"Decoded_size (%d)"
,
decoded_size
);
uint8_t
octet
=
*
(
buf
+
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