From dcf35b2af1acacdd38a8da7668e29e636d14ec99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= <frederic.leroy@b-com.com>
Date: Fri, 22 Jul 2016 14:45:00 +0200
Subject: [PATCH] UE/EMM: fix emm_proc_lowerlayer_* prototype

---
 openair3/NAS/UE/EMM/Attach.c                       |  8 ++++----
 openair3/NAS/UE/EMM/Authentication.c               |  2 +-
 openair3/NAS/UE/EMM/Detach.c                       |  8 ++++----
 openair3/NAS/UE/EMM/Identification.c               |  2 +-
 openair3/NAS/UE/EMM/LowerLayer.h                   | 14 ++++++++++++++
 .../UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c |  4 ++--
 openair3/NAS/UE/EMM/SAP/EmmDeregisteredInitiated.c |  2 +-
 .../NAS/UE/EMM/SAP/EmmDeregisteredLimitedService.c |  6 +++---
 .../NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c  |  6 +++---
 openair3/NAS/UE/EMM/SAP/EmmRegistered.c            |  6 +++---
 openair3/NAS/UE/EMM/SAP/EmmRegisteredInitiated.c   |  6 +++---
 openair3/NAS/UE/EMM/SecurityModeControl.c          |  2 +-
 openair3/NAS/UE/EMM/emm_proc.h                     | 13 -------------
 13 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/openair3/NAS/UE/EMM/Attach.c b/openair3/NAS/UE/EMM/Attach.c
