Commit f8738809 authored by Guido Casati's avatar Guido Casati

Replace type Byte_t used in NAS directly with uint8_t

* the goal is to simplify the code
parent 21df50b3
...@@ -167,7 +167,7 @@ typedef struct as_stmsi_s { ...@@ -167,7 +167,7 @@ typedef struct as_stmsi_s {
/* Dedicated NAS information */ /* Dedicated NAS information */
typedef struct as_nas_info_s { typedef struct as_nas_info_s {
uint32_t length; /* Length of the NAS information data */ uint32_t length; /* Length of the NAS information data */
Byte_t* nas_data; /* Dedicated NAS information data container */ uint8_t* nas_data; /* Dedicated NAS information data container */
} as_nas_info_t; } as_nas_info_t;
/* Radio Access Bearer identity */ /* Radio Access Bearer identity */
...@@ -216,7 +216,7 @@ typedef struct broadcast_info_ind_s { ...@@ -216,7 +216,7 @@ typedef struct broadcast_info_ind_s {
* NAS request AS to refresh its KeNB key * NAS request AS to refresh its KeNB key
*/ */
typedef struct kenb_refresh_req_s { typedef struct kenb_refresh_req_s {
Byte_t kenb[32]; uint8_t kenb[32];
} kenb_refresh_req_t; } kenb_refresh_req_t;
typedef struct nsa_oai_tun_nsa_s { typedef struct nsa_oai_tun_nsa_s {
...@@ -230,7 +230,7 @@ typedef struct nsa_oai_tun_nsa_s { ...@@ -230,7 +230,7 @@ typedef struct nsa_oai_tun_nsa_s {
*/ */
typedef struct cell_info_req_s { typedef struct cell_info_req_s {
plmn_t plmnID; /* Selected PLMN identity */ plmn_t plmnID; /* Selected PLMN identity */
Byte_t rat; /* Bitmap - set of radio access technologies */ uint8_t rat; /* Bitmap - set of radio access technologies */
} cell_info_req_t; } cell_info_req_t;
/* /*
......
...@@ -43,7 +43,6 @@ Description Contains global common definitions ...@@ -43,7 +43,6 @@ Description Contains global common definitions
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include "common/platform_constants.h" #include "common/platform_constants.h"
typedef uint8_t Byte_t; /* 8 bit unsigned integer */
/* /*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -62,30 +61,30 @@ typedef uint8_t AcT_t; /* Access Technology */ ...@@ -62,30 +61,30 @@ typedef uint8_t AcT_t; /* Access Technology */
* International Mobile Subscriber Identity * International Mobile Subscriber Identity
*/ */
typedef struct { typedef struct {
Byte_t length; uint8_t length;
union { union {
struct { struct {
Byte_t digit2:4; uint8_t digit2: 4;
Byte_t digit1:4; uint8_t digit1: 4;
Byte_t digit4:4; uint8_t digit4: 4;
Byte_t digit3:4; uint8_t digit3: 4;
Byte_t digit6:4; uint8_t digit6: 4;
Byte_t digit5:4; uint8_t digit5: 4;
Byte_t digit8:4; uint8_t digit8: 4;
Byte_t digit7:4; uint8_t digit7: 4;
Byte_t digit10:4; uint8_t digit10: 4;
Byte_t digit9:4; uint8_t digit9: 4;
Byte_t digit12:4; uint8_t digit12: 4;
Byte_t digit11:4; uint8_t digit11: 4;
Byte_t digit14:4; uint8_t digit14: 4;
Byte_t digit13:4; uint8_t digit13: 4;
#define EVEN_PARITY 0 #define EVEN_PARITY 0
#define ODD_PARITY 1 #define ODD_PARITY 1
Byte_t parity:4; uint8_t parity: 4;
Byte_t digit15:4; uint8_t digit15: 4;
} num; } num;
#define IMSI_SIZE 8 #define IMSI_SIZE 8
Byte_t value[IMSI_SIZE]; uint8_t value[IMSI_SIZE];
} u; } u;
} imsi_t; } imsi_t;
...@@ -119,7 +118,7 @@ typedef struct { ...@@ -119,7 +118,7 @@ typedef struct {
* Mobile subscriber dialing number * Mobile subscriber dialing number
*/ */
typedef struct { typedef struct {
Byte_t ext:1; uint8_t ext: 1;
/* Type Of Number */ /* Type Of Number */
#define MSISDN_TON_UNKNOWKN 0b000 #define MSISDN_TON_UNKNOWKN 0b000
#define MSISDN_TON_INTERNATIONAL 0b001 #define MSISDN_TON_INTERNATIONAL 0b001
...@@ -128,7 +127,7 @@ typedef struct { ...@@ -128,7 +127,7 @@ typedef struct {
#define MSISDN_TON_SUBCRIBER 0b100 #define MSISDN_TON_SUBCRIBER 0b100
#define MSISDN_TON_ABBREVIATED 0b110 #define MSISDN_TON_ABBREVIATED 0b110
#define MSISDN_TON_RESERVED 0b111 #define MSISDN_TON_RESERVED 0b111
Byte_t ton:3; uint8_t ton: 3;
/* Numbering Plan Identification */ /* Numbering Plan Identification */
#define MSISDN_NPI_UNKNOWN 0b0000 #define MSISDN_NPI_UNKNOWN 0b0000
#define MSISDN_NPI_ISDN_TELEPHONY 0b0001 #define MSISDN_NPI_ISDN_TELEPHONY 0b0001
...@@ -140,11 +139,11 @@ typedef struct { ...@@ -140,11 +139,11 @@ typedef struct {
#define MSISDN_NPI_ISDN_MOBILE 0b0111 #define MSISDN_NPI_ISDN_MOBILE 0b0111
#define MSISDN_NPI_PRIVATE 0b1110 #define MSISDN_NPI_PRIVATE 0b1110
#define MSISDN_NPI_RESERVED 0b1111 #define MSISDN_NPI_RESERVED 0b1111
Byte_t npi:4; uint8_t npi: 4;
/* Dialing Number */ /* Dialing Number */
struct { struct {
Byte_t lsb:4; uint8_t lsb: 4;
Byte_t msb:4; uint8_t msb: 4;
#define MSISDN_DIGIT_SIZE 10 #define MSISDN_DIGIT_SIZE 10
} digit[MSISDN_DIGIT_SIZE]; } digit[MSISDN_DIGIT_SIZE];
} msisdn_t; } msisdn_t;
...@@ -159,12 +158,12 @@ typedef imsi_t imei_t; ...@@ -159,12 +158,12 @@ typedef imsi_t imei_t;
* PLMN = BCD encoding (Mobile Country Code + Mobile Network Code) * PLMN = BCD encoding (Mobile Country Code + Mobile Network Code)
*/ */
typedef struct { typedef struct {
Byte_t MCCdigit2:4; uint8_t MCCdigit2: 4;
Byte_t MCCdigit1:4; uint8_t MCCdigit1: 4;
Byte_t MNCdigit3:4; uint8_t MNCdigit3: 4;
Byte_t MCCdigit3:4; uint8_t MCCdigit3: 4;
Byte_t MNCdigit2:4; uint8_t MNCdigit2: 4;
Byte_t MNCdigit1:4; uint8_t MNCdigit1: 4;
} plmn_t; } plmn_t;
/* /*
...@@ -256,17 +255,29 @@ typedef struct { ...@@ -256,17 +255,29 @@ typedef struct {
/* /*
* A list of PLMNs * A list of PLMNs
*/ */
#define PLMN_LIST_T(SIZE) struct {Byte_t n_plmns; plmn_t plmn[SIZE];} #define PLMN_LIST_T(SIZE) \
struct { \
uint8_t n_plmns; \
plmn_t plmn[SIZE]; \
}
/* /*
* A list of TACs * A list of TACs
*/ */
#define TAC_LIST_T(SIZE) struct {Byte_t n_tacs; TAC_t tac[SIZE];} #define TAC_LIST_T(SIZE) \
struct { \
uint8_t n_tacs; \
TAC_t tac[SIZE]; \
}
/* /*
* A list of TAIs * A list of TAIs
*/ */
#define TAI_LIST_T(SIZE) struct {Byte_t n_tais; tai_t tai[SIZE];} #define TAI_LIST_T(SIZE) \
struct { \
uint8_t n_tais; \
tai_t tai[SIZE]; \
}
typedef enum eps_protocol_discriminator_e { typedef enum eps_protocol_discriminator_e {
/* Protocol discriminator identifier for EPS Mobility Management */ /* Protocol discriminator identifier for EPS Mobility Management */
......
...@@ -461,7 +461,7 @@ typedef struct UE_RRC_INST_NB_IoT_s { ...@@ -461,7 +461,7 @@ typedef struct UE_RRC_INST_NB_IoT_s {
Rrc_State_NB_IoT_t RrcState; Rrc_State_NB_IoT_t RrcState;
Rrc_Sub_State_NB_IoT_t RrcSubState; Rrc_Sub_State_NB_IoT_t RrcSubState;
plmn_t plmnID; plmn_t plmnID;
Byte_t rat; uint8_t rat;
as_nas_info_t initialNasMsg; as_nas_info_t initialNasMsg;
OAI_UECapability_NB_IoT_t *UECap; OAI_UECapability_NB_IoT_t *UECap;
uint8_t *UECapability; uint8_t *UECapability;
......
...@@ -812,7 +812,7 @@ typedef struct UE_RRC_INST_s { ...@@ -812,7 +812,7 @@ typedef struct UE_RRC_INST_s {
Rrc_State_t RrcState; Rrc_State_t RrcState;
Rrc_Sub_State_t RrcSubState; Rrc_Sub_State_t RrcSubState;
plmn_t plmnID; plmn_t plmnID;
Byte_t rat; uint8_t rat;
uint8_t selected_plmn_identity; uint8_t selected_plmn_identity;
as_nas_info_t initialNasMsg; as_nas_info_t initialNasMsg;
OAI_UECapability_t *UECap; OAI_UECapability_t *UECap;
......
...@@ -192,7 +192,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) ...@@ -192,7 +192,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
int bytes = sizeof(msg->msgID); int bytes = sizeof(msg->msgID);
as_nas_info_t nas_msg; as_nas_info_t nas_msg;
Byte_t *dataptr=NULL; uint8_t* dataptr = NULL;
uint32_t len=0; uint32_t len=0;
memset(&nas_msg, 0, sizeof(as_nas_info_t)); memset(&nas_msg, 0, sizeof(as_nas_info_t));
...@@ -230,30 +230,30 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) ...@@ -230,30 +230,30 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_NAS_ESTABLISH_REQ: case AS_NAS_ESTABLISH_REQ:
/* NAS signalling connection establish request */ /* NAS signalling connection establish request */
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*); bytes += sizeof(nas_establish_req_t) - sizeof(uint8_t*);
nas_msg = msg->msg.nas_establish_req.initialNasMsg; nas_msg = msg->msg.nas_establish_req.initialNasMsg;
break; break;
case AS_NAS_ESTABLISH_IND: case AS_NAS_ESTABLISH_IND:
/* NAS signalling connection establish indication */ /* NAS signalling connection establish indication */
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*); bytes += sizeof(nas_establish_ind_t) - sizeof(uint8_t*);
nas_msg = msg->msg.nas_establish_ind.initialNasMsg; nas_msg = msg->msg.nas_establish_ind.initialNasMsg;
dataptr = (Byte_t*)&(msg->msg.nas_establish_ind.initialNasMsg.nas_data); dataptr = (uint8_t*)&(msg->msg.nas_establish_ind.initialNasMsg.nas_data);
len=msg->msg.nas_establish_ind.initialNasMsg.length; len=msg->msg.nas_establish_ind.initialNasMsg.length;
break; break;
case AS_NAS_ESTABLISH_RSP: case AS_NAS_ESTABLISH_RSP:
/* NAS signalling connection establish response */ /* NAS signalling connection establish response */
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*); bytes += sizeof(nas_establish_rsp_t) - sizeof(uint8_t*);
nas_msg = msg->msg.nas_establish_rsp.nasMsg; nas_msg = msg->msg.nas_establish_rsp.nasMsg;
break; break;
case AS_NAS_ESTABLISH_CNF: case AS_NAS_ESTABLISH_CNF:
/* NAS signalling connection establish confirm */ /* NAS signalling connection establish confirm */
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*); bytes += sizeof(nas_establish_cnf_t) - sizeof(uint8_t*);
nas_msg = msg->msg.nas_establish_cnf.nasMsg; nas_msg = msg->msg.nas_establish_cnf.nasMsg;
dataptr = (Byte_t*)&(msg->msg.nas_establish_cnf.nasMsg.nas_data); dataptr = (uint8_t*)&(msg->msg.nas_establish_cnf.nasMsg.nas_data);
len=msg->msg.nas_establish_ind.initialNasMsg.length; len=msg->msg.nas_establish_ind.initialNasMsg.length;
break; break;
...@@ -269,7 +269,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) ...@@ -269,7 +269,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_UL_INFO_TRANSFER_REQ: case AS_UL_INFO_TRANSFER_REQ:
/* Uplink L3 data transfer request */ /* Uplink L3 data transfer request */
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*); bytes += sizeof(ul_info_transfer_req_t) - sizeof(uint8_t*);
nas_msg = msg->msg.ul_info_transfer_req.nasMsg; nas_msg = msg->msg.ul_info_transfer_req.nasMsg;
break; break;
...@@ -280,13 +280,13 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) ...@@ -280,13 +280,13 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_UL_INFO_TRANSFER_IND: case AS_UL_INFO_TRANSFER_IND:
/* Uplink L3 data transfer indication */ /* Uplink L3 data transfer indication */
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*); bytes += sizeof(ul_info_transfer_ind_t) - sizeof(uint8_t*);
nas_msg = msg->msg.ul_info_transfer_ind.nasMsg; nas_msg = msg->msg.ul_info_transfer_ind.nasMsg;
break; break;
case AS_DL_INFO_TRANSFER_REQ: case AS_DL_INFO_TRANSFER_REQ:
/* Downlink L3 data transfer */ /* Downlink L3 data transfer */
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*); bytes += sizeof(dl_info_transfer_req_t) - sizeof(uint8_t*);
nas_msg = msg->msg.dl_info_transfer_req.nasMsg; nas_msg = msg->msg.dl_info_transfer_req.nasMsg;
break; break;
...@@ -297,7 +297,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length) ...@@ -297,7 +297,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_DL_INFO_TRANSFER_IND: case AS_DL_INFO_TRANSFER_IND:
/* Downlink L3 data transfer indication */ /* Downlink L3 data transfer indication */
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*); bytes += sizeof(dl_info_transfer_ind_t) - sizeof(uint8_t*);
nas_msg = msg->msg.dl_info_transfer_ind.nasMsg; nas_msg = msg->msg.dl_info_transfer_ind.nasMsg;
break; break;
......
...@@ -558,7 +558,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) ...@@ -558,7 +558,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
size += 10; size += 10;
// encode the message // encode the message
initialNasMsg->nas_data = malloc16_clear(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc16_clear(size * sizeof(*initialNasMsg->nas_data));
nas->registration_request_buf = initialNasMsg->nas_data; nas->registration_request_buf = initialNasMsg->nas_data;
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size); initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
...@@ -603,7 +603,7 @@ void generateServiceRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas) ...@@ -603,7 +603,7 @@ void generateServiceRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
size += fill_fgstmsi(&mm_msg->service_request.fiveg_s_tmsi, nas->guti); size += fill_fgstmsi(&mm_msg->service_request.fiveg_s_tmsi, nas->guti);
/* message encoding */ /* message encoding */
initialNasMsg->nas_data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(size * sizeof(*initialNasMsg->nas_data));
if (security_protected) { if (security_protected) {
// security protected encoding // security protected encoding
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size);
...@@ -668,7 +668,7 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype ...@@ -668,7 +668,7 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype
} }
// encode the message // encode the message
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(size * sizeof(*initialNasMsg->nas_data));
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size); initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
} }
...@@ -704,7 +704,7 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN ...@@ -704,7 +704,7 @@ static void generateAuthenticationResp(nr_ue_nas_t *nas, as_nas_info_t *initialN
mm_msg->fgs_auth_response.authenticationresponseparameter.res = res; mm_msg->fgs_auth_response.authenticationresponseparameter.res = res;
size += 18; size += 18;
// encode the message // encode the message
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(size * sizeof(*initialNasMsg->nas_data));
initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size); initialNasMsg->length = mm_msg_encode(mm_msg, initialNasMsg->nas_data, size);
// Free res value after encode // Free res value after encode
...@@ -756,7 +756,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia ...@@ -756,7 +756,7 @@ static void generateSecurityModeComplete(nr_ue_nas_t *nas, as_nas_info_t *initia
size += (nas->registration_request_len + 2); size += (nas->registration_request_len + 2);
// encode the message // encode the message
initialNasMsg->nas_data = malloc(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(size * sizeof(*initialNasMsg->nas_data));
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size);
...@@ -884,7 +884,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas, ...@@ -884,7 +884,7 @@ static void generateRegistrationComplete(nr_ue_nas_t *nas,
} }
// encode the message // encode the message
initialNasMsg->nas_data = malloc(length * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(length * sizeof(*initialNasMsg->nas_data));
initialNasMsg->length = length; initialNasMsg->length = length;
/* Encode the first octet of the header (extended protocol discriminator) */ /* Encode the first octet of the header (extended protocol discriminator) */
...@@ -981,7 +981,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi ...@@ -981,7 +981,7 @@ static void generateDeregistrationRequest(nr_ue_nas_t *nas, as_nas_info_t *initi
size += fill_guti(&dereg_req->fgsmobileidentity, nas->guti); size += fill_guti(&dereg_req->fgsmobileidentity, nas->guti);
// encode the message // encode the message
initialNasMsg->nas_data = calloc(size, sizeof(Byte_t)); initialNasMsg->nas_data = calloc_or_fail(size, sizeof(*initialNasMsg->nas_data));
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &nas_msg.header, size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &nas_msg.header, size);
initialNasMsg->length = initialNasMsg->length =
...@@ -1089,7 +1089,7 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t * ...@@ -1089,7 +1089,7 @@ static void generatePduSessionEstablishRequest(nr_ue_nas_t *nas, as_nas_info_t *
size += (1 + 1 + dnnSize + 1); size += (1 + 1 + dnnSize + 1);
// encode the message // encode the message
initialNasMsg->nas_data = (Byte_t *)malloc(size * sizeof(Byte_t)); initialNasMsg->nas_data = malloc_or_fail(size * sizeof(*initialNasMsg->nas_data));
int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size); int security_header_len = nas_protected_security_header_encode((char *)(initialNasMsg->nas_data), &(nas_msg.header), size);
initialNasMsg->length = initialNasMsg->length =
......
...@@ -173,7 +173,7 @@ int process_nas_establish_req(int msg_id, const nas_establish_req_t* req, ...@@ -173,7 +173,7 @@ int process_nas_establish_req(int msg_id, const nas_establish_req_t* req,
ind->tac = DEFAULT_TAC; ind->tac = DEFAULT_TAC;
if (req->initialNasMsg.length > 0) { if (req->initialNasMsg.length > 0) {
ind->initialNasMsg.data = (Byte_t*)malloc(req->initialNasMsg.length); ind->initialNasMsg.data = malloc(req->initialNasMsg.length);
if (ind->initialNasMsg.data) { if (ind->initialNasMsg.data) {
memcpy(ind->initialNasMsg.data, req->initialNasMsg.data, memcpy(ind->initialNasMsg.data, req->initialNasMsg.data,
...@@ -250,7 +250,7 @@ int process_ul_info_transfer_req(int msg_id, const ul_info_transfer_req_t* req, ...@@ -250,7 +250,7 @@ int process_ul_info_transfer_req(int msg_id, const ul_info_transfer_req_t* req,
ind->UEid = 1; // Valid UEid starts at index 1 ind->UEid = 1; // Valid UEid starts at index 1
if (req->nasMsg.length > 0) { if (req->nasMsg.length > 0) {
ind->nasMsg.data = (Byte_t*)malloc(req->nasMsg.length); ind->nasMsg.data = malloc(req->nasMsg.length);
if (ind->nasMsg.data) { if (ind->nasMsg.data) {
memcpy(ind->nasMsg.data, req->nasMsg.data, req->nasMsg.length); memcpy(ind->nasMsg.data, req->nasMsg.data, req->nasMsg.length);
...@@ -360,7 +360,7 @@ int process_nas_establish_rsp(int msg_id, const nas_establish_rsp_t* rsp, ...@@ -360,7 +360,7 @@ int process_nas_establish_rsp(int msg_id, const nas_establish_rsp_t* rsp,
cnf->errCode = rsp->errCode; cnf->errCode = rsp->errCode;
if (rsp->nasMsg.length > 0) { if (rsp->nasMsg.length > 0) {
cnf->nasMsg.data = (Byte_t*)malloc(rsp->nasMsg.length); cnf->nasMsg.data = malloc(rsp->nasMsg.length);
if (cnf->nasMsg.data) { if (cnf->nasMsg.data) {
memcpy(cnf->nasMsg.data, rsp->nasMsg.data, memcpy(cnf->nasMsg.data, rsp->nasMsg.data,
...@@ -426,7 +426,7 @@ int process_dl_info_transfer_req(int msg_id, const dl_info_transfer_req_t* req, ...@@ -426,7 +426,7 @@ int process_dl_info_transfer_req(int msg_id, const dl_info_transfer_req_t* req,
/* Setup downlink information indication message */ /* Setup downlink information indication message */
if (req->nasMsg.length > 0) { if (req->nasMsg.length > 0) {
ind->nasMsg.data = (Byte_t*)malloc(req->nasMsg.length); ind->nasMsg.data = malloc(req->nasMsg.length);
if (ind->nasMsg.data) { if (ind->nasMsg.data) {
memcpy(ind->nasMsg.data, req->nasMsg.data, req->nasMsg.length); memcpy(ind->nasMsg.data, req->nasMsg.data, req->nasMsg.length);
......
...@@ -228,7 +228,7 @@ static int _process_activate_default_eps_bearer_context_accept(const activate_de ...@@ -228,7 +228,7 @@ static int _process_activate_default_eps_bearer_context_accept(const activate_de
static int _process_activate_default_eps_bearer_context_reject(const activate_default_eps_bearer_context_reject_msg* msg); static int _process_activate_default_eps_bearer_context_reject(const activate_default_eps_bearer_context_reject_msg* msg);
static int _process_deactivate_eps_bearer_context_accept(const deactivate_eps_bearer_context_accept_msg* msg); static int _process_deactivate_eps_bearer_context_accept(const deactivate_eps_bearer_context_accept_msg* msg);
static void _dump_buffer(const Byte_t* buffer, size_t len) static void _dump_buffer(const uint8_t* buffer, size_t len)
{ {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if ( (i%16) == 0 ) printf("\n\t"); if ( (i%16) == 0 ) printf("\n\t");
...@@ -538,7 +538,7 @@ static int _process_establish_req(const nas_establish_req_t* req, ...@@ -538,7 +538,7 @@ static int _process_establish_req(const nas_establish_req_t* req,
if (bytes > 0) { if (bytes > 0) {
/* Setup signalling connection establishment confirm message */ /* Setup signalling connection establishment confirm message */
rsp->errCode = AS_SUCCESS; rsp->errCode = AS_SUCCESS;
rsp->nasMsg.data = (Byte_t*)malloc(bytes * sizeof(Byte_t)); rsp->nasMsg.data = malloc(bytes * sizeof(uint8_t));
if (rsp->nasMsg.data) { if (rsp->nasMsg.data) {
rsp->nasMsg.length = bytes; rsp->nasMsg.length = bytes;
...@@ -618,7 +618,7 @@ static int _process_ul_info_transfer_req(const ul_info_transfer_req_t* req, ...@@ -618,7 +618,7 @@ static int _process_ul_info_transfer_req(const ul_info_transfer_req_t* req,
return (AS_UL_INFO_TRANSFER_CNF); return (AS_UL_INFO_TRANSFER_CNF);
} else if (bytes > 0) { } else if (bytes > 0) {
/* Some data has to be sent back to the UE */ /* Some data has to be sent back to the UE */
ind->nasMsg.data = (Byte_t*)malloc(bytes * sizeof(Byte_t)); ind->nasMsg.data = malloc(bytes * sizeof(uint8_t));
if (ind->nasMsg.data) { if (ind->nasMsg.data) {
ind->nasMsg.length = bytes; ind->nasMsg.length = bytes;
...@@ -1258,12 +1258,12 @@ static int _assign_pdn_address(int ue_pdn_type, int is_initial, int* pdn_type, O ...@@ -1258,12 +1258,12 @@ static int _assign_pdn_address(int ue_pdn_type, int is_initial, int* pdn_type, O
U8 cause = [04] - NET_ESTABLISH_CAUSE_MO_SIGNAL U8 cause = [04] - NET_ESTABLISH_CAUSE_MO_SIGNAL
U8 type = [10] - NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL U8 type = [10] - NET_ESTABLISH_TYPE_ORIGINATING_SIGNAL
plmn_t plmnID = [20 8f 10] plmn_t plmnID = [20 8f 10]
Byte_t MCCdigit2:4 = [0] uint8_t MCCdigit2:4 = [0]
Byte_t MCCdigit1:4 = [2] uint8_t MCCdigit1:4 = [2]
Byte_t MNCdigit3:4 = [f] uint8_t MNCdigit3:4 = [f]
Byte_t MCCdigit3:4 = [8] uint8_t MCCdigit3:4 = [8]
Byte_t MNCdigit2:4 = [0] uint8_t MNCdigit2:4 = [0]
Byte_t MNCdigit1:4 = [1] uint8_t MNCdigit1:4 = [1]
as_stmsi_t s_tmsi as_stmsi_t s_tmsi
U8 MMEcode = [0f] U8 MMEcode = [0f]
U32 m_tmsi = [00 00 00 01] U32 m_tmsi = [00 00 00 01]
......
...@@ -73,7 +73,12 @@ Description Implements the API used by the NAS layer to read/write ...@@ -73,7 +73,12 @@ Description Implements the API used by the NAS layer to read/write
* USIM TLV parameter structure * USIM TLV parameter structure
* ---------------------------- * ----------------------------
*/ */
#define USIM_TLV_T(SIZE) struct {uint8_t type; uint8_t length; Byte_t value[SIZE];} #define USIM_TLV_T(SIZE) \
struct { \
uint8_t type; \
uint8_t length; \
uint8_t value[SIZE]; \
}
/* /*
* Non Access Stratum Configuration * Non Access Stratum Configuration
...@@ -116,13 +121,13 @@ typedef struct { ...@@ -116,13 +121,13 @@ typedef struct {
#define USIM_KSI_MIN 0b000 #define USIM_KSI_MIN 0b000
#define USIM_KSI_MAX 0b110 #define USIM_KSI_MAX 0b110
#define USIM_KSI_NOT_AVAILABLE 0b111 #define USIM_KSI_NOT_AVAILABLE 0b111
Byte_t ksi; uint8_t ksi;
/* Cyphering key */ /* Cyphering key */
#define USIM_CK_SIZE 16 #define USIM_CK_SIZE 16
Byte_t ck[USIM_CK_SIZE]; uint8_t ck[USIM_CK_SIZE];
/* Integrity key */ /* Integrity key */
#define USIM_IK_SIZE 16 #define USIM_IK_SIZE 16
Byte_t ik[USIM_IK_SIZE]; uint8_t ik[USIM_IK_SIZE];
uint8_t usim_api_k[USIM_API_K_SIZE]; uint8_t usim_api_k[USIM_API_K_SIZE];
uint8_t opc[16]; uint8_t opc[16];
} usim_keys_t; } usim_keys_t;
...@@ -195,10 +200,10 @@ typedef struct { ...@@ -195,10 +200,10 @@ typedef struct {
* ---------------------------- * ----------------------------
*/ */
typedef struct { typedef struct {
Byte_t length; /* Length of BCD number/SSC contents */ uint8_t length; /* Length of BCD number/SSC contents */
msisdn_t number; /* Mobile subscriber dialing number */ msisdn_t number; /* Mobile subscriber dialing number */
Byte_t conf1_record_id; /* Configuration1 Record Identifier */ uint8_t conf1_record_id; /* Configuration1 Record Identifier */
Byte_t ext1_record_id; /* Extension1 Record Identifier */ uint8_t ext1_record_id; /* Extension1 Record Identifier */
} usim_msisdn_t; } usim_msisdn_t;
/* /*
...@@ -251,12 +256,12 @@ typedef struct { ...@@ -251,12 +256,12 @@ typedef struct {
typedef struct { typedef struct {
uint32_t tmsi; /* Temporary Mobile Subscriber Identity */ uint32_t tmsi; /* Temporary Mobile Subscriber Identity */
lai_t lai; /* Location Area Identity */ lai_t lai; /* Location Area Identity */
Byte_t reserved; /* Reserved for future use */ uint8_t reserved; /* Reserved for future use */
#define USIM_LOCI_UPDATED 0x00 #define USIM_LOCI_UPDATED 0x00
#define USIM_LOCI_NOT_UPDATED 0x01 #define USIM_LOCI_NOT_UPDATED 0x01
#define USIM_LOCI_PLMN_NOT_ALLOWED 0x02 #define USIM_LOCI_PLMN_NOT_ALLOWED 0x02
#define USIM_LOCI_LA_NOT_ALLOWED 0x03 #define USIM_LOCI_LA_NOT_ALLOWED 0x03
Byte_t status; /* Location update status */ uint8_t status; /* Location update status */
} usim_loci_t; } usim_loci_t;
/* /*
...@@ -265,13 +270,13 @@ typedef struct { ...@@ -265,13 +270,13 @@ typedef struct {
*/ */
typedef struct { typedef struct {
uint32_t p_tmsi; /* Packet Temporary Mobile Subscriber Identity */ uint32_t p_tmsi; /* Packet Temporary Mobile Subscriber Identity */
Byte_t signature[3]; /* P-TMSI signature value */ uint8_t signature[3]; /* P-TMSI signature value */
RAI_t rai; /* Routing Area Identity */ RAI_t rai; /* Routing Area Identity */
#define USIM_PSLOCI_UPDATED 0x00 #define USIM_PSLOCI_UPDATED 0x00
#define USIM_PSLOCI_NOT_UPDATED 0x01 #define USIM_PSLOCI_NOT_UPDATED 0x01
#define USIM_PSLOCI_PLMN_NOT_ALLOWED 0x02 #define USIM_PSLOCI_PLMN_NOT_ALLOWED 0x02
#define USIM_PSLOCI_LA_NOT_ALLOWED 0x03 #define USIM_PSLOCI_LA_NOT_ALLOWED 0x03
Byte_t status; /* Routing Area update status */ uint8_t status; /* Routing Area update status */
} usim_psloci_t; } usim_psloci_t;
/* /*
...@@ -284,7 +289,7 @@ typedef struct { ...@@ -284,7 +289,7 @@ typedef struct {
#define USIM_EPSLOCI_UPDATED 0x00 #define USIM_EPSLOCI_UPDATED 0x00
#define USIM_EPSLOCI_NOT_UPDATED 0x01 #define USIM_EPSLOCI_NOT_UPDATED 0x01
#define USIM_EPSLOCI_ROAMING_NOT_ALLOWED 0x02 #define USIM_EPSLOCI_ROAMING_NOT_ALLOWED 0x02
Byte_t status; /* EPS update status */ uint8_t status; /* EPS update status */
} usim_epsloci_t; } usim_epsloci_t;
/* /*
...@@ -308,11 +313,11 @@ typedef struct { ...@@ -308,11 +313,11 @@ typedef struct {
#define USIM_TYPE_APPROVAL_SPECIFIC_MODE 0x81U #define USIM_TYPE_APPROVAL_SPECIFIC_MODE 0x81U
#define USIM_MAINTENANCE_MODE 0x02U #define USIM_MAINTENANCE_MODE 0x02U
#define USIM_CELL_TEST_MODE 0x04U #define USIM_CELL_TEST_MODE 0x04U
Byte_t UE_Operation_Mode; /* Mode of operation for the UE */ uint8_t UE_Operation_Mode; /* Mode of operation for the UE */
uint16_t Additional_Info; /* Additional information depending on uint16_t Additional_Info; /* Additional information depending on
* the UE operation mode */ * the UE operation mode */
Byte_t MNC_Length; /* Number of digits used for extracting uint8_t MNC_Length; /* Number of digits used for extracting
* the MNC from the IMSI */ * the MNC from the IMSI */
} usim_ad_t; } usim_ad_t;
/* /*
...@@ -328,7 +333,7 @@ typedef struct { ...@@ -328,7 +333,7 @@ typedef struct {
*/ */
imsi_t imsi; /* International Mobile Subscriber Identity */ imsi_t imsi; /* International Mobile Subscriber Identity */
usim_keys_t keys; /* Ciphering and Integrity Keys */ usim_keys_t keys; /* Ciphering and Integrity Keys */
Byte_t hpplmn; /* Higher Priority PLMN search period */ uint8_t hpplmn; /* Higher Priority PLMN search period */
#define USIM_FPLMN_MAX 4 #define USIM_FPLMN_MAX 4
plmn_t fplmn[USIM_FPLMN_MAX]; /* List of Forbidden PLMNs */ plmn_t fplmn[USIM_FPLMN_MAX]; /* List of Forbidden PLMNs */
usim_loci_t loci; /* Location Information */ usim_loci_t loci; /* Location Information */
......
...@@ -837,7 +837,7 @@ _emm_as_encode( ...@@ -837,7 +837,7 @@ _emm_as_encode(
} }
/* Allocate memory to the NAS information container */ /* Allocate memory to the NAS information container */
info->nas_data = malloc(length * sizeof(Byte_t)); info->nas_data = malloc(length * sizeof(uint8_t));
if (info->nas_data != NULL) { if (info->nas_data != NULL) {
/* Encode the NAS message */ /* Encode the NAS message */
...@@ -889,7 +889,7 @@ _emm_as_encrypt( ...@@ -889,7 +889,7 @@ _emm_as_encrypt(
} }
/* Allocate memory to the NAS information container */ /* Allocate memory to the NAS information container */
info->nas_data = malloc(length * sizeof(Byte_t)); info->nas_data = malloc(length * sizeof(uint8_t));
if (info->nas_data != NULL) { if (info->nas_data != NULL) {
/* Encrypt the NAS information message */ /* Encrypt the NAS information message */
......
...@@ -229,7 +229,7 @@ typedef struct emm_as_cell_info_s { ...@@ -229,7 +229,7 @@ typedef struct emm_as_cell_info_s {
#define EMM_AS_PLMN_LIST_SIZE 6 #define EMM_AS_PLMN_LIST_SIZE 6
PLMN_LIST_T(EMM_AS_PLMN_LIST_SIZE) plmnIDs; PLMN_LIST_T(EMM_AS_PLMN_LIST_SIZE) plmnIDs;
/* List of identifiers of available PLMNs */ /* List of identifiers of available PLMNs */
Byte_t rat; /* Bitmap of Radio Access Technologies */ uint8_t rat; /* Bitmap of Radio Access Technologies */
tac_t tac; /* Tracking Area Code */ tac_t tac; /* Tracking Area Code */
ci_t cellID; /* cell identity */ ci_t cellID; /* cell identity */
} emm_as_cell_info_t; } emm_as_cell_info_t;
......
...@@ -345,12 +345,12 @@ typedef struct emm_data_s { ...@@ -345,12 +345,12 @@ typedef struct emm_data_s {
* ---------------------------- * ----------------------------
* see "Non Access Stratum Configuration" in USIM API header file * see "Non Access Stratum Configuration" in USIM API header file
*/ */
Byte_t NAS_SignallingPriority; uint8_t NAS_SignallingPriority;
Byte_t NMO_I_Behaviour; uint8_t NMO_I_Behaviour;
Byte_t AttachWithImsi; uint8_t AttachWithImsi;
Byte_t MinimumPeriodicSearchTimer; uint8_t MinimumPeriodicSearchTimer;
Byte_t ExtendedAccessBarring; uint8_t ExtendedAccessBarring;
Byte_t Timer_T3245_Behaviour; uint8_t Timer_T3245_Behaviour;
/* /*
* EMM data stored in the UE's memory * EMM data stored in the UE's memory
......
...@@ -96,14 +96,16 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i ...@@ -96,14 +96,16 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i
} }
#endif #endif
int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id) { int nas_itti_kenb_refresh_req(const uint8_t kenb[32], int user_id)
{
MessageDef *message_p; MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_KENB_REFRESH_REQ); message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_KENB_REFRESH_REQ);
memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kenb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb)); memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kenb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb));
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p); return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p);
} }
int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id) { int nas_itti_cell_info_req(const plmn_t plmnID, const uint8_t rat, int user_id)
{
MessageDef *message_p; MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_CELL_SELECTION_REQ); message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_CELL_SELECTION_REQ);
NAS_CELL_SELECTION_REQ(message_p).plmnID = plmnID; NAS_CELL_SELECTION_REQ(message_p).plmnID = plmnID;
...@@ -111,7 +113,14 @@ int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id) { ...@@ -111,7 +113,14 @@ int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id) {
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p); return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + user_id, message_p);
} }
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data, uint32_t length, int user_id) { int nas_itti_nas_establish_req(as_cause_t cause,
as_call_type_t type,
as_stmsi_t s_tmsi,
plmn_t plmnID,
uint8_t *data,
uint32_t length,
int user_id)
{
MessageDef *message_p; MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_CONN_ESTABLI_REQ); message_p = itti_alloc_new_message(TASK_NAS_UE, 0, NAS_CONN_ESTABLI_REQ);
NAS_CONN_ESTABLI_REQ(message_p).cause = cause; NAS_CONN_ESTABLI_REQ(message_p).cause = cause;
......
...@@ -47,11 +47,17 @@ int nas_itti_protected_msg( ...@@ -47,11 +47,17 @@ int nas_itti_protected_msg(
# if defined(NAS_BUILT_IN_UE) # if defined(NAS_BUILT_IN_UE)
int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id); int nas_itti_kenb_refresh_req(const uint8_t kenb[32], int user_id);
int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id); int nas_itti_cell_info_req(const plmn_t plmnID, const uint8_t rat, int user_id);
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data_pP, uint32_t lengthP, int user_id); int nas_itti_nas_establish_req(as_cause_t cause,
as_call_type_t type,
as_stmsi_t s_tmsi,
plmn_t plmnID,
uint8_t *data_pP,
uint32_t lengthP,
int user_id);
int nas_itti_ul_data_req(const uint32_t ue_idP, void *const data_pP, const uint32_t lengthP, int user_id); int nas_itti_ul_data_req(const uint32_t ue_idP, void *const data_pP, const uint32_t lengthP, int user_id);
......
...@@ -311,11 +311,11 @@ int nas_proc_get_msisdn(nas_user_t *user, char *msisdn_str, int *ton_npi) ...@@ -311,11 +311,11 @@ int nas_proc_get_msisdn(nas_user_t *user, char *msisdn_str, int *ton_npi)
if (msisdn != NULL) { if (msisdn != NULL) {
union { union {
struct { struct {
Byte_t ext:1; uint8_t ext: 1;
Byte_t ton:3; uint8_t ton: 3;
Byte_t npi:4; uint8_t npi: 4;
} ext_ton_npi; } ext_ton_npi;
Byte_t type; uint8_t type;
} converter; } converter;
converter.ext_ton_npi.ext = msisdn->ext; converter.ext_ton_npi.ext = msisdn->ext;
converter.ext_ton_npi.ton = msisdn->ton; converter.ext_ton_npi.ton = msisdn->ton;
...@@ -1058,7 +1058,7 @@ int nas_proc_cell_info(nas_user_t *user, int found, tac_t tac, ci_t ci, AcT_t Ac ...@@ -1058,7 +1058,7 @@ int nas_proc_cell_info(nas_user_t *user, int found, tac_t tac, ci_t ci, AcT_t Ac
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_establish_cnf(nas_user_t *user, const Byte_t *data, uint32_t len) int nas_proc_establish_cnf(nas_user_t *user, const uint8_t *data, uint32_t len)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1236,7 +1236,7 @@ int nas_proc_ul_transfer_rej(nas_user_t *user) ...@@ -1236,7 +1236,7 @@ int nas_proc_ul_transfer_rej(nas_user_t *user)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_dl_transfer_ind(nas_user_t *user, const Byte_t *data, uint32_t len) int nas_proc_dl_transfer_ind(nas_user_t *user, const uint8_t *data, uint32_t len)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
......
...@@ -113,15 +113,13 @@ int nas_proc_activate_pdn(nas_user_t *user, int cid); ...@@ -113,15 +113,13 @@ int nas_proc_activate_pdn(nas_user_t *user, int cid);
*/ */
int nas_proc_cell_info(nas_user_t *user, int found, tac_t tac, ci_t ci, AcT_t AcT, uint8_t rsrq, uint8_t rsrp); int nas_proc_cell_info(nas_user_t *user, int found, tac_t tac, ci_t ci, AcT_t AcT, uint8_t rsrq, uint8_t rsrp);
int nas_proc_establish_cnf(nas_user_t *user, const Byte_t *data, uint32_t len); int nas_proc_establish_cnf(nas_user_t *user, const uint8_t *data, uint32_t len);
int nas_proc_establish_rej(nas_user_t *user); int nas_proc_establish_rej(nas_user_t *user);
int nas_proc_release_ind(nas_user_t *user, int cause); int nas_proc_release_ind(nas_user_t *user, int cause);
int nas_proc_ul_transfer_cnf(nas_user_t *user); int nas_proc_ul_transfer_cnf(nas_user_t *user);
int nas_proc_ul_transfer_rej(nas_user_t *user); int nas_proc_ul_transfer_rej(nas_user_t *user);
int nas_proc_dl_transfer_ind(nas_user_t *user, const Byte_t *data, uint32_t len); int nas_proc_dl_transfer_ind(nas_user_t *user, const uint8_t *data, uint32_t len);
#endif /* __NAS_PROC_H__*/ #endif /* __NAS_PROC_H__*/
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