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
1dbeb565
Commit
1dbeb565
authored
Sep 20, 2022
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup for NAS MM Header
parent
ee09cb41
Changes
34
Show whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
389 additions
and
112 deletions
+389
-112
src/nas/common/3gpp24.007.hpp
src/nas/common/3gpp24.007.hpp
+31
-0
src/nas/common/3gpp_ts24501.hpp
src/nas/common/3gpp_ts24501.hpp
+4
-0
src/nas/common/NasIeHeader.hpp
src/nas/common/NasIeHeader.hpp
+1
-1
src/nas/ies/ExtendedProtocolDiscriminator.cpp
src/nas/ies/ExtendedProtocolDiscriminator.cpp
+40
-12
src/nas/ies/ExtendedProtocolDiscriminator.hpp
src/nas/ies/ExtendedProtocolDiscriminator.hpp
+14
-13
src/nas/ies/NSSAI.hpp
src/nas/ies/NSSAI.hpp
+1
-1
src/nas/ies/NasMessageType.cpp
src/nas/ies/NasMessageType.cpp
+43
-11
src/nas/ies/NasMessageType.hpp
src/nas/ies/NasMessageType.hpp
+12
-10
src/nas/ies/Payload_Container.hpp
src/nas/ies/Payload_Container.hpp
+1
-1
src/nas/ies/S_NSSAI.hpp
src/nas/ies/S_NSSAI.hpp
+1
-1
src/nas/ies/SecurityHeaderType.cpp
src/nas/ies/SecurityHeaderType.cpp
+52
-11
src/nas/ies/SecurityHeaderType.hpp
src/nas/ies/SecurityHeaderType.hpp
+13
-10
src/nas/msgs/AuthenticationFailure.hpp
src/nas/msgs/AuthenticationFailure.hpp
+1
-1
src/nas/msgs/AuthenticationReject.hpp
src/nas/msgs/AuthenticationReject.hpp
+1
-1
src/nas/msgs/AuthenticationRequest.hpp
src/nas/msgs/AuthenticationRequest.hpp
+1
-1
src/nas/msgs/AuthenticationResponse.hpp
src/nas/msgs/AuthenticationResponse.hpp
+1
-1
src/nas/msgs/AuthenticationResult.hpp
src/nas/msgs/AuthenticationResult.hpp
+1
-1
src/nas/msgs/DLNASTransport.hpp
src/nas/msgs/DLNASTransport.hpp
+1
-1
src/nas/msgs/DeregistrationAccept.hpp
src/nas/msgs/DeregistrationAccept.hpp
+1
-1
src/nas/msgs/DeregistrationRequest.hpp
src/nas/msgs/DeregistrationRequest.hpp
+1
-1
src/nas/msgs/IdentityRequest.hpp
src/nas/msgs/IdentityRequest.hpp
+1
-1
src/nas/msgs/IdentityResponse.hpp
src/nas/msgs/IdentityResponse.hpp
+1
-1
src/nas/msgs/NasMmPlainHeader.cpp
src/nas/msgs/NasMmPlainHeader.cpp
+136
-0
src/nas/msgs/NasMmPlainHeader.hpp
src/nas/msgs/NasMmPlainHeader.hpp
+20
-21
src/nas/msgs/RegistrationAccept.hpp
src/nas/msgs/RegistrationAccept.hpp
+1
-1
src/nas/msgs/RegistrationComplete.hpp
src/nas/msgs/RegistrationComplete.hpp
+1
-1
src/nas/msgs/RegistrationReject.hpp
src/nas/msgs/RegistrationReject.hpp
+1
-1
src/nas/msgs/RegistrationRequest.hpp
src/nas/msgs/RegistrationRequest.hpp
+1
-1
src/nas/msgs/SecurityModeCommand.hpp
src/nas/msgs/SecurityModeCommand.hpp
+1
-1
src/nas/msgs/SecurityModeComplete.hpp
src/nas/msgs/SecurityModeComplete.hpp
+1
-1
src/nas/msgs/SecurityModeReject.hpp
src/nas/msgs/SecurityModeReject.hpp
+1
-1
src/nas/msgs/ServiceAccept.hpp
src/nas/msgs/ServiceAccept.hpp
+1
-1
src/nas/msgs/ServiceRequest.hpp
src/nas/msgs/ServiceRequest.hpp
+1
-1
src/nas/msgs/ULNASTransport.hpp
src/nas/msgs/ULNASTransport.hpp
+1
-1
No files found.
src/nas/common/3gpp24.007.hpp
0 → 100644
View file @
1dbeb565
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_24_007_SEEN
#define FILE_3GPP_24_007_SEEN
#include <stdint.h>
// Extended Protocol Discriminator (EPD)
constexpr
uint8_t
kEpd5gsSessionManagementMessage
=
0b00101110
;
constexpr
uint8_t
kEpd5gsMobilityManagementMessage
=
0b01111110
;
#endif
src/nas/common/3gpp_ts24501.hpp
View file @
1dbeb565
...
...
@@ -22,6 +22,8 @@
#ifndef _3GPP_TS_24501_H_
#define _3GPP_TS_24501_H_
#include "3gpp24.007.hpp"
#include <string>
#include <vector>
...
...
@@ -185,4 +187,6 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
#define NAS_MESSAGE_MIN_LENGTH 3
constexpr
uint8_t
KEncodeDecodeError
=
0
;
#endif
src/nas/common/
nas_ie_h
eader.hpp
→
src/nas/common/
NasIeH
eader.hpp
View file @
1dbeb565
...
...
@@ -19,6 +19,7 @@
* contact@openairinterface.org
*/
#include "NasMmPlainHeader.hpp"
#include "5GMMCapability.hpp"
#include "5GSMobilityIdentity.hpp"
#include "5GSRegistrationType.hpp"
...
...
@@ -78,6 +79,5 @@
#include "_5GS_Registration_Result.hpp"
#include "_5GS_Tracking_Area_Identity.hpp"
#include "_5GS_Update_Type.hpp"
#include "nas_mm_plain_header.hpp"
#include "struct.hpp"
#include "Ie_Const.hpp"
src/nas/ies/ExtendedProtocolDiscriminator.cpp
View file @
1dbeb565
...
...
@@ -19,26 +19,54 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "ExtendedProtocolDiscriminator.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
void
ExtendedProtocolDiscriminator
::
setValue
(
const
uint8_t
epd
)
{
m_epd
=
epd
;
ExtendedProtocolDiscriminator
::
ExtendedProtocolDiscriminator
()
{}
//------------------------------------------------------------------------------
ExtendedProtocolDiscriminator
::~
ExtendedProtocolDiscriminator
()
{}
//------------------------------------------------------------------------------
void
ExtendedProtocolDiscriminator
::
Set
(
const
uint8_t
&
epd
)
{
epd_
=
epd
;
}
//------------------------------------------------------------------------------
uint8_t
ExtendedProtocolDiscriminator
::
getValue
()
{
return
m_epd
;
void
ExtendedProtocolDiscriminator
::
Get
(
uint8_t
&
epd
)
const
{
epd
=
epd_
;
}
//------------------------------------------------------------------------------
void
ExtendedProtocolDiscriminator
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{}
uint8_t
ExtendedProtocolDiscriminator
::
Get
()
const
{
return
epd_
;
}
//------------------------------------------------------------------------------
uint32_t
ExtendedProtocolDiscriminator
::
Encode
(
uint8_t
*
buf
,
uint32_t
len
)
{
if
(
len
<
kEdpIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %d octet"
,
kEdpIeSize
);
return
KEncodeDecodeError
;
}
uint32_t
encoded_size
=
0
;
ENCODE_U8
(
buf
,
epd_
,
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
uint32_t
ExtendedProtocolDiscriminator
::
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
)
{
if
(
len
<
kEdpIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %s octet"
,
kEdpIeSize
);
return
KEncodeDecodeError
;
}
uint32_t
decoded_size
=
0
;
DECODE_U8
(
buf
,
epd_
,
decoded_size
);
return
decoded_size
;
}
src/nas/ies/ExtendedProtocolDiscriminator.hpp
View file @
1dbeb565
...
...
@@ -19,28 +19,29 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _EPD_H_
#define _EPD_H_
#ifndef EXTENDED_PROTOCOL_DISCRIMINATOR_H_
#define EXTENDED_PROTOCOL_DISCRIMINATOR_H_
#include <stdint.h>
constexpr
uint8_t
kEdpIeSize
=
1
;
namespace
nas
{
class
ExtendedProtocolDiscriminator
{
public:
void
encode2buffer
(
uint8_t
*
buf
,
int
len
);
void
setValue
(
const
uint8_t
epd
);
uint8_t
getValue
();
ExtendedProtocolDiscriminator
();
virtual
~
ExtendedProtocolDiscriminator
();
void
Set
(
const
uint8_t
&
epd
);
void
Get
(
uint8_t
&
epd
)
const
;
uint8_t
Get
()
const
;
uint32_t
Encode
(
uint8_t
*
buf
,
uint32_t
len
);
uint32_t
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
);
private:
uint8_t
m_epd
;
uint8_t
epd_
;
};
}
// namespace nas
...
...
src/nas/ies/NSSAI.hpp
View file @
1dbeb565
...
...
@@ -32,7 +32,7 @@
#include <vector>
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/ies/NasMessageType.cpp
View file @
1dbeb565
...
...
@@ -19,23 +19,55 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "NasMessageType.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
void
NasMessageType
::
setValue
(
const
uint8_t
type
)
{
m_type
=
type
;
NasMessageType
::
NasMessageType
()
{}
//------------------------------------------------------------------------------
NasMessageType
::~
NasMessageType
()
{}
//------------------------------------------------------------------------------
void
NasMessageType
::
Set
(
const
uint8_t
&
message_type
)
{
message_type_
=
message_type
;
}
//------------------------------------------------------------------------------
void
NasMessageType
::
Get
(
uint8_t
&
message_type
)
const
{
message_type
=
message_type_
;
}
//------------------------------------------------------------------------------
uint8_t
NasMessageType
::
Get
()
const
{
return
message_type_
;
}
//------------------------------------------------------------------------------
uint32_t
NasMessageType
::
Encode
(
uint8_t
*
buf
,
uint32_t
len
)
{
if
(
len
<
kNasMessageTypeIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %d octet"
,
kNasMessageTypeIeSize
);
return
KEncodeDecodeError
;
}
uint32_t
encoded_size
=
0
;
ENCODE_U8
(
buf
,
message_type_
,
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
uint8_t
NasMessageType
::
getValue
()
{
return
m_type
;
uint32_t
NasMessageType
::
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
)
{
if
(
len
<
kNasMessageTypeIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %s octet"
,
kNasMessageTypeIeSize
);
return
KEncodeDecodeError
;
}
uint32_t
decoded_size
=
0
;
DECODE_U8
(
buf
,
message_type_
,
decoded_size
);
return
decoded_size
;
}
src/nas/ies/NasMessageType.hpp
View file @
1dbeb565
...
...
@@ -19,27 +19,29 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _MESSAGE_TYPE_H_
#define _MESSAGE_TYPE_H_
#include <stdint.h>
constexpr
uint8_t
kNasMessageTypeIeSize
=
1
;
namespace
nas
{
class
NasMessageType
{
public:
void
setValue
(
const
uint8_t
type
);
uint8_t
getValue
();
NasMessageType
();
virtual
~
NasMessageType
();
void
Set
(
const
uint8_t
&
message_type
);
void
Get
(
uint8_t
&
message_type
)
const
;
uint8_t
Get
()
const
;
uint32_t
Encode
(
uint8_t
*
buf
,
uint32_t
len
);
uint32_t
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
);
private:
uint8_t
m
_type
;
uint8_t
m
essage_type_
;
};
}
// namespace nas
...
...
src/nas/ies/Payload_Container.hpp
View file @
1dbeb565
...
...
@@ -33,7 +33,7 @@
#include <iostream>
#include <vector>
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
extern
"C"
{
#include "TLVDecoder.h"
#include "TLVEncoder.h"
...
...
src/nas/ies/S_NSSAI.hpp
View file @
1dbeb565
...
...
@@ -31,7 +31,7 @@
#include <stdint.h>
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
#include <optional>
namespace
nas
{
...
...
src/nas/ies/SecurityHeaderType.cpp
View file @
1dbeb565
...
...
@@ -19,23 +19,64 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "SecurityHeaderType.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
void
SecurityHeaderType
::
setValue
(
const
uint8_t
value
)
{
secu_header_type
=
0x0f
&
value
;
SecurityHeaderType
::
SecurityHeaderType
()
{}
//------------------------------------------------------------------------------
SecurityHeaderType
::~
SecurityHeaderType
()
{}
//------------------------------------------------------------------------------
void
SecurityHeaderType
::
Set
(
const
uint8_t
&
secu_header_type
,
const
uint8_t
&
spare
)
{
secu_header_type_
=
0x0f
&
secu_header_type
;
spare_
=
spare
&
0xf0
;
}
//------------------------------------------------------------------------------
void
SecurityHeaderType
::
Get
(
uint8_t
&
secu_header_type
)
const
{
secu_header_type
=
secu_header_type_
&
0x0f
;
}
//------------------------------------------------------------------------------
uint8_t
SecurityHeaderType
::
getValue
()
{
return
secu_header_type
&
0x0f
;
uint8_t
SecurityHeaderType
::
Get
()
const
{
return
(
secu_header_type_
&
0x0f
);
}
//------------------------------------------------------------------------------
uint32_t
SecurityHeaderType
::
Encode
(
uint8_t
*
buf
,
uint32_t
len
)
{
if
(
len
<
kSecurityHeaderIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %d octet"
,
kSecurityHeaderIeSize
);
return
KEncodeDecodeError
;
}
uint8_t
value
=
(
secu_header_type_
&
0x0f
)
|
(
spare_
&
0xf0
);
uint32_t
encoded_size
=
0
;
ENCODE_U8
(
buf
,
value
,
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
uint32_t
SecurityHeaderType
::
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
)
{
if
(
len
<
kSecurityHeaderIeSize
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than %s octet"
,
kSecurityHeaderIeSize
);
return
KEncodeDecodeError
;
}
uint8_t
value
;
uint32_t
decoded_size
=
0
;
DECODE_U8
(
buf
,
value
,
decoded_size
);
secu_header_type_
=
0x0f
&
value
;
spare_
=
value
&
0xf0
;
return
decoded_size
;
}
src/nas/ies/SecurityHeaderType.hpp
View file @
1dbeb565
...
...
@@ -19,27 +19,30 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _SECURITY_HEADER_TYPE_H_
#define _SECURITY_HEADER_TYPE_H_
#include <stdint.h>
constexpr
uint8_t
kSecurityHeaderIeSize
=
1
;
namespace
nas
{
class
SecurityHeaderType
{
public:
void
setValue
(
const
uint8_t
value
);
uint8_t
getValue
();
SecurityHeaderType
();
virtual
~
SecurityHeaderType
();
void
Set
(
const
uint8_t
&
secu_header_type
,
const
uint8_t
&
spare
=
0
);
void
Get
(
uint8_t
&
secu_header_type
)
const
;
uint8_t
Get
()
const
;
uint32_t
Encode
(
uint8_t
*
buf
,
uint32_t
len
);
uint32_t
Decode
(
const
uint8_t
*
const
buf
,
uint32_t
len
);
private:
uint8_t
secu_header_type
:
4
;
uint8_t
spare_
:
4
;
uint8_t
secu_header_type_
:
4
;
};
}
// namespace nas
...
...
src/nas/msgs/AuthenticationFailure.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _AuthenticationFailure_H_
#define _AuthenticationFailure_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/AuthenticationReject.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _AuthenticationReject_H_
#define _AuthenticationReject_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/AuthenticationRequest.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _AuthenticationRequest_H_
#define _AuthenticationRequest_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/AuthenticationResponse.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _AuthenticationResponse_H_
#define _AuthenticationResponse_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/AuthenticationResult.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _AuthenticationResult_H_
#define _AuthenticationResult_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/DLNASTransport.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _DLNASTransport_H_
#define _DLNASTransport_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/DeregistrationAccept.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _DEREGISTRATION_ACCEPT_H_
#define _DEREGISTRATION_ACCEPT_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/DeregistrationRequest.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _DEREGISTRATION_REQUEST_H_
#define _DEREGISTRATION_REQUEST_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
using
namespace
std
;
namespace
nas
{
...
...
src/nas/msgs/IdentityRequest.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _IdentityRequest_H_
#define _IdentityRequest_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/IdentityResponse.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _IdentityResponse_H_
#define _IdentityResponse_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/
nas_mm_plain_h
eader.cpp
→
src/nas/msgs/
NasMmPlainH
eader.cpp
View file @
1dbeb565
...
...
@@ -19,85 +19,118 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "nas_mm_plain_header.hpp"
#include "3gpp_ts24501.hpp"
#include "common_defs.h"
#include "logger.hpp"
#include "NasMmPlainHeader.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
void
NasMmPlainHeader
::
setEpdIE
(
const
uint8_t
epd
)
{
ie_epd
.
setValue
(
epd
);
void
NasMmPlainHeader
::
SetEpd
(
const
uint8_t
epd
)
{
epd_
.
Set
(
epd
);
}
//------------------------------------------------------------------------------
uint8_t
NasMmPlainHeader
::
getEpdIE
()
{
return
ie_epd
.
getValue
();
uint8_t
NasMmPlainHeader
::
GetEpd
()
{
return
epd_
.
Get
();
}
//------------------------------------------------------------------------------
void
NasMmPlainHeader
::
setSecurityHeaderTypeIE
(
const
uint8_t
type
)
{
ie_secu_header_type
.
setValue
(
type
);
void
NasMmPlainHeader
::
SetSecurityHeaderType
(
const
uint8_t
type
)
{
secu_header_type_
.
Set
(
type
);
}
//------------------------------------------------------------------------------
uint8_t
NasMmPlainHeader
::
getSecurityHeaderTypeIE
()
{
return
ie_secu_header_type
.
getValue
();
uint8_t
NasMmPlainHeader
::
GetSecurityHeaderType
()
{
return
secu_header_type_
.
Get
();
}
//------------------------------------------------------------------------------
void
NasMmPlainHeader
::
setMessageTypeIE
(
const
uint8_t
type
)
{
ie_msg_type
.
setValue
(
type
);
void
NasMmPlainHeader
::
SetMessageType
(
const
uint8_t
type
)
{
msg_type_
.
Set
(
type
);
}
//------------------------------------------------------------------------------
uint8_t
NasMmPlainHeader
::
g
etMessageType
()
{
return
msg_type
;
uint8_t
NasMmPlainHeader
::
G
etMessageType
()
{
return
msg_type
_
.
Get
()
;
}
//------------------------------------------------------------------------------
void
NasMmPlainHeader
::
setHeader
(
uint8_t
epd_
,
uint8_t
security_header_type
,
uint8_t
msg_type_
)
{
epd
=
epd_
;
secu_header_type
=
security_header_type
;
msg_type
=
msg_type_
;
const
uint8_t
&
epd
,
const
uint8_t
&
security_header_type
,
const
uint8_t
&
msg_type
)
{
epd_
.
Set
(
epd
);
secu_header_type_
.
Set
(
security_header_type
);
msg_type_
.
Set
(
msg_type
);
}
//------------------------------------------------------------------------------
int
NasMmPlainHeader
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding NasMmPlainHeader"
);
if
(
len
<
3
)
{
if
(
len
<
kNasMmPlainHeaderLength
)
{
Logger
::
nas_mm
().
error
(
"buffer length is less than 3 octets"
);
return
0
;
return
KEncodeDecodeError
;
}
else
{
*
(
buf
++
)
=
epd
;
*
(
buf
++
)
=
secu_header_type
;
*
(
buf
++
)
=
msg_type
;
Logger
::
nas_mm
().
debug
(
"Encoded NasMmPlainHeader (len 3 octets)"
);
return
3
;
uint32_t
encoded_size
=
0
;
uint32_t
size
=
0
;
if
((
size
=
epd_
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
encoded_size
+=
size
;
if
((
size
=
secu_header_type_
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
encoded_size
+=
size
;
if
((
size
=
msg_type_
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
encoded_size
+=
size
;
Logger
::
nas_mm
().
debug
(
"Encoded NasMmPlainHeader (len %d octets)"
,
encoded_size
);
return
encoded_size
;
}
}
//------------------------------------------------------------------------------
int
NasMmPlainHeader
::
decodefrombuffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"
d
ecoding NasMmPlainHeader"
);
if
(
len
<
3
)
{
Logger
::
nas_mm
().
error
(
"[decoding nas mm header error][buffer length is less than 3 octets]
"
);
return
0
;
int
NasMmPlainHeader
::
decodefrombuffer
(
const
uint8_t
*
const
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"
D
ecoding NasMmPlainHeader"
);
uint32_t
decoded_size
=
0
;
if
(
len
<
kNasMmPlainHeaderLength
)
{
Logger
::
nas_mm
().
error
(
"Buffer length is less than 3 octets
"
);
return
KEncodeDecodeError
;
}
else
{
epd
=
*
(
buf
++
);
secu_header_type
=
*
(
buf
++
);
msg_type
=
*
(
buf
++
);
uint32_t
size
=
0
;
if
((
size
=
epd_
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Decode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
decoded_size
+=
size
;
if
((
size
=
secu_header_type_
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Decode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
decoded_size
+=
size
;
if
((
size
=
msg_type_
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Decode NAS MM Header IE error"
);
return
KEncodeDecodeError
;
}
decoded_size
+=
size
;
}
Logger
::
nas_mm
().
debug
(
"decoded NasMmPlainHeader len(3 octets)"
);
return
3
;
Logger
::
nas_mm
().
debug
(
"decoded NasMmPlainHeader len (%d octets)"
,
decoded_size
);
return
decoded_size
;
}
src/nas/msgs/
nas_mm_plain_h
eader.hpp
→
src/nas/msgs/
NasMmPlainH
eader.hpp
View file @
1dbeb565
...
...
@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _NAS_MM_PLAIN_HEADER_H_
#define _NAS_MM_PLAIN_HEADER_H_
...
...
@@ -33,27 +26,33 @@
#include "NasMessageType.hpp"
#include "SecurityHeaderType.hpp"
constexpr
uint8_t
kNasMmPlainHeaderLength
=
3
;
namespace
nas
{
class
NasMmPlainHeader
{
public:
void
setHeader
(
uint8_t
epd_
,
uint8_t
security_header_type
,
uint8_t
msg_type_
);
void
setHeader
(
const
uint8_t
&
epd
,
const
uint8_t
&
security_header_type
,
const
uint8_t
&
msg_type
);
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
void
setEpdIE
(
const
uint8_t
epd
);
void
setSecurityHeaderTypeIE
(
const
uint8_t
type
);
void
setMessageTypeIE
(
const
uint8_t
type
);
uint8_t
getEpdIE
();
uint8_t
getSecurityHeaderTypeIE
();
uint8_t
getMessageType
();
int
decodefrombuffer
(
const
uint8_t
*
const
buf
,
int
len
);
void
SetEpd
(
const
uint8_t
epd
);
uint8_t
GetEpd
();
void
SetSecurityHeaderType
(
const
uint8_t
type
);
uint8_t
GetSecurityHeaderType
();
void
SetMessageType
(
const
uint8_t
type
);
uint8_t
GetMessageType
();
private:
ExtendedProtocolDiscriminator
ie_epd
;
SecurityHeaderType
ie_secu_header_type
;
NasMessageType
ie_msg_type
;
uint8_t
epd
;
uint8_t
secu_header_type
;
uint8_t
msg_type
;
ExtendedProtocolDiscriminator
epd_
;
// Mandatory
// TODO: Spare half octet (1/2 octet)
SecurityHeaderType
secu_header_type_
;
// Mandatory (1/2 octet)
NasMessageType
msg_type_
;
// Mandatory
};
}
// namespace nas
...
...
src/nas/msgs/RegistrationAccept.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _RegistrationAccept_H_
#define _RegistrationAccept_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/RegistrationComplete.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _RegistrationComplete_H_
#define _RegistrationComplete_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/RegistrationReject.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _RegistrationReject_H_
#define _RegistrationReject_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/RegistrationRequest.hpp
View file @
1dbeb565
...
...
@@ -36,7 +36,7 @@
#include <string>
#include <vector>
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
using
namespace
std
;
namespace
nas
{
...
...
src/nas/msgs/SecurityModeCommand.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _SecurityModeCommand_H_
#define _SecurityModeCommand_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/SecurityModeComplete.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _SecurityModeComplete_H_
#define _SecurityModeComplete_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/SecurityModeReject.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _SecurityModeReject_H_
#define _SecurityModeReject_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/ServiceAccept.hpp
View file @
1dbeb565
...
...
@@ -33,7 +33,7 @@
#include <string>
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
src/nas/msgs/ServiceRequest.hpp
View file @
1dbeb565
...
...
@@ -32,7 +32,7 @@
#include <string>
#include "bstrlib.h"
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
using
namespace
std
;
...
...
src/nas/msgs/ULNASTransport.hpp
View file @
1dbeb565
...
...
@@ -29,7 +29,7 @@
#ifndef _ULNASTransport_H_
#define _ULNASTransport_H_
#include "
nas_ie_h
eader.hpp"
#include "
NasIeH
eader.hpp"
namespace
nas
{
...
...
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