Migrated NAS 5GS (5GMM & 5GSM) to NR folders and refactor CMakeLists.txt files
This commit is introducing the following macro changes:
(1) Migrate NAS 5GS lib files to a new 5GS subfolder in NR_UE
and organize NAS 5GS lib messages into 5GMM and 5GSM subfolders.
A nested CMake structure was implemented and CMakeLists.txt were
added whenever necessary. This is effectively separating 5GS
libraries from LTE libraries.
(2) In order to simplify the separation of 5GS libs from LTE libs,
remaining dependencies from NAS LTE (e.g. nas_ue_task.c, ue-idx-standalone)
were removed in the process
(3) ExtendedProtocolDiscriminator.c/.h and SpareHalfOctet.c/.h were deleted
and affected types were replaced with simple integer types
(4) Cleanup: unused definitions and libs (e.g. LIB_5GNAS_GNB)
were removed
(5) Update doc/Doxyfile
(6) clang-formatted the migrated files in the process
(7) Update includes of headers in affected files
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
add_library(fgs_ies_lib OBJECT
|
||||
NasKeySetIdentifier.c
|
||||
FGSMobileIdentity.c
|
||||
add_library(nas_common_ies_lib OBJECT
|
||||
AuthenticationResponseParameter.c
|
||||
NasKeySetIdentifier.c
|
||||
)
|
||||
|
||||
target_include_directories(fgs_ies_lib PUBLIC
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
target_include_directories(nas_common_ies_lib PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 ExtendedProtocolDiscriminator.c
|
||||
|
||||
\brief Extended protocol discriminator for registration request procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "ExtendedProtocolDiscriminator.h"
|
||||
|
||||
int encode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int decode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* 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 ExtendedProtocolDiscriminator.h
|
||||
|
||||
\brief Extended protocol discriminator for registration request procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef EXTENDED_PROTOCOL_DISCRIMINATOR_H_
|
||||
#define EXTENDED_PROTOCOL_DISCRIMINATOR_H_
|
||||
|
||||
typedef uint8_t ExtendedProtocolDiscriminator;
|
||||
|
||||
int encode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_ex_protocol_discriminator(ExtendedProtocolDiscriminator *exprotocoldiscriminator, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* EXTENDED PROTOCOL DISCRIMINATOR_H_ */
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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 FGCNasMessageContainer.c
|
||||
|
||||
\brief security mode complete procedures for gNB
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGCNasMessageContainer.h"
|
||||
|
||||
int decode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint8_t ielen = 0;
|
||||
int decode_result;
|
||||
|
||||
if (iei > 0) {
|
||||
CHECK_IEI_DECODER(iei, *buffer);
|
||||
decoded++;
|
||||
}
|
||||
|
||||
ielen = *(buffer + decoded);
|
||||
decoded += 2;
|
||||
CHECK_LENGTH_DECODER(len - decoded, ielen);
|
||||
|
||||
if ((decode_result = decode_octet_string(&nasmessagecontainer->nasmessagecontainercontents, ielen, buffer + decoded, len - decoded)) < 0)
|
||||
return decode_result;
|
||||
else
|
||||
decoded += decode_result;
|
||||
|
||||
return decoded;
|
||||
}
|
||||
int encode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
int encode_result;
|
||||
/* Checking IEI and pointer */
|
||||
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, FGC_NAS_MESSAGE_CONTAINER_MINIMUM_LENGTH, len);
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
encoded += 2;
|
||||
|
||||
if ((encode_result = encode_octet_string(&nasmessagecontainer->nasmessagecontainercontents, buffer + encoded, len - encoded)) < 0) {
|
||||
return encode_result;
|
||||
} else {
|
||||
uint16_t tmp = htons(encoded + encode_result - 3);
|
||||
memcpy(buffer + 1, &tmp, sizeof(tmp));
|
||||
encoded += encode_result;
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
void dump_fgc_nas_message_container_xml(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei)
|
||||
{
|
||||
printf("<Nas Message Container>\n");
|
||||
|
||||
if (iei > 0)
|
||||
/* Don't display IEI if = 0 */
|
||||
printf(" <IEI>0x%X</IEI>\n", iei);
|
||||
|
||||
printf("%s", dump_octet_string_xml(&nasmessagecontainer->nasmessagecontainercontents));
|
||||
printf("</Nas Message Container>\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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 FGCNasMessageContainer.h
|
||||
|
||||
\brief security mode complete procedures for gNB
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef FGC_NAS_MESSAGE_CONTAINER_H_
|
||||
#define FGC_NAS_MESSAGE_CONTAINER_H_
|
||||
|
||||
#define FGC_NAS_MESSAGE_CONTAINER_MINIMUM_LENGTH 4
|
||||
#define FGC_NAS_MESSAGE_CONTAINER_MAXIMUM_LENGTH 65535
|
||||
|
||||
typedef struct FGCNasMessageContainer_tag {
|
||||
OctetString nasmessagecontainercontents;
|
||||
} FGCNasMessageContainer;
|
||||
|
||||
int encode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_fgc_nas_message_container(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
void dump_fgc_nas_message_container_xml(FGCNasMessageContainer *nasmessagecontainer, uint8_t iei);
|
||||
|
||||
#endif /* FGC NAS MESSAGE CONTAINER_H_ */
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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 FGMMCapability.c
|
||||
* \brief 5GS Mobile Identity for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGMMCapability.h"
|
||||
|
||||
|
||||
|
||||
int encode_5gmm_capability(FGMMCapability *fgmmcapability, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int encoded = 0;
|
||||
if(iei){
|
||||
*buffer = fgmmcapability->iei;
|
||||
encoded++;
|
||||
*(buffer+encoded) = fgmmcapability->length;
|
||||
encoded++;
|
||||
*(buffer+encoded) = fgmmcapability->value;
|
||||
encoded++;
|
||||
}
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 FGMMCapability.h
|
||||
* \brief 5GS Mobile Capability for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef FGMM_CAPABILITY_H_
|
||||
#define FGMM_CAPABILITY_H_
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t iei;
|
||||
uint8_t length;
|
||||
uint8_t value;
|
||||
} FGMMCapability;
|
||||
|
||||
|
||||
int encode_5gmm_capability(FGMMCapability *fgmmcapability, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* FGMM_CAPABILITY_H_ */
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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 FGS_DEREGISTRATION_TYPE_H_
|
||||
#define FGS_DEREGISTRATION_TYPE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "OctetString.h"
|
||||
|
||||
#define FGS_DEREGISTRATION_TYPE_MINIMUM_LENGTH 1
|
||||
#define FGS_DEREGISTRATION_TYPE_MAXIMUM_LENGTH 1
|
||||
|
||||
typedef struct FGSDeregistrationType_tag {
|
||||
#define NORMAL_DEREGISTRATION 0
|
||||
#define SWITCH_OFF 1
|
||||
uint8_t switchoff: 1;
|
||||
#define REREGISTRATION_NOT_REQUIRED 0
|
||||
#define REREGISTRATION_REQUIRED 1
|
||||
uint8_t reregistration_required: 1;
|
||||
#define TGPP_ACCESS 1
|
||||
#define NON_TGPP_ACCESS 2
|
||||
#define TGPP_AND_NON_TGPP_ACCESS 3
|
||||
uint8_t access_type: 2;
|
||||
} FGSDeregistrationType;
|
||||
|
||||
int encode_fgs_deregistration_type(FGSDeregistrationType *dt, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* FGS_DEREGISTRATION_TYPE_H_ */
|
||||
@@ -1,326 +0,0 @@
|
||||
/*
|
||||
* 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 FGSMobileIdentity.c
|
||||
* \brief 5GS Mobile Identity for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGSMobileIdentity.h"
|
||||
|
||||
#define MIN_LEN_FGS_MOBILE_ID_IE 3 // type of identity "No identity"
|
||||
#define LEN_5G_FGS_TMSI_IE 9
|
||||
|
||||
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, const uint8_t *buffer);
|
||||
|
||||
static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer);
|
||||
static int encode_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_t *buffer);
|
||||
static int encode_imeisv_5gs_mobile_identity(Imeisv5GSMobileIdentity_t *imeisv, uint8_t *buffer);
|
||||
|
||||
int encode_stmsi_5gs_mobile_identity(uint8_t *buffer, Stmsi5GSMobileIdentity_t *stmsi, uint32_t len)
|
||||
{
|
||||
// Return if buffer is shorter than min length
|
||||
if (len < LEN_5G_FGS_TMSI_IE)
|
||||
return -1;
|
||||
|
||||
uint32_t encoded = 0;
|
||||
// octet 4
|
||||
*(buffer + encoded) = (DIGIT1 << 4) | ((stmsi->spare & 0x1) << 3) | (stmsi->typeofidentity & 0x7);
|
||||
encoded++;
|
||||
// octet 5-6
|
||||
uint16_t temp = 0x00 | ((stmsi->amfsetid) << 6) | (stmsi->amfpointer & 0x3f);
|
||||
IES_ENCODE_U16(buffer, encoded, temp);
|
||||
// octet 7
|
||||
IES_ENCODE_U32(buffer, encoded, stmsi->tmsi);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int decode_stmsi_5gs_mobile_identity(Stmsi5GSMobileIdentity_t *stmsi, const uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint16_t temp;
|
||||
|
||||
// Return if buffer is shorter than min length
|
||||
if (len < LEN_5G_FGS_TMSI_IE)
|
||||
return -1;
|
||||
|
||||
// Octet 4: spare (bit 3) and type of identity (bits 0-2)
|
||||
stmsi->digit1 = DIGIT1;
|
||||
stmsi->spare = (*(buffer + decoded) >> 3) & 0x1;
|
||||
stmsi->typeofidentity = *(buffer + decoded) & 0x7;
|
||||
|
||||
// Validate type of identity
|
||||
if (stmsi->typeofidentity != FGS_MOBILE_IDENTITY_5GS_TMSI) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
decoded++;
|
||||
|
||||
// Octet 5-6: AMF Set ID (bits 6-15) and AMF Pointer (bits 0-5)
|
||||
IES_DECODE_U16(buffer, decoded, temp);
|
||||
stmsi->amfsetid = (temp >> 6) & 0x03ff;
|
||||
stmsi->amfpointer = temp & 0x3f;
|
||||
|
||||
// Octet 7-10: 32-bit TMSI
|
||||
IES_DECODE_U32(buffer, decoded, stmsi->tmsi);
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, const uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded_rc = TLV_DECODE_VALUE_DOESNT_MATCH;
|
||||
int decoded = 0;
|
||||
uint8_t ielen = 0;
|
||||
|
||||
if (iei > 0) {
|
||||
CHECK_IEI_DECODER(iei, *buffer);
|
||||
decoded++;
|
||||
}
|
||||
uint16_t tmp;
|
||||
memcpy(&tmp, buffer + decoded, sizeof(tmp));
|
||||
ielen = (uint8_t)tmp;
|
||||
decoded += 2;
|
||||
CHECK_LENGTH_DECODER(len - decoded, ielen);
|
||||
|
||||
uint8_t typeofidentity = *(buffer + decoded) & 0x7;
|
||||
|
||||
if (typeofidentity == FGS_MOBILE_IDENTITY_5G_GUTI) {
|
||||
decoded_rc = decode_guti_5gs_mobile_identity(&fgsmobileidentity->guti,
|
||||
buffer + decoded);
|
||||
} else {
|
||||
AssertFatal(false, "Mobile Identity encoding of type %d not implemented\n", typeofidentity);
|
||||
}
|
||||
|
||||
if (decoded_rc < 0) {
|
||||
return decoded_rc;
|
||||
}
|
||||
|
||||
return (decoded + decoded_rc);
|
||||
}
|
||||
|
||||
int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
// Return if buffer is shorter than min length
|
||||
if (len < MIN_LEN_FGS_MOBILE_ID_IE)
|
||||
return -1;
|
||||
|
||||
int encoded_rc = TLV_ENCODE_VALUE_DOESNT_MATCH;
|
||||
uint32_t encoded = 0;
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
encoded = encoded + 2;
|
||||
len -= encoded;
|
||||
|
||||
if (fgsmobileidentity->guti.typeofidentity == FGS_MOBILE_IDENTITY_5G_GUTI) {
|
||||
encoded_rc = encode_guti_5gs_mobile_identity(&fgsmobileidentity->guti,
|
||||
buffer + encoded);
|
||||
}
|
||||
|
||||
if (fgsmobileidentity->suci.typeofidentity == FGS_MOBILE_IDENTITY_SUCI) {
|
||||
encoded_rc = encode_suci_5gs_mobile_identity(&fgsmobileidentity->suci,
|
||||
buffer + encoded);
|
||||
}
|
||||
|
||||
if (fgsmobileidentity->imeisv.typeofidentity == FGS_MOBILE_IDENTITY_IMEISV) {
|
||||
encoded_rc = encode_imeisv_5gs_mobile_identity(&fgsmobileidentity->imeisv,
|
||||
buffer + encoded);
|
||||
}
|
||||
|
||||
if (fgsmobileidentity->stmsi.typeofidentity == FGS_MOBILE_IDENTITY_5GS_TMSI) {
|
||||
encoded_rc = encode_stmsi_5gs_mobile_identity(buffer + encoded, &fgsmobileidentity->stmsi, len);
|
||||
}
|
||||
|
||||
if (encoded_rc < 0) {
|
||||
return encoded_rc;
|
||||
}
|
||||
|
||||
if(iei > 0){
|
||||
uint16_t tmp = htons(encoded + encoded_rc - 3);
|
||||
memcpy(buffer + 1, &tmp, sizeof(tmp));
|
||||
} else {
|
||||
uint16_t tmp = htons(encoded + encoded_rc - 2);
|
||||
memcpy(buffer, &tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
return (encoded + encoded_rc);
|
||||
}
|
||||
|
||||
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, const uint8_t *buffer)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint16_t temp;
|
||||
guti->spare = (*(buffer + decoded) >> 4) & 0xf;
|
||||
|
||||
/*
|
||||
* For the 5G-GUTI, bits 5 to 8 of octet 3 are coded as "1111"
|
||||
*/
|
||||
if (guti->spare != 0xf) {
|
||||
return (TLV_ENCODE_VALUE_DOESNT_MATCH);
|
||||
}
|
||||
|
||||
|
||||
guti->oddeven = (*(buffer + decoded) >> 3) & 0x1;
|
||||
|
||||
/*
|
||||
* For the 5G-GUTI, bits 4 of octet 3 are coded as "0"
|
||||
*/
|
||||
if (guti->oddeven != 0) {
|
||||
return (TLV_ENCODE_VALUE_DOESNT_MATCH);
|
||||
}
|
||||
guti->typeofidentity = *(buffer + decoded) & 0x7;
|
||||
|
||||
if (guti->typeofidentity != FGS_MOBILE_IDENTITY_5G_GUTI) {
|
||||
return (TLV_ENCODE_VALUE_DOESNT_MATCH);
|
||||
}
|
||||
|
||||
decoded++;
|
||||
guti->mccdigit2 = (*(buffer + decoded) >> 4) & 0xf;
|
||||
guti->mccdigit1 = *(buffer + decoded) & 0xf;
|
||||
decoded++;
|
||||
guti->mncdigit3 = (*(buffer + decoded) >> 4) & 0xf;
|
||||
guti->mccdigit3 = *(buffer + decoded) & 0xf;
|
||||
decoded++;
|
||||
guti->mncdigit2 = (*(buffer + decoded) >> 4) & 0xf;
|
||||
guti->mncdigit1 = *(buffer + decoded) & 0xf;
|
||||
decoded++;
|
||||
|
||||
|
||||
guti->amfregionid = *(buffer+decoded);
|
||||
decoded++;
|
||||
IES_DECODE_U16(buffer, decoded, temp);
|
||||
guti->amfsetid = temp>>3;
|
||||
guti->amfpointer = temp&0x3f;
|
||||
|
||||
IES_DECODE_U32(buffer, decoded, guti->tmsi);
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
||||
static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
uint16_t temp;
|
||||
*(buffer + encoded) = 0xf0 | ((guti->oddeven & 0x1) << 3) |
|
||||
(guti->typeofidentity & 0x7);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | ((guti->mccdigit2 & 0xf) << 4) |
|
||||
(guti->mccdigit1 & 0xf);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | ((guti->mncdigit3 & 0xf) << 4) |
|
||||
(guti->mccdigit3 & 0xf);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | ((guti->mncdigit2 & 0xf) << 4) |
|
||||
(guti->mncdigit1 & 0xf);
|
||||
encoded++;
|
||||
|
||||
*(buffer + encoded) = guti->amfregionid;
|
||||
encoded++;
|
||||
|
||||
temp = 0x00 | ((guti->amfsetid) << 6) | (guti->amfpointer & 0x3f);
|
||||
|
||||
IES_ENCODE_U16(buffer, encoded, temp);
|
||||
IES_ENCODE_U32(buffer, encoded, guti->tmsi);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
||||
static int encode_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_t *buffer)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
*(buffer + encoded) = (suci->supiformat << 4) | (suci->typeofidentity);
|
||||
encoded++;
|
||||
*(buffer + encoded) = ((suci->mccdigit2 & 0xf) << 4) |
|
||||
(suci->mccdigit1 & 0xf);
|
||||
encoded++;
|
||||
*(buffer + encoded) = ((suci->mncdigit3 & 0xf) << 4) |
|
||||
(suci->mccdigit3 & 0xf);
|
||||
encoded++;
|
||||
*(buffer + encoded) = ((suci->mncdigit2 & 0xf) << 4) |
|
||||
(suci->mncdigit1 & 0xf);
|
||||
encoded++;
|
||||
|
||||
*(buffer + encoded) = ((suci->routingindicatordigit2 & 0xf) << 4) |
|
||||
(suci->routingindicatordigit1 & 0xf);
|
||||
encoded++;
|
||||
|
||||
*(buffer + encoded) = ((suci->routingindicatordigit4 & 0xf) << 4) |
|
||||
(suci->routingindicatordigit3 & 0xf);
|
||||
encoded++;
|
||||
|
||||
*(buffer + encoded) = 0x00 | (suci->protectionschemeId & 0xf);
|
||||
encoded++;
|
||||
|
||||
*(buffer + encoded) = suci->homenetworkpki;
|
||||
encoded++;
|
||||
|
||||
char *ptr=suci->schemeoutput;
|
||||
while ( ptr < suci->schemeoutput+strlen(suci->schemeoutput) ) {
|
||||
buffer[encoded]=((*(ptr+1)-'0')<<4) | (*(ptr) -'0');
|
||||
encoded++;
|
||||
ptr+=2;
|
||||
}
|
||||
|
||||
if (strlen(suci->schemeoutput)%2 == 1)
|
||||
buffer[encoded++]=((*(ptr-1)-'0')) | 0xF0;
|
||||
return encoded;
|
||||
}
|
||||
|
||||
static int encode_imeisv_5gs_mobile_identity(Imeisv5GSMobileIdentity_t *imeisv, uint8_t *buffer)
|
||||
{
|
||||
uint32_t encoded = 0;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digittac01 << 4) | (imeisv->oddeven << 3) | (imeisv->typeofidentity);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digittac03 << 4) | (imeisv->digittac02);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digittac05 << 4) | (imeisv->digittac04);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digittac07 << 4) | (imeisv->digittac06);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digit09 << 4) | (imeisv->digittac08);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digit11 << 4) | (imeisv->digit10);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digit13 << 4) | (imeisv->digit12);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->digitsv1 << 4) | (imeisv->digit14);
|
||||
encoded++;
|
||||
*(buffer + encoded) = 0x00 | (imeisv->spare << 4) | (imeisv->digitsv2);
|
||||
encoded++;
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* 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 FGSMobileIdentity.h
|
||||
* \brief 5GS Mobile Identity for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef FGS_MOBILE_IDENTITY_H_
|
||||
#define FGS_MOBILE_IDENTITY_H_
|
||||
|
||||
// 4x 1bit according to 9.11.3.4 5GS mobile identity (type 5G-S-TMSI)
|
||||
#define DIGIT1 0xF
|
||||
|
||||
typedef struct {
|
||||
uint8_t spare:5;
|
||||
uint8_t typeofidentity:3;
|
||||
} NoIdentity5GSMobileIdentity_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t spare1:1;
|
||||
uint8_t supiformat:3;
|
||||
uint8_t spare2:1;
|
||||
uint8_t typeofidentity:3;
|
||||
uint8_t mccdigit2:4;
|
||||
uint8_t mccdigit1:4;
|
||||
uint8_t mncdigit3:4;
|
||||
uint8_t mccdigit3:4;
|
||||
uint8_t mncdigit2:4;
|
||||
uint8_t mncdigit1:4;
|
||||
uint8_t routingindicatordigit2:4;
|
||||
uint8_t routingindicatordigit1:4;
|
||||
uint8_t routingindicatordigit4:4;
|
||||
uint8_t routingindicatordigit3:4;
|
||||
uint8_t spare3:1;
|
||||
uint8_t spare4:1;
|
||||
uint8_t spare5:1;
|
||||
uint8_t spare6:1;
|
||||
uint8_t protectionschemeId:4;
|
||||
uint8_t homenetworkpki;
|
||||
char schemeoutput[32];
|
||||
} Suci5GSMobileIdentity_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t spare:4;
|
||||
uint8_t oddeven:1;
|
||||
uint8_t typeofidentity:3;
|
||||
uint8_t mccdigit2:4;
|
||||
uint8_t mccdigit1:4;
|
||||
uint8_t mncdigit3:4;
|
||||
uint8_t mccdigit3:4;
|
||||
uint8_t mncdigit2:4;
|
||||
uint8_t mncdigit1:4;
|
||||
uint8_t amfregionid;
|
||||
uint16_t amfsetid:10;
|
||||
uint16_t amfpointer:6;
|
||||
uint32_t tmsi;
|
||||
} Guti5GSMobileIdentity_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t digit1:4;
|
||||
uint8_t oddeven:1;
|
||||
uint8_t typeofidentity:3;
|
||||
uint8_t digitp1:4;
|
||||
uint8_t digitp:4;
|
||||
} Imei5GSMobileIdentity_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t digittac01:4;
|
||||
uint8_t oddeven:1;
|
||||
uint8_t typeofidentity:3;
|
||||
uint8_t digittac02:4;
|
||||
uint8_t digittac03:4;
|
||||
uint8_t digittac04:4;
|
||||
uint8_t digittac05:4;
|
||||
uint8_t digittac06:4;
|
||||
uint8_t digittac07:4;
|
||||
uint8_t digittac08:4;
|
||||
uint8_t digit09:4;
|
||||
uint8_t digit10:4;
|
||||
uint8_t digit11:4;
|
||||
uint8_t digit12:4;
|
||||
uint8_t digit13:4;
|
||||
uint8_t digit14:4;
|
||||
uint8_t digitsv1:4;
|
||||
uint8_t digitsv2:4;
|
||||
uint8_t spare:4;
|
||||
} Imeisv5GSMobileIdentity_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t digit1:4;
|
||||
uint8_t spare:1;
|
||||
uint8_t typeofidentity:3;
|
||||
uint16_t amfsetid:10;
|
||||
uint16_t amfpointer:6;
|
||||
uint32_t tmsi;
|
||||
} Stmsi5GSMobileIdentity_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t spare:5;
|
||||
uint8_t typeofidentity:3;
|
||||
uint8_t macaddr;
|
||||
} Macaddr5GSMobileIdentity_t;
|
||||
|
||||
typedef union FGSMobileIdentity_tag {
|
||||
#define FGS_MOBILE_IDENTITY_NOIDENTITY 0b000
|
||||
#define FGS_MOBILE_IDENTITY_SUCI 0b001
|
||||
#define FGS_MOBILE_IDENTITY_5G_GUTI 0b010
|
||||
#define FGS_MOBILE_IDENTITY_IMEI 0b011
|
||||
#define FGS_MOBILE_IDENTITY_5GS_TMSI 0b100
|
||||
#define FGS_MOBILE_IDENTITY_IMEISV 0b101
|
||||
#define FGS_MOBILE_IDENTITY_MAC_ADDR 0b110
|
||||
NoIdentity5GSMobileIdentity_t noidentity;
|
||||
Suci5GSMobileIdentity_t suci;
|
||||
Guti5GSMobileIdentity_t guti;
|
||||
Imei5GSMobileIdentity_t imei;
|
||||
Stmsi5GSMobileIdentity_t stmsi;
|
||||
Imeisv5GSMobileIdentity_t imeisv;
|
||||
Macaddr5GSMobileIdentity_t macaddress;
|
||||
} FGSMobileIdentity;
|
||||
|
||||
int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, const uint8_t *buffer, uint32_t len);
|
||||
|
||||
int encode_stmsi_5gs_mobile_identity(uint8_t *buffer, Stmsi5GSMobileIdentity_t *stmsi, uint32_t len);
|
||||
int decode_stmsi_5gs_mobile_identity(Stmsi5GSMobileIdentity_t *stmsi, const uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* FGS MOBILE IDENTITY_H_ */
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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 FGSRegistrationResult.c
|
||||
|
||||
\brief 5GS Registration result for registration request procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGSRegistrationResult.h"
|
||||
|
||||
|
||||
int decode_fgs_registration_result(FGSRegistrationResult *fgsregistrationresult, uint8_t iei, uint16_t value, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint16_t *buffer = &value;
|
||||
fgsregistrationresult->registrationresult = *buffer & 0x7;
|
||||
fgsregistrationresult->smsallowed = *buffer & 0x8;
|
||||
decoded = decoded+2;
|
||||
return decoded;
|
||||
}
|
||||
|
||||
uint16_t encode_fgs_registration_result(FGSRegistrationResult *fgsregistrationresult)
|
||||
{
|
||||
uint16_t bufferReturn;
|
||||
uint16_t *buffer = &bufferReturn;
|
||||
uint8_t encoded = 0;
|
||||
*(buffer + encoded) = 0x00 | (fgsregistrationresult->smsallowed & 0x8) |
|
||||
(fgsregistrationresult->registrationresult & 0x7);
|
||||
encoded= encoded+2;
|
||||
|
||||
return bufferReturn;
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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 FGSRegistrationResult.h
|
||||
|
||||
\brief 5GS Registration result for registration request procedures
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
|
||||
|
||||
#ifndef FGS_REGISTRATION_RESULT_H_
|
||||
#define FGS_REGISTRATION_RESULT_H_
|
||||
#define FGS_REGISTRATION_RESULT_3GPP 0b001
|
||||
#define FGS_REGISTRATION_RESULT_NON_3GPP 0b010
|
||||
#define FGS_REGISTRATION_RESULT_3GPP_AND_NON_3GPP 0b011
|
||||
|
||||
typedef struct {
|
||||
uint8_t iei;
|
||||
uint8_t resultlength;
|
||||
uint8_t spare:4;
|
||||
uint8_t smsallowed:1;
|
||||
uint8_t registrationresult:3;
|
||||
} FGSRegistrationResult;
|
||||
|
||||
|
||||
uint16_t encode_fgs_registration_result(FGSRegistrationResult *fgsregistrationresult);
|
||||
|
||||
int decode_fgs_registration_result(FGSRegistrationResult *fgsregistrationresult, uint8_t iei, uint16_t value, uint32_t len);
|
||||
|
||||
#endif /* FGS REGISTRATION RESULT_H_*/
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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 FGSRegistrationType.c
|
||||
* \brief 5GS Registration Type for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGSRegistrationType.h"
|
||||
|
||||
int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t value, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
uint8_t *buffer = &value;
|
||||
if (iei > 0) {
|
||||
CHECK_IEI_DECODER((*buffer & 0xf0), iei);
|
||||
}
|
||||
|
||||
*fgsregistrationtype = *buffer & 0x7;
|
||||
decoded++;
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
int encode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype)
|
||||
{
|
||||
uint8_t bufferReturn;
|
||||
uint8_t *buffer = &bufferReturn;
|
||||
uint8_t encoded = 0;
|
||||
uint8_t iei = 0;
|
||||
*(buffer + encoded) = 0x00 | (iei & 0xf0) | 0x8|
|
||||
(*fgsregistrationtype & 0x7);
|
||||
encoded++;
|
||||
|
||||
return bufferReturn;
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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 FGSRegistrationType.h
|
||||
* \brief 5GS Registration Type for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef FGS_REGISTRATION_TYPE_H_
|
||||
#define FGS_REGISTRATION_TYPE_H_
|
||||
|
||||
#define FGS_REGISTRATION_TYPE_MINIMUM_LENGTH 1
|
||||
#define FGS_REGISTRATION_TYPE_MAXIMUM_LENGTH 1
|
||||
|
||||
typedef uint8_t FGSRegistrationType;
|
||||
|
||||
|
||||
#define INITIAL_REGISTRATION 0b001
|
||||
#define MOBILITY_REGISTRATION_UPDATING 0b010
|
||||
#define PERIODIC_REGISTRATION_UPDATING 0b011
|
||||
#define EMERGENCY_REGISTRATION 0b100
|
||||
|
||||
int encode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype);
|
||||
|
||||
int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t value, uint32_t len);
|
||||
|
||||
|
||||
#endif /* FGS_REGISTRATION_TYPE_H_*/
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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 NrUESecurityCapability.c
|
||||
* \brief 5GS UE Security Capability for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "NrUESecurityCapability.h"
|
||||
|
||||
|
||||
|
||||
int encode_nrue_security_capability(NrUESecurityCapability *nruesecuritycapability, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int encoded = 0;
|
||||
if(iei){
|
||||
*buffer = nruesecuritycapability->iei;
|
||||
encoded++;
|
||||
*(buffer+encoded) = nruesecuritycapability->length;
|
||||
encoded++;
|
||||
*(buffer+encoded) = nruesecuritycapability->fg_EA;
|
||||
encoded++;
|
||||
*(buffer+encoded) = nruesecuritycapability->fg_IA;
|
||||
encoded++;
|
||||
*(buffer+encoded) = nruesecuritycapability->EEA;
|
||||
encoded++;
|
||||
*(buffer+encoded) = nruesecuritycapability->EIA;
|
||||
encoded++;
|
||||
if((nruesecuritycapability->length - 4) > 0)
|
||||
encoded = encoded + nruesecuritycapability->length - 4;
|
||||
}
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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 NrUESecurityCapability.h
|
||||
* \brief 5GS UE Security Capability for registration request procedures
|
||||
* \author Yoshio INOUE, Masayuki HARADA
|
||||
* \email yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
* \date 2020
|
||||
* \version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef NRUE_SECURITY_CAPABILITY_H_
|
||||
#define NRUE_SECURITY_CAPABILITY_H_
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t iei;
|
||||
uint8_t length;
|
||||
uint8_t fg_EA;
|
||||
uint8_t fg_IA;
|
||||
uint8_t EEA;
|
||||
uint8_t EIA;
|
||||
} NrUESecurityCapability;
|
||||
|
||||
|
||||
int encode_nrue_security_capability(NrUESecurityCapability *nruesecuritycapability, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* NRUE_SECURITY_CAPABILITY_H_ */
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "SORTransparentContainer.h"
|
||||
#include "nas_log.h"
|
||||
|
||||
//#define NAS_DEBUG 1
|
||||
|
||||
int decode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
int decode_result;
|
||||
uint16_t ielen;
|
||||
|
||||
LOG_FUNC_IN;
|
||||
|
||||
if (iei > 0) {
|
||||
CHECK_IEI_DECODER(iei, *buffer);
|
||||
decoded++;
|
||||
}
|
||||
|
||||
DECODE_LENGTH_U16(buffer + decoded, ielen, decoded);
|
||||
|
||||
CHECK_LENGTH_DECODER(len - decoded, ielen);
|
||||
|
||||
|
||||
if ((decode_result = decode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, ielen, buffer + decoded, len - decoded)) < 0) {
|
||||
LOG_FUNC_RETURN(decode_result);
|
||||
} else {
|
||||
decoded += decode_result;
|
||||
}
|
||||
|
||||
#if defined (NAS_DEBUG)
|
||||
dump_sor_transparent_container_xml(sortransparentcontainer, iei);
|
||||
#endif
|
||||
LOG_FUNC_RETURN(decoded);
|
||||
}
|
||||
|
||||
int encode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
uint8_t *lenPtr;
|
||||
uint32_t encoded = 0;
|
||||
int32_t encode_result;
|
||||
/* Checking IEI and pointer */
|
||||
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(buffer, SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH, len);
|
||||
#if defined (NAS_DEBUG)
|
||||
dump_sor_transparent_container_xml(sortransparentcontainer, iei);
|
||||
#endif
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
lenPtr = (buffer + encoded);
|
||||
|
||||
//encoded += 2;
|
||||
//if ((encode_result = encode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, buffer + sizeof(uint16_t), len - sizeof(uint16_t))) < 0)
|
||||
if ((encode_result = encode_octet_string(&sortransparentcontainer->sortransparentcontainercontents, lenPtr + sizeof(uint16_t), len - sizeof(uint16_t))) < 0)
|
||||
return encode_result;
|
||||
else
|
||||
encoded += encode_result;
|
||||
|
||||
ENCODE_U16(lenPtr, encode_result, encoded);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
void dump_sor_transparent_container_xml(SORTransparentContainer *sortransparentcontainer, uint8_t iei)
|
||||
{
|
||||
printf("<SOR Transparent Container>\n");
|
||||
|
||||
if (iei > 0)
|
||||
/* Don't display IEI if = 0 */
|
||||
printf(" <IEI>0x%X</IEI>\n", iei);
|
||||
|
||||
printf("%s", dump_octet_string_xml(&sortransparentcontainer->sortransparentcontainercontents));
|
||||
printf("</SOR Transparent Container>\n");
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef SOR_TRANSPARENT_CONTAINER_H_
|
||||
#define SOR_TRANSPARENT_CONTAINER_H_
|
||||
|
||||
#define SOR_TRANSPARENT_CONTAINER_MINIMUM_LENGTH 2 // [length]+[length]
|
||||
#define SOR_TRANSPARENT_CONTAINER_MAXIMUM_LENGTH 65538 // [IEI]+[length]+[length]+[ESM msg]
|
||||
|
||||
typedef struct SORTransparentContainer_tag {
|
||||
OctetString sortransparentcontainercontents;
|
||||
} SORTransparentContainer;
|
||||
|
||||
int encode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_sor_transparent_container(SORTransparentContainer *sortransparentcontainer, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
void dump_sor_transparent_container_xml(SORTransparentContainer *sortransparentcontainer, uint8_t iei);
|
||||
|
||||
#endif /* ESM MESSAGE CONTAINER_H_ */
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 SpareHalfOctet.c
|
||||
|
||||
\brief registration request procedures for gNB
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "SpareHalfOctet.h"
|
||||
|
||||
int decode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int encode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 SpareHalfOctet.h
|
||||
|
||||
\brief registration request procedures for gNB
|
||||
\author Yoshio INOUE, Masayuki HARADA
|
||||
\email: yoshio.inoue@fujitsu.com,masayuki.harada@fujitsu.com
|
||||
\date 2020
|
||||
\version 0.1
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "OctetString.h"
|
||||
|
||||
#ifndef SPARE_HALF_OCTET_H_
|
||||
#define SPARE_HALF_OCTET_H_
|
||||
|
||||
#define SPARE_HALF_OCTET_MINIMUM_LENGTH 1
|
||||
#define SPARE_HALF_OCTET_MAXIMUM_LENGTH 1
|
||||
|
||||
typedef uint8_t SpareHalfOctet;
|
||||
|
||||
int encode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
int decode_spare_half_octet(SpareHalfOctet *sparehalfoctet, uint8_t iei, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* SPARE HALF OCTET_H_ */
|
||||
|
||||
Reference in New Issue
Block a user