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
79ed2879
Commit
79ed2879
authored
Sep 24, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process UE-initiated Deregistration request
parent
fdf5094a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
669 additions
and
45 deletions
+669
-45
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+49
-15
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+3
-3
src/nas/common/3gpp_ts24501.hpp
src/nas/common/3gpp_ts24501.hpp
+40
-27
src/nas/common/nas_ie_header.hpp
src/nas/common/nas_ie_header.hpp
+1
-0
src/nas/ies/5GSMobilityIdentity.hpp
src/nas/ies/5GSMobilityIdentity.hpp
+6
-0
src/nas/ies/_5GSDeregistrationType.cpp
src/nas/ies/_5GSDeregistrationType.cpp
+101
-0
src/nas/ies/_5GSDeregistrationType.hpp
src/nas/ies/_5GSDeregistrationType.hpp
+72
-0
src/nas/msgs/DeregistrationAccept.cpp
src/nas/msgs/DeregistrationAccept.cpp
+70
-0
src/nas/msgs/DeregistrationAccept.hpp
src/nas/msgs/DeregistrationAccept.hpp
+51
-0
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+205
-0
src/nas/msgs/DeregistrationRequest.hpp
src/nas/msgs/DeregistrationRequest.hpp
+71
-0
No files found.
src/amf-app/amf_n1.cpp
View file @
79ed2879
...
...
@@ -28,26 +28,28 @@
#include "amf_n1.hpp"
#include "amf_n11.hpp"
#include "amf_app.hpp"
#include "itti.hpp"
#include "logger.hpp"
#include "RegistrationRequest.hpp"
#include "RegistrationReject.hpp"
#include "amf_config.hpp"
#include "amf_n11.hpp"
#include "AuthenticationRequest.hpp"
#include "AuthenticationResponse.hpp"
#include "AuthenticationFailure.hpp"
#include "comUt.hpp"
#include "DeregistrationRequest.hpp"
#include "DeregistrationAccept.hpp"
#include "itti_msg_n2.hpp"
#include "itti_msg_n11.hpp"
#include "itti.hpp"
#include "logger.hpp"
#include "nas_algorithms.hpp"
#include "SecurityModeCommand.hpp"
#include "RegistrationRequest.hpp"
#include "RegistrationAccept.hpp"
#include "RegistrationReject.hpp"
#include "ULNASTransport.hpp"
#include "ServiceRequest.hpp"
#include "ServiceAccept.hpp"
#include "itti_msg_n2.hpp"
#include "itti_msg_n11.hpp"
#include "amf_config.hpp"
#include "String2Value.hpp"
#include "nas_algorithms.hpp"
#include "comUt.hpp"
#include "sha256.hpp"
extern
"C"
{
...
...
@@ -1513,12 +1515,44 @@ void amf_n1::run_initial_registration_procedure() {
//------------------------------------------------------------------------------
void
amf_n1
::
ue_initiate_de_registration_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas
)
{
string
guti
=
"1234567890"
;
//need modify
Logger
::
amf_n1
().
debug
(
"Handling UE-initiated De-registration Request"
);
std
::
shared_ptr
<
nas_context
>
nc
;
nc
=
guti_2_nas_context
(
guti
);
nc
.
get
()
->
is_auth_vectors_present
=
false
;
nc
.
get
()
->
is_current_security_available
=
false
;
nc
.
get
()
->
security_ctx
->
sc_type
=
SECURITY_CTX_TYPE_NOT_AVAILABLE
;
if
(
is_amf_ue_id_2_nas_context
(
amf_ue_ngap_id
))
nc
=
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
else
{
Logger
::
amf_n1
().
warn
(
"No existed nas_context with amf_ue_ngap_id(0x%x)"
,
amf_ue_ngap_id
);
return
;
}
//decode NAS msg
DeregistrationRequest
*
deregReq
=
new
DeregistrationRequest
();
deregReq
->
decodefrombuffer
(
NULL
,
(
uint8_t
*
)
bdata
(
nas
),
blength
(
nas
));
_5gs_deregistration_type_t
type
=
{};
deregReq
->
getDeregistrationType
(
type
);
//TODO: validate 5G Mobile Identity
//Prepare DeregistrationAccept
DeregistrationAccept
*
deregAccept
=
new
DeregistrationAccept
();
deregAccept
->
setHeader
(
PLAIN_5GS_MSG
);
//nc.get()->is_auth_vectors_present = false;
//nc.get()->is_current_security_available = false;
//nc.get()->security_ctx->sc_type = SECURITY_CTX_TYPE_NOT_AVAILABLE;
uint8_t
buffer
[
512
]
=
{
0
};
int
encoded_size
=
deregAccept
->
encode2buffer
(
buffer
,
1024
);
print_buffer
(
"amf_n1"
,
"De-registration Accept message buffer"
,
buffer
,
encoded_size
);
if
(
!
encoded_size
)
{
Logger
::
nas_mm
().
error
(
"Encode De-registration Accept message error"
);
free_wrapper
((
void
**
)
&
deregAccept
);
return
;
}
bstring
b
=
blk2bstr
(
buffer
,
encoded_size
);
itti_send_dl_nas_buffer_to_task_n2
(
b
,
ran_ue_ngap_id
,
amf_ue_ngap_id
);
free_wrapper
((
void
**
)
&
deregAccept
);
}
//------------------------------------------------------------------------------
...
...
src/amf-app/amf_n11.cpp
View file @
79ed2879
...
...
@@ -236,15 +236,15 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer &smf) {
}
switch
(
smf
.
req_type
&
0x07
)
{
case
PDU_SESSION
_INITIAL_REQUEST
:
{
case
REQUEST_TYPE
_INITIAL_REQUEST
:
{
handle_pdu_session_initial_request
(
supi
,
psc
,
smf_addr
,
smf
.
sm_msg
,
dnn
);
}
break
;
case
EXISTING_PDU_SESSION
:
{
case
REQUEST_TYPE_
EXISTING_PDU_SESSION
:
{
//TODO:
}
break
;
case
PDU_SESSION
_MODIFICATION_REQUEST
:
{
case
REQUEST_TYPE
_MODIFICATION_REQUEST
:
{
//TODO:
}
break
;
...
...
src/nas/common/3gpp_ts24501.hpp
View file @
79ed2879
...
...
@@ -44,25 +44,38 @@
/********** message type ********************/
#define REGISTRATION_REQUEST 0b01000001
#define REGISTRATION_REJECT 0b01000100
#define AUTHENTICATION_REQUEST 0b01010110
#define AUTHENTICATION_RESPONSE 0b01010111
#define AUTHENTICATION_RESULT 0b01011010
#define AUTHENTICATION_FAILURE 0b01011001
#define AUTHENTICATION_REJECT 0b01011000
#define SECURITY_MODE_COMMAND 0b01011101
#define SECURITY_MODE_COMPLETE 0b01011110
#define SECURITY_MODE_REJECT 0b01011111
#define REGISTRATION_COMPLETE 0b01000011
#define REGISTRATION_ACCEPT 0b01000010
#define IDENTITY_REQUEST 0b01011011
#define IDENTITY_RESPONSE 0b01011100
#define UL_NAS_TRANSPORT 0b01100111
#define DL_NAS_TRANSPORT 0b01101000
#define SERVICE_REQUEST 0b01001100
#define SERVICE_REJECT 0b01001101
#define SERVICE_ACCEPT 0b01001110
#define REGISTRATION_REQUEST 0b01000001
#define REGISTRATION_ACCEPT 0b01000010
#define REGISTRATION_COMPLETE 0b01000011
#define REGISTRATION_REJECT 0b01000100
#define DEREGISTRATION_REQUEST_UE_ORIGINATING 0b01000101
#define DEREGISTRATION_ACCEPT_UE_ORIGINATING 0b01000110
#define DEREGISTRATION_REQUEST_UE_TERMINATED 0b01000111
#define DEREGISTRATION_ACCEPT_UE_TERMINATED 0b01001000
#define SERVICE_REQUEST 0b01001100
#define SERVICE_REJECT 0b01001101
#define SERVICE_ACCEPT 0b01001110
#define CONFIGURATION_UPDATE_COMMAND 0b01010100
#define CONFIGURATION_UPDATE_COMPLETE 0b01010101
#define AUTHENTICATION_REQUEST 0b01010110
#define AUTHENTICATION_RESPONSE 0b01010111
#define AUTHENTICATION_REJECT 0b01011000
#define AUTHENTICATION_FAILURE 0b01011001
#define AUTHENTICATION_RESULT 0b01011010
#define IDENTITY_REQUEST 0b01011011
#define IDENTITY_RESPONSE 0b01011100
#define SECURITY_MODE_COMMAND 0b01011101
#define SECURITY_MODE_COMPLETE 0b01011110
#define SECURITY_MODE_REJECT 0b01011111
#define _5GMM_STATUS 0b01100100
#define MESSAGE_TYPE_NOTIFICATION 0b01100101
#define MESSAGE_TYPE_NOTIFICATION_RESPONSE 0b01100110
#define UL_NAS_TRANSPORT 0b01100111
#define DL_NAS_TRANSPORT 0b01101000
#define UE_INIT_DEREGISTER 0b01000101
/********* registration type ***************/
...
...
@@ -137,16 +150,16 @@
#define UE_PARAMETERS_UPDATE 0x06
#define MULTIPLE_PAYLOADS 0x0f
#define
PDU_SESSION_INITIAL_REQUEST
0b001
#define
EXISTING_PDU_SESSION
0b010
#define
PDU_SESSION_INITIAL_EMERGENCY_REQUEST
0b011
#define
EXISTING_EMERGENCY_PDU_SESSION
0b100
#define
PDU_SESSION_MODIFICATION_REQUEST
0b101
#define
MA_PDU_REQUEST
0b110
#define
REQUEST_TYPE_INITIAL_REQUEST
0b001
#define
REQUEST_TYPE_EXISTING_PDU_SESSION
0b010
#define
REQUEST_TYPE_INITIAL_EMERGENCY_REQUEST
0b011
#define
REQUEST_TYPE_EXISTING_EMERGENCY_PDU_SESSION
0b100
#define
REQUEST_TYPE_MODIFICATION_REQUEST
0b101
#define
REQUEST_TYPE_MA_PDU_REQUEST
0b110
#define PDU_SESSION_MESSAGE_TYPE_UNKNOWN 0b
00
000000
#define PDU_SESSION_MESSAGE_TYPE_UNKNOWN 0b
11
000000
#define PDU_SESSION_ESTABLISHMENT_REQUEST 0b11000001
#define PDU_SESSION_ESTABLISHMENT_ACCEPT 0b11000010
#define PDU_SESSION_ESTABLISHMENT_REJECT 0b11000011
...
...
@@ -157,7 +170,7 @@
#define PDU_SESSION_MODIFICATION_REJECT 0b11001010
#define PDU_SESSION_MODIFICATION_COMMAND 0b11001011
#define PDU_SESSION_MODIFICATION_COMPLETE 0b11001100
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT
0b11001101
#define PDU_SESSION_MODIFICATION_COMMAND_REJECT 0b11001101
#define PDU_SESSION_RELEASE_REQUEST 0b11010001
#define PDU_SESSION_RELEASE_REJECT 0b11010010
#define PDU_SESSION_RELEASE_COMMAND 0b11010011
...
...
src/nas/common/nas_ie_header.hpp
View file @
79ed2879
...
...
@@ -28,6 +28,7 @@
#include "nas_mm_plain_header.hpp"
#include "5GSRegistrationType.hpp"
#include "_5GSDeregistrationType.hpp"
#include "NasKeySetIdentifier.hpp"
#include "5GSMobilityIdentity.hpp"
#include "5GMMCapability.hpp"
...
...
src/nas/ies/5GSMobilityIdentity.hpp
View file @
79ed2879
...
...
@@ -47,6 +47,12 @@ typedef struct _5G_GUTI_s {
uint8_t
amf_set_id
;
uint16_t
amf_pointer
;
uint32_t
_5g_tmsi
;
const
std
::
string
&
toString
()
const
{
std
::
string
str
;
str
=
mcc
+
mnc
+
std
::
to_string
(
amf_region_id
)
+
std
::
to_string
(
amf_set_id
)
+
std
::
to_string
(
amf_pointer
)
+
std
::
to_string
(
_5g_tmsi
);
return
str
;
}
}
_5G_GUTI_t
;
typedef
struct
IMEI_or_IMEISV_s
{
...
...
src/nas/ies/_5GSDeregistrationType.cpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "_5GSDeregistrationType.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
_5GSDeregistrationType
::
_5GSDeregistrationType
()
{
u1
.
b
=
0
;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType
::
_5GSDeregistrationType
(
uint8_t
type
)
{
u1
.
b
=
type
;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType
::
_5GSDeregistrationType
(
_5gs_deregistration_type_t
type
)
{
u1
.
b
=
0
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
dereg_required
=
type
.
dereg_required
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
iei
=
type
.
iei
;
}
//------------------------------------------------------------------------------
_5GSDeregistrationType
::~
_5GSDeregistrationType
()
{
}
//------------------------------------------------------------------------------
void
_5GSDeregistrationType
::
set
(
_5gs_deregistration_type_t
type
)
{
u1
.
b
=
0
;
u1
.
bf
.
switch_off
=
type
.
switch_off
;
u1
.
bf
.
dereg_required
=
type
.
dereg_required
;
u1
.
bf
.
access_type
=
type
.
access_type
;
u1
.
bf
.
iei
=
type
.
iei
;
}
//------------------------------------------------------------------------------
void
_5GSDeregistrationType
::
get
(
_5gs_deregistration_type_t
&
type
)
{
type
.
switch_off
=
u1
.
bf
.
switch_off
;
type
.
dereg_required
=
u1
.
bf
.
dereg_required
;
type
.
access_type
=
u1
.
bf
.
access_type
;
type
.
iei
=
u1
.
bf
.
iei
;
}
//------------------------------------------------------------------------------
void
_5GSDeregistrationType
::
set
(
uint8_t
type
)
{
u1
.
b
=
type
;
}
//------------------------------------------------------------------------------
void
_5GSDeregistrationType
::
get
(
uint8_t
&
type
)
{
type
=
u1
.
b
;
}
//------------------------------------------------------------------------------
int
_5GSDeregistrationType
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
error
(
"Encoding 5GSDeregistrationType IE"
);
if
(
len
<
1
)
{
Logger
::
nas_mm
().
error
(
"encoding 5GSDeregistrationType error(len is less than one)"
);
return
-
1
;
}
*
buf
=
u1
.
b
;
}
//------------------------------------------------------------------------------
int
_5GSDeregistrationType
::
decodefrombuffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Decoding 5GSDeregistrationType"
);
u1
.
b
=
*
buf
;
Logger
::
nas_mm
().
debug
(
"Decoded 5GSDeRegistrationType"
);
return
0
;
}
src/nas/ies/_5GSDeregistrationType.hpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _5GS_DEREGISTRATION_TYPE_H_
#define _5GS_DEREGISTRATION_TYPE_H_
#include <stdint.h>
namespace
nas
{
typedef
struct
_5gs_deregistration_type_s
{
uint8_t
iei
:
4
;
uint8_t
switch_off
:
1
;
uint8_t
dereg_required
:
1
;
uint8_t
access_type
:
2
;
}
_5gs_deregistration_type_t
;
class
_5GSDeregistrationType
{
public:
_5GSDeregistrationType
();
_5GSDeregistrationType
(
uint8_t
type
);
_5GSDeregistrationType
(
_5gs_deregistration_type_t
type
);
~
_5GSDeregistrationType
();
int
decodefrombuffer
(
uint8_t
*
buf
,
int
len
);
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
void
set
(
_5gs_deregistration_type_t
type
);
void
get
(
_5gs_deregistration_type_t
&
type
);
void
set
(
uint8_t
type
);
void
get
(
uint8_t
&
type
);
public:
union
{
struct
{
uint8_t
iei
:
4
;
uint8_t
switch_off
:
1
;
uint8_t
dereg_required
:
1
;
uint8_t
access_type
:
2
;
}
bf
;
uint8_t
b
;
}
u1
;
};
}
#endif
src/nas/msgs/DeregistrationAccept.cpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "DeregistrationAccept.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
#include "String2Value.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
DeregistrationAccept
::
DeregistrationAccept
()
{
plain_header
=
NULL
;
}
//------------------------------------------------------------------------------
DeregistrationAccept
::~
DeregistrationAccept
()
{
}
//------------------------------------------------------------------------------
void
DeregistrationAccept
::
setHeader
(
uint8_t
security_header_type
)
{
plain_header
=
new
NasMmPlainHeader
();
plain_header
->
setHeader
(
EPD_5GS_MM_MSG
,
security_header_type
,
DEREGISTRATION_ACCEPT_UE_ORIGINATING
);
}
//------------------------------------------------------------------------------
int
DeregistrationAccept
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding De-registration Accept message"
);
int
encoded_size
=
0
;
if
(
!
plain_header
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Header"
);
return
0
;
}
encoded_size
=
plain_header
->
encode2buffer
(
buf
,
len
);
Logger
::
nas_mm
().
debug
(
"Encoded De-registration Accept message len (%d)"
,
encoded_size
);
return
encoded_size
;
}
//------------------------------------------------------------------------------
int
DeregistrationAccept
::
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Decoding De-registrationReject message"
);
int
decoded_size
=
3
;
plain_header
=
header
;
Logger
::
nas_mm
().
debug
(
"decoded De-registrationReject message len (%d)"
,
decoded_size
);
}
src/nas/msgs/DeregistrationAccept.hpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DEREGISTRATION_ACCEPT_H_
#define _DEREGISTRATION_ACCEPT_H_
#include "nas_ie_header.hpp"
namespace
nas
{
class
DeregistrationAccept
{
public:
DeregistrationAccept
();
~
DeregistrationAccept
();
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
);
void
setHeader
(
uint8_t
security_header_type
);
public:
NasMmPlainHeader
*
plain_header
;
};
}
#endif
src/nas/msgs/DeregistrationRequest.cpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#include "DeregistrationRequest.hpp"
#include "3gpp_ts24501.hpp"
#include "logger.hpp"
#include "String2Value.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
DeregistrationRequest
::
DeregistrationRequest
()
{
plain_header
=
NULL
;
ie_deregistrationtype
=
NULL
;
ie_ngKSI
=
NULL
;
ie_5gs_mobility_id
=
NULL
;
}
//------------------------------------------------------------------------------
DeregistrationRequest
::~
DeregistrationRequest
()
{
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setHeader
(
uint8_t
security_header_type
)
{
plain_header
=
new
NasMmPlainHeader
();
plain_header
->
setHeader
(
EPD_5GS_MM_MSG
,
security_header_type
,
DEREGISTRATION_REQUEST_UE_ORIGINATING
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setDeregistrationType
(
uint8_t
dereg_type
)
{
ie_deregistrationtype
=
new
_5GSDeregistrationType
(
dereg_type
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setDeregistrationType
(
_5gs_deregistration_type_t
type
)
{
ie_deregistrationtype
=
new
_5GSDeregistrationType
(
type
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
getDeregistrationType
(
uint8_t
&
dereg_type
)
{
ie_deregistrationtype
->
get
(
dereg_type
);
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
getDeregistrationType
(
_5gs_deregistration_type_t
&
type
)
{
ie_deregistrationtype
->
get
(
type
);
}
//------------------------------------------------------------------------------
uint8_t
DeregistrationRequest
::
getngKSI
()
{
if
(
ie_ngKSI
)
{
uint8_t
a
=
0
;
a
=
(
ie_ngKSI
->
getTypeOfSecurityContext
())
|
ie_ngKSI
->
getasKeyIdentifier
();
return
a
;
}
else
{
return
-
1
;
}
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setSUCI_SUPI_format_IMSI
(
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
uint8_t
protection_sch_id
,
const
string
msin
)
{
if
(
protection_sch_id
!=
NULL_SCHEME
)
{
Logger
::
nas_mm
().
error
(
"encoding suci and supi format for imsi error, please choose right interface"
);
return
;
}
else
{
ie_5gs_mobility_id
=
new
_5GSMobilityIdentity
(
mcc
,
mnc
,
routingInd
,
protection_sch_id
,
msin
);
}
}
//------------------------------------------------------------------------------
uint8_t
DeregistrationRequest
::
getMobilityIdentityType
()
{
if
(
ie_5gs_mobility_id
)
{
return
ie_5gs_mobility_id
->
gettypeOfIdentity
();
}
else
{
return
-
1
;
}
}
//------------------------------------------------------------------------------
bool
DeregistrationRequest
::
getSuciSupiFormatImsi
(
nas
::
SUCI_imsi_t
&
imsi
)
{
if
(
ie_5gs_mobility_id
)
{
ie_5gs_mobility_id
->
getSuciWithSupiImsi
(
imsi
);
return
true
;
}
else
{
return
false
;
}
}
//------------------------------------------------------------------------------
std
::
string
DeregistrationRequest
::
get_5g_guti
()
{
if
(
ie_5gs_mobility_id
)
{
nas
::
_5G_GUTI_t
guti
;
ie_5gs_mobility_id
->
get5GGUTI
(
guti
);
return
guti
.
toString
();
}
else
{
return
"error"
;
}
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setSUCI_SUPI_format_IMSI
(
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
uint8_t
protection_sch_id
,
uint8_t
hnpki
,
const
string
msin
)
{
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
set5G_GUTI
()
{
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setIMEI_IMEISV
()
{
}
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
set5G_S_TMSI
()
{
}
//------------------------------------------------------------------------------
int
DeregistrationRequest
::
encode2buffer
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding DeregistrationRequest message"
);
int
encoded_size
=
0
;
if
(
!
plain_header
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Header"
);
return
0
;
}
if
(
!
ie_deregistrationtype
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing Deregistration Type"
);
return
0
;
}
if
(
!
ie_ngKSI
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing ie_ngKSI"
);
return
0
;
}
if
(
!
ie_5gs_mobility_id
)
{
Logger
::
nas_mm
().
error
(
"Mandatory IE missing ie_5gs_mobility_id"
);
return
0
;
}
if
(
!
(
plain_header
->
encode2buffer
(
buf
,
len
)))
return
0
;
encoded_size
+=
3
;
if
(
!
(
ie_deregistrationtype
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
if
(
!
(
ie_ngKSI
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
encoded_size
+=
1
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_ngKSI error"
);
return
0
;
}
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE Deregistrationt Type error"
);
return
0
;
}
if
(
int
size
=
ie_5gs_mobility_id
->
encode2buffer
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_5gs_mobility_id error"
);
return
0
;
}
Logger
::
nas_mm
().
debug
(
"Encoded DeregistrationRequest message len (%d)"
,
encoded_size
);
return
1
;
}
//------------------------------------------------------------------------------
int
DeregistrationRequest
::
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"****Decoding DeregistrationRequest message****"
);
int
decoded_size
=
3
;
plain_header
=
header
;
ie_deregistrationtype
=
new
_5GSDeregistrationType
();
decoded_size
+=
ie_deregistrationtype
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
);
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
true
);
decoded_size
++
;
ie_5gs_mobility_id
=
new
_5GSMobilityIdentity
();
decoded_size
+=
ie_5gs_mobility_id
->
decodefrombuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
Logger
::
nas_mm
().
debug
(
"****Decoded DeregistrationRequest message (len %d)****"
,
decoded_size
);
}
src/nas/msgs/DeregistrationRequest.hpp
0 → 100644
View file @
79ed2879
/*
* 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
*/
/*! \file
\brief
\author
\date 2020
\email: contact@openairinterface.org
*/
#ifndef _DEREGISTRATION_REQUEST_H_
#define _DEREGISTRATION_REQUEST_H_
#include "nas_ie_header.hpp"
using
namespace
std
;
namespace
nas
{
class
DeregistrationRequest
{
public:
DeregistrationRequest
();
~
DeregistrationRequest
();
int
encode2buffer
(
uint8_t
*
buf
,
int
len
);
int
decodefrombuffer
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
);
void
setHeader
(
uint8_t
security_header_type
);
void
setDeregistrationType
(
uint8_t
dereg_type
);
void
setDeregistrationType
(
_5gs_deregistration_type_t
type
);
void
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
);
void
setMobilityIdentityType
(
uint8_t
type
);
void
setSUCI_SUPI_format_IMSI
(
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
uint8_t
protection_sch_id
,
const
string
msin
);
void
setSUCI_SUPI_format_IMSI
(
const
string
mcc
,
const
string
mnc
,
const
string
routingInd
,
uint8_t
protection_sch_id
,
uint8_t
hnpki
,
const
string
msin
);
void
set5G_GUTI
();
void
setIMEI_IMEISV
();
void
set5G_S_TMSI
();
void
getDeregistrationType
(
uint8_t
&
dereg_type
);
void
getDeregistrationType
(
_5gs_deregistration_type_t
&
type
);
uint8_t
getngKSI
();
uint8_t
getMobilityIdentityType
();
std
::
string
get_5g_guti
();
bool
getSuciSupiFormatImsi
(
nas
::
SUCI_imsi_t
&
imsi
);
public:
NasMmPlainHeader
*
plain_header
;
_5GSDeregistrationType
*
ie_deregistrationtype
;
NasKeySetIdentifier
*
ie_ngKSI
;
_5GSMobilityIdentity
*
ie_5gs_mobility_id
;
};
}
#endif
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