Fix for packRICSubscriptionResponse packing problem

Change-Id: I7b5c7dbcf1ae8a2011610edf2819b6358e709d7c
Signed-off-by: Anssi Mannila <anssi.mannila@nokia.com>
diff --git a/e2ap/libe2ap_wrapper/E2AP_if.c b/e2ap/libe2ap_wrapper/E2AP_if.c
index 881e396..32aeeba 100644
--- a/e2ap/libe2ap_wrapper/E2AP_if.c
+++ b/e2ap/libe2ap_wrapper/E2AP_if.c
@@ -193,17 +193,18 @@
                   // This is not used in RIC
 
                 // RICsubsequentAction, OPTIONAL
-                RICsubsequentAction_t* pRICsubsequentAction = calloc(1, sizeof(RICsubsequentAction_t));
-                if (pRICsubsequentAction) {
-                    pRICsubsequentAction->ricSubsequentActionType =
-                      pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType;
-                    pRICsubsequentAction->ricTimeToWait =
-                      pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait;
-                    pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = pRICsubsequentAction;
+                if (pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentActionPresent) {
+                    RICsubsequentAction_t* pRICsubsequentAction = calloc(1, sizeof(RICsubsequentAction_t));
+                    if (pRICsubsequentAction) {
+                        pRICsubsequentAction->ricSubsequentActionType =
+                        pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricSubsequentActionType;
+                        pRICsubsequentAction->ricTimeToWait =
+                        pRICSubscriptionRequest->ricSubscription.ricActionToBeSetupItemIEs.ricActionToBeSetupItem[index].ricSubsequentAction.ricTimeToWait;
+                        pRICaction_ToBeSetup_ItemIEs->value.choice.RICaction_ToBeSetup_Item.ricSubsequentAction = pRICsubsequentAction;
+                    }
+                    else
+                        return e2err_RICSubscriptionRequestAllocRICsubsequentActionFail;
                 }
-                else
-                    return e2err_RICSubscriptionRequestAllocRICsubsequentActionFail;
-
                 ASN_SEQUENCE_ADD(&pRICsubscriptionRequest_IEs->value.choice.RICsubscription.ricAction_ToBeSetup_List.list, pRICaction_ToBeSetup_ItemIEs);
                 index++;
             }
@@ -454,7 +455,7 @@
 
         ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
 
-        // RICaction-NotAdmitted list
+        // RICaction-NotAdmitted list, OPTIONAL
         if (pRICSubscriptionResponse->ricActionNotAdmittedListPresent) {
             pRICsubscriptionResponse_IEs = calloc(1, sizeof(RICsubscriptionResponse_IEs_t));
             if (pRICsubscriptionResponse_IEs) {
@@ -511,8 +512,6 @@
             }
             ASN_SEQUENCE_ADD(&pE2AP_PDU->choice.successfulOutcome.value.choice.RICsubscriptionResponse.protocolIEs.list, pRICsubscriptionResponse_IEs);
         }
-        else
-            return e2err_RICSubscriptionResponseAllocRICActionNotAdmittedListFail;
 
         if (E2encode(pE2AP_PDU, pDataBufferSize, pDataBuffer, pLogBuffer))
             return e2err_OK;
diff --git a/e2ap/libe2ap_wrapper/E2AP_if.h b/e2ap/libe2ap_wrapper/E2AP_if.h
index 1e81852..06a429d 100644
--- a/e2ap/libe2ap_wrapper/E2AP_if.h
+++ b/e2ap/libe2ap_wrapper/E2AP_if.h
@@ -335,7 +335,6 @@
     e2err_RICSubscriptionResponseAllocRICaction_Admitted_ItemIEsFail,
     e2err_RICSubscriptionResponseAllocRICActionAdmittedListFail,
     e2err_RICSubscriptionResponseAllocRICaction_NotAdmitted_ItemIEsFail,
-    e2err_RICSubscriptionResponseAllocRICActionNotAdmittedListFail,
     e2err_RICSubscriptionResponseEncodeFail,
     e2err_RICSubscriptionResponseAllocE2AP_PDUFail,
     e2err_RICSubscriptionFailureAllocRICrequestIDFail,
@@ -415,7 +414,6 @@
     "e2err_RICSubscriptionResponseAllocRICaction_Admitted_ItemIEsFail",
     "e2err_RICSubscriptionResponseAllocRICActionAdmittedListFail",
     "e2err_RICSubscriptionResponseAllocRICaction_NotAdmitted_ItemIEsFail",
-    "e2err_RICSubscriptionResponseAllocRICActionNotAdmittedListFail",
     "e2err_RICSubscriptionResponseEncodeFail",
     "e2err_RICSubscriptionResponseAllocE2AP_PDUFail",
     "e2err_RICSubscriptionFailureAllocRICrequestIDFail",