merge develop,fix basic sim and warnings

This commit is contained in:
laurent
2020-03-04 13:32:03 +01:00
108 changed files with 2470 additions and 4075 deletions
+4 -117
View File
@@ -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 */
+1 -1
View File
@@ -107,7 +107,7 @@ void* socket_udp_open(int type, const char* host, const char* port)
{
struct addrinfo socket_info; /* endpoint information */
struct addrinfo *socket_addr, *sp; /* endpoint address */
int sfd; /* socket file descriptor */
int sfd=-1; /* socket file descriptor */
/*
* Parameters sanity check
+1 -1
View File
@@ -80,7 +80,6 @@ bool parse_plmn_param(config_setting_t *plmn_setting, plmn_conf_param_t *conf) {
bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) {
config_setting_t *plmn_setting = NULL;
char plmn[10];
int size = 0;
size = config_setting_length(all_plmn_setting);
@@ -93,6 +92,7 @@ bool parse_plmns(config_setting_t *all_plmn_setting, networks_t *networks) {
for (int i = 0; i < networks->size; i++) {
network_t *network = &networks->items[i];
char plmn[100];
sprintf(plmn, "%s%d", PLMN, i);
plmn_setting = config_setting_get_member(all_plmn_setting, plmn);
if (plmn_setting == NULL) {
+1 -1
View File
@@ -13,7 +13,6 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
config_setting_t *root_setting = NULL;
config_setting_t *ue_setting = NULL;
config_setting_t *all_plmn_setting = NULL;
char user[10];
config_t cfg;
networks_t networks;;
@@ -47,6 +46,7 @@ bool parse_config_file(const char *output_dir, const char *conf_filename, int ou
user_plmns_t user_plmns;
char user[100];
sprintf(user, "%s%d", UE, i);
ue_setting = config_setting_get_member(root_setting, user);
-2
View File
@@ -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 ****************/
-2
View File
@@ -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
-2
View File
@@ -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_ */