add decode and encode for registration accept
This commit is contained in:
@@ -2454,6 +2454,7 @@ if(ITTI_SIM)
|
|||||||
|
|
||||||
set(libnrnas_emm_msg_OBJS
|
set(libnrnas_emm_msg_OBJS
|
||||||
${NAS_SRC}COMMON/EMM/MSG/RegistrationRequest.c
|
${NAS_SRC}COMMON/EMM/MSG/RegistrationRequest.c
|
||||||
|
${NAS_SRC}COMMON/EMM/MSG/RegistrationAccept.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(libnrnas_ies_OBJS
|
set(libnrnas_ies_OBJS
|
||||||
@@ -2461,6 +2462,7 @@ if(ITTI_SIM)
|
|||||||
${NAS_SRC}COMMON/IES/FGSMobileIdentity.c
|
${NAS_SRC}COMMON/IES/FGSMobileIdentity.c
|
||||||
${NAS_SRC}COMMON/IES/FGSRegistrationType.c
|
${NAS_SRC}COMMON/IES/FGSRegistrationType.c
|
||||||
${NAS_SRC}COMMON/IES/SpareHalfOctet.c
|
${NAS_SRC}COMMON/IES/SpareHalfOctet.c
|
||||||
|
${NAS_SRC}COMMON/IES/FGSRegistrationResult.c
|
||||||
${NAS_SRC}COMMON/IES/FGMMCapability.c
|
${NAS_SRC}COMMON/IES/FGMMCapability.c
|
||||||
${NAS_SRC}COMMON/IES/NrUESecurityCapability.c
|
${NAS_SRC}COMMON/IES/NrUESecurityCapability.c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*! \file RegistrationAccept.c
|
||||||
|
|
||||||
|
\brief 5GS registration accept 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 <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "TLVEncoder.h"
|
||||||
|
#include "TLVDecoder.h"
|
||||||
|
#include "RegistrationAccept.h"
|
||||||
|
#include "assertions.h"
|
||||||
|
|
||||||
|
int decode_registration_accept(registration_accept_msg *registration_accept, uint8_t *buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
uint32_t decoded = 0;
|
||||||
|
int decoded_result = 0;
|
||||||
|
|
||||||
|
/* Decoding mandatory fields */
|
||||||
|
if ((decoded_result = decode_fgs_registration_result(®istration_accept->fgsregistrationresult, 0, *(buffer + decoded), len - decoded)) < 0)
|
||||||
|
return decoded_result;
|
||||||
|
|
||||||
|
decoded += decoded_result;
|
||||||
|
|
||||||
|
// todo ,Decoding optional fields
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
int encode_registration_accept(registration_accept_msg *registration_accept, uint8_t *buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
int encoded = 0;
|
||||||
|
|
||||||
|
LOG_FUNC_IN;
|
||||||
|
|
||||||
|
|
||||||
|
*(buffer + encoded) = encode_fgs_registration_result(®istration_accept->fgsregistrationresult);
|
||||||
|
encoded = encoded + 2;
|
||||||
|
|
||||||
|
// todo ,Encoding optional fields
|
||||||
|
LOG_FUNC_RETURN(encoded);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*! \file RegistrationAccept.h
|
||||||
|
|
||||||
|
\brief 5GS registration accept 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 "ExtendedProtocolDiscriminator.h"
|
||||||
|
#include "SecurityHeaderType.h"
|
||||||
|
#include "SpareHalfOctet.h"
|
||||||
|
#include "MessageType.h"
|
||||||
|
#include "FGSRegistrationResult.h"
|
||||||
|
|
||||||
|
#ifndef REGISTRATION_ACCEPT_H_
|
||||||
|
#define REGISTRATION_ACCEPT_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Message name: Registration accept
|
||||||
|
* Description: The REGISTRATION ACCEPT message is sent by the AMF to the UE. See table 8.2.7.1.1.
|
||||||
|
* Significance: dual
|
||||||
|
* Direction: network to UE
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct registration_accept_msg_tag {
|
||||||
|
/* Mandatory fields */
|
||||||
|
ExtendedProtocolDiscriminator protocoldiscriminator;
|
||||||
|
SecurityHeaderType securityheadertype:4;
|
||||||
|
SpareHalfOctet sparehalfoctet:4;
|
||||||
|
MessageType messagetype;
|
||||||
|
FGSRegistrationResult fgsregistrationresult;
|
||||||
|
} registration_accept_msg;
|
||||||
|
|
||||||
|
int decode_registration_accept(registration_accept_msg *registrationaccept, uint8_t *buffer, uint32_t len);
|
||||||
|
|
||||||
|
int encode_registration_accept(registration_accept_msg *registrationaccept, uint8_t *buffer, uint32_t len);
|
||||||
|
|
||||||
|
#endif /* ! defined(REGISTRATION_ACCEPT_H_) */
|
||||||
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*! \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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*! \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_*/
|
||||||
|
|
||||||
Reference in New Issue
Block a user