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 a2848c3ad11cb6db61ab28dc03017c3e196dd1b1..b87ed244cd65aaf95ba821f489fabf4bc2b0d0fc 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 65f3b6ed9e622fc9ff1ba9b4a862d2dfc4c3c86f..218b39d8d972bdbfaa71aa39a14fddcbb7822923 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 329edadeaa495f830f1c836e14f72b7cc66af3d6..62fa4674e4fae50e1a3cdf72852b8dde48b0a7a8 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 156eac828c27f0bcdf328f0211c91c396ed9f596..1d28962ac79d0d5db5d7468e40438c36a3fd7ed6 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 08f6714aebd2fb902b361b4646ef14af1489998a..a06e8f690aa3d9ae1aea78d27767f293eace592b 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)