Commit 6195a197 authored by Lionel Gauthier's avatar Lionel Gauthier

OK for start of MME_GW and HSS on same host

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7113 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent ff98e6ea
......@@ -4,14 +4,15 @@ CCC=gcc
linux := $(shell if [ `uname` = "Linux" ] ; then echo "1" ; else echo "0" ; fi)
#CFLAGS += -std=gnu99
CFLAGS += -Wall -g -ggdb -Wstrict-prototypes -fno-strict-aliasing -rdynamic
CFLAGS += -std=gnu99
#CFLAGS += -Wall -g -ggdb -Wstrict-prototypes -fno-strict-aliasing
# Need to force this option because default kernel module builder is wrong
CFLAGS += $(call cc-option,-mpreferred-stack-boundary=4)
#For performance, if some option doesn't exist in all gcc versions, use $(call cc-option,MY_OPTION)
CFLAGS += -O2 -funroll-loops
CFLAGS += -O2
CFLAGS += -funroll-loops
CFLAGS += -Wno-packed-bitfield-compat
# This is the minimum CPU faetures for OAI
......@@ -46,7 +47,7 @@ HASHTABLE_DIR = $(COMMON_UTILS_DIR)/collection/hashtable
HASHTABLE_OBJS = $(HASHTABLE_DIR)/hashtable.o
HASHTABLE_OBJS += $(HASHTABLE_DIR)/obj_hashtable.o
UTILS_OBJS = $(ITTI_OBJS) $(HASHTABLE_OBJS)
UTILS_OBJS = $(ITTI_OBJS) $(HASHTABLE_OBJS) $(COMMON_UTILS_DIR)/backtrace.o
UTILS_incl = \
-I$(COMMON_UTILS_DIR) \
......
......@@ -27,49 +27,9 @@
*******************************************************************************/
#ifndef ASSERTIONS_H_
#define ASSERTIONS_H_
#ifndef UTILS_ASSERTIONS_H_
#define UTILS_ASSERTIONS_H_
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "./itti/assertions.h"
#define _Assert_Exit_ \
{ \
fprintf(stderr, "\nExiting execution\n"); \
fflush(stdout); \
fflush(stderr); \
abort(); \
}
#define _Assert_(cOND, aCTION, fORMAT, aRGS...) \
do { \
if (!(cOND)) { \
fprintf(stderr, "\nAssertion ("#cOND") failed!\n" \
"In %s() %s:%d\n" fORMAT, \
__FUNCTION__, __FILE__, __LINE__, ##aRGS); \
aCTION; \
} \
} while(0)
#define AssertFatal(cOND, fORMAT, aRGS...) _Assert_(cOND, _Assert_Exit_, fORMAT, ##aRGS)
#define AssertError(cOND, aCTION, fORMAT, aRGS...) _Assert_(cOND, aCTION, fORMAT, ##aRGS)
#define DevCheck(cOND, vALUE1, vALUE2, vALUE3) \
_Assert_(cOND, _Assert_Exit_, #vALUE1": %"PRIdMAX"\n"#vALUE2": %"PRIdMAX"\n"#vALUE3": %"PRIdMAX"\n\n", \
(intmax_t)vALUE1, (intmax_t)vALUE2, (intmax_t)vALUE3)
#define DevCheck4(cOND, vALUE1, vALUE2, vALUE3, vALUE4) \
_Assert_(cOND, _Assert_Exit_, #vALUE1": %"PRIdMAX"\n"#vALUE2": %"PRIdMAX"\n"#vALUE3": %"PRIdMAX"\n"#vALUE4": %"PRIdMAX"\n\n", \
(intmax_t)vALUE1, (intmax_t)vALUE2, (intmax_t)vALUE3, (intmax_t)vALUE4)
#define DevParam(vALUE1, vALUE2, vALUE3) DevCheck(0, vALUE1, vALUE2, vALUE3)
#define DevAssert(cOND) _Assert_(cOND, _Assert_Exit_, "")
#define DevMessage(mESSAGE) _Assert_(0, _Assert_Exit_, #mESSAGE)
#endif /* ASSERTIONS_H_ */
#endif /* UTILS_ASSERTIONS_H_ */
......@@ -30,12 +30,13 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "hashtable.h"
#include "assertions.h"
//-------------------------------------------------------------------------------------------------------------------------------
char* hashtble_rc_code2string(hashtable_rc_t rcP)
char* hashtable_rc_code2string(hashtable_rc_t rcP)
//-------------------------------------------------------------------------------------------------------------------------------
{
switch (rcP) {
......@@ -74,7 +75,7 @@ static hash_size_t def_hashfunc(const uint64_t keyP)
* The user can also specify a hash function. If the hashfunc argument is NULL, a default hash function is used.
* If an error occurred, NULL is returned. All other values in the returned hash_table_t pointer should be released with hashtable_destroy().
*/
hash_table_t *hashtable_create(hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void*))
hash_table_t *hashtable_create(const hash_size_t sizeP, hash_size_t (*hashfuncP)(const hash_key_t ), void (*freefuncP)(void*))
{
hash_table_t *hashtbl = NULL;
......@@ -102,7 +103,7 @@ hash_table_t *hashtable_create(hash_size_t sizeP, hash_size_t (*hashfuncP)(const
* Cleanup
* The hashtable_destroy() walks through the linked lists for each possible hash value, and releases the elements. It also releases the nodes array and the hash_table_t.
*/
hashtable_rc_t hashtable_destroy(hash_table_t *hashtblP)
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtblP)
{
hash_size_t n;
hash_node_t *node, *oldnode;
......@@ -127,7 +128,7 @@ hashtable_rc_t hashtable_destroy(hash_table_t *hashtblP)
return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_is_key_exists (hash_table_t *hashtblP, const hash_key_t keyP)
hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtblP, const hash_key_t keyP)
//-------------------------------------------------------------------------------------------------------------------------------
{
hash_node_t *node = NULL;
......@@ -148,7 +149,7 @@ hashtable_rc_t hashtable_is_key_exists (hash_table_t *hashtblP, const hash_key_t
return HASH_TABLE_KEY_NOT_EXISTS;
}
//-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *hashtblP, void functP(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP)
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void functP(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP)
//-------------------------------------------------------------------------------------------------------------------------------
{
hash_node_t *node = NULL;
......@@ -170,12 +171,44 @@ hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *hashtblP, void f
}
return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP )
//-------------------------------------------------------------------------------------------------------------------------------
{
hash_node_t *node = NULL;
unsigned int i = 0;
unsigned int num_elements = 0;
if (hashtblP == NULL) {
*remaining_bytes_in_buffer_pP = snprintf(
buffer_pP,
*remaining_bytes_in_buffer_pP,
"HASH_TABLE_BAD_PARAMETER_HASHTABLE");
return HASH_TABLE_BAD_PARAMETER_HASHTABLE;
}
while ((i < hashtblP->size) && (*remaining_bytes_in_buffer_pP > 0)) {
if (hashtblP->nodes[i] != NULL) {
node=hashtblP->nodes[i];
while(node) {
*remaining_bytes_in_buffer_pP = snprintf(
buffer_pP,
*remaining_bytes_in_buffer_pP,
"Key 0x%"PRIx64" Element %p\n",
node->key,
node->data);
node=node->next;
}
}
i += 1;
}
return HASH_TABLE_OK;
}
//-------------------------------------------------------------------------------------------------------------------------------
/*
* Adding a new element
* To make sure the hash value is not bigger than size, the result of the user provided hash function is used modulo size.
*/
hashtable_rc_t hashtable_insert(hash_table_t *hashtblP, const hash_key_t keyP, void *dataP)
hashtable_rc_t hashtable_insert(hash_table_t * const hashtblP, const hash_key_t keyP, void *dataP)
{
hash_node_t *node = NULL;
hash_size_t hash = 0;
......@@ -212,7 +245,7 @@ hashtable_rc_t hashtable_insert(hash_table_t *hashtblP, const hash_key_t keyP, v
* To remove an element from the hash table, we just search for it in the linked list for that hash value,
* and remove it if it is found. If it was not found, it is an error and -1 is returned.
*/
hashtable_rc_t hashtable_remove(hash_table_t *hashtblP, const hash_key_t keyP)
hashtable_rc_t hashtable_remove(hash_table_t * const hashtblP, const hash_key_t keyP)
{
hash_node_t *node, *prevnode=NULL;
hash_size_t hash = 0;
......@@ -243,7 +276,7 @@ hashtable_rc_t hashtable_remove(hash_table_t *hashtblP, const hash_key_t keyP)
* Searching for an element is easy. We just search through the linked list for the corresponding hash value.
* NULL is returned if we didn't find it.
*/
hashtable_rc_t hashtable_get(hash_table_t *hashtblP, const hash_key_t keyP, void** dataP)
hashtable_rc_t hashtable_get(const hash_table_t * const hashtblP, const hash_key_t keyP, void** dataP)
{
hash_node_t *node = NULL;
hash_size_t hash = 0;
......@@ -279,7 +312,7 @@ hashtable_rc_t hashtable_get(hash_table_t *hashtblP, const hash_key_t keyP, void
* After that, we can just free the old table and copy the elements from newtbl to hashtbl.
*/
hashtable_rc_t hashtable_resize(hash_table_t *hashtblP, hash_size_t sizeP)
hashtable_rc_t hashtable_resize(hash_table_t * const hashtblP, const hash_size_t sizeP)
{
hash_table_t newtbl;
hash_size_t n;
......
......@@ -37,7 +37,7 @@
typedef size_t hash_size_t;
typedef uint64_t hash_key_t;
#define HASHTABLE_QUESTIONABLE_KEY_VALUE ((uint64_t)-1)
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
typedef enum hashtable_return_code_e {
HASH_TABLE_OK = 0,
......@@ -64,16 +64,17 @@ typedef struct hash_table_s {
void (*freefunc)(void*);
} hash_table_t;
char* hashtble_rc_code2string(hashtable_rc_t rcP);
char* hashtable_rc_code2string(hashtable_rc_t rcP);
void hash_free_int_func(void* memoryP);
hash_table_t *hashtable_create (hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*));
hashtable_rc_t hashtable_destroy(hash_table_t *hashtbl);
hashtable_rc_t hashtable_is_key_exists (hash_table_t *hashtbl, const uint64_t key);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP);
hashtable_rc_t hashtable_insert (hash_table_t *hashtbl, const hash_key_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t *hashtbl, const hash_key_t key);
hashtable_rc_t hashtable_get (hash_table_t *hashtbl, const hash_key_t key, void **dataP);
hashtable_rc_t hashtable_resize (hash_table_t *hashtbl, hash_size_t size);
hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*));
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl);
hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtbl, const uint64_t key);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t * const hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP);
hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP );
hashtable_rc_t hashtable_insert (hash_table_t * const hashtbl, const hash_key_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t * const hashtbl, const hash_key_t key);
hashtable_rc_t hashtable_get (const hash_table_t * const hashtbl, const hash_key_t key, void **dataP);
hashtable_rc_t hashtable_resize (hash_table_t * const hashtbl, const hash_size_t size);
......
This diff is collapsed.
......@@ -31,6 +31,13 @@
#define MSC_H_
#include <stdarg.h>
typedef enum {
MSC_E_UTRAN = 0,
MSC_EPC,
MAX_MSC_ENV
} msc_env_t;
typedef enum {
MIN_MSC_PROTOS = 0,
MSC_NAS_UE = MIN_MSC_PROTOS,
......@@ -48,12 +55,17 @@ typedef enum {
MSC_GTPU_ENB,
MSC_GTPU_SGW,
MSC_S1AP_MME,
MSC_MMEAPP_MME,
MSC_NAS_MME,
MSC_NAS_EMM_MME,
MSC_NAS_ESM_MME,
MSC_S6A_MME,
MSC_HSS,
MAX_MSC_PROTOS,
} msc_proto_t;
// Access stratum
#define MSC_AS_TIME_FMT "%05u:%02u"
......@@ -61,7 +73,7 @@ typedef enum {
(CTXT_Pp)->frame, \
(CTXT_Pp)->subframe
int msc_init(void);
int msc_init(msc_env_t envP);
void msc_end(void);
void msc_log_declare_proto(const msc_proto_t protoP);
void msc_log_event(const msc_proto_t protoP,char *format, ...);
......
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