add struct for registration request message
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*! \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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*! \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_ */
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*! \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 "TLVEncoder.h"
|
||||
#include "TLVDecoder.h"
|
||||
#include "FGSMobileIdentity.h"
|
||||
|
||||
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer);
|
||||
|
||||
static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer);
|
||||
|
||||
int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, 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++;
|
||||
}
|
||||
|
||||
ielen = *(buffer + decoded);
|
||||
decoded++;
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
uint8_t *lenPtr;
|
||||
int encoded_rc = TLV_ENCODE_VALUE_DOESNT_MATCH;
|
||||
uint32_t encoded = 0;
|
||||
|
||||
if (iei > 0) {
|
||||
*buffer = iei;
|
||||
encoded++;
|
||||
}
|
||||
|
||||
lenPtr = (buffer + encoded);
|
||||
encoded ++;
|
||||
|
||||
if (fgsmobileidentity->guti.typeofidentity == FGS_MOBILE_IDENTITY_5G_GUTI) {
|
||||
encoded_rc = encode_guti_5gs_mobile_identity(&fgsmobileidentity->guti,
|
||||
buffer + encoded);
|
||||
}
|
||||
|
||||
if (encoded_rc < 0) {
|
||||
return encoded_rc;
|
||||
}
|
||||
|
||||
*lenPtr = encoded + encoded_rc - 1 - ((iei > 0) ? 1 : 0);
|
||||
return (encoded + encoded_rc);
|
||||
}
|
||||
|
||||
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, 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 & 0x3f) << 6) | (guti->amfpointer & 0x3f);
|
||||
|
||||
IES_ENCODE_U16(buffer, encoded, temp);
|
||||
IES_ENCODE_U32(buffer, encoded, guti->tmsi);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*! \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_
|
||||
|
||||
|
||||
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;
|
||||
} 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 Imei5GSMobileIdentity_t 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, uint8_t *buffer, uint32_t len);
|
||||
|
||||
#endif /* FGS MOBILE IDENTITY_H_ */
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*! \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 *buffer, uint32_t len)
|
||||
{
|
||||
int decoded = 0;
|
||||
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) |
|
||||
(*fgsregistrationtype & 0x7);
|
||||
encoded++;
|
||||
|
||||
return bufferReturn;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*! \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 *buffer, uint32_t len);
|
||||
|
||||
|
||||
#endif /* FGS_REGISTRATION_TYPE_H_*/
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*! \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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*! \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