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
3397bfc4
Commit
3397bfc4
authored
Jan 15, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update S_NSSAI
parent
8d48f47e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
63 deletions
+65
-63
src/nas/ies/S_NSSAI.cpp
src/nas/ies/S_NSSAI.cpp
+50
-46
src/nas/ies/S_NSSAI.hpp
src/nas/ies/S_NSSAI.hpp
+13
-16
src/nas/msgs/ULNASTransport.cpp
src/nas/msgs/ULNASTransport.cpp
+2
-1
No files found.
src/nas/ies/S_NSSAI.cpp
View file @
3397bfc4
...
@@ -25,15 +25,26 @@
...
@@ -25,15 +25,26 @@
#include "logger.hpp"
#include "logger.hpp"
using
namespace
nas
;
using
namespace
nas
;
//------------------------------------------------------------------------------
S_NSSAI
::
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
)
:
Type4NasIe
()
{
if
(
iei_
.
has_value
())
{
SetIei
(
iei
.
value
());
}
sst_
=
{
0
};
sd_
=
std
::
nullopt
;
mapped_hplmn_sst_
=
std
::
nullopt
;
mapped_hplmn_sd_
=
std
::
nullopt
;
SetLengthIndicator
(
1
);
// SST
SetIeName
(
kSNssaiIeName
);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
S_NSSAI
::
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
,
SNSSAI_s
snssai
)
{
S_NSSAI
::
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
,
SNSSAI_s
snssai
)
{
// IEI
// IEI
iei_
=
iei
;
if
(
iei_
.
has_value
())
{
if
(
iei_
.
has_value
())
{
length
=
snssai
.
length
+
1
;
SetIei
(
iei
.
value
());
}
else
{
length
=
snssai
.
length
;
}
}
// SST
// SST
sst_
=
snssai
.
sst
;
sst_
=
snssai
.
sst
;
...
@@ -63,16 +74,9 @@ S_NSSAI::S_NSSAI(std::optional<uint8_t> iei, SNSSAI_s snssai) {
...
@@ -63,16 +74,9 @@ S_NSSAI::S_NSSAI(std::optional<uint8_t> iei, SNSSAI_s snssai) {
}
else
{
}
else
{
sd_
=
std
::
nullopt
;
sd_
=
std
::
nullopt
;
}
}
}
//------------------------------------------------------------------------------
SetLengthIndicator
(
snssai
.
length
);
S_NSSAI
::
S_NSSAI
()
{
SetIeName
(
kSNssaiIeName
);
iei_
=
std
::
nullopt
;
sst_
=
{
0
};
sd_
=
std
::
nullopt
;
mapped_hplmn_sst_
=
std
::
nullopt
;
mapped_hplmn_sd_
=
std
::
nullopt
;
length
=
{
0
};
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -119,11 +123,10 @@ void S_NSSAI::SetSNSSAI(
...
@@ -119,11 +123,10 @@ void S_NSSAI::SetSNSSAI(
std
::
optional
<
int8_t
>
mapped_hplmn_sst
,
std
::
optional
<
int8_t
>
mapped_hplmn_sst
,
std
::
optional
<
int32_t
>
mapped_hplmn_sd
)
{
std
::
optional
<
int32_t
>
mapped_hplmn_sd
)
{
// IEI
// IEI
iei_
=
iei
;
if
(
iei_
.
has_value
())
{
if
(
iei_
.
has_value
())
{
length
+=
1
;
SetIei
(
iei
.
value
())
;
}
}
uint8_t
length
=
0
;
// SST
// SST
sst_
=
sst
;
sst_
=
sst
;
length
+=
SST_LENGTH
;
length
+=
SST_LENGTH
;
...
@@ -145,11 +148,8 @@ void S_NSSAI::SetSNSSAI(
...
@@ -145,11 +148,8 @@ void S_NSSAI::SetSNSSAI(
if
(
mapped_hplmn_sd_
.
has_value
())
{
if
(
mapped_hplmn_sd_
.
has_value
())
{
length
+=
SD_LENGTH
;
length
+=
SD_LENGTH
;
}
}
}
//------------------------------------------------------------------------------
SetLengthIndicator
(
length
);
uint8_t
S_NSSAI
::
GetLength
()
{
return
length
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -173,19 +173,19 @@ std::string S_NSSAI::ToString() {
...
@@ -173,19 +173,19 @@ std::string S_NSSAI::ToString() {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
S_NSSAI
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
int
S_NSSAI
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding S-NSSAI"
);
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
if
(
len
<
length
)
{
int
ie_len
=
GetIeLength
();
Logger
::
nas_mm
().
error
(
"len is less than %d"
,
length
);
return
0
;
}
int
encoded_size
=
0
;
// IEI
if
(
len
<
ie_len
)
{
if
(
iei_
.
has_value
())
Logger
::
nas_mm
().
error
(
"Len is less than %d"
,
ie_len
);
ENCODE_U8
(
buf
+
encoded_size
,
iei_
.
value
(),
encoded_size
);
return
KEncodeDecodeError
;
}
// LENGTH
int
encoded_size
=
0
;
ENCODE_U8
(
buf
+
encoded_size
,
length
-
2
,
encoded_size
);
// IEI and Length
int
encoded_header_size
=
Type4NasIe
::
Encode
(
buf
+
encoded_size
,
len
);
if
(
encoded_header_size
==
KEncodeDecodeError
)
return
KEncodeDecodeError
;
encoded_size
+=
encoded_header_size
;
// SST
// SST
ENCODE_U8
(
buf
+
encoded_size
,
sst_
,
encoded_size
);
ENCODE_U8
(
buf
+
encoded_size
,
sst_
,
encoded_size
);
...
@@ -202,27 +202,30 @@ int S_NSSAI::Encode(uint8_t* buf, int len) {
...
@@ -202,27 +202,30 @@ int S_NSSAI::Encode(uint8_t* buf, int len) {
if
(
mapped_hplmn_sd_
.
has_value
())
if
(
mapped_hplmn_sd_
.
has_value
())
ENCODE_U24
(
buf
+
encoded_size
,
mapped_hplmn_sd_
.
value
(),
encoded_size
);
ENCODE_U24
(
buf
+
encoded_size
,
mapped_hplmn_sd_
.
value
(),
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded S-NSSAI len (%d)"
,
encoded_size
);
Logger
::
nas_mm
().
debug
(
"Encoded %s, len (%d)"
,
GetIeName
().
c_str
(),
encoded_size
);
return
encoded_size
;
return
encoded_size
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int
S_NSSAI
::
Decode
(
uint8_t
*
buf
,
int
len
,
const
bool
is_option
)
{
int
S_NSSAI
::
Decode
(
uint8_t
*
buf
,
int
len
,
const
bool
is_iei
)
{
Logger
::
nas_mm
().
debug
(
"Decoding S_NSSAI"
);
if
(
len
<
kSNssaiMinimumLength
)
{
int
decoded_size
=
{
0
};
Logger
::
nas_mm
().
error
(
"Buffer length is less than the minimum length of this IE (%d octet)"
,
if
(
is_option
)
{
kSNssaiMinimumLength
);
uint8_t
iei_value
=
{
0
};
return
KEncodeDecodeError
;
DECODE_U8
(
buf
+
decoded_size
,
iei_value
,
decoded_size
);
iei_
=
std
::
optional
<
uint8_t
>
{
iei_value
};
Logger
::
nas_mm
().
debug
(
"IEI (0x%x)"
,
iei_value
);
}
else
{
iei_
=
std
::
nullopt
;
}
}
DECODE_U8
(
buf
+
decoded_size
,
length
,
decoded_size
);
uint8_t
decoded_size
=
0
;
uint8_t
octet
=
0
;
Logger
::
nas_mm
().
debug
(
"Decoding %s"
,
GetIeName
().
c_str
());
// IEI and Length
int
decoded_header_size
=
Type4NasIe
::
Decode
(
buf
+
decoded_size
,
len
,
is_iei
);
if
(
decoded_header_size
==
KEncodeDecodeError
)
return
KEncodeDecodeError
;
decoded_size
+=
decoded_header_size
;
switch
(
length
)
{
switch
(
GetLengthIndicator
()
)
{
case
1
:
{
case
1
:
{
DECODE_U8
(
buf
+
decoded_size
,
sst_
,
decoded_size
);
DECODE_U8
(
buf
+
decoded_size
,
sst_
,
decoded_size
);
sd_
=
std
::
nullopt
;
sd_
=
std
::
nullopt
;
...
@@ -274,6 +277,7 @@ int S_NSSAI::Decode(uint8_t* buf, int len, const bool is_option) {
...
@@ -274,6 +277,7 @@ int S_NSSAI::Decode(uint8_t* buf, int len, const bool is_option) {
}
}
Logger
::
nas_mm
().
debug
(
"Decoded S-NSSAI %s"
,
ToString
().
c_str
());
Logger
::
nas_mm
().
debug
(
"Decoded S-NSSAI %s"
,
ToString
().
c_str
());
Logger
::
nas_mm
().
debug
(
"Decoded S-NSSAI len (%d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded %s, len (%d)"
,
GetIeName
().
c_str
(),
decoded_size
);
return
decoded_size
;
return
decoded_size
;
}
}
src/nas/ies/S_NSSAI.hpp
View file @
3397bfc4
...
@@ -19,43 +19,40 @@
...
@@ -19,43 +19,40 @@
* contact@openairinterface.org
* contact@openairinterface.org
*/
*/
/*! \file
#ifndef _S_NSSAI_NAS_H_
\brief
#define _S_NSSAI_NAS_H_
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef __S_NSSAI_H_
#define __S_NSSAI_H_
#include <stdint.h>
#include "Type4NasIe.hpp"
#include "struct.hpp"
#include "NasIeHeader.hpp"
constexpr
uint8_t
kSNssaiMinimumLength
=
3
;
#include <optional>
constexpr
uint8_t
kSNssaiMaximumLength
=
10
;
constexpr
auto
kSNssaiIeName
=
"S-NSSAI"
;
namespace
nas
{
namespace
nas
{
class
S_NSSAI
{
class
S_NSSAI
:
public
Type4NasIe
{
public:
public:
S_NSSAI
();
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
);
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
,
SNSSAI_s
snssai
);
S_NSSAI
(
std
::
optional
<
uint8_t
>
iei
,
SNSSAI_s
snssai
);
~
S_NSSAI
();
~
S_NSSAI
();
// void SetSNssai(SNSSAI_s snssai);
// void SetSNssai(SNSSAI_s snssai);
int
Encode
(
uint8_t
*
buf
,
int
len
);
int
Encode
(
uint8_t
*
buf
,
int
len
);
int
Decode
(
uint8_t
*
buf
,
int
len
,
const
bool
is_option
=
true
);
int
Decode
(
uint8_t
*
buf
,
int
len
,
const
bool
is_option
=
true
);
void
getValue
(
SNSSAI_t
&
snssai
);
void
getValue
(
SNSSAI_t
&
snssai
);
void
SetSNSSAI
(
void
SetSNSSAI
(
std
::
optional
<
int8_t
>
iei
,
uint8_t
sst
,
std
::
optional
<
int32_t
>
sd
,
std
::
optional
<
int8_t
>
iei
,
uint8_t
sst
,
std
::
optional
<
int32_t
>
sd
,
std
::
optional
<
int8_t
>
mapped_hplmn_sst
,
std
::
optional
<
int8_t
>
mapped_hplmn_sst
,
std
::
optional
<
int32_t
>
mapped_hplmn_sd
);
std
::
optional
<
int32_t
>
mapped_hplmn_sd
);
uint8_t
GetLength
();
uint8_t
GetLength
();
std
::
string
ToString
();
std
::
string
ToString
();
private:
private:
std
::
optional
<
int8_t
>
iei_
;
uint8_t
length
;
uint8_t
sst_
;
uint8_t
sst_
;
std
::
optional
<
int32_t
>
sd_
;
std
::
optional
<
int32_t
>
sd_
;
std
::
optional
<
int8_t
>
mapped_hplmn_sst_
;
std
::
optional
<
int8_t
>
mapped_hplmn_sst_
;
...
...
src/nas/msgs/ULNASTransport.cpp
View file @
3397bfc4
...
@@ -424,7 +424,8 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
...
@@ -424,7 +424,8 @@ int ULNASTransport::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
}
break
;
}
break
;
case
0x22
:
{
case
0x22
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x22)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x22)"
);
S_NSSAI
ie_s_nssai_tmp
=
{};
auto
s_nssai_ie
=
std
::
optional
<
uint8_t
>
(
kIeiSNssai
);
S_NSSAI
ie_s_nssai_tmp
(
s_nssai_ie
);
if
((
decoded_result
=
ie_s_nssai_tmp
.
Decode
(
if
((
decoded_result
=
ie_s_nssai_tmp
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
kIeIsOptional
))
==
buf
+
decoded_size
,
len
-
decoded_size
,
kIeIsOptional
))
==
KEncodeDecodeError
)
KEncodeDecodeError
)
...
...
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