From 7423854fffc82bff12e0b3df3ffbdf59e5801634 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Sat, 7 Dec 2013 09:47:19 +0000
Subject: [PATCH] - Fix broken build when NAS disabled - Fix compiler warning

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4636 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair-cn/COMMON/nas_messages_types.h        |  4 +-
 openair-cn/MME_APP/mme_app_authentication.c   |  5 +-
 openair-cn/MME_APP/mme_app_main.c             |  9 ++-
 openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c | 60 ++++++++++---------
 4 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/openair-cn/COMMON/nas_messages_types.h b/openair-cn/COMMON/nas_messages_types.h
index f6ce130cd8..c1fade8987 100644
--- a/openair-cn/COMMON/nas_messages_types.h
+++ b/openair-cn/COMMON/nas_messages_types.h
@@ -141,8 +141,10 @@ typedef struct nas_auth_param_fail_s {
     nas_cause_t cause;
 } nas_auth_param_fail_t;
 
+#if defined(DISABLE_USE_NAS)
 typedef struct nas_attach_accept_s {
-    
+    s1ap_initial_ctxt_setup_req_t transparent;
 } nas_attach_accept_t;
+#endif
 
 #endif /* NAS_MESSAGES_TYPES_H_ */
diff --git a/openair-cn/MME_APP/mme_app_authentication.c b/openair-cn/MME_APP/mme_app_authentication.c
index d0ed75c149..d9717ec258 100644
--- a/openair-cn/MME_APP/mme_app_authentication.c
+++ b/openair-cn/MME_APP/mme_app_authentication.c
@@ -211,7 +211,7 @@ int mme_app_handle_attach_req(nas_attach_req_t *attach_req_p)
         ue_context->eNB_ue_s1ap_id = attach_req_p->transparent.eNB_ue_s1ap_id;
         ue_context->mme_ue_s1ap_id = attach_req_p->transparent.mme_ue_s1ap_id;
 
