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
c950dc54
Commit
c950dc54
authored
Jan 10, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Payload Container
parent
585d36de
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
94 deletions
+138
-94
src/nas/common/Ie_Const.hpp
src/nas/common/Ie_Const.hpp
+38
-38
src/nas/ies/Payload_Container.cpp
src/nas/ies/Payload_Container.cpp
+80
-41
src/nas/ies/Payload_Container.hpp
src/nas/ies/Payload_Container.hpp
+14
-9
src/nas/msgs/DLNASTransport.cpp
src/nas/msgs/DLNASTransport.cpp
+2
-2
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+1
-1
src/nas/msgs/ULNASTransport.cpp
src/nas/msgs/ULNASTransport.cpp
+3
-3
No files found.
src/nas/common/Ie_Const.hpp
View file @
c950dc54
...
...
@@ -48,7 +48,8 @@ constexpr uint8_t kIeiDsTtEthernetPortMacAddress = 0x6e;
constexpr
uint8_t
kIeiEthernetHeaderCompressionConfiguration
=
0x1f
;
constexpr
uint8_t
kIeiExtendedDrxParameters
=
0x6e
;
constexpr
uint8_t
kIeiExtendedProtocolConfigurationOptions
=
0x7b
;
constexpr
uint8_t
kIeiExtendedProtocolConfigurationOptions
=
0x7b
;
// To be verified
constexpr
uint8_t
kIeiIntegrityProtectionMaximumDataRate
=
0x13
;
constexpr
uint8_t
kIeiIpHeaderCompressionConfiguration
=
0x66
;
constexpr
uint8_t
kIeiMaPduSessionInformation
=
0xa0
;
...
...
@@ -119,5 +120,4 @@ constexpr uint8_t kIeiImeisv = 0x77;
constexpr
uint8_t
kIeiNonImeisvPei
=
0x78
;
constexpr
uint8_t
kIeiEapMessage
=
0x78
;
// TODO: to be verified
constexpr
uint8_t
kIeiPayloadContainer
=
0x7b
;
// Should be verified (kIeiExtendedProtocolConfigurationOptions)
constexpr
uint8_t
kIeiPayloadContainer
=
0x7b
;
src/nas/ies/Payload_Container.cpp
View file @
c950dc54
...
...
@@ -27,54 +27,85 @@
using
namespace
nas
;
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
uint8_t
iei
)
{
_iei
=
iei
;
length
=
0
;
Payload_Container
::
Payload_Container
()
:
Type6NasIe
()
{
content
=
std
::
nullopt
;
CONTENT
=
std
::
nullopt
;
SetLengthIndicator
(
0
);
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
uint8_t
iei
,
bstring
b
)
{
_iei
=
iei
;
Payload_Container
::
Payload_Container
(
uint8_t
iei
)
:
Type6NasIe
(
iei
)
{
content
=
std
::
nullopt
;
CONTENT
=
std
::
nullopt
;
SetLengthIndicator
(
0
);
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
const
bstring
&
b
)
:
Type6NasIe
()
{
content
=
std
::
optional
<
bstring
>
(
b
);
CONTENT
=
std
::
nullopt
;
length
=
blength
(
b
);
SetLengthIndicator
(
blength
(
b
));
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
uint8_t
iei
,
const
bstring
&
b
)
:
Type6NasIe
(
iei
)
{
content
=
std
::
optional
<
bstring
>
(
b
);
CONTENT
=
std
::
nullopt
;
SetLengthIndicator
(
blength
(
b
));
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
const
uint8_t
iei
,
std
::
vector
<
PayloadContainerEntry
>
contents
)
{
_iei
=
iei
;
const
std
::
vector
<
PayloadContainerEntry
>&
contents
)
:
Type6NasIe
()
{
content
=
std
::
nullopt
;
length
=
1
;
// for number of entries
int
length
=
1
;
// for number of entries
// CONTENT.assign(content.begin(), content.end());
CONTENT
=
std
::
optional
<
std
::
vector
<
PayloadContainerEntry
>>
(
contents
);
for
(
int
i
=
0
;
i
<
contents
.
size
();
i
++
)
{
length
=
length
+
2
+
contents
.
at
(
i
).
length
;
// 2 for Length of Payload container entry
}
SetLengthIndicator
(
length
);
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::
Payload_Container
(
)
{
_iei
=
0
;
length
=
0
;
Payload_Container
::
Payload_Container
(
const
uint8_t
iei
,
const
std
::
vector
<
PayloadContainerEntry
>&
contents
)
:
Type6NasIe
(
iei
)
{
content
=
std
::
nullopt
;
CONTENT
=
std
::
nullopt
;
int
length
=
1
;
// for number of entries
// CONTENT.assign(content.begin(), content.end());
CONTENT
=
std
::
optional
<
std
::
vector
<
PayloadContainerEntry
>>
(
contents
);
for
(
int
i
=
0
;
i
<
contents
.
size
();
i
++
)
{
length
=
length
+
2
+
contents
.
at
(
i
).
length
;
// 2 for Length of Payload container entry
}
SetLengthIndicator
(
length
);
SetIeName
(
kPayloadContainerIeName
);
}
//------------------------------------------------------------------------------
Payload_Container
::~
Payload_Container
()
{}
/*
//------------------------------------------------------------------------------
void Payload_Container::setValue(uint8_t iei, uint8_t value) {
_iei = iei;
}
*/
//------------------------------------------------------------------------------
bool
Payload_Container
::
getValue
(
std
::
vector
<
PayloadContainerEntry
>&
content
)
{
bool
Payload_Container
::
GetValue
(
std
::
vector
<
PayloadContainerEntry
>&
content
)
const
{
if
(
CONTENT
.
has_value
())
{
content
.
assign
(
CONTENT
.
value
().
begin
(),
CONTENT
.
value
().
end
());
return
true
;
...
...
@@ -83,7 +114,7 @@ bool Payload_Container::getValue(std::vector<PayloadContainerEntry>& content) {
}
//------------------------------------------------------------------------------
bool
Payload_Container
::
getValue
(
bstring
&
cnt
)
{
bool
Payload_Container
::
GetValue
(
bstring
&
cnt
)
const
{
if
(
content
.
has_value
())
{
cnt
=
content
.
value
();
return
true
;
...
...
@@ -93,31 +124,31 @@ bool Payload_Container::getValue(bstring& cnt) {
//------------------------------------------------------------------------------
int
Payload_Container
::
Encode
(
uint8_t
*
buf
,
int
len
,
uint8_t
type
)
{
Logger
::
nas_mm
().
debug
(
"Encoding Payload_Container"
);
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
int
ie_len
=
GetIeLength
();
if
(
(
len
<
kPayloadContainerMinimumLength
)
or
(
len
<
length
+
3
))
{
if
(
len
<
ie_len
)
{
// Length of the content + IEI/Len
Logger
::
nas_mm
().
error
(
"
Buffer length is less than the minimum length of this IE (%d octet
)"
,
kPayloadContainerMinimumLength
);
"
Size of the buffer is not enough to store this IE (IE len %d
)"
,
ie_len
);
return
KEncodeDecodeError
;
}
int
encoded_size
=
0
;
if
(
_iei
)
{
ENCODE_U8
(
buf
+
encoded_size
,
_iei
,
encoded_size
);
}
ENCODE_U16
(
buf
+
encoded_size
,
length
,
encoded_size
);
// IEI and Length (later)
int
len_pos
=
0
;
int
encoded_header_size
=
Type6NasIe
::
Encode
(
buf
+
encoded_size
,
len
,
len_pos
);
if
(
encoded_header_size
==
KEncodeDecodeError
)
return
KEncodeDecodeError
;
encoded_size
+=
encoded_header_size
;
if
(
content
.
has_value
())
{
uint8_t
*
buf_tmp
=
(
uint8_t
*
)
bdata
(
content
.
value
());
if
(
buf_tmp
!=
nullptr
)
memcpy
(
buf
+
encoded_size
,
buf_tmp
,
blength
(
content
.
value
()));
encoded_size
+=
blength
(
content
.
value
());
return
encoded_size
;
}
if
(
CONTENT
.
has_value
())
{
}
else
if
(
CONTENT
.
has_value
())
{
// Number of entries
ENCODE_U8
(
buf
+
encoded_size
,
CONTENT
.
value
().
size
(),
encoded_size
);
...
...
@@ -148,34 +179,40 @@ int Payload_Container::Encode(uint8_t* buf, int len, uint8_t type) {
}
}
Logger
::
nas_mm
().
debug
(
"Encoded Payload_Container len(%d)"
,
encoded_size
);
// Encode length
int
encoded_len_ie
=
0
;
ENCODE_U16
(
buf
+
len_pos
,
encoded_size
-
GetHeaderLength
(),
encoded_len_ie
);
Logger
::
nas_mm
().
debug
(
"Encoded %s, len (%d)"
,
GetIeName
().
c_str
(),
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
int
Payload_Container
::
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_option
,
uint8_t
type
)
{
Logger
::
nas_mm
().
debug
(
"Decoding Payload_Container"
);
uint8_t
*
buf
,
int
len
,
bool
is_iei
,
uint8_t
type
)
{
Logger
::
nas_mm
().
debug
(
"Decoding EPS_NAS_Message_Container"
);
int
decoded_size
=
0
;
if
(
is_option
)
{
DECODE_U8
(
buf
+
decoded_size
,
_iei
,
decoded_size
);
}
DECODE_U16
(
buf
+
decoded_size
,
length
,
decoded_size
);
// IEI and Length
uint16_t
ie_len
=
0
;
int
decoded_header_size
=
Type6NasIe
::
Decode
(
buf
+
decoded_size
,
len
,
is_iei
);
if
(
decoded_header_size
==
KEncodeDecodeError
)
return
KEncodeDecodeError
;
decoded_size
+=
decoded_header_size
;
ie_len
=
GetLengthIndicator
();
if
(
type
!=
MULTIPLE_PAYLOADS
)
{
// not multiple payloads
uint8_t
octet
=
0
;
bstring
content_tmp
=
{};
content_tmp
=
blk2bstr
(
buf
+
decoded_size
,
length
);
content_tmp
=
blk2bstr
(
buf
+
decoded_size
,
ie_len
);
content
=
std
::
optional
<
bstring
>
(
content_tmp
);
decoded_size
+=
length
;
decoded_size
+=
ie_len
;
return
decoded_size
;
}
// Multiple payloads
uint8_t
num_entries
;
uint8_t
num_optional
;
uint8_t
num_entries
=
{}
;
uint8_t
num_optional
=
{}
;
std
::
vector
<
PayloadContainerEntry
>
CONTENT_tmp
;
PayloadContainerEntry
payloadcontainerentry
=
{};
...
...
@@ -207,6 +244,8 @@ int Payload_Container::Decode(
num_entries
--
;
}
CONTENT
=
std
::
optional
<
std
::
vector
<
PayloadContainerEntry
>>
(
CONTENT
);
Logger
::
nas_mm
().
debug
(
"Decoded Payload_Container (len %d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded EPS_NAS_Message_Container (len %d)"
,
decoded_size
);
return
decoded_size
;
}
src/nas/ies/Payload_Container.hpp
View file @
c950dc54
...
...
@@ -27,6 +27,8 @@
#include <vector>
#include "NasIeHeader.hpp"
#include "Type6NasIe.hpp"
extern
"C"
{
#include "TLVDecoder.h"
#include "TLVEncoder.h"
...
...
@@ -35,25 +37,28 @@ extern "C" {
constexpr
uint8_t
kPayloadContainerMinimumLength
=
4
;
constexpr
uint32_t
kPayloadContainerMaximumLength
=
65538
;
constexpr
auto
kPayloadContainerIeName
=
"Payload Container"
;
namespace
nas
{
class
Payload_Container
{
class
Payload_Container
:
Type6NasIe
{
public:
Payload_Container
();
Payload_Container
(
uint8_t
iei
);
Payload_Container
(
uint8_t
iei
,
bstring
b
);
Payload_Container
(
const
bstring
&
b
);
Payload_Container
(
uint8_t
iei
,
const
bstring
&
b
);
Payload_Container
(
const
std
::
vector
<
PayloadContainerEntry
>&
content
);
Payload_Container
(
const
uint8_t
iei
,
std
::
vector
<
PayloadContainerEntry
>
content
);
const
uint8_t
iei
,
const
std
::
vector
<
PayloadContainerEntry
>&
content
);
~
Payload_Container
();
void
setValue
(
uint8_t
iei
,
uint8_t
value
);
// void setValue(uint8_t iei, uint8_t value);
int
Encode
(
uint8_t
*
buf
,
int
len
,
uint8_t
type
);
int
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_option
,
uint8_t
type
);
bool
getValue
(
std
::
vector
<
PayloadContainerEntry
>&
content
);
bool
getValue
(
bstring
&
cnt
);
int
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
,
uint8_t
type
);
bool
GetValue
(
std
::
vector
<
PayloadContainerEntry
>&
content
)
const
;
bool
GetValue
(
bstring
&
cnt
)
const
;
private:
uint8_t
_iei
;
uint16_t
length
;
std
::
optional
<
bstring
>
content
;
std
::
optional
<
std
::
vector
<
PayloadContainerEntry
>>
CONTENT
;
};
...
...
src/nas/msgs/DLNASTransport.cpp
View file @
c950dc54
...
...
@@ -63,13 +63,13 @@ void DLNASTransport::setPayload_Container_Type(uint8_t value) {
//------------------------------------------------------------------------------
void
DLNASTransport
::
setPayload_Container
(
std
::
vector
<
PayloadContainerEntry
>
content
)
{
ie_payload_container
=
new
Payload_Container
(
0x00
,
content
);
ie_payload_container
=
new
Payload_Container
(
content
);
}
//------------------------------------------------------------------------------
void
DLNASTransport
::
setPayload_Container
(
uint8_t
*
buf
,
int
len
)
{
bstring
b
=
blk2bstr
(
buf
,
len
);
ie_payload_container
=
new
Payload_Container
(
0x00
,
b
);
ie_payload_container
=
new
Payload_Container
(
b
);
}
//------------------------------------------------------------------------------
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
c950dc54
...
...
@@ -450,7 +450,7 @@ void RegistrationRequest::setPayload_Container(
bool
RegistrationRequest
::
getPayloadContainer
(
std
::
vector
<
PayloadContainerEntry
>&
content
)
{
if
(
ie_payload_container
.
has_value
())
{
return
ie_payload_container
.
value
().
g
etValue
(
content
);
return
ie_payload_container
.
value
().
G
etValue
(
content
);
}
else
{
return
false
;
}
...
...
src/nas/msgs/ULNASTransport.cpp
View file @
c950dc54
...
...
@@ -68,12 +68,12 @@ uint8_t ULNASTransport::getPayloadContainerType() {
//------------------------------------------------------------------------------
void
ULNASTransport
::
setPayload_Container
(
std
::
vector
<
PayloadContainerEntry
>
content
)
{
ie_payload_container
=
new
Payload_Container
(
0x00
,
content
);
ie_payload_container
=
new
Payload_Container
(
content
);
}
//------------------------------------------------------------------------------
bool
ULNASTransport
::
getPayloadContainer
(
bstring
&
content
)
{
ie_payload_container
->
g
etValue
(
content
);
ie_payload_container
->
G
etValue
(
content
);
return
true
;
}
...
...
@@ -81,7 +81,7 @@ bool ULNASTransport::getPayloadContainer(bstring& content) {
bool
ULNASTransport
::
getPayloadContainer
(
std
::
vector
<
PayloadContainerEntry
>&
content
)
{
if
(
ie_payload_container
)
{
ie_payload_container
->
g
etValue
(
content
);
ie_payload_container
->
G
etValue
(
content
);
return
0
;
}
else
{
return
-
1
;
...
...
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