From f29364874272fffc2c28db1f087e948ddbc9c766 Mon Sep 17 00:00:00 2001
From: Lionel Gauthier <lionel.gauthier@eurecom.fr>
Date: Thu, 7 Aug 2014 20:02:48 +0000
Subject: [PATCH] Now should receive attach complete (TODO: GUTI is still
 hardcoded)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5690 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c   | 23 +++++++++++--------
 .../EURECOM-NAS/src/emm/msg/AttachAccept.c    |  3 +++
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c b/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
index 0cb19ad37d3..b4dae2da930 100644
--- a/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
+++ b/openair-cn/NAS/EURECOM-NAS/src/emm/Attach.c
@@ -2309,8 +2309,14 @@ static int _emm_attach_accept(emm_data_context_t *emm_ctx, attach_data_t *data)
     if (emm_ctx->guti_is_new && emm_ctx->old_guti) {
         /* Implicit GUTI reallocation;
          * include the new assigned GUTI in the Attach Accept message  */
+        LOG_TRACE(INFO,"EMM-PROC  - Implicit GUTI reallocation, include the new assigned GUTI in the Attach Accept message");
         emm_sap.u.emm_as.u.establish.UEid.guti = emm_ctx->old_guti;
         emm_sap.u.emm_as.u.establish.new_guti  = emm_ctx->guti;
+    } else if (emm_ctx->guti_is_new && emm_ctx->guti) {
+        /* include the new assigned GUTI in the Attach Accept message  */
+        LOG_TRACE(INFO,"EMM-PROC  - Include the new assigned GUTI in the Attach Accept message");
+        emm_sap.u.emm_as.u.establish.UEid.guti = emm_ctx->guti;
+        emm_sap.u.emm_as.u.establish.new_guti  = emm_ctx->guti;
     } else {
         emm_sap.u.emm_as.u.establish.UEid.guti = emm_ctx->guti;
         emm_sap.u.emm_as.u.establish.new_guti  = NULL;
@@ -2516,13 +2522,12 @@ static int _emm_attach_update(emm_data_context_t *ctx, unsigned int ueid,
     ctx->uea  = uea;
     ctx->uia  = uia;
     ctx->gea  = gea;
-    LOG_TRACE(WARNING, "EMM-PROC  - umts_present %u", umts_present);
-    LOG_TRACE(WARNING, "EMM-PROC  - gprs_present %u", gprs_present);
     ctx->umts_present  = umts_present;
     ctx->gprs_present  = gprs_present;
 
     /* The GUTI if provided by the UE */
     if (guti) {
+        LOG_TRACE(INFO, "EMM-PROC  - GUTI NOT NULL");
         if (ctx->guti == NULL) {
             ctx->guti = (GUTI_t *)malloc(sizeof(GUTI_t));
         }
@@ -2537,20 +2542,20 @@ static int _emm_attach_update(emm_data_context_t *ctx, unsigned int ueid,
         }
         if (ctx->guti != NULL) {
             /* TODO: FIXME */
-            LOG_TRACE(WARNING, "EMM-PROC  - Assign hardcoded PLMN 208.92 and tac 0001 to emm_data_context");
+            LOG_TRACE(WARNING, "EMM-PROC  - Assign GUTI hardcoded PLMN 208.92 and tac 15 to emm_data_context");
             ctx->guti->gummei.plmn.MCCdigit1 = 2;
             ctx->guti->gummei.plmn.MCCdigit2 = 0;
             ctx->guti->gummei.plmn.MCCdigit3 = 8;
             ctx->guti->gummei.plmn.MNCdigit1 = 9;
             ctx->guti->gummei.plmn.MNCdigit2 = 2;
             ctx->guti->gummei.plmn.MNCdigit3 = 15;
+            ctx->tac                         = 15;
+            ctx->guti->gummei.MMEcode        = 29;
+            ctx->guti->gummei.MMEgid         = 30;
+            ctx->guti->m_tmsi                = (uint32_t) ctx;
+            LOG_TRACE(WARNING, "EMM-PROC  - Set ctx->guti_is_new to emm_data_context");
+            ctx->guti_is_new                 = TRUE;
 
-            ctx->guti->gummei.MMEcode = 0;
-            ctx->guti->gummei.MMEgid  = 0;
-
-            ctx->guti->m_tmsi = (uint32_t) ctx;
-
-            ctx->tac          = 1;
         } else {
             LOG_FUNC_RETURN (RETURNerror);
         }
diff --git a/openair-cn/NAS/EURECOM-NAS/src/emm/msg/AttachAccept.c b/openair-cn/NAS/EURECOM-NAS/src/emm/msg/AttachAccept.c
index 393e94197cf..20669028ddb 100644
--- a/openair-cn/NAS/EURECOM-NAS/src/emm/msg/AttachAccept.c
+++ b/openair-cn/NAS/EURECOM-NAS/src/emm/msg/AttachAccept.c
@@ -192,6 +192,9 @@ int encode_attach_accept(attach_accept_msg *attach_accept, uint8_t *buffer, uint
 
     *(buffer + encoded) = (encode_u8_eps_attach_result(&attach_accept->epsattachresult) & 0x0f);
     encoded++;
+#warning "LG TEST override t3412value"
+    attach_accept->t3412value.unit = GPRS_TIMER_UNIT_360S;
+    attach_accept->t3412value.timervalue = 10;
     if ((encode_result = encode_gprs_timer(&attach_accept->t3412value, 0, buffer
          + encoded, len - encoded)) < 0) {        //Return in case of error
         LOG_TRACE(WARNING, "Failed encode_gprs_timer");
-- 
GitLab