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
734434ca
Commit
734434ca
authored
Jan 04, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 5GMMCapability
parent
5ea14f46
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
36 deletions
+83
-36
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+1
-1
src/nas/ies/5GMMCapability.cpp
src/nas/ies/5GMMCapability.cpp
+32
-26
src/nas/ies/5GMMCapability.hpp
src/nas/ies/5GMMCapability.hpp
+6
-4
src/nas/ies/NasKeySetIdentifier.cpp
src/nas/ies/NasKeySetIdentifier.cpp
+2
-0
src/nas/ies/NasKeySetIdentifier.hpp
src/nas/ies/NasKeySetIdentifier.hpp
+0
-4
src/nas/ies/Type4NasIe.cpp
src/nas/ies/Type4NasIe.cpp
+42
-1
No files found.
src/contexts/nas_context.hpp
View file @
734434ca
...
@@ -84,7 +84,7 @@ class nas_context {
...
@@ -84,7 +84,7 @@ class nas_context {
uint8_t
ngKsi
:
4
;
uint8_t
ngKsi
:
4
;
// 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
;
// TODO: multiple octets
uint8_t
ueSecurityCaplen
;
uint8_t
ueSecurityCaplen
;
uint8_t
ueSecurityCapEnc
;
uint8_t
ueSecurityCapEnc
;
uint8_t
ueSecurityCapInt
;
uint8_t
ueSecurityCapInt
;
...
...
src/nas/ies/5GMMCapability.cpp
View file @
734434ca
...
@@ -28,10 +28,12 @@
...
@@ -28,10 +28,12 @@
using
namespace
nas
;
using
namespace
nas
;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
_5GMMCapability
::
_5GMMCapability
(
const
uint8_t
iei
,
uint8_t
value
)
{
_5GMMCapability
::
_5GMMCapability
(
const
uint8_t
iei
,
uint8_t
octet3
)
{
m_iei
=
iei
;
iei_
=
iei
;
octet3_
=
value
;
octet3_
=
octet3
;
length
=
k5gmmCapabilityMinimumLength
;
octet4_
=
std
::
nullopt
;
octet5_
=
std
::
nullopt
;
length
=
1
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -41,36 +43,39 @@ _5GMMCapability::_5GMMCapability() {}
...
@@ -41,36 +43,39 @@ _5GMMCapability::_5GMMCapability() {}
_5GMMCapability
::~
_5GMMCapability
()
{}
_5GMMCapability
::~
_5GMMCapability
()
{}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
_5GMMCapability
::
set
Value
(
uint8_t
iei
,
uint8_t
value
)
{
void
_5GMMCapability
::
set
Octet3
(
const
uint8_t
iei
,
uint8_t
octet3
)
{
m_iei
=
iei
;
iei_
=
iei
;
octet3_
=
value
;
octet3_
=
octet3
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
uint8_t
_5GMMCapability
::
get
Value
()
{
uint8_t
_5GMMCapability
::
get
Octet3
()
const
{
return
octet3_
;
return
octet3_
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
_5GMMCapability
::
encode2Buffer
(
uint8_t
*
buf
,
int
len
)
{
int
_5GMMCapability
::
encode2Buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding _5GMMCapability IEI (0x%x)"
,
m_iei
);
Logger
::
nas_mm
().
debug
(
"Encoding _5GMMCapability IEI"
);
if
(
len
<
length
)
{
int
ie_len
=
iei_
?
(
length
+
2
)
:
(
length
+
1
);
// 1 for IEI, 1 for Length
Logger
::
nas_mm
().
error
(
"Len is less than %d"
,
length
);
if
(
len
<
ie_len
)
{
Logger
::
nas_mm
().
error
(
"Len is less than %d"
,
ie_len
);
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
int
encoded_size
=
0
;
int
encoded_size
=
0
;
if
(
m_iei
)
{
// IEI
ENCODE_U8
(
buf
+
encoded_size
,
m_iei
,
encoded_size
);
if
(
iei_
)
{
ENCODE_U8
(
buf
+
encoded_size
,
length
-
2
,
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
iei_
,
encoded_size
);
}
else
{
ENCODE_U8
(
buf
+
encoded_size
,
length
-
1
,
encoded_size
);
}
}
// Length
ENCODE_U8
(
buf
+
encoded_size
,
length
,
encoded_size
);
// Octet 3
ENCODE_U8
(
buf
+
encoded_size
,
octet3_
,
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
octet3_
,
encoded_size
);
// TODO: Encode spare for the rest
// TODO: Encode spare for the rest
uint8_t
spare
=
0
;
uint8_t
spare
=
0
;
for
(
int
i
=
0
;
i
<
(
length
-
encoded_size
);
i
++
)
{
int
spare_len
=
ie_len
-
encoded_size
;
for
(
int
i
=
0
;
i
<
spare_len
;
i
++
)
{
ENCODE_U8
(
buf
+
encoded_size
,
spare
,
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
spare
,
encoded_size
);
}
}
...
@@ -88,24 +93,25 @@ int _5GMMCapability::decodeFromBuffer(uint8_t* buf, int len, bool is_option) {
...
@@ -88,24 +93,25 @@ int _5GMMCapability::decodeFromBuffer(uint8_t* buf, int len, bool is_option) {
}
}
uint8_t
decoded_size
=
0
;
uint8_t
decoded_size
=
0
;
uint8_t
octet
=
0
;
Logger
::
nas_mm
().
debug
(
"Decoding _5GMMCapability IE
I (0x%x)"
,
*
buf
);
Logger
::
nas_mm
().
debug
(
"Decoding _5GMMCapability IE
"
);
if
(
is_option
)
{
if
(
is_option
)
{
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
iei_
=
std
::
optional
<
uint8_t
>
(
octet
);
}
}
uint8_t
ie_len
=
0
;
DECODE_U8
(
buf
+
decoded_size
,
length
,
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
ie_len
,
decoded_size
);
length
=
ie_len
+
decoded_size
;
DECODE_U8
(
buf
+
decoded_size
,
octet3_
,
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
octet3_
,
decoded_size
);
// TODO: decode the rest as spare for now
// TODO: decode the rest as spare for now
uint8_t
spare
=
0
;
uint8_t
spare
=
0
;
for
(
int
i
=
0
;
i
<
(
ie_len
-
1
);
i
++
)
{
for
(
int
i
=
0
;
i
<
(
length
-
1
);
i
++
)
{
ENCODE_U8
(
buf
+
decoded_size
,
spare
,
decoded_size
);
ENCODE_U8
(
buf
+
decoded_size
,
spare
,
decoded_size
);
}
}
Logger
::
nas_mm
().
debug
(
"Decoded _5GMMCapability value(0x%x)"
,
octet3_
);
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"Decoded _5GMMCapability len(%d)"
,
decoded_size
);
"Decoded _5GMMCapability Octet3 value (0x%x)"
,
octet3_
);
Logger
::
nas_mm
().
debug
(
"Decoded _5GMMCapability len (%d)"
,
decoded_size
);
return
decoded_size
;
return
decoded_size
;
}
}
src/nas/ies/5GMMCapability.hpp
View file @
734434ca
...
@@ -32,18 +32,20 @@ namespace nas {
...
@@ -32,18 +32,20 @@ namespace nas {
class
_5GMMCapability
{
class
_5GMMCapability
{
public:
public:
_5GMMCapability
();
_5GMMCapability
();
_5GMMCapability
(
const
uint8_t
iei
,
uint8_t
value
);
_5GMMCapability
(
const
uint8_t
iei
,
uint8_t
octet3
);
~
_5GMMCapability
();
~
_5GMMCapability
();
void
set
Value
(
uint8_t
iei
,
uint8_t
value
);
void
set
Octet3
(
const
uint8_t
iei
,
uint8_t
octet3
);
uint8_t
get
Value
()
;
uint8_t
get
Octet3
()
const
;
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
encode2Buffer
(
uint8_t
*
buf
,
int
len
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
=
true
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
=
true
);
private:
private:
uint8_t
m_iei
;
uint8_t
iei_
;
uint8_t
octet3_
;
// minimum length of 3 octets
uint8_t
octet3_
;
// minimum length of 3 octets
std
::
optional
<
uint8_t
>
octet4_
;
std
::
optional
<
uint8_t
>
octet5_
;
uint8_t
length
;
uint8_t
length
;
};
};
...
...
src/nas/ies/NasKeySetIdentifier.cpp
View file @
734434ca
...
@@ -57,6 +57,7 @@ NasKeySetIdentifier::~NasKeySetIdentifier(){};
...
@@ -57,6 +57,7 @@ NasKeySetIdentifier::~NasKeySetIdentifier(){};
void
NasKeySetIdentifier
::
Set
(
const
bool
&
high_pos
)
{
void
NasKeySetIdentifier
::
Set
(
const
bool
&
high_pos
)
{
Type1NasIe
::
Set
(
high_pos
);
Type1NasIe
::
Set
(
high_pos
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
SetValue
()
{
void
NasKeySetIdentifier
::
SetValue
()
{
if
(
tsc_
)
if
(
tsc_
)
...
@@ -64,6 +65,7 @@ void NasKeySetIdentifier::SetValue() {
...
@@ -64,6 +65,7 @@ void NasKeySetIdentifier::SetValue() {
else
else
value_
=
0x07
&
key_id_
;
value_
=
0x07
&
key_id_
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
GetValue
()
{
void
NasKeySetIdentifier
::
GetValue
()
{
tsc_
=
(
0b1000
&
value_
)
>>
3
;
tsc_
=
(
0b1000
&
value_
)
>>
3
;
...
...
src/nas/ies/NasKeySetIdentifier.hpp
View file @
734434ca
...
@@ -43,10 +43,6 @@ class NasKeySetIdentifier : public Type1NasIe {
...
@@ -43,10 +43,6 @@ class NasKeySetIdentifier : public Type1NasIe {
// void Set(const bool& tsc, const uint8_t& key_id, const uint8_t& iei);
// void Set(const bool& tsc, const uint8_t& key_id, const uint8_t& iei);
void
Get
(
bool
&
tsc
,
uint8_t
&
key_id
);
void
Get
(
bool
&
tsc
,
uint8_t
&
key_id
);
// int encode2Buffer(uint8_t* buf, const int& len);
// int decodeFromBuffer(
// uint8_t* buf, const int& len, bool is_option, bool is_high);
void
setTypeOfSecurityContext
(
const
bool
&
type
);
void
setTypeOfSecurityContext
(
const
bool
&
type
);
bool
getTypeOfSecurityContext
()
const
;
bool
getTypeOfSecurityContext
()
const
;
...
...
src/nas/ies/Type4NasIe.cpp
View file @
734434ca
...
@@ -47,7 +47,8 @@ void Type4NasIe::SetIei(const uint8_t& iei) {
...
@@ -47,7 +47,8 @@ void Type4NasIe::SetIei(const uint8_t& iei) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool
Type4NasIe
::
Validate
(
const
int
&
len
)
const
{
bool
Type4NasIe
::
Validate
(
const
int
&
len
)
const
{
uint8_t
actual_lengh
=
iei_
.
has_value
()
?
li_
+
1
:
li_
;
uint8_t
actual_lengh
=
iei_
.
has_value
()
?
(
li_
+
2
)
:
(
li_
+
1
);
// 1 for IEI and 1 for LI
if
(
len
<
actual_lengh
)
{
if
(
len
<
actual_lengh
)
{
Logger
::
nas_mm
().
error
(
Logger
::
nas_mm
().
error
(
"Buffer length is less than the minimum length of this IE (%d octet)"
,
"Buffer length is less than the minimum length of this IE (%d octet)"
,
...
@@ -56,3 +57,43 @@ bool Type4NasIe::Validate(const int& len) const {
...
@@ -56,3 +57,43 @@ bool Type4NasIe::Validate(const int& len) const {
}
}
return
true
;
return
true
;
}
}
//------------------------------------------------------------------------------
int
Type4NasIe
::
Encode
(
uint8_t
*
buf
,
const
int
&
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
if
(
!
Validate
(
len
))
return
KEncodeDecodeError
;
int
encoded_size
=
0
;
uint8_t
octet
=
0
;
if
(
iei_
.
has_value
())
{
ENCODE_U8
(
buf
+
encoded_size
,
iei_
.
value
(),
encoded_size
);
}
ENCODE_U8
(
buf
+
encoded_size
,
li_
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded %s (len %d)"
,
GetIeName
().
c_str
(),
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
int
Type4NasIe
::
Decode
(
const
uint8_t
*
const
buf
,
const
int
&
len
,
bool
is_iei
=
false
)
{
Logger
::
nas_mm
().
debug
(
"Decoding %s"
,
GetIeName
().
c_str
());
if
(
!
Validate
(
len
))
return
KEncodeDecodeError
;
int
decoded_size
=
0
;
uint8_t
octet
=
0
;
if
(
is_iei
)
{
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
iei_
=
std
::
optional
<
uint8_t
>
(
octet
);
}
DECODE_U8
(
buf
+
decoded_size
,
li_
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded %s (len %d)"
,
GetIeName
().
c_str
(),
decoded_size
);
return
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