Commit ee82aed1 authored by Frédéric Leroy's avatar Frédéric Leroy

UE: move _nas_proc_data to nas_user_t struct

parent 2ee6ae11
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "nas_user.h" #include "nas_user.h"
#include "nas_network.h" #include "nas_network.h"
#include "nas_parser.h" #include "nas_parser.h"
#include "user_defs.h"
#include <stdlib.h> // exit #include <stdlib.h> // exit
#include <poll.h> // poll #include <poll.h> // poll
...@@ -72,6 +73,8 @@ static void _nas_signal_handler(int signal); ...@@ -72,6 +73,8 @@ static void _nas_signal_handler(int signal);
static void _nas_clean(int usr_fd, int net_fd); static void _nas_clean(int usr_fd, int net_fd);
uint8_t usim_test = 0; uint8_t usim_test = 0;
// FIXME user must be set up with right itti message instance
nas_user_t *user = NULL;
/****************************************************************************/ /****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/ /****************** E X P O R T E D F U N C T I O N S ******************/
...@@ -129,7 +132,7 @@ int main(int argc, const char *argv[]) ...@@ -129,7 +132,7 @@ int main(int argc, const char *argv[])
/* /*
* Initialize the NAS contexts * Initialize the NAS contexts
*/ */
nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, nas_user_initialize (user, &user_api_emm_callback, &user_api_esm_callback,
FIRMWARE_VERSION); FIRMWARE_VERSION);
nas_network_initialize (); nas_network_initialize ();
...@@ -226,7 +229,7 @@ static void *_nas_user_mngr(void *args) ...@@ -226,7 +229,7 @@ static void *_nas_user_mngr(void *args)
/* User receiving loop */ /* User receiving loop */
while (!exit_loop) { while (!exit_loop) {
exit_loop = nas_user_receive_and_process(fd, NULL); exit_loop = nas_user_receive_and_process(user, NULL);
} }
/* Close the connection to the user application layer */ /* Close the connection to the user application layer */
...@@ -291,7 +294,7 @@ static void *_nas_network_mngr(void *args) ...@@ -291,7 +294,7 @@ static void *_nas_network_mngr(void *args)
} }
/* Process the network data message */ /* Process the network data message */
ret_code = nas_network_process_data (network_message_id, ret_code = nas_network_process_data (user, network_message_id,
network_api_get_data ()); network_api_get_data ());
if (ret_code != RETURNok) { if (ret_code != RETURNok) {
......
...@@ -43,6 +43,7 @@ Description NAS procedure functions triggered by the network ...@@ -43,6 +43,7 @@ Description NAS procedure functions triggered by the network
#include "as_message.h" #include "as_message.h"
#include "nas_proc.h" #include "nas_proc.h"
#include "user_defs.h"
/****************************************************************************/ /****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/ /**************** E X T E R N A L D E F I N I T I O N S ****************/
...@@ -118,7 +119,7 @@ void nas_network_cleanup(void) ...@@ -118,7 +119,7 @@ void nas_network_cleanup(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_network_process_data(int msg_id, const void *data) int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -142,7 +143,7 @@ int nas_network_process_data(int msg_id, const void *data) ...@@ -142,7 +143,7 @@ int nas_network_process_data(int msg_id, const void *data)
/* Received cell information confirm */ /* Received cell information confirm */
const cell_info_cnf_t *info = &msg->msg.cell_info_cnf; const cell_info_cnf_t *info = &msg->msg.cell_info_cnf;
int cell_found = (info->errCode == AS_SUCCESS); int cell_found = (info->errCode == AS_SUCCESS);
rc = nas_proc_cell_info(cell_found, info->tac, rc = nas_proc_cell_info(user, cell_found, info->tac,
info->cellID, info->rat, info->cellID, info->rat,
info->rsrp, info->rsrq); info->rsrp, info->rsrq);
break; break;
......
...@@ -40,6 +40,8 @@ Description NAS procedure functions triggered by the network ...@@ -40,6 +40,8 @@ Description NAS procedure functions triggered by the network
#ifndef __NAS_NETWORK_H__ #ifndef __NAS_NETWORK_H__
#define __NAS_NETWORK_H__ #define __NAS_NETWORK_H__
#include "user_defs.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/ /****************************************************************************/
...@@ -61,7 +63,7 @@ void nas_network_initialize(void); ...@@ -61,7 +63,7 @@ void nas_network_initialize(void);
void nas_network_cleanup(void); void nas_network_cleanup(void);
int nas_network_process_data(int command_id, const void *data); int nas_network_process_data(nas_user_t *user, int command_id, const void *data);
const void *nas_network_get_data(void); const void *nas_network_get_data(void);
......
...@@ -38,6 +38,7 @@ Description NAS procedure call manager ...@@ -38,6 +38,7 @@ Description NAS procedure call manager
#include "nas_proc.h" #include "nas_proc.h"
#include "nas_log.h" #include "nas_log.h"
#include "nas_user.h"
#include "emm_main.h" #include "emm_main.h"
#include "emm_sap.h" #include "emm_sap.h"
...@@ -62,17 +63,6 @@ Description NAS procedure call manager ...@@ -62,17 +63,6 @@ Description NAS procedure call manager
#define NAS_PROC_RSRQ_UNKNOWN 255 #define NAS_PROC_RSRQ_UNKNOWN 255
#define NAS_PROC_RSRP_UNKNOWN 255 #define NAS_PROC_RSRP_UNKNOWN 255
/*
* Local NAS data
*/
static struct {
/* EPS capibility status */
int EPS_capability_status;
/* Reference signal received quality */
int rsrq;
/* Reference signal received power */
int rsrp;
} _nas_proc_data;
static int _nas_proc_activate(int cid, int apply_to_all); static int _nas_proc_activate(int cid, int apply_to_all);
static int _nas_proc_deactivate(int cid, int apply_to_all); static int _nas_proc_deactivate(int cid, int apply_to_all);
...@@ -97,15 +87,15 @@ static int _nas_proc_deactivate(int cid, int apply_to_all); ...@@ -97,15 +87,15 @@ static int _nas_proc_deactivate(int cid, int apply_to_all);
** Others: _nas_proc_data ** ** Others: _nas_proc_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
void nas_proc_initialize(emm_indication_callback_t emm_cb, void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char *imei) esm_indication_callback_t esm_cb, const char *imei)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
/* Initialize local NAS data */ /* Initialize local NAS data */
_nas_proc_data.EPS_capability_status = FALSE; user->proc.EPS_capability_status = FALSE;
_nas_proc_data.rsrq = NAS_PROC_RSRQ_UNKNOWN; user->proc.rsrq = NAS_PROC_RSRQ_UNKNOWN;
_nas_proc_data.rsrp = NAS_PROC_RSRP_UNKNOWN; user->proc.rsrp = NAS_PROC_RSRP_UNKNOWN;
/* Initialize the EMM procedure manager */ /* Initialize the EMM procedure manager */
emm_main_initialize(emm_cb, imei); emm_main_initialize(emm_cb, imei);
...@@ -131,7 +121,7 @@ void nas_proc_initialize(emm_indication_callback_t emm_cb, ...@@ -131,7 +121,7 @@ void nas_proc_initialize(emm_indication_callback_t emm_cb,
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
void nas_proc_cleanup(void) void nas_proc_cleanup()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -172,7 +162,7 @@ void nas_proc_cleanup(void) ...@@ -172,7 +162,7 @@ void nas_proc_cleanup(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_enable_s1_mode(void) int nas_proc_enable_s1_mode(nas_user_t *user)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -183,7 +173,7 @@ int nas_proc_enable_s1_mode(void) ...@@ -183,7 +173,7 @@ int nas_proc_enable_s1_mode(void)
* Notify the EMM procedure call manager that EPS capability * Notify the EMM procedure call manager that EPS capability
* of the UE is enabled * of the UE is enabled
*/ */
_nas_proc_data.EPS_capability_status = TRUE; user->proc.EPS_capability_status = TRUE;
emm_sap.primitive = EMMREG_S1_ENABLED; emm_sap.primitive = EMMREG_S1_ENABLED;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
...@@ -205,7 +195,7 @@ int nas_proc_enable_s1_mode(void) ...@@ -205,7 +195,7 @@ int nas_proc_enable_s1_mode(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_disable_s1_mode(void) int nas_proc_disable_s1_mode(nas_user_t *user)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -216,7 +206,7 @@ int nas_proc_disable_s1_mode(void) ...@@ -216,7 +206,7 @@ int nas_proc_disable_s1_mode(void)
* Notify the EMM procedure call manager that EPS capability * Notify the EMM procedure call manager that EPS capability
* of the UE is disabled * of the UE is disabled
*/ */
_nas_proc_data.EPS_capability_status = FALSE; user->proc.EPS_capability_status = FALSE;
emm_sap.primitive = EMMREG_S1_DISABLED; emm_sap.primitive = EMMREG_S1_DISABLED;
rc = emm_sap_send(&emm_sap); rc = emm_sap_send(&emm_sap);
...@@ -238,11 +228,11 @@ int nas_proc_disable_s1_mode(void) ...@@ -238,11 +228,11 @@ int nas_proc_disable_s1_mode(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_get_eps(int *stat) int nas_proc_get_eps(nas_user_t *user, int *stat)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
*stat = _nas_proc_data.EPS_capability_status; *stat = user->proc.EPS_capability_status;
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -358,12 +348,12 @@ int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi) ...@@ -358,12 +348,12 @@ int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_get_signal_quality(int *rsrq, int *rsrp) int nas_proc_get_signal_quality(nas_user_t *user, int *rsrq, int *rsrp)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
*rsrq = _nas_proc_data.rsrq; *rsrq = user->proc.rsrq;
*rsrp = _nas_proc_data.rsrp; *rsrp = user->proc.rsrp;
LOG_FUNC_RETURN (RETURNok); LOG_FUNC_RETURN (RETURNok);
} }
...@@ -426,7 +416,7 @@ int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT) ...@@ -426,7 +416,7 @@ int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_deregister(void) int nas_proc_deregister()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -604,7 +594,7 @@ int nas_proc_detach(int switch_off) ...@@ -604,7 +594,7 @@ int nas_proc_detach(int switch_off)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_attach(void) int nas_proc_attach()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -636,7 +626,7 @@ int nas_proc_attach(void) ...@@ -636,7 +626,7 @@ int nas_proc_attach(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_get_attach_status(void) int nas_proc_get_attach_status()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -659,7 +649,7 @@ int nas_proc_get_attach_status(void) ...@@ -659,7 +649,7 @@ int nas_proc_get_attach_status(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_get_pdn_range(void) int nas_proc_get_pdn_range()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1021,7 +1011,7 @@ int nas_proc_activate_pdn(int cid) ...@@ -1021,7 +1011,7 @@ int nas_proc_activate_pdn(int cid)
** Others: _nas_proc_data ** ** Others: _nas_proc_data **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT, 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) uint8_t rsrq, uint8_t rsrp)
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1030,8 +1020,8 @@ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT, ...@@ -1030,8 +1020,8 @@ int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t AcT,
int rc; int rc;
/* Store LTE signal strength/quality measurement data */ /* Store LTE signal strength/quality measurement data */
_nas_proc_data.rsrq = rsrq; user->proc.rsrq = rsrq;
_nas_proc_data.rsrp = rsrp; user->proc.rsrp = rsrp;
/* /*
* Notify the EMM procedure call manager that cell information * Notify the EMM procedure call manager that cell information
...@@ -1103,7 +1093,7 @@ int nas_proc_establish_cnf(const Byte_t *data, uint32_t len) ...@@ -1103,7 +1093,7 @@ int nas_proc_establish_cnf(const Byte_t *data, uint32_t len)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_establish_rej(void) int nas_proc_establish_rej()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1170,7 +1160,7 @@ int nas_proc_release_ind(int cause) ...@@ -1170,7 +1160,7 @@ int nas_proc_release_ind(int cause)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_ul_transfer_cnf(void) int nas_proc_ul_transfer_cnf()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
...@@ -1207,7 +1197,7 @@ int nas_proc_ul_transfer_cnf(void) ...@@ -1207,7 +1197,7 @@ int nas_proc_ul_transfer_cnf(void)
** Others: None ** ** Others: None **
** ** ** **
***************************************************************************/ ***************************************************************************/
int nas_proc_ul_transfer_rej(void) int nas_proc_ul_transfer_rej()
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
......
...@@ -40,6 +40,7 @@ Description NAS procedure call manager ...@@ -40,6 +40,7 @@ Description NAS procedure call manager
#include "commonDef.h" #include "commonDef.h"
#include "networkDef.h" #include "networkDef.h"
#include "user_defs.h"
#include "emm_main.h" #include "emm_main.h"
#include "esm_ebr.h" #include "esm_ebr.h"
...@@ -59,7 +60,7 @@ Description NAS procedure call manager ...@@ -59,7 +60,7 @@ Description NAS procedure call manager
/****************** E X P O R T E D F U N C T I O N S ******************/ /****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/ /****************************************************************************/
void nas_proc_initialize(emm_indication_callback_t emm_cb, void nas_proc_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char *imei); esm_indication_callback_t esm_cb, const char *imei);
void nas_proc_cleanup(void); void nas_proc_cleanup(void);
...@@ -70,14 +71,14 @@ void nas_proc_cleanup(void); ...@@ -70,14 +71,14 @@ void nas_proc_cleanup(void);
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
int nas_proc_enable_s1_mode(void); int nas_proc_enable_s1_mode(nas_user_t *user);
int nas_proc_disable_s1_mode(void); int nas_proc_disable_s1_mode(nas_user_t *user);
int nas_proc_get_eps(int *stat); int nas_proc_get_eps(nas_user_t *user, int *stat);
int nas_proc_get_imsi(char *imsi_str); int nas_proc_get_imsi(char *imsi_str);
int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi); int nas_proc_get_msisdn(char *msisdn_str, int *ton_npi);
int nas_proc_get_signal_quality(int *rsrq, int *rsrp); int nas_proc_get_signal_quality(nas_user_t *user, int *rsrq, int *rsrp);
int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT); int nas_proc_register(int mode, int format, const network_plmn_t *oper, int AcT);
int nas_proc_deregister(void); int nas_proc_deregister(void);
...@@ -110,7 +111,7 @@ int nas_proc_activate_pdn(int cid); ...@@ -110,7 +111,7 @@ int nas_proc_activate_pdn(int cid);
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
int nas_proc_cell_info(int found, tac_t tac, ci_t ci, AcT_t rat, uint8_t rsrp, int nas_proc_cell_info(nas_user_t *user, int found, tac_t tac, ci_t ci, AcT_t rat, uint8_t rsrp,
uint8_t rsrq); uint8_t rsrq);
int nas_proc_establish_cnf(const Byte_t *data, uint32_t len); int nas_proc_establish_cnf(const Byte_t *data, uint32_t len);
......
#ifndef _NAS_PROC_DEFS_H
#define _NAS_PROC_DEFS_H
/*
* Local NAS data
*/
typedef struct {
/* EPS capibility status */
int EPS_capability_status;
/* Reference signal received quality */
int rsrq;
/* Reference signal received power */
int rsrp;
} proc_data_t;
#endif
...@@ -49,7 +49,7 @@ static int nas_ue_process_events(nas_user_t *user, struct epoll_event *events, i ...@@ -49,7 +49,7 @@ static int nas_ue_process_events(nas_user_t *user, struct epoll_event *events, i
if (events[event].events != 0) { if (events[event].events != 0) {
/* If the event has not been yet been processed (not an itti message) */ /* If the event has not been yet been processed (not an itti message) */
if (events[event].data.fd == user->fd) { if (events[event].data.fd == user->fd) {
exit_loop = nas_user_receive_and_process(&user->fd, NULL); exit_loop = nas_user_receive_and_process(user, NULL);
} else { } else {
LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd); LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd);
} }
...@@ -89,7 +89,7 @@ void *nas_ue_task(void *args_p) ...@@ -89,7 +89,7 @@ void *nas_ue_task(void *args_p)
} }
/* Initialize NAS user */ /* Initialize NAS user */
nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); nas_user_initialize (user, &user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION);
} }
/* Set UE activation state */ /* Set UE activation state */
...@@ -117,7 +117,7 @@ void *nas_ue_task(void *args_p) ...@@ -117,7 +117,7 @@ void *nas_ue_task(void *args_p)
/* Send an activate modem command to NAS like UserProcess should do it */ /* Send an activate modem command to NAS like UserProcess should do it */
char *user_data = "at+cfun=1\r"; char *user_data = "at+cfun=1\r";
nas_user_receive_and_process (&user->fd, user_data); nas_user_receive_and_process (user, user_data);
} }
#endif #endif
break; break;
...@@ -137,7 +137,7 @@ void *nas_ue_task(void *args_p) ...@@ -137,7 +137,7 @@ void *nas_ue_task(void *args_p)
{ {
int cell_found = (NAS_CELL_SELECTION_CNF (msg_p).errCode == AS_SUCCESS); int cell_found = (NAS_CELL_SELECTION_CNF (msg_p).errCode == AS_SUCCESS);
nas_proc_cell_info (cell_found, NAS_CELL_SELECTION_CNF (msg_p).tac, nas_proc_cell_info (user, cell_found, NAS_CELL_SELECTION_CNF (msg_p).tac,
NAS_CELL_SELECTION_CNF (msg_p).cellID, NAS_CELL_SELECTION_CNF (msg_p).rat, NAS_CELL_SELECTION_CNF (msg_p).cellID, NAS_CELL_SELECTION_CNF (msg_p).rat,
NAS_CELL_SELECTION_CNF (msg_p).rsrq, NAS_CELL_SELECTION_CNF (msg_p).rsrp); NAS_CELL_SELECTION_CNF (msg_p).rsrq, NAS_CELL_SELECTION_CNF (msg_p).rsrp);
} }
......
This diff is collapsed.
...@@ -42,6 +42,7 @@ Description NAS procedure functions triggered by the user ...@@ -42,6 +42,7 @@ Description NAS procedure functions triggered by the user
#include "networkDef.h" #include "networkDef.h"
#include "emm_main.h" #include "emm_main.h"
#include "esm_ebr.h" #include "esm_ebr.h"
#include "user_defs.h"
/****************************************************************************/ /****************************************************************************/
/********************* G L O B A L C O N S T A N T S *******************/ /********************* G L O B A L C O N S T A N T S *******************/
...@@ -59,12 +60,12 @@ Description NAS procedure functions triggered by the user ...@@ -59,12 +60,12 @@ Description NAS procedure functions triggered by the user
/****************** E X P O R T E D F U N C T I O N S ******************/ /****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/ /****************************************************************************/
void nas_user_initialize(emm_indication_callback_t emm_cb, void nas_user_initialize(nas_user_t *user, emm_indication_callback_t emm_cb,
esm_indication_callback_t esm_cb, const char *version); esm_indication_callback_t esm_cb, const char *version);
int nas_user_receive_and_process(int * fd, char *message); int nas_user_receive_and_process(nas_user_t *user, char *message);
int nas_user_process_data(const void *data); int nas_user_process_data(nas_user_t *user, const void *data);
const void *nas_user_get_data(void); const void *nas_user_get_data(void);
......
...@@ -45,7 +45,11 @@ Description NAS type definition to manage a user equipment ...@@ -45,7 +45,11 @@ Description NAS type definition to manage a user equipment
#ifndef __USER_DEFS_H__ #ifndef __USER_DEFS_H__
#define __USER_DEFS_H__ #define __USER_DEFS_H__
#include "nas_proc_defs.h"
typedef struct { typedef struct {
int fd;
proc_data_t proc;
} nas_user_t; } nas_user_t;
#endif #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