From 8eee121ea99fd7aed5e34c8d3f2784ff3bb71a15 Mon Sep 17 00:00:00 2001
From: Lionel Gauthier <lionel.gauthier@eurecom.fr>
Date: Fri, 24 Apr 2015 13:21:07 +0000
Subject: [PATCH] NAS NON DELIVERY INDICATION

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7269 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair-cn/S1AP/s1ap_eNB_nas_procedures.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
index c5c5ad7061..4d910c7443 100644
--- a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
+++ b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c
@@ -455,6 +455,10 @@ void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
     /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
     S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %06x\n",
               s1ap_nas_non_delivery_ind->eNB_ue_s1ap_id);
+    MSC_LOG_EVENT(
+      MSC_S1AP_ENB,
+      MSC_AS_TIME_FMT" Sent of NAS_NON_DELIVERY_IND to MME failed, no context for eNB_ue_s1ap_id %06x",
+      s1ap_nas_non_delivery_ind->eNB_ue_s1ap_id);
     return;
   }
 
@@ -465,13 +469,6 @@ void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
   message.procedureCode = S1ap_ProcedureCode_id_NASNonDeliveryIndication;
 
   nas_non_delivery_p = &message.msg.s1ap_NASNonDeliveryIndication_IEs;
-
-  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
-    S1AP_ERROR("Failed to encode NAS NON delivery indication\n");
-    /* Encode procedure has failed... */
-    return;
-  }
-
   nas_non_delivery_p->eNB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id;
   nas_non_delivery_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
   nas_non_delivery_p->nas_pdu.buf    = s1ap_nas_non_delivery_ind->nas_pdu.buffer;
@@ -481,6 +478,16 @@ void s1ap_eNB_nas_non_delivery_ind(instance_t instance,
   nas_non_delivery_p->cause.present = S1ap_Cause_PR_radioNetwork;
   nas_non_delivery_p->cause.choice.radioNetwork = S1ap_CauseRadioNetwork_radio_connection_with_ue_lost;
 
+  if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
+    S1AP_ERROR("Failed to encode NAS NON delivery indication\n");
+    /* Encode procedure has failed... */
+    MSC_LOG_EVENT(
+      MSC_S1AP_ENB,
+      MSC_AS_TIME_FMT" Sent of NAS_NON_DELIVERY_IND to MME failed (encoding)");
+    return;
+  }
+
+
   MSC_LOG_TX_MESSAGE(
     MSC_S1AP_ENB,
     MSC_S1AP_MME,
-- 
GitLab