index d765ff0fa7..c0c82b9b4c 100644
--- a/openair3/NAS/UE/EMM/Attach.c
+++ b/openair3/NAS/UE/EMM/Attach.c
@@ -240,7 +240,7 @@ int emm_proc_attach(nas_user_t *user, emm_proc_attach_type_t type)
   if (rc != RETURNerror) {
     /* Setup EMM procedure handler to be executed upon receiving
      * lower layer notification */
-    rc = emm_proc_lowerlayer_initialize(emm_proc_attach_request,
+    rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, emm_proc_attach_request,
                                         emm_proc_attach_failure,
                                         emm_proc_attach_release, user);
 
@@ -423,7 +423,7 @@ int emm_proc_attach_accept(nas_user_t *user, long t3412, long t3402, long t3423,
   if ( (rc != RETURNerror) && (esm_sap.err == ESM_SAP_SUCCESS) ) {
     /* Setup EMM procedure handler to be executed upon receiving
      * lower layer notification */
-    rc = emm_proc_lowerlayer_initialize(emm_proc_attach_complete,
+    rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, emm_proc_attach_complete,
                                         emm_proc_attach_failure,
                                         NULL, user);
 
@@ -721,7 +721,7 @@ int emm_proc_attach_complete(void *args)
   LOG_TRACE(INFO, "EMM-PROC  - EPS attach complete");
 
   /* Reset EMM procedure handler */
-  (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   /* Reset the attach attempt counter */
   emm_attach_data->attempt_count = 0;
@@ -787,7 +787,7 @@ int emm_proc_attach_failure(int is_initial, void *args)
   LOG_TRACE(WARNING, "EMM-PROC  - EPS attach failure");
 
   /* Reset EMM procedure handler */
-  (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   /* Stop timer T3410 if still running */
   if (emm_timers->T3410.id != NAS_TIMER_INACTIVE_ID) {
diff --git a/openair3/NAS/UE/EMM/Authentication.c b/openair3/NAS/UE/EMM/Authentication.c
index 56ec2bd833..e49bdd2db7 100644
--- a/openair3/NAS/UE/EMM/Authentication.c
+++ b/openair3/NAS/UE/EMM/Authentication.c
@@ -289,7 +289,7 @@ int emm_proc_authentication_request(nas_user_t *user, int native_ksi, int ksi,
 
   /* Setup EMM procedure handler to be executed upon receiving
    * lower layer notification */
-  rc = emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   if (rc != RETURNok) {
     LOG_TRACE(WARNING,
diff --git a/openair3/NAS/UE/EMM/Detach.c b/openair3/NAS/UE/EMM/Detach.c
index e59d8b7d94..fd2db1b617 100644
--- a/openair3/NAS/UE/EMM/Detach.c
+++ b/openair3/NAS/UE/EMM/Detach.c
@@ -132,7 +132,7 @@ int emm_proc_detach(nas_user_t *user, emm_proc_detach_type_t type, int switch_of
 
   /* Setup EMM procedure handler to be executed upon receiving
    * lower layer notification */
-  rc = emm_proc_lowerlayer_initialize(emm_proc_detach_request,
+  rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, emm_proc_detach_request,
                                       emm_proc_detach_failure,
                                       emm_proc_detach_release, user);
 
@@ -240,7 +240,7 @@ int emm_proc_detach_accept(void* args)
   LOG_TRACE(INFO, "EMM-PROC  - UE initiated detach procedure completion");
 
   /* Reset EMM procedure handler */
-  (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  (void) emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   /* Stop timer T3421 */
   emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
@@ -292,7 +292,7 @@ int emm_proc_detach_failure(int is_initial, void *args)
   LOG_TRACE(WARNING, "EMM-PROC  - Network detach failure");
 
   /* Reset EMM procedure handler */
-  (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  (void) emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   /* Stop timer T3421 */
   emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
@@ -458,7 +458,7 @@ static int _emm_detach_abort(nas_user_t *user, emm_proc_detach_type_t type)
   LOG_TRACE(WARNING, "EMM-PROC  - Abort the detach procedure");
 
   /* Reset EMM procedure handler */
-  (void) emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   /* Stop timer T3421 */
   emm_timers->T3421.id = nas_timer_stop(emm_timers->T3421.id);
diff --git a/openair3/NAS/UE/EMM/Identification.c b/openair3/NAS/UE/EMM/Identification.c
index e894e9e045..7cf2e765c6 100644
--- a/openair3/NAS/UE/EMM/Identification.c
+++ b/openair3/NAS/UE/EMM/Identification.c
@@ -115,7 +115,7 @@ int emm_proc_identification_request(nas_user_t *user, emm_proc_identity_type_t t
 
   /* Setup EMM procedure handler to be executed upon receiving
    * lower layer notification */
-  rc = emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   if (rc != RETURNok) {
     LOG_TRACE(WARNING,
diff --git a/openair3/NAS/UE/EMM/LowerLayer.h b/openair3/NAS/UE/EMM/LowerLayer.h
index 1e56316c69..00e271feaa 100644
--- a/openair3/NAS/UE/EMM/LowerLayer.h
+++ b/openair3/NAS/UE/EMM/LowerLayer.h
@@ -62,6 +62,20 @@ Description Defines EMM procedures executed by the Non-Access Stratum
 /******************  E X P O R T E D    F U N C T I O N S  ******************/
 /****************************************************************************/
 
+/*
+ *---------------------------------------------------------------------------
+ *              Lower layer procedure
+ *---------------------------------------------------------------------------
+ */
+int emm_proc_lowerlayer_initialize(lowerlayer_data_t *lowerlayer_data, lowerlayer_success_callback_t success,
+                                   lowerlayer_failure_callback_t failure,
+                                   lowerlayer_release_callback_t release,
+                                   void *args);
+int emm_proc_lowerlayer_success(lowerlayer_data_t *lowerlayer_data);
+int emm_proc_lowerlayer_failure(lowerlayer_data_t *lowerlayer_data, int is_initial);
+int emm_proc_lowerlayer_release(lowerlayer_data_t *lowerlayer_data);
+
+
 int lowerlayer_success(nas_user_t *user);
 int lowerlayer_failure(nas_user_t *user);
 int lowerlayer_establish(nas_user_t *user);
diff --git a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c
index 3415eee99f..7ddfac03db 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c
@@ -113,14 +113,14 @@ int EmmDeregisteredAttemptingToAttach(nas_user_t *user, const emm_reg_t *evt)
     /*
      * Data successfully delivered to the network
      */
-    rc = emm_proc_lowerlayer_success();
+    rc = emm_proc_lowerlayer_success(user->lowerlayer_data);
     break;
 
   case _EMMREG_LOWERLAYER_FAILURE:
     /*
      * Data failed to be delivered to the network
      */
-    rc = emm_proc_lowerlayer_failure(FALSE);
+    rc = emm_proc_lowerlayer_failure(user->lowerlayer_data, FALSE);
     break;
 
   default:
diff --git a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredInitiated.c b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredInitiated.c
index 6706d144b6..d18b66a316 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredInitiated.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredInitiated.c
@@ -124,7 +124,7 @@ int EmmDeregisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
      * before the Detach Accept is received
      */
     // FIXME review
-    rc = emm_proc_lowerlayer_release();
+    rc = emm_proc_lowerlayer_release(user->lowerlayer_data);
     break;
 
   default:
diff --git a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredLimitedService.c b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredLimitedService.c
index 04c60aef01..3943254415 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredLimitedService.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredLimitedService.c
@@ -126,21 +126,21 @@ int EmmDeregisteredLimitedService(nas_user_t *user, const emm_reg_t *evt)
      * Initial NAS message has been successfully delivered
      * to the network
      */
-    rc = emm_proc_lowerlayer_success();
+    rc = emm_proc_lowerlayer_success(user->lowerlayer_data);
     break;
 
   case _EMMREG_LOWERLAYER_FAILURE:
     /*
      * Initial NAS message failed to be delivered to the network
      */
-    rc = emm_proc_lowerlayer_failure(TRUE);
+    rc = emm_proc_lowerlayer_failure(user->lowerlayer_data, TRUE);
     break;
 
   case _EMMREG_LOWERLAYER_RELEASE:
     /*
      * NAS signalling connection has been released
      */
-    rc = emm_proc_lowerlayer_release();
+    rc = emm_proc_lowerlayer_release(user->lowerlayer_data);
     break;
 
   default:
diff --git a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c
index fd31eaf6dc..3ec7a96ba8 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmDeregisteredNormalService.c
@@ -134,21 +134,21 @@ int EmmDeregisteredNormalService(nas_user_t *user, const emm_reg_t *evt)
      * Initial NAS message has been successfully delivered
      * to the network
      */
-    rc = emm_proc_lowerlayer_success();
+    rc = emm_proc_lowerlayer_success(user->lowerlayer_data);
     break;
 
   case _EMMREG_LOWERLAYER_FAILURE:
     /*
      * Initial NAS message failed to be delivered to the network
      */
-    rc = emm_proc_lowerlayer_failure(TRUE);
+    rc = emm_proc_lowerlayer_failure(user->lowerlayer_data, TRUE);
     break;
 
   case _EMMREG_LOWERLAYER_RELEASE:
     /*
      * NAS signalling connection has been released
      */
-    rc = emm_proc_lowerlayer_release();
+    rc = emm_proc_lowerlayer_release(user->lowerlayer_data);
     break;
 
   case _EMMREG_ATTACH_CNF:
diff --git a/openair3/NAS/UE/EMM/SAP/EmmRegistered.c b/openair3/NAS/UE/EMM/SAP/EmmRegistered.c
index cb1db33985..dbc51e5155 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmRegistered.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmRegistered.c
@@ -136,21 +136,21 @@ int EmmRegistered(nas_user_t *user, const emm_reg_t *evt)
     /*
      * Data transfer message has been successfully delivered
      */
-    rc = emm_proc_lowerlayer_success();
+    rc = emm_proc_lowerlayer_success(user->lowerlayer_data);
     break;
 
   case _EMMREG_LOWERLAYER_FAILURE:
     /*
      * Data transfer message failed to be delivered
      */
-    rc = emm_proc_lowerlayer_failure(FALSE);
+    rc = emm_proc_lowerlayer_failure(user->lowerlayer_data, FALSE);
     break;
 
   case _EMMREG_LOWERLAYER_RELEASE:
     /*
      * NAS signalling connection has been released
      */
-    rc = emm_proc_lowerlayer_release();
+    rc = emm_proc_lowerlayer_release(user->lowerlayer_data);
     break;
 
   default:
diff --git a/openair3/NAS/UE/EMM/SAP/EmmRegisteredInitiated.c b/openair3/NAS/UE/EMM/SAP/EmmRegisteredInitiated.c
index c0d5f50ebc..d10f0d1053 100644
--- a/openair3/NAS/UE/EMM/SAP/EmmRegisteredInitiated.c
+++ b/openair3/NAS/UE/EMM/SAP/EmmRegisteredInitiated.c
@@ -230,7 +230,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
      * any message transfered by EMM common procedures requested
      * by the network.
      */
-    rc = emm_proc_lowerlayer_success();
+    rc = emm_proc_lowerlayer_success(user->lowerlayer_data);
     break;
 
   case _EMMREG_LOWERLAYER_FAILURE:
@@ -240,7 +240,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
      * any message transfered by EMM common procedures requested
      * by the network.
      */
-    rc = emm_proc_lowerlayer_failure(FALSE);
+    rc = emm_proc_lowerlayer_failure(user->lowerlayer_data, FALSE);
     break;
 
   case _EMMREG_LOWERLAYER_RELEASE:
@@ -249,7 +249,7 @@ int EmmRegisteredInitiated(nas_user_t *user, const emm_reg_t *evt)
      * Accept, Attach Reject, or any message transfered by EMM common
      * procedures requested by the network, is received.
      */
-    rc = emm_proc_lowerlayer_release();
+    rc = emm_proc_lowerlayer_release(user->lowerlayer_data);
     break;
 
   default:
diff --git a/openair3/NAS/UE/EMM/SecurityModeControl.c b/openair3/NAS/UE/EMM/SecurityModeControl.c
index 43a5db1ff4..46d2a4fc2e 100644
--- a/openair3/NAS/UE/EMM/SecurityModeControl.c
+++ b/openair3/NAS/UE/EMM/SecurityModeControl.c
@@ -308,7 +308,7 @@ int emm_proc_security_mode_command(nas_user_t *user, int native_ksi, int ksi,
 
   /* Setup EMM procedure handler to be executed upon receiving
    * lower layer notification */
-  rc = emm_proc_lowerlayer_initialize(NULL, NULL, NULL, NULL);
+  rc = emm_proc_lowerlayer_initialize(user->lowerlayer_data, NULL, NULL, NULL, NULL);
 
   if (rc != RETURNok) {
     LOG_TRACE(WARNING,
diff --git a/openair3/NAS/UE/EMM/emm_proc.h b/openair3/NAS/UE/EMM/emm_proc.h
index a6a32448a4..4505257335 100644
--- a/openair3/NAS/UE/EMM/emm_proc.h
+++ b/openair3/NAS/UE/EMM/emm_proc.h
@@ -68,19 +68,6 @@ Description Defines the EPS Mobility Management procedures executed at
 int emm_proc_status_ind(unsigned int ueid, int emm_cause);
 int emm_proc_status(nas_user_t *user, int emm_cause);
 
-/*
- *---------------------------------------------------------------------------
- *              Lower layer procedure
- *---------------------------------------------------------------------------
- */
-int emm_proc_lowerlayer_initialize(lowerlayer_success_callback_t success,
-                                   lowerlayer_failure_callback_t failure,
-                                   lowerlayer_release_callback_t release,
-                                   void *args);
-int emm_proc_lowerlayer_success(void);
-int emm_proc_lowerlayer_failure(int is_initial);
-int emm_proc_lowerlayer_release(void);
-
 /*
  *---------------------------------------------------------------------------
  *              UE's Idle mode procedure
-- 
GitLab