Commit 8b022848 authored by Sakthivel Velumani's avatar Sakthivel Velumani

Enable AT command interface and link to NAS layer

1. Add AT command handlers to set and activate PDP context.
2. Changes to NAS for sending multiple PDU session request.
3. Provide command line option to enable AT command interface.
parent e33c7d26
......@@ -217,6 +217,9 @@ int create_tasks_nrue(uint32_t ue_nb) {
if (itti_create_task(TASK_NAS_NRUE, nas_nrue_task, &parmsNAS) < 0) {
LOG_E(NR_RRC, "Create task for NAS UE failed\n");
return -1;
} else {
if (get_nrUE_params()->enable_AT)
nas_nrue_user((void *)&parmsNAS);
}
}
......
......@@ -12,6 +12,12 @@
#define CONFIG_HLP_DLSCH_PARA "number of threads for dlsch processing 0 for no parallelization\n"
#define CONFIG_HLP_OFFSET_DIV "Divisor for computing OFDM symbol offset in Rx chain (num samples in CP/<the value>). Default value is 8. To set the sample offset to 0, set this value ~ 10e6\n"
#define CONFIG_HLP_MAX_LDPC_ITERATIONS "Maximum LDPC decoder iterations\n"
#define CONFIG_HLP_AT_IF \
"Name of the virtual serial interface to be used by UE process (used along with --AT). Use 'socat' utility to connect two " \
"virtual serial ports and " \
"access the AT command interface. One interface (given here) will be used by the UE process and other interface can be " \
"accessed via minicom or screen.\n"
#define CONFIG_HLP_AT "Enable AT-command interface\n"
/***************************************************************************************************************************************/
/* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument
when calling config_get or config_getlist functions */
......@@ -61,6 +67,8 @@
{"chest-time", CONFIG_HLP_CHESTTIME, 0, .iptr=&(nrUE_params.chest_time), .defintval=0, TYPE_INT, 0}, \
{"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, .iptr=&(nrUE_params.no_timing_correction), .defintval=0, TYPE_INT, 0}, \
{"SLC", CONFIG_HLP_SLF, 0, .u64ptr=&(sidelink_frequency[0][0]), .defuintval=2600000000,TYPE_UINT64,0}, \
{"AT", CONFIG_HLP_AT, PARAMFLAG_BOOL, .iptr=&(nrUE_params.enable_AT), .defintval=0, TYPE_INT, 0}, \
{"AT-interface", CONFIG_HLP_AT_IF, 0, .strptr=&(nrUE_params.at_interface_name), .defstrval="/dev/pts/7", TYPE_STRING, 0}, \
}
// clang-format on
......@@ -80,6 +88,8 @@ typedef struct {
int nb_antennas_tx;
int N_RB_DL;
int ssb_start_subcarrier;
int enable_AT;
char *at_interface_name;
} nrUE_params_t;
extern uint64_t get_nrUE_optmask(void);
extern uint64_t set_nrUE_optmask(uint64_t bitmask);
......
......@@ -464,13 +464,6 @@ typedef ul_info_transfer_cnf_t dl_info_transfer_cnf_t;
*/
typedef ul_info_transfer_ind_t dl_info_transfer_ind_t;
typedef struct nas_pdu_session_req_s {
int pdusession_id;
int pdusession_type;
int sst;
int sd;
} nas_pdu_session_req_t;
typedef struct nas_nos1_msg_s {
rnti_t rnti;
} nas_nos1_msg_t;
......@@ -552,6 +545,18 @@ typedef struct rab_release_ind_s {
as_rab_id_t rabID; /* Radio access bearer identity */
} rab_release_ind_t;
/* PDP context stored in UE */
typedef struct nr_nas_pdp_context_s {
int pdu_session_id;
int pdu_session_type;
char dnn[64];
char nssaiStr[64];
int nssai_sst;
int nssai_sd;
bool is_active;
bool is_defined;
} nr_nas_pdp_context_t;
/*
* --------------------------------------------------------------------------
* Structure of the AS messages handled by the network sublayer
......
......@@ -84,6 +84,6 @@ MESSAGE_DEF(NRRRC_FRAME_PROCESS, MESSAGE_PRIORITY_MED, NRRrcFramePr
// eNB: RLC -> RRC messages
MESSAGE_DEF(RLC_SDU_INDICATION, MESSAGE_PRIORITY_MED, RlcSduIndication, rlc_sdu_indication)
MESSAGE_DEF(NAS_PDU_SESSION_REQ, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_req)
MESSAGE_DEF(NAS_PDU_SESSION_REQ, MESSAGE_PRIORITY_MED, nr_nas_pdp_context_t, nas_pdu_session_req)
MESSAGE_DEF(NAS_INIT_NOS1_IF, MESSAGE_PRIORITY_MED, nas_nos1_msg_t, nas_init_nos1_if)
MESSAGE_DEF(NAS_PDU_SESSION_REL, MESSAGE_PRIORITY_MED, nas_pdu_session_req_t, nas_pdu_session_rel)
MESSAGE_DEF(NAS_PDU_SESSION_REL, MESSAGE_PRIORITY_MED, nr_nas_pdp_context_t, nas_pdu_session_rel)
......@@ -27,19 +27,19 @@
extern char *baseNetAddress;
static uint16_t getShort(uint8_t *input)
static uint16_t getShort(const uint8_t *input)
{
uint16_t tmp16;
memcpy(&tmp16, input, sizeof(tmp16));
return htons(tmp16);
}
void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length)
void capture_pdu_session_establishment_accept_msg(const uint8_t *buffer, uint32_t msg_length, int *pdu_id)
{
security_protected_nas_5gs_msg_t sec_nas_hdr;
security_protected_plain_nas_5gs_msg_t sec_nas_msg;
pdu_session_establishment_accept_msg_t psea_msg;
uint8_t *curPtr = buffer;
const uint8_t *curPtr = buffer;
sec_nas_hdr.epd = *curPtr++;
sec_nas_hdr.sht = *curPtr++;
uint32_t tmp;
......@@ -56,6 +56,7 @@ void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_
/* Mandatory Presence IEs */
psea_msg.epd = *curPtr++;
psea_msg.pdu_id = *curPtr++;
*pdu_id = psea_msg.pdu_id;
psea_msg.pti = *curPtr++;
psea_msg.msg_type = *curPtr++;
psea_msg.pdu_type = *curPtr & 0x0f;
......
......@@ -166,6 +166,6 @@ typedef struct security_protected_nas_5gs_msg_s {
uint8_t sqn; /* Sequence Number */
} security_protected_nas_5gs_msg_t; /* 24.501 Figure 9.1.1.2 */
void capture_pdu_session_establishment_accept_msg(uint8_t *buffer, uint32_t msg_length);
void capture_pdu_session_establishment_accept_msg(const uint8_t *buffer, uint32_t msg_length, int *pdu_id);
#endif
This diff is collapsed.
......@@ -42,6 +42,9 @@
#include "FGSUplinkNasTransport.h"
#include <openair3/UICC/usim_interface.h>
#include "secu_defs.h"
#include <openair3/NAS/UE/API/USER/user_api_defs.h>
#include "openair3/NAS/UE/API/USER/at_response.h"
#include "openair3/NAS/UE/user_defs.h"
#define PLAIN_5GS_MSG 0b0000
#define INTEGRITY_PROTECTED 0b0001
......@@ -108,6 +111,8 @@ typedef struct {
stream_security_container_t *security_container;
Guti5GSMobileIdentity_t *guti;
bool termination_procedure;
nr_nas_msg_snssai_t nas_allowed_nssai[8];
nas_user_t *nas_user;
} nr_ue_nas_t;
typedef enum fgs_protocol_discriminator_e {
......@@ -194,6 +199,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg, nr_ue_nas_t *nas)
void *nas_nrue_task(void *args_p);
void *nas_nrue(void *args_p);
void nr_ue_create_ip_if(const char *ifname, int ue_id, int pdu_session_id, bool ipv6, const uint8_t addr[IPV4V6_ADDR_LEN]);
void nas_nrue_user(void *args_p);
#endif /* __NR_NAS_MSG_SIM_H__*/
......
......@@ -55,8 +55,8 @@ Description Defines the ATtention (AT) command set supported by the NAS
/****************************************************************************/
// FIXME Put this in .h
extern int at_response_format_v1;
extern int at_error_code_suppression_q1;
extern bool at_response_format_v1;
extern bool at_error_code_suppression_q1;
extern at_error_format_t at_error_format;
/****************************************************************************/
......@@ -1512,7 +1512,11 @@ static int parse_cereg_test(const char* string, int position, at_command_t* at_c
static int parse_cgdcont_set(const char* string, int position, at_command_t* at_command)
{
/* CGDCONT parameter command - Parameters [<cid>[,<PDP_type>[,<APN>[,<PDP_addr>[,<d_comp>[,<h_comp>[,<IPv4AddrAlloc>[,<emergency indication>[,<P-CSCF_discovery>[,<IM_CN_Signalling_Flag_Ind>]]]]]]]]]] */
/* CGDCONT parameter command - Parameters [<cid>[,<PDP_type>[,<APN>[,<PDP_addr>[,<d_comp>[,<h_comp>
[,<IPv4AddrAlloc>[,<request_type>[,<P-CSCF_discovery>[,<IM_CN_Signalling_Flag_Ind>[,<NSLPI>[,<securePCO>
[,<IPv4_MTU_discovery>[,<Local_Addr_Ind>[,<Non-IP_MTU_discovery>[,<Reliable_Data_Service>[,<SSC_mode>
[,<S-NSSAI>[,<Pref_access_type>]]]]]]]]]]]]]]]]]]]
*/
at_command->id = AT_CGDCONT;
unsigned char* parameter_start_index = (unsigned char*) string + position;
......@@ -1752,6 +1756,80 @@ static int parse_cgdcont_set(const char* string, int position, at_command_t* at_
AT_CGDCONT_EMERGECY_INDICATION_MASK | AT_CGDCONT_P_CSCF_DISCOVERY_MASK | AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK;
break;
case 19: /* <cid>,<PDP_type>,<APN>,<PDP_addr>,<d_comp>,<h_comp>
,<IPv4AddrAlloc>,<request_type>,<P-CSCF_discovery>,<IM_CN_Signalling_Flag_Ind>,<NSLPI>,<securePCO>
,<IPv4_MTU_discovery>,<Local_Addr_Ind>,<Non-IP_MTU_discovery>,<Reliable_Data_Service>,<SSC_mode>
,<S-NSSAI>,<Pref_access_type> are present */
if (ParseCommand(parameter_start_index,
"@i,@r,@r,@r,@I,@I,@I,@I,@I,@I,@I,@I,@I,@I,@I,@I,@I,@r,@I",
&at_command->command.cgdcont.cid,
&at_command->command.cgdcont.PDP_type,
AT_CGDCONT_PDP_SIZE,
&at_command->command.cgdcont.APN,
AT_CGDCONT_APN_SIZE,
&at_command->command.cgdcont.PDP_addr,
AT_CGDCONT_ADDR_SIZE,
&at_command->command.cgdcont.d_comp,
&at_command->command.cgdcont.h_comp,
&at_command->command.cgdcont.IPv4AddrAlloc,
&at_command->command.cgdcont.emergency_indication,
&at_command->command.cgdcont.P_CSCF_discovery,
&at_command->command.cgdcont.IM_CN_Signalling_Flag_Ind,
&at_command->command.cgdcont.nspli,
&at_command->command.cgdcont.secure_PCO,
&at_command->command.cgdcont.IPv4_MTU_discovery,
&at_command->command.cgdcont.Local_Addr_Ind,
&at_command->command.cgdcont.Non_IP_MTU_discovery,
&at_command->command.cgdcont.Reliable_Data_Service,
&at_command->command.cgdcont.SSC_mode,
&at_command->command.cgdcont.nssaiStr,
AT_CGDCONT_NSSAI_SIZE,
&at_command->command.cgdcont.Pref_access_type)
!= RETURNok) {
LOG_TRACE(ERROR,
"USR-API - Parsing of "
"AT+CGDCONT=<cid>,<PDP_type>,<APN>,<PDP_addr>,<d_comp>,<h_comp>,<IPv4AddrAlloc>,<request_type>,<P-CSCF_discovery>,<"
"IM_CN_Signalling_Flag_Ind>,<NSLPI>,<securePCO>,<IPv4_MTU_discovery>,<Local_Addr_Ind>,<Non-IP_MTU_discovery>,<"
"Reliable_Data_Service>,<SSC_mode>,<S-NSSAI>,<Pref_access_type> failed\n");
return RETURNerror;
}
LOG_TRACE(INFO,
"USR-API - Parsing of "
"AT+CGDCONT=<cid>,<PDP_type>,<APN>,<PDP_addr>,<d_comp>,<h_comp>,<IPv4AddrAlloc>,<request_type>,<P-CSCF_discovery>,<"
"IM_CN_Signalling_Flag_Ind>,<NSLPI>,<securePCO>,<IPv4_MTU_discovery>,<Local_Addr_Ind>,<Non-IP_MTU_discovery>,<"
"Reliable_Data_Service>,<SSC_mode>,<S-NSSAI>,<Pref_access_type> succeeded (cid:%d, PDP_type:%s ,APN:%s, PDP_addr:%s, "
"d_comp:%d, h_comp:%d, IPv4AddrAlloc:%d, request_type:%d, P-CSCF_discovery:%d, IM_CN_Signalling_Flag_Ind:%d, "
"NSLPI:%d, securePCO:%d, IPv4_MTU_discovery:%d, Local_Addr_Ind:%d, Non-IP_MTU_discovery:%d, "
"Reliable_Data_Service:%d, SSC_mode:%d, S-NSSAI:%s, Pref_access_type:%d)",
at_command->command.cgdcont.cid,
at_command->command.cgdcont.PDP_type,
at_command->command.cgdcont.APN,
at_command->command.cgdcont.PDP_addr,
at_command->command.cgdcont.d_comp,
at_command->command.cgdcont.h_comp,
at_command->command.cgdcont.IPv4AddrAlloc,
at_command->command.cgdcont.emergency_indication,
at_command->command.cgdcont.P_CSCF_discovery,
at_command->command.cgdcont.IM_CN_Signalling_Flag_Ind,
at_command->command.cgdcont.nspli,
at_command->command.cgdcont.secure_PCO,
at_command->command.cgdcont.IPv4_MTU_discovery,
at_command->command.cgdcont.Local_Addr_Ind,
at_command->command.cgdcont.Non_IP_MTU_discovery,
at_command->command.cgdcont.Reliable_Data_Service,
at_command->command.cgdcont.SSC_mode,
at_command->command.cgdcont.nssaiStr,
at_command->command.cgdcont.Pref_access_type);
at_command->mask = AT_CGDCONT_CID_MASK | AT_CGDCONT_PDP_TYPE_MASK | AT_CGDCONT_APN_MASK | AT_CGDCONT_PDP_ADDR_MASK
| AT_CGDCONT_D_COMP_MASK | AT_CGDCONT_H_COMP_MASK | AT_CGDCONT_IPV4ADDRALLOC_MASK
| AT_CGDCONT_EMERGECY_INDICATION_MASK | AT_CGDCONT_P_CSCF_DISCOVERY_MASK
| AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK | AT_CGDCONT_NSPLI | AT_CGDCONT_SECURE_PCO
| AT_CGDCONT_IPV4_MTU_DIS | AT_CGDCONT_LOCAL_ADDR_IND | AT_CGDCONT_NON_IP_MTU_DIS
| AT_CGDCONT_REL_DATA_SERVICE | AT_CGDCONT_SSC_MODE | AT_CGDCONT_NSSAI | AT_CGDCONT_PREF_ACCESS_TYPE;
break;
default:
LOG_TRACE(ERROR, "USR-API - Invalid number of parameters (%d)", number_of_parameters);
return RETURNerror;
......
......@@ -65,6 +65,9 @@ Description Defines the ATtention (AT) command set supported by the NAS
#define AT_COMMAND_PARAM14 0x2000 /* 14th parameter is present */
#define AT_COMMAND_PARAM15 0x4000 /* 15th parameter is present */
#define AT_COMMAND_PARAM16 0x8000 /* 16th parameter is present */
#define AT_COMMAND_PARAM17 0x10000 /* 17th parameter is present */
#define AT_COMMAND_PARAM18 0x20000 /* 18th parameter is present */
#define AT_COMMAND_PARAM19 0x40000 /* 19th parameter is present */
/* Value of the mask parameter for AT commands without any parameters */
#define AT_COMMAND_NO_PARAM AT_COMMAND_PARAM0
......@@ -737,6 +740,15 @@ typedef struct {
#define AT_CGDCONT_EMERGECY_INDICATION_MASK AT_COMMAND_PARAM8
#define AT_CGDCONT_P_CSCF_DISCOVERY_MASK AT_COMMAND_PARAM9
#define AT_CGDCONT_IM_CN_SIGNALLING_FLAG_IND_MASK AT_COMMAND_PARAM10
#define AT_CGDCONT_NSPLI AT_COMMAND_PARAM11
#define AT_CGDCONT_SECURE_PCO AT_COMMAND_PARAM12
#define AT_CGDCONT_IPV4_MTU_DIS AT_COMMAND_PARAM13
#define AT_CGDCONT_LOCAL_ADDR_IND AT_COMMAND_PARAM14
#define AT_CGDCONT_NON_IP_MTU_DIS AT_COMMAND_PARAM15
#define AT_CGDCONT_REL_DATA_SERVICE AT_COMMAND_PARAM16
#define AT_CGDCONT_SSC_MODE AT_COMMAND_PARAM17
#define AT_CGDCONT_NSSAI AT_COMMAND_PARAM18
#define AT_CGDCONT_PREF_ACCESS_TYPE AT_COMMAND_PARAM19
/* CGDCONT AT command type */
typedef struct {
......@@ -754,6 +766,16 @@ typedef struct {
int emergency_indication;
int P_CSCF_discovery;
int IM_CN_Signalling_Flag_Ind;
int nspli;
int secure_PCO;
int IPv4_MTU_discovery;
int Local_Addr_Ind;
int Non_IP_MTU_discovery;
int Reliable_Data_Service;
int SSC_mode;
#define AT_CGDCONT_NSSAI_SIZE 16
char nssaiStr[AT_CGDCONT_NSSAI_SIZE];
int Pref_access_type;
} at_cgdcont_t;
/* CGACT: PDP context activate or deactivate
......
......@@ -50,7 +50,7 @@ Description Defines error codes returned when execution of AT command
/****************************************************************************/
// FIXME put this in .h
extern int at_response_format_v1;
extern bool at_response_format_v1;
/*
* Result code suppression indicator (set by ATQ0 and ATQ1)
......
......@@ -951,8 +951,13 @@ static int _at_response_encode_cgdcont(char* buffer, const at_response_t* data)
offset += sprintf(buffer+offset, ",%s", cgdcont->APN[i]);
/* No data/header compression */
offset += sprintf(buffer+offset, ",%u,%u\r\n",
(unsigned int)(AT_CGDCONT_D_COMP_OFF), (unsigned int)(AT_CGDCONT_H_COMP_OFF));
offset +=
sprintf(buffer + offset, ",%u,%u", (unsigned int)(AT_CGDCONT_D_COMP_OFF), (unsigned int)(AT_CGDCONT_H_COMP_OFF));
offset += sprintf(buffer + offset, ",,,,,,,,,,,"); /* Currently unused parameters */
/* NSSAI */
offset += sprintf(buffer + offset, ",%s", cgdcont->nssaiStr[i]);
/* Preferred access type */
offset += sprintf(buffer + offset, ",\r\n");
}
} else if (data->type == AT_COMMAND_TST) {
const at_cgdcont_tst_t * cgdcont = &(data->response.cgdcont.tst);
......
......@@ -641,6 +641,19 @@ typedef struct {
const char* APN[AT_CGDCONT_RESP_SIZE];
int d_comp[AT_CGDCONT_RESP_SIZE];
int h_comp[AT_CGDCONT_RESP_SIZE];
int IPv4AddrAlloc[AT_CGDCONT_RESP_SIZE];
int emergency_indication[AT_CGDCONT_RESP_SIZE];
int P_CSCF_discovery[AT_CGDCONT_RESP_SIZE];
int IM_CN_Signalling_Flag_Ind[AT_CGDCONT_RESP_SIZE];
int nspli[AT_CGDCONT_RESP_SIZE];
int secure_PCO[AT_CGDCONT_RESP_SIZE];
int IPv4_MTU_discovery[AT_CGDCONT_RESP_SIZE];
int Local_Addr_Ind[AT_CGDCONT_RESP_SIZE];
int Non_IP_MTU_discovery[AT_CGDCONT_RESP_SIZE];
int Reliable_Data_Service[AT_CGDCONT_RESP_SIZE];
int SSC_mode[AT_CGDCONT_RESP_SIZE];
const char* nssaiStr[AT_CGDCONT_RESP_SIZE];
int Pref_access_type[AT_CGDCONT_RESP_SIZE];
} at_cgdcont_get_t;
/* Structure of CGDCONT AT read parameter command */
......
......@@ -106,6 +106,15 @@ void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
/* Initialize the ESM procedure manager */
esm_main_initialize(user, esm_cb);
AssertFatal(user->nas_ue_type != UE_NR, "Wrong UE type\n");
user->nas_reset_pdn = nas_proc_reset_pdn;
user->nas_set_pdn = nas_proc_set_pdn;
user->nas_get_pdn = nas_proc_get_pdn_param;
user->nas_get_pdn_range = nas_proc_get_pdn_range;
user->nas_deactivate_pdn = nas_proc_deactivate_pdn;
user->nas_activate_pdn = nas_proc_activate_pdn;
user->nas_get_pdn_status = nas_proc_get_pdn_status;
LOG_FUNC_OUT;
}
......@@ -652,11 +661,11 @@ bool nas_proc_get_attach_status(nas_user_t *user)
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_range(esm_data_t *esm_data)
int nas_proc_get_pdn_range(nas_user_t *user)
{
LOG_FUNC_IN;
int max_pdn_id = esm_main_get_nb_pdns_max(esm_data);
int max_pdn_id = esm_main_get_nb_pdns_max(user->esm_data);
LOG_FUNC_RETURN (max_pdn_id);
}
......@@ -721,13 +730,13 @@ int nas_proc_get_pdn_status(nas_user_t *user, int *cids, int *states, int n_pdn_
** Others: None **
** **
***************************************************************************/
int nas_proc_get_pdn_param(esm_data_t *esm_data, int *cids, int *types, const char **apns,
int n_pdn_max)
int nas_proc_get_pdn_param(nas_user_t *user, int *cids, int *types, const char **apns, const char **nssai, int n_pdn_max)
{
LOG_FUNC_IN;
int cid;
int n_defined_pdn = 0;
esm_data_t *esm_data = user->esm_data;
/* Get the maximum number of supported PDN contexts */
int n_pdn = esm_main_get_nb_pdns_max(esm_data);
......@@ -836,9 +845,20 @@ int nas_proc_get_pdn_addr(nas_user_t *user, int cid, int *cids, const char **add
** Others: None **
** **
***************************************************************************/
int nas_proc_set_pdn(nas_user_t *user, int cid, int type, const char *apn, int ipv4_addr,
int emergency, int p_cscf, int im_cn_signal)
int nas_proc_set_pdn(nas_user_t *user,
int cid,
int type,
const char *apn,
int ipv4_addr,
int emergency,
int p_cscf,
int im_cn_signal,
const char *nssai)
{
if (user->nas_ue_type != UE_LTE || nssai != NULL) {
LOG_TRACE(ERROR, "NSSAI is an unvalid parameter for LTE\n");
return RETURNerror;
}
LOG_FUNC_IN;
int rc;
......
......@@ -95,12 +95,18 @@ int nas_proc_attach(nas_user_t *user);
bool nas_proc_get_attach_status(nas_user_t *user);
int nas_proc_reset_pdn(nas_user_t *user, int cid);
int nas_proc_set_pdn(nas_user_t *user, int cid, int type, const char *apn, int ipv4_addr,
int emergency, int p_cscf, int im_cn_signal);
int nas_proc_get_pdn_range(esm_data_t *esm_data);
int nas_proc_set_pdn(nas_user_t *user,
int cid,
int type,
const char *apn,
int ipv4_addr,
int emergency,
int p_cscf,
int im_cn_signal,
const char *nssai);
int nas_proc_get_pdn_range(nas_user_t *user);
int nas_proc_get_pdn_status(nas_user_t *user, int *cids, int *states, int n_pdn_max);
int nas_proc_get_pdn_param(esm_data_t *esm_data, int *cids, int *types, const char **apns,
int n_pdn_max);
int nas_proc_get_pdn_param(nas_user_t *user, int *cids, int *types, const char **apns, const char **nssai, int n_pdn_max);
int nas_proc_get_pdn_addr(nas_user_t *user, int cid, int *cids, const char **addr1,
const char **addr2, int n_addr_max);
int nas_proc_deactivate_pdn(nas_user_t *user, int cid);
......
......@@ -134,6 +134,7 @@ void *nas_ue_task(void *args_p)
user->at_response = calloc_or_fail(1, sizeof(at_response_t));
user->lowerlayer_data = calloc_or_fail(1, sizeof(lowerlayer_data_t));
/* Initialize NAS user */
user->nas_ue_type = UE_LTE;
nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION);
}
}
......@@ -174,6 +175,7 @@ void *nas_ue_task(void *args_p)
user->at_response = calloc_or_fail(1, sizeof(at_response_t));
user->lowerlayer_data = calloc_or_fail(1, sizeof(lowerlayer_data_t));
/* Initialize NAS user */
user->nas_ue_type = UE_LTE;
nas_user_initialize(user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION);
user->ueid = 0;
}
......
......@@ -53,6 +53,8 @@ Description NAS procedure functions triggered by the user
#include <string.h> // memset, strncpy, strncmp
#include <stdlib.h> // free
#include "openair3/NAS/NR_UE/nr_nas_msg_sim.h"
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
/****************************************************************************/
......@@ -128,7 +130,8 @@ static const char *const _nas_user_sim_status_str[] = {"READY", "SIM PIN", "SIM
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
void _nas_user_context_initialize(nas_user_context_t *nas_user_context, const char *version) {
void nas_user_context_initialize(nas_user_context_t *nas_user_context, const char *version)
{
nas_user_context->version = version;
nas_user_context->sim_status = NAS_USER_SIM_PIN;
nas_user_context->fun = AT_CFUN_FUN_DEFAULT;
......@@ -164,7 +167,7 @@ void nas_user_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
}
user->nas_user_context = calloc_or_fail(1, sizeof(nas_user_context_t));
_nas_user_context_initialize(user->nas_user_context, version);
nas_user_context_initialize(user->nas_user_context, version);
/* Initialize the internal NAS processing data */
nas_proc_initialize(user, emm_cb, esm_cb, user->nas_user_nvdata->IMEI);
......@@ -201,6 +204,7 @@ bool nas_user_receive_and_process(nas_user_t *user, char *message)
} else {
/* Read the user data message */
bytes = user_api_read_data (user_api_id);
LOG_TRACE(INFO, "%d bytes read\n", bytes);
if (bytes == RETURNerror) {
/* Failed to read data from the user application layer;
......@@ -1816,6 +1820,7 @@ static int _nas_user_proc_cgdcont(nas_user_t *user, const at_command_t *data)
int emergency = AT_CGDCONT_EBS_DEFAULT;
int p_cscf = AT_CGDCONT_PCSCF_DEFAULT;
int im_cn_signalling = AT_CGDCONT_IM_CM_DEFAULT;
const char *nssai = NULL;
bool reset_pdn = true;
at_response->id = data->id;
......@@ -1967,18 +1972,20 @@ static int _nas_user_proc_cgdcont(nas_user_t *user, const at_command_t *data)
im_cn_signalling = data->command.cgdcont.IM_CN_Signalling_Flag_Ind;
}
if (data->mask & AT_CGDCONT_NSSAI) {
nssai = data->command.cgdcont.nssaiStr;
}
/*
* Setup PDN context
*/
if (reset_pdn) {
/* A special form of the set command, +CGDCONT=<cid> causes
* the values for context number <cid> to become undefined */
ret_code = nas_proc_reset_pdn(user, cid);
ret_code = user->nas_reset_pdn(user, cid);
} else {
/* Define a new PDN connection */
ret_code = nas_proc_set_pdn(user, cid, pdn_type, apn,
ipv4_addr_allocation, emergency,
p_cscf, im_cn_signalling);
ret_code = user->nas_set_pdn(user, cid, pdn_type, apn, ipv4_addr_allocation, emergency, p_cscf, im_cn_signalling, nssai);
}
if (ret_code != RETURNok) {
......@@ -1994,10 +2001,8 @@ static int _nas_user_proc_cgdcont(nas_user_t *user, const at_command_t *data)
* Read command returns the current settings for each
* defined PDN connection/default EPS bearer context
*/
cgdcont->n_pdns = nas_proc_get_pdn_param(user->esm_data, cgdcont->cid,
cgdcont->PDP_type,
cgdcont->APN,
AT_CGDCONT_RESP_SIZE);
cgdcont->n_pdns =
user->nas_get_pdn(user, cgdcont->cid, cgdcont->PDP_type, cgdcont->APN, cgdcont->nssaiStr, AT_CGDCONT_RESP_SIZE);
if (cgdcont->n_pdns == 0) {
LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined");
......@@ -2012,7 +2017,7 @@ static int _nas_user_proc_cgdcont(nas_user_t *user, const at_command_t *data)
*/
{
/* Get the maximum value of a PDN context identifier */
int cid_max = nas_proc_get_pdn_range(user->esm_data);
int cid_max = user->nas_get_pdn_range(user);
if (cid_max > AT_CGDCONT_RESP_SIZE) {
/* The range is defined by the user interface */
......@@ -2115,9 +2120,9 @@ static int _nas_user_proc_cgact(nas_user_t *user, const at_command_t *data)
ret_code = RETURNerror;
if (state == AT_CGACT_DEACTIVATED) {
ret_code = nas_proc_deactivate_pdn(user, cid);
ret_code = user->nas_deactivate_pdn(user, cid);
} else if (state == AT_CGACT_ACTIVATED) {
ret_code = nas_proc_activate_pdn(user, cid);
ret_code = user->nas_activate_pdn(user, cid);
}
if (ret_code != RETURNok) {
......@@ -2135,8 +2140,7 @@ static int _nas_user_proc_cgact(nas_user_t *user, const at_command_t *data)
* The read command returns the current activation states for
* all the defined PDN/EPS bearer contexts
*/
cgact->n_pdns = nas_proc_get_pdn_status(user, cgact->cid, cgact->state,
AT_CGACT_RESP_SIZE);
cgact->n_pdns = user->nas_get_pdn_status(user, cgact->cid, cgact->state, AT_CGACT_RESP_SIZE);
if (cgact->n_pdns == 0) {
LOG_TRACE(ERROR, "USR-MAIN - No any PDN context is defined");
......
......@@ -43,6 +43,7 @@ Description NAS procedure functions triggered by the user
#include "emm_main.h"
#include "esm_ebr.h"
#include "user_defs.h"
#include "openair3/NAS/NR_UE/nr_nas_msg_sim.h"
/****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/
......@@ -69,4 +70,6 @@ int nas_user_process_data(nas_user_t *user, const void *data);
const void *nas_user_get_data(nas_user_t *nas_user);
void nas_user_context_initialize(nas_user_context_t *nas_user_context, const char *version);
#endif /* __NAS_USER_H__*/
......@@ -51,8 +51,18 @@ Description NAS type definition to manage a user equipment
#include "SecurityModeControl.h"
#include "userDef.h"
#include "at_response.h"
#include "as_message.h"
typedef struct {
enum ue_type {
UE_LTE,
UE_NR,
};
#define MAX_PDP_CONTEXTS 8
struct nas_user_s;
typedef struct nas_user_s {
int ueid; /* UE lower layer identifier */
proc_data_t proc;
// Eps Session Management
......@@ -79,6 +89,23 @@ typedef struct {
user_at_commands_t *user_at_commands; //decoded data received from the user application layer
user_api_id_t *user_api_id;
lowerlayer_data_t *lowerlayer_data;
enum ue_type nas_ue_type;
nr_nas_pdp_context_t pdp_context[MAX_PDP_CONTEXTS];
int (*nas_reset_pdn)(struct nas_user_s *user, int cid);
int (*nas_set_pdn)(struct nas_user_s *user,
int cid,
int type,
const char *apn,
int ipv4_addr,
int emergency,
int p_cscf,
int im_cn_signal,
const char *nssai);
int (*nas_get_pdn)(struct nas_user_s *user, int *cids, int *types, const char **apns, const char **nssai, int n_pdn_max);
int (*nas_get_pdn_range)(struct nas_user_s *user);
int (*nas_deactivate_pdn)(struct nas_user_s *user, int cid);
int (*nas_activate_pdn)(struct nas_user_s *user, int cid);
int (*nas_get_pdn_status)(struct nas_user_s *user, int *cid, int *status, int n_pdn_max);
} nas_user_t;
#endif
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