From 4a4773b3de92ab4b256ed38b2244c22a9247c0f9 Mon Sep 17 00:00:00 2001 From: winckel <winckel@eurecom.fr> Date: Mon, 9 Dec 2013 15:41:14 +0000 Subject: [PATCH] Moved "nas_ue_task.c" to integrate it into libuenas.a to simplify include dependencies. Modified nas logging function to use the same than oaisim or lte-softmodem. Added some object and include paths in nas ue lib makefile. git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4653 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair-cn/NAS/EURECOM-NAS/src/util/nas_log.c | 5 +- openair-cn/NAS/EURECOM-NAS/src/util/nas_log.h | 54 ++++++++++++++++--- openair-cn/NAS/Makefile.UE | 28 ++++++++-- {openair2 => openair-cn}/NAS/nas_ue_task.c | 12 +++-- openair2/NAS/Makefile.inc | 2 +- 5 files changed, 86 insertions(+), 15 deletions(-) rename {openair2 => openair-cn}/NAS/nas_ue_task.c (87%) diff --git a/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.c b/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.c index a2848c3ad11..b87ed244cd6 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.c +++ b/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.c @@ -19,7 +19,9 @@ Description Usefull logging functions *****************************************************************************/ #include "nas_log.h" - +#if defined(UE_BUILD) && defined(NAS_UE) +int nas_log_func_indent; +#else #include <stdio.h> // stderr, sprintf, fprintf, vfprintf #include <stdarg.h> // va_list, va_start, va_end @@ -239,4 +241,5 @@ void log_dump(const char* data, int len) /****************************************************************************/ /********************* L O C A L F U N C T I O N S *********************/ /****************************************************************************/ +#endif diff --git a/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.h b/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.h index 65f3b6ed9e6..218b39d8d97 100644 --- a/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.h +++ b/openair-cn/NAS/EURECOM-NAS/src/util/nas_log.h @@ -20,6 +20,11 @@ Description Usefull logging functions #ifndef __NAS_LOG_H__ #define __NAS_LOG_H__ +#if defined(UE_BUILD) && defined(NAS_UE) +# include "UTIL/LOG/log.h" +# undef LOG_TRACE +#endif + /****************************************************************************/ /********************* G L O B A L C O N S T A N T S *******************/ /****************************************************************************/ @@ -73,12 +78,48 @@ typedef enum /****************** E X P O R T E D F U N C T I O N S ******************/ /****************************************************************************/ -#define LOG_TRACE log_data(__FILE__, __LINE__); log_trace -#define LOG_DUMP(a, b) log_dump((a),(b)); - -#define LOG_FUNC_IN LOG_TRACE(FUNC_IN, "Entering %s()", __FUNCTION__) -#define LOG_FUNC_OUT LOG_TRACE(FUNC_OUT, "Leaving %s()", __FUNCTION__) -#define LOG_FUNC_RETURN(rETURNcODE) \ +#if defined(UE_BUILD) && defined(NAS_UE) +# define LOG_TRACE(s, x, args...) \ +do { \ + switch (s) { \ + case ERROR: LOG_E(NAS, " " x "\n", ##args); break; \ + case WARNING: LOG_W(NAS, " " x "\n", ##args); break; \ + case INFO: LOG_I(NAS, " " x "\n", ##args); break; \ + default: LOG_D(NAS, " " x "\n", ##args); break; \ + } \ +} while (0) + +# define LOG_DUMP(a, b) LOG_D(NAS, " Dump %d\n", b) + +# define LOG_FUNC_IN \ +do { \ + LOG_D(NAS, " %*sEntering %s()\n", nas_log_func_indent, "", __FUNCTION__); \ + nas_log_func_indent += 4; \ +} while (0) + +# define LOG_FUNC_OUT \ +do { \ + nas_log_func_indent -= 4; \ + LOG_D(NAS, " %*sLeaving %s()\n", nas_log_func_indent, "", __FUNCTION__); \ +} while (0) + +# define LOG_FUNC_RETURN(rETURNcODE) \ +do { \ + nas_log_func_indent -= 4; \ + LOG_D(NAS, " %*sLeaving %s(rc = %ld)\n", nas_log_func_indent, "", \ + __FUNCTION__, (long) rETURNcODE); \ + return (rETURNcODE); \ +} while (0) + +extern int nas_log_func_indent; + +#else +# define LOG_TRACE log_data(__FILE__, __LINE__); log_trace +# define LOG_DUMP(a, b) log_dump((a),(b)); + +# define LOG_FUNC_IN LOG_TRACE(FUNC_IN, "Entering %s()", __FUNCTION__) +# define LOG_FUNC_OUT LOG_TRACE(FUNC_OUT, "Leaving %s()", __FUNCTION__) +# define LOG_FUNC_RETURN(rETURNcODE) \ do { \ LOG_TRACE(FUNC_OUT, "Leaving %s(rc = %ld)", __FUNCTION__, \ (long) rETURNcODE); \ @@ -89,5 +130,6 @@ void nas_log_init(char filter); void log_data(const char* filename, int line); void log_trace(log_severity_t severity, const char* data, ...); void log_dump(const char* data, int len); +#endif #endif /* __NAS_LOG_H__*/ diff --git a/openair-cn/NAS/Makefile.UE b/openair-cn/NAS/Makefile.UE index 329edadeaa4..62fa4674e4f 100644 --- a/openair-cn/NAS/Makefile.UE +++ b/openair-cn/NAS/Makefile.UE @@ -3,6 +3,9 @@ PROJDIR = $(UE_NAS_DIR)/EURECOM-NAS include $(UE_NAS_DIR)/EURECOM-NAS/Makefile.inc libnas_INCLUDES = \ + -I$(OPENAIR2_DIR) \ + -I$(OPENAIR2_DIR)/NAS \ + -I$(SRCDIR) \ -I$(INCDIR) \ -I$(UTILDIR) \ -I$(USERAPIDIR) \ @@ -224,18 +227,35 @@ libnas_ies_OBJS = \ EURECOM-NAS/src/ies/KsiAndSequenceNumber.o libnas_utils_OBJS = \ + EURECOM-NAS/src/util/device.o \ + EURECOM-NAS/src/util/memory.o \ EURECOM-NAS/src/util/nas_log.o \ EURECOM-NAS/src/util/nas_timer.o \ + EURECOM-NAS/src/util/socket.o \ + EURECOM-NAS/src/util/stty.o \ EURECOM-NAS/src/util/TLVEncoder.o \ EURECOM-NAS/src/util/TLVDecoder.o \ EURECOM-NAS/src/util/OctetString.o +libnas_user_OBJS = \ + EURECOM-NAS/src/api/user/user_api.o \ + EURECOM-NAS/src/api/user/user_indication.o \ + EURECOM-NAS/src/api/user/at_command.o \ + EURECOM-NAS/src/api/user/at_error.o \ + EURECOM-NAS/src/api/user/at_response.o + +libnas_usim_OBJS = \ + EURECOM-NAS/src/api/usim/aka_functions.o \ + EURECOM-NAS/src/api/usim/usim_api.o + libnas_OBJS = \ - EURECOM-NAS/src/nas_network.o \ + nas_ue_task.o \ EURECOM-NAS/src/nas_parser.o \ EURECOM-NAS/src/nas_proc.o \ EURECOM-NAS/src/nas_user.o \ $(libnas_utils_OBJS) \ + $(libnas_user_OBJS) \ + $(libnas_usim_OBJS) \ $(libnas_emm_OBJS) \ $(libnas_emm_msg_OBJS) \ $(libnas_emm_sap_OBJS) \ @@ -275,9 +295,9 @@ $(OUTDIR)/libuenas.a: $(NAS_UE_COMPILED_OBJS) @$(AR) rcs $@ $(addprefix $(OUTDIR)/,$(libnas_OBJS)) clean: - @$(RM_F_V) $(OUTDIR)/*.o - @$(RM_F_V) $(OUTDIR)/*.d - @$(RM_F_V) $(OUTDIR)/libuenas.a + @$(RM_F_V) --recursive $(OUTDIR)/* + +cleanall: clean showcflags: @echo uenas cflags: $(CFLAGS) diff --git a/openair2/NAS/nas_ue_task.c b/openair-cn/NAS/nas_ue_task.c similarity index 87% rename from openair2/NAS/nas_ue_task.c rename to openair-cn/NAS/nas_ue_task.c index 156eac828c2..1d28962ac79 100644 --- a/openair2/NAS/nas_ue_task.c +++ b/openair-cn/NAS/nas_ue_task.c @@ -31,7 +31,10 @@ #if defined(ENABLE_ITTI) # include "intertask_interface.h" # include "nas_ue_task.h" -# include "log.h" + +# include "nas_log.h" +# include "nas_user.h" +# include "user_api.h" extern unsigned char NB_eNB_INST; @@ -43,6 +46,10 @@ void *nas_ue_task(void *args_p) { itti_mark_task_ready (TASK_NAS_UE); + /* Initialize NAS */ +// nas_log_init(0x2F); + nas_user_initialize (&user_api_emm_callback, &user_api_esm_callback, FIRMWARE_VERSION); + while(1) { // Wait for a message itti_receive_msg (TASK_NAS_UE, &msg_p); @@ -61,8 +68,7 @@ void *nas_ue_task(void *args_p) { break; case NAS_DOWNLINK_DATA_IND: - LOG_I(NAS, "[UE %d] Received %s: UEid %u, lenght %u\n", Mod_id, msg_name, - NAS_DOWNLINK_DATA_IND (msg_p).UEid, NAS_DOWNLINK_DATA_IND (msg_p).nasMsg.length); + LOG_I(NAS, "[UE %d] Received %s: UEid %u, lenght %u\n", Mod_id, msg_name, NAS_DOWNLINK_DATA_IND (msg_p).UEid, NAS_DOWNLINK_DATA_IND (msg_p).nasMsg.length); break; default: diff --git a/openair2/NAS/Makefile.inc b/openair2/NAS/Makefile.inc index 08f6714aebd..a06e8f690aa 100644 --- a/openair2/NAS/Makefile.inc +++ b/openair2/NAS/Makefile.inc @@ -1,6 +1,6 @@ NAS_UE_DIR = $(OPENAIR2_TOP)/NAS -NAS_UE_OBJS = $(NAS_UE_DIR)/nas_ue_task.o +NAS_UE_OBJS = NAS_UE_incl = \ -I$(NAS_UE_DIR) -- GitLab