From 1f816e3a101bb2e45f57898a452ae79ab147caf2 Mon Sep 17 00:00:00 2001
From: navid <navid@mycompany.com>
Date: Thu, 6 Aug 2015 15:09:17 +0000
Subject: [PATCH] * fix the compilation of at_nas_ue * fix the check for
 MIH_C_MEDIEVAL_EXTENSIONS var in CMakeLists, and seg fault in eNB when
 multiple MCC/MNC issued by EPC

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7770 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 cmake_targets/CMakeLists.txt             |  4 ++--
 cmake_targets/at_commands/CMakeLists.txt |  2 ++
 openair-cn/S1AP/s1ap_eNB_handlers.c      | 16 ++++++++++------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 047b941a92e..1fca4bf41dd 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -379,7 +379,7 @@ elseif (${RF_BOARD} STREQUAL "OAI_BLADERF")
     )
   LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu")
   set(option_HW_lib "bladeRF")
-  #set(LOWLATENCY False)
+#set(LOWLATENCY False)
 
 elseif (${RF_BOARD} STREQUAL "ETHERNET")
   include_directories ("${OPENAIR_TARGETS}/ARCH/ETHERNET/USERSPACE/LIB")
@@ -920,7 +920,7 @@ if (${ENABLE_RAL})
   set(RAL_LIB RAL)
 endif()
 
-if(MIH_C_MEDIEVAL_EXTENSIONS)
+if(${MIH_C_MEDIEVAL_EXTENSIONS})
   set(MIH_SRC
     ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_header_codec.c
     ${RAL_LTE_DIR}INTERFACE-802.21/C/MIH_C_msg_codec.c
diff --git a/cmake_targets/at_commands/CMakeLists.txt b/cmake_targets/at_commands/CMakeLists.txt
index cc06b93f1e0..cfdb6ec2aac 100755
--- a/cmake_targets/at_commands/CMakeLists.txt
+++ b/cmake_targets/at_commands/CMakeLists.txt
@@ -526,6 +526,7 @@ set(ies_SRC
     ${OPENAIR_NAS_DIR}/COMMON/IES/MobileStationClassmark2.c
     ${OPENAIR_NAS_DIR}/COMMON/IES/MobileStationClassmark3.c
     ${OPENAIR_NAS_DIR}/COMMON/IES/MsNetworkCapability.c
+    ${OPENAIR_NAS_DIR}/COMMON/IES/MsNetworkFeatureSupport.c
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasKeySetIdentifier.c
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasMessageContainer.c
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasRequestType.c
@@ -605,6 +606,7 @@ set(ies_HDR
     ${OPENAIR_NAS_DIR}/COMMON/IES/MobileStationClassmark2.h
     ${OPENAIR_NAS_DIR}/COMMON/IES/MobileStationClassmark3.h
     ${OPENAIR_NAS_DIR}/COMMON/IES/MsNetworkCapability.h
+    ${OPENAIR_NAS_DIR}/COMMON/IES/MsNetworkFeatureSupport.h
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasKeySetIdentifier.h
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasMessageContainer.h
     ${OPENAIR_NAS_DIR}/COMMON/IES/NasRequestType.h
diff --git a/openair-cn/S1AP/s1ap_eNB_handlers.c b/openair-cn/S1AP/s1ap_eNB_handlers.c
index 34f010d2976..7469e83ac20 100644
--- a/openair-cn/S1AP/s1ap_eNB_handlers.c
+++ b/openair-cn/S1AP/s1ap_eNB_handlers.c
@@ -291,7 +291,10 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
   /* The list of served gummei can contain at most 8 elements.
    * LTE related gummei is the first element in the list, i.e with an id of 0.
    */
-  DevAssert(s1SetupResponse_p->servedGUMMEIs.list.count == 1);
+  S1AP_DEBUG("servedGUMMEIs.list.count %d\n",s1SetupResponse_p->servedGUMMEIs.list.count); 
+  DevAssert(s1SetupResponse_p->servedGUMMEIs.list.count > 0);
+  DevAssert(s1SetupResponse_p->servedGUMMEIs.list.count <= 8);
+
 
   for (i = 0; i < s1SetupResponse_p->servedGUMMEIs.list.count; i++) {
     struct S1ap_ServedGUMMEIsItem *gummei_item_p;
@@ -305,12 +308,13 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
     STAILQ_INIT(&new_gummei_p->served_plmns);
     STAILQ_INIT(&new_gummei_p->served_group_ids);
     STAILQ_INIT(&new_gummei_p->mme_codes);
-
+    
+    S1AP_DEBUG("servedPLMNs.list.count %d\n",gummei_item_p->servedPLMNs.list.count);
     for (j = 0; j < gummei_item_p->servedPLMNs.list.count; j++) {
       S1ap_PLMNidentity_t *plmn_identity_p;
       struct plmn_identity_s *new_plmn_identity_p;
-
-      plmn_identity_p = gummei_item_p->servedPLMNs.list.array[i];
+      
+      plmn_identity_p = gummei_item_p->servedPLMNs.list.array[j];
       new_plmn_identity_p = calloc(1, sizeof(struct plmn_identity_s));
       TBCD_TO_MCC_MNC(plmn_identity_p, new_plmn_identity_p->mcc,
                       new_plmn_identity_p->mnc, new_plmn_identity_p->mnc_digit_length);
@@ -322,7 +326,7 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
       S1ap_MME_Group_ID_t           *mme_group_id_p;
       struct served_group_id_s *new_group_id_p;
 
-      mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[i];
+      mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[j];
       new_group_id_p = calloc(1, sizeof(struct served_group_id_s));
       OCTET_STRING_TO_INT16(mme_group_id_p, new_group_id_p->mme_group_id);
       STAILQ_INSERT_TAIL(&new_gummei_p->served_group_ids, new_group_id_p, next);
@@ -333,7 +337,7 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t               assoc_id,
       S1ap_MME_Code_t        *mme_code_p;
       struct mme_code_s *new_mme_code_p;
 
-      mme_code_p = gummei_item_p->servedMMECs.list.array[i];
+      mme_code_p = gummei_item_p->servedMMECs.list.array[j];
       new_mme_code_p = calloc(1, sizeof(struct mme_code_s));
 
       OCTET_STRING_TO_INT8(mme_code_p, new_mme_code_p->mme_code);
-- 
GitLab