From 53fa94785ac2dad424e24d56dce8be874686bda8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= <frederic.leroy@b-com.com>
Date: Tue, 19 Jul 2016 09:09:40 +0200
Subject: [PATCH] UE/EMM: remove extern definitions for timers

---
 openair3/NAS/UE/EMM/Attach.c             |  9 ++++-----
 openair3/NAS/UE/EMM/Authentication.c     | 19 ++++++-------------
 openair3/NAS/UE/EMM/Detach.c             | 11 ++++-------
 openair3/NAS/UE/EMM/ServiceRequestHdl.c  |  7 +------
 openair3/NAS/UE/EMM/TrackingAreaUpdate.c |  6 +-----
 openair3/NAS/UE/EMM/emm_timers.h         | 14 ++++++++++++++
 openair3/NAS/UE/ESM/esm_ip.c             |  1 +
 7 files changed, 31 insertions(+), 36 deletions(-)
 create mode 100644 openair3/NAS/UE/EMM/emm_timers.h

diff --git a/openair3/NAS/UE/EMM/Attach.c b/openair3/NAS/UE/EMM/Attach.c
index b47b8cea8b..12be189d9b 100644
--- a/openair3/NAS/UE/EMM/Attach.c
+++ b/openair3/NAS/UE/EMM/Attach.c
@@ -59,6 +59,7 @@ Description Defines the attach related EMM procedure executed by the
 #include "nas_timer.h"
 
 #include "emmData.h"
+#include "emm_timers.h"
 
 #include "emm_sap.h"
 #include "esm_sap.h"
@@ -90,9 +91,7 @@ static const char *_emm_attach_type_str[] = {
 /*
  * Timer handlers
  */
-void *_emm_attach_t3410_handler(void *);
-static void *_emm_attach_t3411_handler(void *);
-static void *_emm_attach_t3402_handler(void *);
+static void *_emm_attach_t3411_handler(void *args);
 
 /*
  * Abnormal case attach procedure
@@ -251,7 +250,7 @@ int emm_proc_attach(nas_user_t *user, emm_proc_attach_type_t type)
     }
 
     /* Start T3410 timer */
-    emm_timers->T3410.id = nas_timer_start(emm_timers->T3410.sec, _emm_attach_t3410_handler, user);
+    emm_timers->T3410.id = nas_timer_start(emm_timers->T3410.sec, emm_attach_t3410_handler, user);
     LOG_TRACE(INFO,"EMM-PROC  - Timer T3410 (%d) expires in %ld seconds",
               emm_timers->T3410.id, emm_timers->T3410.sec);
     /* Stop T3402 and T3411 timers if running */
@@ -991,7 +990,7 @@ int emm_proc_attach_set_detach(void *nas_user)
  **      Others:    T3410                                      **
  **                                                                        **
  ***************************************************************************/
-void *_emm_attach_t3410_handler(void *args)
+void *emm_attach_t3410_handler(void *args)
 {
   LOG_FUNC_IN;
 
diff --git a/openair3/NAS/UE/EMM/Authentication.c b/openair3/NAS/UE/EMM/Authentication.c
index cee8553113..cb448388f7 100644
--- a/openair3/NAS/UE/EMM/Authentication.c
+++ b/openair3/NAS/UE/EMM/Authentication.c
@@ -59,9 +59,11 @@ Description Defines the authentication EMM procedure executed by the
 #include "nas_timer.h"
 
 #include "emmData.h"
+#include "emm_timers.h"
 
 #include "emm_sap.h"
 #include "emm_cause.h"
+#include "emm_timers.h"
 
 #include "usim_api.h"
 #include "secu_defs.h"
@@ -72,15 +74,6 @@ Description Defines the authentication EMM procedure executed by the
 /****************  E X T E R N A L    D E F I N I T I O N S  ****************/
 /****************************************************************************/
 
-/*
- * Retransmission timer handlers
- */
-// FIXME REVIEW
-extern void *_emm_attach_t3410_handler(void *);
-extern void *_emm_service_t3417_handler(void *);
-extern void *_emm_detach_t3421_handler(void *);
-extern void *_emm_tau_t3430_handler(void *);
-
 extern uint8_t usim_test;
 
 /****************************************************************************/
@@ -876,28 +869,28 @@ static int _authentication_start_timers(nas_user_t *user)
 
   if (authentication_data->timers & AUTHENTICATION_T3410) {
     /* Start attach timer */
-    emm_timers->T3410.id = nas_timer_start(emm_timers->T3410.sec, _emm_attach_t3410_handler, NULL);
+    emm_timers->T3410.id = nas_timer_start(emm_timers->T3410.sec, emm_attach_t3410_handler, NULL);
     LOG_TRACE(INFO,"EMM-PROC  - Timer T3410 (%d) expires in "
               "%ld seconds", emm_timers->T3410.id, emm_timers->T3410.sec);
   }
 
   if (authentication_data->timers & AUTHENTICATION_T3417) {
     /* Start service request timer */
-    emm_timers->T3417.id = nas_timer_start(emm_timers->T3417.sec, _emm_service_t3417_handler, NULL);
+    emm_timers->T3417.id = nas_timer_start(emm_timers->T3417.sec, emm_service_t3417_handler, NULL);
     LOG_TRACE(INFO,"EMM-PROC  - Timer T3417 (%d) expires in "
               "%ld seconds", emm_timers->T3417.id, emm_timers->T3417.sec);
   }
 
   if (authentication_data->timers & AUTHENTICATION_T3421) {
     /* Start detach timer */
-    emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, _emm_detach_t3421_handler, NULL);
+    emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, emm_detach_t3421_handler, NULL);
     LOG_TRACE(INFO,"EMM-PROC  - Timer T3421 (%d) expires in "
               "%ld seconds", emm_timers->T3421.id, emm_timers->T3421.sec);
   }
 
   if (authentication_data->timers & AUTHENTICATION_T3430) {
     /* Start tracking area update timer */
-    emm_timers->T3430.id = nas_timer_start(emm_timers->T3430.sec, _emm_tau_t3430_handler, NULL);
+    emm_timers->T3430.id = nas_timer_start(emm_timers->T3430.sec, emm_tau_t3430_handler, NULL);
     LOG_TRACE(INFO,"EMM-PROC  - Timer T3430 (%d) expires in "
               "%ld seconds", emm_timers->T3430.id, emm_timers->T3430.sec);
   }
