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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
+107
-31
@@ -48,61 +48,78 @@ char msc_proto2str[MAX_MSC_PROTOS][MSC_MAX_PROTO_NAME_LENGTH];
|
||||
uint64_t msc_event_counter = 0;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int msc_init(void)
|
||||
int msc_init(msc_env_t envP)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
int i;
|
||||
int rv;
|
||||
|
||||
for (i = MIN_MSC_PROTOS; i < MAX_MSC_PROTOS; i++) {
|
||||
msc_fd[i] = NULL;
|
||||
switch (i) {
|
||||
case MSC_NAS_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.nas_ue.log","w");
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.nas_ue.log","w");
|
||||
}
|
||||
msc_log_declare_proto(i);
|
||||
break;
|
||||
case MSC_RRC_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "RRC_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rrc_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rrc_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_PDCP_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "PDCP_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.pdcp_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.pdcp_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_RLC_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "RLC_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rlc_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rlc_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_MAC_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "MAC_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.mac_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.mac_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_PHY_UE:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "PHY_UE");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.phy_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.phy_ue.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_PHY_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "PHY_ENB");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.phy_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.phy_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_MAC_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "MAC_ENB");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.mac_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.mac_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_RLC_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "RLC_ENB");
|
||||
@@ -113,14 +130,18 @@ int msc_init(void)
|
||||
case MSC_PDCP_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "PDCP_ENB");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.pdcp_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.pdcp_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_RRC_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "RRC_ENB");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rrc_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
if (envP == MSC_E_UTRAN) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.rrc_enb.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_S1AP_ENB:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_ENB");
|
||||
@@ -137,17 +158,60 @@ int msc_init(void)
|
||||
case MSC_GTPU_SGW:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "GTPU_SGW");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = NULL;
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.gtpu_sgw.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
break;
|
||||
case MSC_S1AP_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_MME");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = NULL;
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.s1ap_mme.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
break;
|
||||
case MSC_MMEAPP_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "MME_APP");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
if (envP == MSC_EPC) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.mme_app.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_NAS_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_MME");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
msc_fd[i] = NULL;
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.nas_mme.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
break;
|
||||
case MSC_NAS_EMM_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_EMM");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
if (envP == MSC_EPC) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.nas_emm_mme.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_NAS_ESM_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_ESM");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
if (envP == MSC_EPC) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.nas_esm_mme.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_S6A_MME:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S6A");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
if (envP == MSC_EPC) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.s6a_mme.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
case MSC_HSS:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_ESM");
|
||||
if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH-1] = 0;}
|
||||
if (envP == MSC_EPC) {
|
||||
msc_fd[i] = fopen("/tmp/openair.msc.hss.log","w");
|
||||
msc_log_declare_proto(i);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = snprintf(&msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "UNKNOWN");
|
||||
@@ -166,14 +230,16 @@ void msc_end(void)
|
||||
int rv;
|
||||
int i;
|
||||
for (i = MIN_MSC_PROTOS; i < MAX_MSC_PROTOS; i++) {
|
||||
rv = fflush(msc_fd[i]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno));
|
||||
}
|
||||
rv = fclose(msc_fd[i]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while closing MSC log file: %s", strerror(errno));
|
||||
}
|
||||
if (msc_fd[i] != NULL) {
|
||||
rv = fflush(msc_fd[i]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno));
|
||||
}
|
||||
rv = fclose(msc_fd[i]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while closing MSC log file: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +257,10 @@ void msc_log_declare_proto(
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "Error while declaring new protocol in MSC log file: %s", strerror(errno));
|
||||
}
|
||||
rv = fflush(msc_fd[protoP]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -223,6 +293,12 @@ void msc_log_event(
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "Error while logging MSC event : %s", &msc_proto2str[protoP][0]);
|
||||
}
|
||||
#if 1
|
||||
rv = fflush(msc_fd[protoP]);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Error while flushing stream of MSC log file: %s", strerror(errno));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
+13
-1
@@ -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, ...);
|
||||
|
||||
Reference in New Issue
Block a user