diff --git a/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.c b/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.c index 81825f585a..68861c1142 100644 --- a/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.c +++ b/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.c @@ -30,11 +30,14 @@ #include #include #include - +#include #include "TLVEncoder.h" #include "TLVDecoder.h" #include "FGSRegistrationType.h" +#define NO_FOLLOW_ON_REQUEST 0x0 +#define FOLLOW_ON_REQUEST 0x08 + int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t value, uint32_t len) { int decoded = 0; @@ -49,14 +52,14 @@ int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8 return decoded; } -int encode_5gs_registration_type(const FGSRegistrationType *fgsregistrationtype) +/** + * @brief Encode 5GS registration type (9.11.3.7 of 3GPP TS 24.501) + * Note: mandatory IE (IEI = 0) + */ +int encode_5gs_registration_type(const FGSRegistrationType *fgsregistrationtype, bool follow_on_request) { - 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; + // Follow-on request bit + uint8_t foR = follow_on_request ? FOLLOW_ON_REQUEST : NO_FOLLOW_ON_REQUEST; + // Return encoded value + return (foR | (*fgsregistrationtype & 0x7)); } diff --git a/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.h b/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.h index ea42ac160e..7a0e832942 100644 --- a/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.h +++ b/openair3/NAS/NR_UE/5GS/5GMM/IES/FGSRegistrationType.h @@ -29,7 +29,7 @@ #include #include #include - +#include #include "OctetString.h" #ifndef FGS_REGISTRATION_TYPE_H_ @@ -41,13 +41,15 @@ typedef uint8_t FGSRegistrationType; // clang-format off +/* 3GPP TS 24.501 Table 9.11.3.7.1: 5GS registration type IE */ #define INITIAL_REGISTRATION 0b001 #define MOBILITY_REGISTRATION_UPDATING 0b010 #define PERIODIC_REGISTRATION_UPDATING 0b011 #define EMERGENCY_REGISTRATION 0b100 +#define REG_TYPE_RESERVED 0b111 // clang-format on -int encode_5gs_registration_type(const FGSRegistrationType *fgsregistrationtype); +int encode_5gs_registration_type(const FGSRegistrationType *fgsregistrationtype, bool follow_on_request); int decode_5gs_registration_type(FGSRegistrationType *fgsregistrationtype, uint8_t iei, uint8_t value, uint32_t len); diff --git a/openair3/NAS/NR_UE/5GS/5GMM/MSG/RegistrationRequest.c b/openair3/NAS/NR_UE/5GS/5GMM/MSG/RegistrationRequest.c index 8f6fea900e..f71030f1f7 100644 --- a/openair3/NAS/NR_UE/5GS/5GMM/MSG/RegistrationRequest.c +++ b/openair3/NAS/NR_UE/5GS/5GMM/MSG/RegistrationRequest.c @@ -72,9 +72,10 @@ int encode_registration_request(const registration_request_msg *registration_req { int encoded = 0; int encode_result = 0; + bool is_for = true; // Follow-on request pending *(buffer + encoded) = ((encode_nas_key_set_identifier(®istration_request->naskeysetidentifier, IEI_NULL) & 0x0f) << 4) - | (encode_5gs_registration_type(®istration_request->fgsregistrationtype) & 0x0f); + | (encode_5gs_registration_type(®istration_request->fgsregistrationtype, is_for) & 0x0f); encoded++; if ((encode_result = encode_5gs_mobile_identity(®istration_request->fgsmobileidentity, 0, buffer + encoded, len - encoded))