diff --git a/openair3/NAS/UE/EMM/Detach.c b/openair3/NAS/UE/EMM/Detach.c
index 44fbe95181..58148205a3 100644
--- a/openair3/NAS/UE/EMM/Detach.c
+++ b/openair3/NAS/UE/EMM/Detach.c
@@ -49,6 +49,7 @@ Description Defines the detach related EMM procedure executed by the
 #include "nas_timer.h"
 
 #include "emmData.h"
+#include "emm_timers.h"
 
 #include "emm_sap.h"
 #include "esm_sap.h"
@@ -75,10 +76,6 @@ static const char *_emm_detach_type_str[] = {
  *      Internal data handled by the detach procedure in the UE
  * --------------------------------------------------------------------------
  */
-/*
- * Timer handlers
- */
-void *_emm_detach_t3421_handler(void *);
 
 /*
  * Abnormal case detach procedures
@@ -196,7 +193,7 @@ int emm_proc_detach_request(void *args)
 
   if ( !emm_detach_data->switch_off ) {
     /* Start T3421 timer */
-    emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, _emm_detach_t3421_handler, user);
+    emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, emm_detach_t3421_handler, user);
     LOG_TRACE(INFO, "EMM-PROC  - Timer T3421 (%d) expires in %ld seconds",
               emm_timers->T3421.id, emm_timers->T3421.sec);
   }
@@ -372,7 +369,7 @@ int emm_proc_detach_release(void *args)
  **      Others:    None                                       **
  **                                                                        **
  ***************************************************************************/
