Merge with branch NR_RRC_PRACH_procedures
This commit is contained in:
@@ -95,14 +95,15 @@ typedef enum {
|
||||
/****************** E X P O R T E D F U N C T I O N S ******************/
|
||||
/****************************************************************************/
|
||||
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
#ifdef LOG_E
|
||||
# define LOG_TRACE(s, x, args...) \
|
||||
do { \
|
||||
switch (s) { \
|
||||
case ERROR: LOG_E(NAS, " %s:%d " x "\n", __FILE__, __LINE__, ##args); break; \
|
||||
case WARNING: LOG_W(NAS, " %s:%d " x "\n", __FILE__, __LINE__, ##args); break; \
|
||||
case INFO: LOG_I(NAS, " %s:%d " x "\n", __FILE__, __LINE__, ##args); break; \
|
||||
default: LOG_D(NAS, " %s:%d " x "\n", __FILE__, __LINE__, ##args); break; \
|
||||
case ERROR: LOG_E(NAS, " %s:%d " x "\n", __FILENAME__, __LINE__, ##args); break; \
|
||||
case WARNING: LOG_W(NAS, " %s:%d " x "\n", __FILENAME__, __LINE__, ##args); break; \
|
||||
case INFO: LOG_I(NAS, " %s:%d " x "\n", __FILENAME__, __LINE__, ##args); break; \
|
||||
default: LOG_D(NAS, " %s:%d " x "\n", __FILENAME__, __LINE__, ##args); break; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -43,13 +43,7 @@ Description Timer utilities
|
||||
#include <string.h> // memset
|
||||
#include <stdlib.h> // malloc, free
|
||||
#include <sys/time.h> // setitimer
|
||||
|
||||
#if defined(ENABLE_ITTI)
|
||||
# include "intertask_interface.h"
|
||||
#else
|
||||
# include <signal.h>
|
||||
# include <time.h> // clock_gettime
|
||||
#endif
|
||||
#include "intertask_interface.h"
|
||||
#include "nas_timer.h"
|
||||
#include "commonDef.h"
|
||||
#include "msc.h"
|
||||
@@ -69,11 +63,7 @@ Description Timer utilities
|
||||
* value when the timer entry was allocated.
|
||||
*/
|
||||
typedef struct {
|
||||
#if defined(ENABLE_ITTI)
|
||||
long timer_id; /* Timer id returned by the timer API from ITTI */
|
||||
#else
|
||||
pthread_t pid; /* Thread identifier of the callback */
|
||||
#endif
|
||||
long timer_id; /* Timer id returned by the timer API from ITTI */
|
||||
|
||||
struct timeval itv; /* Initial interval timer value */
|
||||
struct timeval tv; /* Interval timer value */
|
||||
@@ -105,10 +95,6 @@ typedef struct {
|
||||
#define TIMER_DATABASE_SIZE 256
|
||||
timer_queue_t tq[TIMER_DATABASE_SIZE];
|
||||
timer_queue_t *head;/* Pointer to the first timer entry to be fired */
|
||||
|
||||
#if !defined(ENABLE_ITTI)
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
} nas_timer_database_t;
|
||||
|
||||
/*
|
||||
@@ -118,25 +104,15 @@ static nas_timer_database_t _nas_timer_db = {
|
||||
0,
|
||||
{},
|
||||
NULL
|
||||
#if !defined(ENABLE_ITTI)
|
||||
, PTHREAD_MUTEX_INITIALIZER
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(ENABLE_ITTI)
|
||||
#define nas_timer_lock_db()
|
||||
#define nas_timer_unlock_db()
|
||||
#else
|
||||
#define nas_timer_lock_db() pthread_mutex_lock(&_nas_timer_db.mutex)
|
||||
#define nas_timer_unlock_db() pthread_mutex_unlock(&_nas_timer_db.mutex)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The handler executed whenever the system timer expires
|
||||
*/
|
||||
#if !defined(ENABLE_ITTI)
|
||||
static void _nas_timer_handler(int signal);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
@@ -191,33 +167,6 @@ int nas_timer_init(void)
|
||||
/* Initialize the timer database */
|
||||
_nas_timer_db_init();
|
||||
|
||||
#if !defined(ENABLE_ITTI)
|
||||
/* Setup the timer database handler */
|
||||
struct sigaction act;
|
||||
|
||||
(void) memset (&act, 0, sizeof (act));
|
||||
(void) sigfillset (&act.sa_mask);
|
||||
(void) sigdelset (&act.sa_mask, SIGHUP);
|
||||
(void) sigdelset (&act.sa_mask, SIGINT);
|
||||
(void) sigdelset (&act.sa_mask, SIGTERM);
|
||||
(void) sigdelset (&act.sa_mask, SIGILL);
|
||||
(void) sigdelset (&act.sa_mask, SIGTRAP);
|
||||
(void) sigdelset (&act.sa_mask, SIGIOT);
|
||||
# ifndef LINUX
|
||||
(void) sigdelset (&act.sa_mask, SIGEMT);
|
||||
# endif
|
||||
(void) sigdelset (&act.sa_mask, SIGFPE);
|
||||
(void) sigdelset (&act.sa_mask, SIGBUS);
|
||||
(void) sigdelset (&act.sa_mask, SIGSEGV);
|
||||
(void) sigdelset (&act.sa_mask, SIGSYS);
|
||||
|
||||
act.sa_handler = _nas_timer_handler;
|
||||
|
||||
if ( sigaction (SIGALRM, &act, 0) < 0 ) {
|
||||
return (RETURNerror);
|
||||
}
|
||||
|
||||
#endif
|
||||
return (RETURNok);
|
||||
}
|
||||
|
||||
@@ -243,10 +192,8 @@ int nas_timer_start(long sec, nas_timer_callback_t cb, void *args)
|
||||
{
|
||||
int id;
|
||||
nas_timer_entry_t *te;
|
||||
#if defined(ENABLE_ITTI)
|
||||
int ret;
|
||||
long timer_id;
|
||||
#endif
|
||||
|
||||
/* Do not start null timer */
|
||||
if (sec == 0) {
|
||||
@@ -270,7 +217,6 @@ int nas_timer_start(long sec, nas_timer_callback_t cb, void *args)
|
||||
|
||||
/* Insert the new entry into the timer queue */
|
||||
_nas_timer_db_insert_entry(id, te);
|
||||
#if defined(ENABLE_ITTI)
|
||||
# if defined(NAS_MME)
|
||||
ret = timer_setup(sec, 0, TASK_NAS_MME, INSTANCE_DEFAULT, TIMER_PERIODIC, args, &timer_id);
|
||||
# else
|
||||
@@ -280,10 +226,7 @@ int nas_timer_start(long sec, nas_timer_callback_t cb, void *args)
|
||||
if (ret == -1) {
|
||||
return NAS_TIMER_INACTIVE_ID;
|
||||
}
|
||||
|
||||
te->timer_id = timer_id;
|
||||
#endif
|
||||
|
||||
return (id);
|
||||
}
|
||||
|
||||
@@ -309,11 +252,7 @@ int nas_timer_stop(int id)
|
||||
nas_timer_entry_t *entry;
|
||||
/* Remove the entry from the timer queue */
|
||||
entry = _nas_timer_db_remove_entry(id);
|
||||
#if defined(ENABLE_ITTI)
|
||||
timer_remove(entry->timer_id);
|
||||
#else
|
||||
(void)entry;
|
||||
#endif
|
||||
/* Delete the timer entry */
|
||||
_nas_timer_db_delete_entry(id);
|
||||
return (NAS_TIMER_INACTIVE_ID);
|
||||
@@ -380,7 +319,7 @@ int nas_timer_restart(int id)
|
||||
** Others: _nas_timer_db **
|
||||
** **
|
||||
***************************************************************************/
|
||||
#if defined(ENABLE_ITTI)
|
||||
|
||||
void nas_timer_handle_signal_expiry(long timer_id, void *arg_p)
|
||||
{
|
||||
/* Get the timer entry for which the system timer expired */
|
||||
@@ -388,25 +327,7 @@ void nas_timer_handle_signal_expiry(long timer_id, void *arg_p)
|
||||
|
||||
te->cb(te->args);
|
||||
}
|
||||
#else
|
||||
static void _nas_timer_handler(int signal)
|
||||
{
|
||||
/* At least one timer has been started */
|
||||
assert( (_nas_timer_db.head != NULL) && (_nas_timer_db.head->entry != NULL) );
|
||||
|
||||
/* Get the timer entry for which the system timer expired */
|
||||
nas_timer_entry_t *te = _nas_timer_db.head->entry;
|
||||
|
||||
threadCreate (&te->pid, te->cb, te->args, "nas-timer", -1, OAI_PRIORITY_RT_LOW);
|
||||
|
||||
void *result = NULL;
|
||||
(void) pthread_join(te->pid, &result);
|
||||
|
||||
if (result) {
|
||||
free(result);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
@@ -605,17 +526,7 @@ static void _nas_timer_db_insert_entry(int id, nas_timer_entry_t *te)
|
||||
restart = _nas_timer_db_insert(&_nas_timer_db.tq[id]);
|
||||
nas_timer_unlock_db();
|
||||
|
||||
#if !defined(ENABLE_ITTI)
|
||||
|
||||
if (restart) {
|
||||
/* The new entry is the first entry of the list;
|
||||
* restart the system timer */
|
||||
setitimer(ITIMER_REAL, &it, 0);
|
||||
}
|
||||
|
||||
#else
|
||||
(void)(restart);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int _nas_timer_db_insert(timer_queue_t *entry)
|
||||
@@ -704,21 +615,8 @@ static nas_timer_entry_t *_nas_timer_db_remove_entry(int id)
|
||||
tv.tv_usec = ts.tv_nsec/1000;
|
||||
/* tv = tv - time() */
|
||||
rc = _nas_timer_sub(&_nas_timer_db.head->entry->tv, &tv, &it.it_value);
|
||||
|
||||
#if defined(ENABLE_ITTI)
|
||||
timer_remove(_nas_timer_db.head->entry->timer_id);
|
||||
(void) (rc);
|
||||
#else
|
||||
|
||||
if (rc < 0) {
|
||||
/* The system timer should have already expired */
|
||||
_nas_timer_handler(SIGALRM);
|
||||
} else {
|
||||
/* Restart the system timer */
|
||||
setitimer(ITIMER_REAL, &it, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return a pointer to the removed entry */
|
||||
@@ -749,17 +647,6 @@ static int _nas_timer_db_remove(timer_queue_t *entry)
|
||||
/* Other timers are scheduled to expire */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if !defined(ENABLE_ITTI)
|
||||
{
|
||||
/* No more timer is scheduled to expire; stop the system timer */
|
||||
struct itimerval it;
|
||||
it.it_interval.tv_sec = it.it_interval.tv_usec = 0;
|
||||
it.it_value.tv_sec = it.it_value.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &it, 0);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* The entry was NOT the first entry of the list */
|
||||
|
||||
@@ -286,7 +286,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
|
||||
user->emm_data->security->selected_algorithms.encryption = seea;
|
||||
user->emm_data->security->selected_algorithms.integrity = seia;
|
||||
#if defined(NAS_BUILT_IN_UE)
|
||||
nas_itti_kenb_refresh_req(security_data->kenb.value);
|
||||
nas_itti_kenb_refresh_req(security_data->kenb.value, user->ueid);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -61,9 +61,7 @@ Description Defines the PDN connectivity ESM procedure executed by the
|
||||
|
||||
#include "emm_sap.h"
|
||||
|
||||
#if defined(ENABLE_ITTI)
|
||||
# include "assertions.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/**************** E X T E R N A L D E F I N I T I O N S ****************/
|
||||
|
||||
@@ -100,7 +100,7 @@ int nas_itti_protected_msg(const char *buffer, const nas_message_t *msg, const i
|
||||
|
||||
extern unsigned char NB_eNB_INST;
|
||||
|
||||
int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) {
|
||||
int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id) {
|
||||
MessageDef *message_p;
|
||||
message_p = itti_alloc_new_message(TASK_NAS_UE, NAS_KENB_REFRESH_REQ);
|
||||
memcpy(NAS_KENB_REFRESH_REQ(message_p).kenb, kenb, sizeof(NAS_KENB_REFRESH_REQ(message_p).kenb));
|
||||
@@ -125,7 +125,7 @@ int nas_itti_kenb_refresh_req(const Byte_t kenb[32]) {
|
||||
kenb[20], kenb[21], kenb[22], kenb[23],
|
||||
kenb[24], kenb[25], kenb[26], kenb[27],
|
||||
kenb[28], kenb[29], kenb[30], kenb[31]);
|
||||
return itti_send_msg_to_task(TASK_RRC_UE, NB_eNB_INST + 0 /* TODO to be virtualized */, 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) {
|
||||
|
||||
@@ -48,7 +48,7 @@ int nas_itti_protected_msg(
|
||||
|
||||
# if defined(NAS_BUILT_IN_UE)
|
||||
|
||||
int nas_itti_kenb_refresh_req(const Byte_t kenb[32]);
|
||||
int nas_itti_kenb_refresh_req(const Byte_t kenb[32], int user_id);
|
||||
|
||||
int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat, int user_id);
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#if defined(ENABLE_ITTI)
|
||||
# include "assertions.h"
|
||||
# include "intertask_interface.h"
|
||||
# include "nas_ue_task.h"
|
||||
@@ -301,4 +300,3 @@ char *make_port_str_from_ueid(const char *base_port_str, int ueid) {
|
||||
|
||||
return itoa(port);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,8 +33,6 @@ typedef struct {
|
||||
|
||||
nas_user_t *find_user_from_fd(nas_user_container_t *users, int fd);
|
||||
|
||||
# if defined(ENABLE_ITTI)
|
||||
void *nas_ue_task(void *args_p);
|
||||
# endif
|
||||
|
||||
#endif /* NAS_TASK_H_ */
|
||||
|
||||
Reference in New Issue
Block a user