-        STAILQ_INIT(&ue_context->vector_list);
+//         STAILQ_INIT(&ue_context->vector_list);
         DevAssert(mme_insert_ue_context(&mme_app_desc.mme_ue_contexts, ue_context) == 0);
         goto request_auth;
     } else {
@@ -230,7 +230,8 @@ int mme_app_handle_attach_req(nas_attach_req_t *attach_req_p)
         } else {
             MME_APP_DEBUG("UE is not authenticated\n");
             /* UE is not authenticated or an initial request */
-            if (STAILQ_EMPTY(&ue_context->vector_list))
+//              if (STAILQ_EMPTY(&ue_context->vector_list))
+            if (ue_context->nb_of_vectors == 0)
 request_auth: {
                 /* We have no vector for this UE, send an authentication request
                  * to the HSS.
diff --git a/openair-cn/MME_APP/mme_app_main.c b/openair-cn/MME_APP/mme_app_main.c
index 38209421b6..4e42f77c82 100644
--- a/openair-cn/MME_APP/mme_app_main.c
+++ b/openair-cn/MME_APP/mme_app_main.c
@@ -78,10 +78,6 @@ void *mme_app_thread(void *args)
                 mme_app_handle_create_sess_resp(&received_message_p->ittiMsg.sgwCreateSessionResponse);
             } break;
 
-            case NAS_AUTHENTICATION_PARAM_REQ: {
-                mme_app_handle_nas_auth_param_req(&received_message_p->ittiMsg.nas_auth_param_req);
-            } break;
-
 #if defined(DISABLE_USE_NAS)
             case NAS_ATTACH_REQ: {
                 mme_app_handle_attach_req(&received_message_p->ittiMsg.nas_attach_req);
@@ -90,8 +86,11 @@ void *mme_app_thread(void *args)
             case NAS_AUTHENTICATION_RESP: {
                 mme_app_handle_nas_auth_resp(&received_message_p->ittiMsg.nas_auth_resp);
             } break;
+#else
+            case NAS_AUTHENTICATION_PARAM_REQ: {
+                mme_app_handle_nas_auth_param_req(&received_message_p->ittiMsg.nas_auth_param_req);
+            } break;
 #endif
-
             case TIMER_HAS_EXPIRED: {
                 /* Check if it is the statistic timer */
                 if (received_message_p->ittiMsg.timer_has_expired.timer_id ==
diff --git a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c
index dad2456209..571574131e 100644
--- a/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c
+++ b/openair-cn/NAS/EURECOM-NAS/src/esm/esm_main.c
@@ -121,50 +121,52 @@ void esm_main_initialize(void)
 
 /****************************************************************************
  **                                                                        **
- ** Name:    esm_main_cleanup()                                        **
+ ** Name:        esm_main_cleanup()                                        **
  **                                                                        **
  ** Description: Performs the EPS Session Management clean up procedure    **
  **                                                                        **
- ** Inputs:  None                                                      **
- **          Others:    None                                       **
+ ** Inputs:      None                                                      **
+ **                  Others:    None                                       **
  **                                                                        **
  ** Outputs:     None                                                      **
- **          Return:    None                                       **
- **          Others:    None                                       **
+ **                  Return:    None                                       **
+ **                  Others:    None                                       **
  **                                                                        **
  ***************************************************************************/
 void esm_main_cleanup(void)
 {
     LOG_FUNC_IN;
 
-    int i;
-    int pid;
-    int bid;
-
-    #ifdef NAS_UE
-    /* De-activate EPS bearers and clean up PDN connections */
-    for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
-        if (_esm_data.pdn[pid].data) {
-            esm_pdn_t *pdn = _esm_data.pdn[pid].data;
-            if (pdn->apn.length > 0) {
-                free(pdn->apn.value);
-            }
-            /* Release EPS bearer contexts */
-            for (bid = 0; bid < pdn->n_bearers; bid++) {
-                if (pdn->bearer[bid]) {
-                    LOG_TRACE(WARNING, "ESM-MAIN  - Release EPS bearer "
-                              "context (ebi=%d)", pdn->bearer[bid]->ebi);
-                    /* Delete the TFT */
-                    for (i = 0; i < pdn->bearer[bid]->tft.n_pkfs; i++) {
-                        if (pdn->bearer[bid]->tft.pkf[i]) {
-                            free(pdn->bearer[bid]->tft.pkf[i]);
+#ifdef NAS_UE
+    {
+        int i;
+        int pid;
+        int bid;
+
+        /* De-activate EPS bearers and clean up PDN connections */
+        for (pid = 0; pid < ESM_DATA_PDN_MAX; pid++) {
+            if (_esm_data.pdn[pid].data) {
+                esm_pdn_t *pdn = _esm_data.pdn[pid].data;
+                if (pdn->apn.length > 0) {
+                    free(pdn->apn.value);
+                }
+                /* Release EPS bearer contexts */
+                for (bid = 0; bid < pdn->n_bearers; bid++) {
+                    if (pdn->bearer[bid]) {
+                        LOG_TRACE(WARNING, "ESM-MAIN  - Release EPS bearer "
+                                  "context (ebi=%d)", pdn->bearer[bid]->ebi);
+                        /* Delete the TFT */
+                        for (i = 0; i < pdn->bearer[bid]->tft.n_pkfs; i++) {
+                            if (pdn->bearer[bid]->tft.pkf[i]) {
+                                free(pdn->bearer[bid]->tft.pkf[i]);
+                            }
                         }
+                        free(pdn->bearer[bid]);
                     }
-                    free(pdn->bearer[bid]);
                 }
+                /* Release the PDN connection */
+                free(_esm_data.pdn[pid].data);
             }
-            /* Release the PDN connection */
-            free(_esm_data.pdn[pid].data);
         }
     }
 #endif
-- 
2.26.2