-void *_emm_detach_t3421_handler(void *args)
+void *emm_detach_t3421_handler(void *args)
 {
   LOG_FUNC_IN;
 
@@ -419,7 +416,7 @@ void *_emm_detach_t3421_handler(void *args)
 
     if (rc != RETURNerror) {
       /* Start T3421 timer */
-      emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, _emm_detach_t3421_handler, user);
+      emm_timers->T3421.id = nas_timer_start(emm_timers->T3421.sec, emm_detach_t3421_handler, user);
       LOG_TRACE(INFO, "EMM-PROC  - Timer T3421 (%d) expires in %ld "
                 "seconds", emm_timers->T3421.id, emm_timers->T3421.sec);
     }
diff --git a/openair3/NAS/UE/EMM/ServiceRequestHdl.c b/openair3/NAS/UE/EMM/ServiceRequestHdl.c
index 65df01b114..93e66efdbd 100644
--- a/openair3/NAS/UE/EMM/ServiceRequestHdl.c
+++ b/openair3/NAS/UE/EMM/ServiceRequestHdl.c
@@ -67,11 +67,6 @@ Description Defines the service request EMM procedure executed by the
  *  Internal data handled by the service request procedure in the UE
  * --------------------------------------------------------------------------
  */
-/*
- * Timer handlers
- */
-void *_emm_service_t3417_handler(void *);
-
 /*
  * --------------------------------------------------------------------------
  *  Internal data handled by the service request procedure in the MME
@@ -109,7 +104,7 @@ void *_emm_service_t3417_handler(void *);
  **      Others:    None                                       **
  **                                                                        **
  ***************************************************************************/
-void *_emm_service_t3417_handler(void *args)
+void *emm_service_t3417_handler(void *args)
 {
   LOG_FUNC_IN;
   nas_user_t *user = args;
diff --git a/openair3/NAS/UE/EMM/TrackingAreaUpdate.c b/openair3/NAS/UE/EMM/TrackingAreaUpdate.c
index 5fe732b22d..bafddaf317 100644
--- a/openair3/NAS/UE/EMM/TrackingAreaUpdate.c
+++ b/openair3/NAS/UE/EMM/TrackingAreaUpdate.c
@@ -67,10 +67,6 @@ Description Defines the tracking area update EMM procedure executed by the
  *   Internal data handled by the tracking area update procedure in the UE
  * --------------------------------------------------------------------------
  */
-/*
- * Timer handlers
- */
-void *_emm_tau_t3430_handler(void *);
 
 /*
  * --------------------------------------------------------------------------
@@ -110,7 +106,7 @@ void *_emm_tau_t3430_handler(void *);
  **              Others:        None                                       **
  **                                                                        **
  ***************************************************************************/
-void *_emm_tau_t3430_handler(void *args)
+void *emm_tau_t3430_handler(void *args)
 {
   LOG_FUNC_IN;
   nas_user_t *user = args;
diff --git a/openair3/NAS/UE/EMM/emm_timers.h b/openair3/NAS/UE/EMM/emm_timers.h
new file mode 100644
index 0000000000..abf7c9ff87
--- /dev/null
+++ b/openair3/NAS/UE/EMM/emm_timers.h
@@ -0,0 +1,14 @@
+#ifndef EMM_TIMERS_H
+#define EMM_TIMERS_H
+
+/*
+ * Retransmission timer handlers
+ */
+
+void *emm_attach_t3410_handler(void *);
+void *emm_service_t3417_handler(void *);
+void *emm_detach_t3421_handler(void *);
+void *emm_tau_t3430_handler(void *);
+
+
+#endif
diff --git a/openair3/NAS/UE/ESM/esm_ip.c b/openair3/NAS/UE/ESM/esm_ip.c
index f21305a1a0..23d8ecce97 100644
--- a/openair3/NAS/UE/ESM/esm_ip.c
+++ b/openair3/NAS/UE/ESM/esm_ip.c
@@ -22,6 +22,7 @@
 #include "emmData.h"
 #include "esmData.h"
 
+// FIXME don't work for reentrant calls
 char ip_addr_str[100];
 
 inline char *esm_data_get_ipv4_addr(const OctetString *ip_addr)
-- 
GitLab