Commit 3156a9df authored by francescomani's avatar francescomani

function to handle NAS registraction accept

parent b2c5f4bc
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "RegistrationAccept.h" #include "RegistrationAccept.h"
#include "assertions.h" #include "assertions.h"
int decode_registration_accept(registration_accept_msg *registration_accept, uint8_t *buffer, uint32_t len) int decode_registration_accept(registration_accept_msg *registration_accept, const uint8_t *buffer, uint32_t len)
{ {
uint32_t decoded = 0; uint32_t decoded = 0;
int decoded_result = 0; int decoded_result = 0;
......
...@@ -62,7 +62,7 @@ typedef struct registration_accept_msg_tag { ...@@ -62,7 +62,7 @@ typedef struct registration_accept_msg_tag {
FGSMobileIdentity *guti; FGSMobileIdentity *guti;
} registration_accept_msg; } registration_accept_msg;
int decode_registration_accept(registration_accept_msg *registrationaccept, uint8_t *buffer, uint32_t len); int decode_registration_accept(registration_accept_msg *registrationaccept, const uint8_t *buffer, uint32_t len);
int encode_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);
......
...@@ -37,13 +37,13 @@ ...@@ -37,13 +37,13 @@
#include "TLVDecoder.h" #include "TLVDecoder.h"
#include "FGSMobileIdentity.h" #include "FGSMobileIdentity.h"
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer); 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_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_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_t *buffer);
static int encode_imeisv_5gs_mobile_identity(Imeisv5GSMobileIdentity_t *imeisv, uint8_t *buffer); static int encode_imeisv_5gs_mobile_identity(Imeisv5GSMobileIdentity_t *imeisv, uint8_t *buffer);
int decode_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 decoded_rc = TLV_DECODE_VALUE_DOESNT_MATCH; int decoded_rc = TLV_DECODE_VALUE_DOESNT_MATCH;
int decoded = 0; int decoded = 0;
...@@ -117,7 +117,7 @@ int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei ...@@ -117,7 +117,7 @@ int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei
return (encoded + encoded_rc); return (encoded + encoded_rc);
} }
static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_t *buffer) static int decode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, const uint8_t *buffer)
{ {
int decoded = 0; int decoded = 0;
uint16_t temp; uint16_t temp;
......
...@@ -149,7 +149,7 @@ typedef union FGSMobileIdentity_tag { ...@@ -149,7 +149,7 @@ typedef union FGSMobileIdentity_tag {
int encode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, uint8_t *buffer, uint32_t len); 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); int decode_5gs_mobile_identity(FGSMobileIdentity *fgsmobileidentity, uint8_t iei, const uint8_t *buffer, uint32_t len);
#endif /* FGS MOBILE IDENTITY_H_ */ #endif /* FGS MOBILE IDENTITY_H_ */
...@@ -617,7 +617,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -617,7 +617,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
} }
} }
static void decodeRegistrationAccept(uint8_t *buf, int len, nr_ue_nas_t *nas) static void decodeRegistrationAccept(const uint8_t *buf, int len, nr_ue_nas_t *nas)
{ {
registration_accept_msg reg_acc = {0}; registration_accept_msg reg_acc = {0};
/* it seems there is no 5G corresponding emm_msg_decode() function, so here /* it seems there is no 5G corresponding emm_msg_decode() function, so here
...@@ -1033,6 +1033,29 @@ void *nas_nrue_task(void *args_p) ...@@ -1033,6 +1033,29 @@ void *nas_nrue_task(void *args_p)
} }
} }
static void handle_registration_accept(instance_t instance,
nr_ue_nas_t *nas,
const uint8_t *pdu_buffer,
uint32_t msg_length)
{
LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
decodeRegistrationAccept(pdu_buffer, msg_length, nas);
get_allowed_nssai(nas_allowed_nssai, pdu_buffer, msg_length);
as_nas_info_t initialNasMsg = {0};
generateRegistrationComplete(nas, &initialNasMsg, NULL);
if (initialNasMsg.length > 0) {
send_nas_uplink_data_req(instance, &initialNasMsg);
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
}
const int nssai_idx = get_user_nssai_idx(nas_allowed_nssai, nas);
if (nssai_idx < 0) {
LOG_E(NAS, "NSSAI parameters not match with allowed NSSAI. Couldn't request PDU session.\n");
} else {
request_default_pdusession(instance, nssai_idx);
}
}
void *nas_nrue(void *args_p) void *nas_nrue(void *args_p)
{ {
// Wait for a message or an event // Wait for a message or an event
...@@ -1112,24 +1135,8 @@ void *nas_nrue(void *args_p) ...@@ -1112,24 +1135,8 @@ void *nas_nrue(void *args_p)
int msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length); int msg_type = get_msg_type(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
if (msg_type == REGISTRATION_ACCEPT) { if (msg_type == REGISTRATION_ACCEPT) {
LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n");
nr_ue_nas_t *nas = get_ue_nas_info(0); nr_ue_nas_t *nas = get_ue_nas_info(0);
decodeRegistrationAccept(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length, nas); handle_registration_accept(instance, nas, pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
get_allowed_nssai(nas_allowed_nssai, pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
as_nas_info_t initialNasMsg = {0};
generateRegistrationComplete(nas, &initialNasMsg, NULL);
if (initialNasMsg.length > 0) {
send_nas_uplink_data_req(instance, &initialNasMsg);
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
}
const int nssai_idx = get_user_nssai_idx(nas_allowed_nssai, nas);
if (nssai_idx < 0) {
LOG_E(NAS, "NSSAI parameters not match with allowed NSSAI. Couldn't request PDU session.\n");
} else {
request_default_pdusession(instance, nssai_idx);
}
} else if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) { } else if (msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC) {
capture_pdu_session_establishment_accept_msg(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length); capture_pdu_session_establishment_accept_msg(pdu_buffer, NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length);
} }
...@@ -1198,21 +1205,7 @@ void *nas_nrue(void *args_p) ...@@ -1198,21 +1205,7 @@ void *nas_nrue(void *args_p)
decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer); decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer);
break; break;
case REGISTRATION_ACCEPT: case REGISTRATION_ACCEPT:
LOG_I(NAS, "[UE] Received REGISTRATION ACCEPT message\n"); handle_registration_accept(instance, nas, pdu_buffer, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length);
decodeRegistrationAccept(pdu_buffer, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length, nas);
as_nas_info_t initialNasMsg = {0};
generateRegistrationComplete(nas, &initialNasMsg, NULL);
if (initialNasMsg.length > 0) {
send_nas_uplink_data_req(instance, &initialNasMsg);
LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(RegistrationComplete)\n");
}
const int nssai_idx = get_user_nssai_idx(nas_allowed_nssai, nas);
if (nssai_idx < 0) {
LOG_E(NAS, "NSSAI parameters not match with allowed NSSAI. Couldn't request PDU session.\n");
} else {
request_default_pdusession(instance, nssai_idx);
}
break; break;
case FGS_DEREGISTRATION_ACCEPT: case FGS_DEREGISTRATION_ACCEPT:
LOG_I(NAS, "received deregistration accept\n"); LOG_I(NAS, "received deregistration accept\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment