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
6e336ecb
Commit
6e336ecb
authored
Oct 03, 2022
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup for Registration Request
parent
9f43c107
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
154 additions
and
135 deletions
+154
-135
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+1
-1
src/nas/ies/5GMMCapability.cpp
src/nas/ies/5GMMCapability.cpp
+4
-6
src/nas/ies/UESecurityCapability.cpp
src/nas/ies/UESecurityCapability.cpp
+50
-55
src/nas/ies/UESecurityCapability.hpp
src/nas/ies/UESecurityCapability.hpp
+6
-10
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+89
-60
src/nas/msgs/RegistrationRequest.hpp
src/nas/msgs/RegistrationRequest.hpp
+4
-3
No files found.
src/amf-app/amf_n1.cpp
View file @
6e336ecb
...
@@ -1050,7 +1050,7 @@ void amf_n1::registration_request_handle(
...
@@ -1050,7 +1050,7 @@ void amf_n1::registration_request_handle(
// Check 5gs Mobility Identity (Mandatory IE)
// Check 5gs Mobility Identity (Mandatory IE)
std
::
string
guti
=
{};
std
::
string
guti
=
{};
uint8_t
mobility_id_type
=
registration_request
->
getMobil
ity
IdentityType
();
uint8_t
mobility_id_type
=
registration_request
->
getMobil
e
IdentityType
();
switch
(
mobility_id_type
)
{
switch
(
mobility_id_type
)
{
case
SUCI
:
{
case
SUCI
:
{
nas
::
SUCI_imsi_t
imsi
=
{};
nas
::
SUCI_imsi_t
imsi
=
{};
...
...
src/nas/ies/5GMMCapability.cpp
View file @
6e336ecb
...
@@ -56,7 +56,7 @@ int _5GMMCapability::encode2Buffer(uint8_t* buf, int len) {
...
@@ -56,7 +56,7 @@ 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 (0x%x)"
,
m_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
);
return
0
;
return
KEncodeDecodeError
;
}
}
int
encoded_size
=
0
;
int
encoded_size
=
0
;
...
@@ -80,12 +80,10 @@ int _5GMMCapability::encode2Buffer(uint8_t* buf, int len) {
...
@@ -80,12 +80,10 @@ int _5GMMCapability::encode2Buffer(uint8_t* buf, int len) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
_5GMMCapability
::
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
int
_5GMMCapability
::
decodeFromBuffer
(
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
if
((
len
<
k5gmmCapabilityMinimumLength
)
or
if
(
len
<
k5gmmCapabilityMinimumLength
)
{
(
len
>
k5gmmCapabilityMaximumLength
))
{
Logger
::
nas_mm
().
error
(
Logger
::
nas_mm
().
error
(
"Buffer length is less than the minimum/or greater than the maximum "
"Buffer length is less than the minimum length of this IE (%d octet)"
,
"length of this IE (Min %d octet, Max %d octet)"
,
k5gmmCapabilityMinimumLength
);
k5gmmCapabilityMinimumLength
,
k5gmmCapabilityMaximumLength
);
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
...
...
src/nas/ies/UESecurityCapability.cpp
View file @
6e336ecb
...
@@ -19,16 +19,12 @@
...
@@ -19,16 +19,12 @@
* contact@openairinterface.org
* contact@openairinterface.org
*/
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "UESecurityCapability.hpp"
#include "UESecurityCapability.hpp"
#include "logger.hpp"
#include "logger.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
using
namespace
nas
;
using
namespace
nas
;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -62,7 +58,7 @@ UESecurityCapability::UESecurityCapability(
...
@@ -62,7 +58,7 @@ UESecurityCapability::UESecurityCapability(
_5g_IASel
=
_5gg_IASel
;
_5g_IASel
=
_5gg_IASel
;
EEASel
=
0
;
EEASel
=
0
;
EIASel
=
0
;
EIASel
=
0
;
length
=
2
;
length
=
kUESecurityCapabilityMinimumLength
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -74,7 +70,7 @@ UESecurityCapability::UESecurityCapability(
...
@@ -74,7 +70,7 @@ UESecurityCapability::UESecurityCapability(
_5g_IASel
=
_5gg_IASel
;
_5g_IASel
=
_5gg_IASel
;
EEASel
=
_EEASel
;
EEASel
=
_EEASel
;
EIASel
=
_EIASel
;
EIASel
=
_EIASel
;
length
=
4
;
length
=
kUESecurityCapabilityMaximumLength
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -119,7 +115,8 @@ uint8_t UESecurityCapability::getEIASel() {
...
@@ -119,7 +115,8 @@ uint8_t UESecurityCapability::getEIASel() {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
UESecurityCapability
::
setLength
(
uint8_t
len
)
{
void
UESecurityCapability
::
setLength
(
uint8_t
len
)
{
if
((
len
>
0
)
&&
(
len
<=
4
))
{
if
((
len
>=
kUESecurityCapabilityMinimumLength
)
&&
(
len
<=
kUESecurityCapabilityMaximumLength
))
{
length
=
len
;
length
=
len
;
}
else
{
}
else
{
Logger
::
nas_mm
().
debug
(
"Set UESecurityCapability Length fail %d"
,
len
);
Logger
::
nas_mm
().
debug
(
"Set UESecurityCapability Length fail %d"
,
len
);
...
@@ -136,66 +133,64 @@ uint8_t UESecurityCapability::getLength() {
...
@@ -136,66 +133,64 @@ uint8_t UESecurityCapability::getLength() {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
UESecurityCapability
::
encode2Buffer
(
uint8_t
*
buf
,
int
len
)
{
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
+
2
))
{
// Length of the content + IEI/Len
Logger
::
nas_mm
().
error
(
"len is less than %d"
,
length
);
Logger
::
nas_mm
().
error
(
return
0
;
"Size of the buffer is not enough to store this IE (IE len %d)"
,
length
+
2
);
return
KEncodeDecodeError
;
}
}
int
encoded_size
=
0
;
int
encoded_size
=
0
;
if
(
_iei
)
{
if
(
_iei
)
{
*
(
buf
+
encoded_size
)
=
_iei
;
ENCODE_U8
(
buf
+
encoded_size
,
_iei
,
encoded_size
);
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
length
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
encoded_size
++
;
if
(
length
==
4
)
{
*
(
buf
+
encoded_size
)
=
EEASel
;
// 0xf0; //TODO: remove hardcoded value
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
EIASel
;
// 0x70; //TODO: remove hardcoded value
encoded_size
++
;
}
}
// Length
ENCODE_U8
(
buf
+
encoded_size
,
length
,
encoded_size
);
// EA
ENCODE_U8
(
buf
+
encoded_size
,
_5g_EASel
,
encoded_size
);
// IA
ENCODE_U8
(
buf
+
encoded_size
,
_5g_IASel
,
encoded_size
);
}
else
{
*
(
buf
+
encoded_size
)
=
length
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_EASel
;
encoded_size
++
;
*
(
buf
+
encoded_size
)
=
_5g_IASel
;
encoded_size
++
;
if
(
length
==
4
)
{
if
(
length
==
4
)
{
*
(
buf
+
encoded_size
)
=
EEASel
;
// 0xf0; //TODO: remove hardcoded value
// EEA
encoded_size
++
;
ENCODE_U8
(
buf
+
encoded_size
,
EEASel
,
encoded_size
);
*
(
buf
+
encoded_size
)
=
EIASel
;
// 0x70; //TODO: remove hardcoded value
// EIA
encoded_size
++
;
ENCODE_U8
(
buf
+
encoded_size
,
EIASel
,
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
,
bool
is_option
)
{
uint8_t
*
buf
,
int
len
,
bool
is_option
)
{
Logger
::
nas_mm
().
debug
(
"Decoding UESecurityCapability IEI 0x%x"
,
*
buf
);
Logger
::
nas_mm
().
debug
(
"Decoding UESecurityCapability"
);
if
(
len
<
kUESecurityCapabilityMinimumLength
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than the minimum length of this IE (%d octet)"
,
kUESecurityCapabilityMinimumLength
);
return
KEncodeDecodeError
;
}
int
decoded_size
=
0
;
int
decoded_size
=
0
;
if
(
is_option
)
{
if
(
is_option
)
{
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
_iei
,
decoded_size
)
;
}
}
length
=
*
(
buf
+
decoded_size
);
decoded_size
++
;
// Length
_5g_EASel
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
length
,
decoded_size
);
decoded_size
++
;
// EA
_5g_IASel
=
*
(
buf
+
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
_5g_EASel
,
decoded_size
);
decoded_size
++
;
// IA
DECODE_U8
(
buf
+
decoded_size
,
_5g_IASel
,
decoded_size
);
if
(
length
>=
4
)
{
if
(
length
>=
4
)
{
EEASel
=
*
(
buf
+
decoded_size
);
// EEA
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
EEASel
,
decoded_size
)
;
EIASel
=
*
(
buf
+
decoded_size
);
// EIA
decoded_size
++
;
DECODE_U8
(
buf
+
decoded_size
,
EIASel
,
decoded_size
)
;
decoded_size
+=
(
length
-
4
);
// TODO:
decoding EEA EIA
decoded_size
+=
(
length
-
4
);
// TODO:
Spare
}
}
Logger
::
nas_mm
().
debug
(
Logger
::
nas_mm
().
debug
(
"UESecurityCapability (length %d) EA 0x%x,IA 0x%x, EEA 0x%x, EIA 0x%x,"
,
"UESecurityCapability (length %d) EA 0x%x,IA 0x%x, EEA 0x%x, EIA 0x%x,"
,
...
...
src/nas/ies/UESecurityCapability.hpp
View file @
6e336ecb
...
@@ -19,18 +19,14 @@
...
@@ -19,18 +19,14 @@
* contact@openairinterface.org
* contact@openairinterface.org
*/
*/
/*! \file
#ifndef _UE_SECURITY_CAPABILITY_H
\brief
#define _UE_SECURITY_CAPABILITY_H
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _UESecurityCapability_H
#define _UESecurityCapability_H
#include <stdint.h>
#include <stdint.h>
constexpr
uint8_t
kUESecurityCapabilityMinimumLength
=
2
;
constexpr
uint8_t
kUESecurityCapabilityMaximumLength
=
4
;
namespace
nas
{
namespace
nas
{
class
UESecurityCapability
{
class
UESecurityCapability
{
...
@@ -60,7 +56,7 @@ class UESecurityCapability {
...
@@ -60,7 +56,7 @@ class UESecurityCapability {
private:
private:
uint8_t
_iei
;
uint8_t
_iei
;
uint8_t
length
;
uint8_t
length
;
// Length of UE security capability contents
uint8_t
_5g_EASel
;
uint8_t
_5g_EASel
;
uint8_t
_5g_IASel
;
uint8_t
_5g_IASel
;
uint8_t
EEASel
;
uint8_t
EEASel
;
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
6e336ecb
This diff is collapsed.
Click to expand it.
src/nas/msgs/RegistrationRequest.hpp
View file @
6e336ecb
...
@@ -51,7 +51,8 @@ class RegistrationRequest : public NasMmPlainHeader {
...
@@ -51,7 +51,8 @@ class RegistrationRequest : public NasMmPlainHeader {
void
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
);
void
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
);
bool
getngKSI
(
uint8_t
&
ng_ksi
);
bool
getngKSI
(
uint8_t
&
ng_ksi
);
uint8_t
getMobilityIdentityType
();
uint8_t
getMobileIdentityType
();
// TODO: SetMobileIdentityType(uint8_t);
void
setSUCI_SUPI_format_IMSI
(
void
setSUCI_SUPI_format_IMSI
(
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
...
@@ -149,11 +150,11 @@ class RegistrationRequest : public NasMmPlainHeader {
...
@@ -149,11 +150,11 @@ class RegistrationRequest : public NasMmPlainHeader {
// NasMmPlainHeader* plain_header;
// NasMmPlainHeader* plain_header;
_5GSRegistrationType
ie_5gsregistrationtype
;
// Mandatory
_5GSRegistrationType
ie_5gsregistrationtype
;
// Mandatory
NasKeySetIdentifier
ie_ngKSI
;
// Mandatory
NasKeySetIdentifier
ie_ngKSI
;
// Mandatory
_5GSMobileIdentity
ie_5gs_mobil
ity_id
;
// Mandatory
_5GSMobileIdentity
ie_5gs_mobil
e_identity
;
// Mandatory
std
::
optional
<
NasKeySetIdentifier
>
ie_non_current_native_nas_ksi
;
// Optional
std
::
optional
<
NasKeySetIdentifier
>
ie_non_current_native_nas_ksi
;
// Optional
std
::
optional
<
_5GMMCapability
>
ie_5g_mm_capability
;
// Optional
std
::
optional
<
_5GMMCapability
>
ie_5g_mm_capability
;
// Optional
UESecurityCapability
*
ie_ue_security_capability
;
// Optional
std
::
optional
<
UESecurityCapability
>
ie_ue_security_capability
;
// Optional
NSSAI
*
ie_requested_NSSAI
;
// Optional
NSSAI
*
ie_requested_NSSAI
;
// Optional
// TODO: Last visited registered TAI
// TODO: Last visited registered TAI
UENetworkCapability
*
ie_s1_ue_network_capability
;
// Optional
UENetworkCapability
*
ie_s1_ue_network_capability
;
// Optional
...
...
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