Added IndicationMessage 15/4915/2
authorsjana <sj492a@att.com>
Fri, 23 Oct 2020 19:52:48 +0000 (12:52 -0700)
committersjana <sj492a@att.com>
Fri, 23 Oct 2020 20:14:08 +0000 (13:14 -0700)
Issue-ID: RICAPP-120

Signed-off-by: sjana <sj492a@att.com>
Change-Id: I30c11b6fa9e1556f170e60bb93e9288c99be96ec

src/xapp-asn/e2ap/e2ap_control_helper.hpp [deleted file]
src/xapp-asn/e2ap/e2ap_control_response.cc [deleted file]
src/xapp-asn/e2ap/e2ap_control_response.hpp [deleted file]
src/xapp-asn/e2ap/e2ap_indication.hpp
src/xapp-asn/e2ap/e2ap_indication_helper.hpp [deleted file]
src/xapp-asn/e2sm/e2sm_indication.cc
src/xapp-asn/e2sm/e2sm_indication.hpp
src/xapp-mgmt/msgs_proc.cc
test/test_e2sm.h
test/test_subs.h

diff --git a/src/xapp-asn/e2ap/e2ap_control_helper.hpp b/src/xapp-asn/e2ap/e2ap_control_helper.hpp
deleted file mode 100644 (file)
index d01013e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-==================================================================================
-
-        Copyright (c) 2019-2020 AT&T Intellectual Property.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-/*
- * ric_indication.h
- *
- *  Created on: Jul 11, 2019
- *      Author: sjana, Ashwin Sridharan
- */
-
-#ifndef CONTROL_HELPER_H
-#define CONTROL_HELPER_H
-
-// control and indication helper objects are very similar and can be merged into one
-// currently leaving them as two distnict entities till final design becomes clear
-
-typedef struct ric_control_helper ric_control_helper;
-
-struct ric_control_helper{
-  ric_control_helper(void):req_id(1), req_seq_no(1), func_id(0), action_id(1), control_ack(-1), cause(0), sub_cause(0), control_status(1), control_msg(0), control_msg_size(0), control_header(0), control_header_size(0), call_process_id(0), call_process_id_size(0){};
-  
-  long int req_id, req_seq_no, func_id, action_id,  control_ack, cause, sub_cause, control_status;
-  
-  unsigned char* control_msg;
-  size_t control_msg_size;
-  
-  unsigned char* control_header;
-  size_t control_header_size;
-  
-  unsigned char *call_process_id;
-  size_t call_process_id_size;
-  
-};
-
-#endif
diff --git a/src/xapp-asn/e2ap/e2ap_control_response.cc b/src/xapp-asn/e2ap/e2ap_control_response.cc
deleted file mode 100644 (file)
index 6b7c9b5..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
-==================================================================================
-
-        Copyright (c) 2019-2020 AT&T Intellectual Property.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
- */
-/*
- * ric_control_response.c
- *
- *  Created on: Jul 11, 2019
- *      Author: sjana, Ashwin Sridharan
- */
-
-#include "e2ap_control_response.hpp"
-
-// Set up the initiating message and also allocate protocolIEs in container
-// Note : this bypasses requirement to use ASN_SEQUENCE_ADD. We can directly
-// assign pointers to the array in ProtocolIE. However, this also leaves us on the
-// hook to manually clear the memory
-
-ric_control_response::ric_control_response(void){
-
-       e2ap_pdu_obj = 0;
-       e2ap_pdu_obj = (E2AP_PDU_t * )calloc(1, sizeof(E2AP_PDU_t));
-       assert(e2ap_pdu_obj != 0);
-
-       successMsg = 0;
-       successMsg = (SuccessfulOutcome_t * )calloc(1, sizeof(SuccessfulOutcome_t));
-       assert(successMsg != 0);
-
-       successMsg->procedureCode = ProcedureCode_id_RICcontrol;
-       successMsg->criticality = Criticality_reject;
-       successMsg->value.present = SuccessfulOutcome__value_PR_RICcontrolAcknowledge;
-
-
-       unsuccessMsg = 0;
-       unsuccessMsg = (UnsuccessfulOutcome_t * )calloc(1, sizeof(UnsuccessfulOutcome_t));
-       assert(unsuccessMsg != 0);
-
-
-       unsuccessMsg->procedureCode = ProcedureCode_id_RICcontrol;
-       unsuccessMsg->criticality = Criticality_reject;
-       unsuccessMsg->value.present = UnsuccessfulOutcome__value_PR_RICcontrolFailure;
-
-       IE_array = 0;
-       IE_array = (RICcontrolAcknowledge_IEs_t *)calloc(NUM_CONTROL_ACKNOWLEDGE_IES, sizeof(RICcontrolAcknowledge_IEs_t));
-       assert(IE_array != 0);
-
-       RICcontrolAcknowledge_t * ric_acknowledge = &(successMsg->value.choice.RICcontrolAcknowledge);
-       for(int i = 0; i < NUM_CONTROL_ACKNOWLEDGE_IES; i++){
-               ASN_SEQUENCE_ADD(&(ric_acknowledge->protocolIEs), &(IE_array[i]));
-       }
-
-
-       IE_failure_array = 0;
-       IE_failure_array = (RICcontrolFailure_IEs_t *)calloc(NUM_CONTROL_FAILURE_IES, sizeof(RICcontrolFailure_IEs_t));
-       assert(IE_failure_array != 0);
-
-       RICcontrolFailure_t * ric_failure = &(unsuccessMsg->value.choice.RICcontrolFailure);
-       for(int i = 0; i < NUM_CONTROL_FAILURE_IES; i++){
-               ASN_SEQUENCE_ADD(&(ric_failure->protocolIEs), &(IE_failure_array[i]));
-       }
-
-};
-
-
-// Clear assigned protocolIE list from RIC control_request IE container
-ric_control_response::~ric_control_response(void){
-
-       mdclog_write(MDCLOG_DEBUG, "Freeing E2AP Control Response object memory");
-
-       RICcontrolAcknowledge_t * ric_acknowledge = &(successMsg->value.choice.RICcontrolAcknowledge);
-       for(int i  = 0; i < ric_acknowledge->protocolIEs.list.size; i++){
-               ric_acknowledge->protocolIEs.list.array[i] = 0;
-       }
-       if (ric_acknowledge->protocolIEs.list.size > 0){
-               free(ric_acknowledge->protocolIEs.list.array);
-               ric_acknowledge->protocolIEs.list.array = 0;
-               ric_acknowledge->protocolIEs.list.count = 0;
-       }
-
-       RICcontrolFailure_t * ric_failure = &(unsuccessMsg->value.choice.RICcontrolFailure);
-       for(int i  = 0; i < ric_failure->protocolIEs.list.size; i++){
-               ric_failure->protocolIEs.list.array[i] = 0;
-       }
-       if (ric_failure->protocolIEs.list.size > 0){
-               free(ric_failure->protocolIEs.list.array);
-               ric_failure->protocolIEs.list.array = 0;
-               ric_failure->protocolIEs.list.count = 0;
-       }
-
-       free(IE_array);
-       free(IE_failure_array);
-       free(successMsg);
-       free(unsuccessMsg);
-
-       e2ap_pdu_obj->choice.initiatingMessage = 0;
-       e2ap_pdu_obj->present = E2AP_PDU_PR_initiatingMessage;
-
-       ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, e2ap_pdu_obj);
-       mdclog_write(MDCLOG_DEBUG, "Freed E2AP Control Response object mempory");
-}
-
-
-bool ric_control_response::encode_e2ap_control_response(unsigned char *buf, size_t *size, ric_control_helper & dinput, bool is_success){
-
-       bool res;
-       if (is_success){
-               res = set_fields(successMsg, dinput);
-       }
-       else{
-               res = set_fields(unsuccessMsg, dinput);
-       }
-
-       if (!res){
-               return false;
-       }
-
-
-       if (is_success){
-               e2ap_pdu_obj->choice.successfulOutcome = successMsg;
-               e2ap_pdu_obj->present = E2AP_PDU_PR_successfulOutcome ;
-       }
-       else{
-               e2ap_pdu_obj->choice.unsuccessfulOutcome = unsuccessMsg;
-               e2ap_pdu_obj->present = E2AP_PDU_PR_unsuccessfulOutcome ;
-
-       }
-
-       //xer_fprint(stdout, &asn_DEF_E2AP_PDU, e2ap_pdu_obj);
-
-       int ret_constr = asn_check_constraints(&asn_DEF_E2AP_PDU, (void *) e2ap_pdu_obj, errbuf, &errbuf_len);
-       if(ret_constr){
-               error_string.assign(errbuf, errbuf_len);
-               error_string = "Constraints failed for encoding control response. Reason = " + error_string;
-               return false;
-       }
-
-       asn_enc_rval_t retval = asn_encode_to_buffer(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, e2ap_pdu_obj, buf, *size);
-
-       if(retval.encoded == -1){
-               error_string.assign(strerror(errno));
-               return false;
-       }
-       else {
-               if(*size < retval.encoded){
-                       std::stringstream ss;
-                       ss  <<"Error encoding E2AP Control response . Reason =  encoded pdu size " << retval.encoded << " exceeds buffer size " << *size << std::endl;
-                       error_string = ss.str();
-                       return false;
-               }
-       }
-
-       *size = retval.encoded;
-       return true;
-
-}
-
-bool ric_control_response::set_fields(SuccessfulOutcome_t *successMsg, ric_control_helper &dinput){
-       unsigned int ie_index;
-
-       if (successMsg == 0){
-               error_string = "Invalid reference for E2AP Control Acknowledge in set_fields";
-               return false;
-       }
-
-       // for(i = 0; i < NUM_CONTROL_ACKNOWLEDGE_IES;i++){
-       //   memset(&(IE_array[i]), 0, sizeof(RICcontrolAcknowledge_IEs_t));
-       // }
-
-       //RICcontrolAcknowledge_t * ric_acknowledge = &(successMsg->value.choice.RICcontrolAcknowledge);
-       //ric_acknowledge->protocolIEs.list.count = 0;
-
-       ie_index = 0;
-       RICcontrolAcknowledge_IEs_t *ies_ricreq = &IE_array[ie_index];
-       ies_ricreq->criticality = Criticality_reject;
-       ies_ricreq->id = ProtocolIE_ID_id_RICrequestID;
-       ies_ricreq->value.present = RICcontrolAcknowledge_IEs__value_PR_RICrequestID;
-       RICrequestID_t *ricrequest_ie = &ies_ricreq->value.choice.RICrequestID;
-       ricrequest_ie->ricRequestorID = dinput.req_id;
-       //ricrequest_ie->ricRequestSequenceNumber = dinput.req_seq_no;
-       //ASN_SEQUENCE_ADD(&(ric_acknowledge->protocolIEs), ies_ricreq);
-
-       ie_index = 1;
-       RICcontrolAcknowledge_IEs_t *ies_ranfunc = &IE_array[ie_index];
-       ies_ranfunc->criticality = Criticality_reject;
-       ies_ranfunc->id = ProtocolIE_ID_id_RANfunctionID;
-       ies_ranfunc->value.present = RICcontrolAcknowledge_IEs__value_PR_RANfunctionID;
-       RANfunctionID_t *ranfunction_ie = &ies_ranfunc->value.choice.RANfunctionID;
-       *ranfunction_ie = dinput.func_id;
-       //ASN_SEQUENCE_ADD(&(ric_acknowledge->protocolIEs), ies_ranfunc);
-
-       // ie_index = 2;
-       // RICcontrolAcknowledge_IEs_t *ies_riccallprocessid = &IE_array[ie_index];
-       // ies_riccallprocessid->criticality = Criticality_reject;
-       // ies_riccallprocessid->id = ProtocolIE_ID_id_RICcallProcessID;
-       // ies_riccallprocessid->value.present = RICcontrolAcknowledge_IEs__value_PR_RICcallProcessID;
-       // RICcallProcessID_t *riccallprocessid_ie = &ies_riccallprocessid->value.choice.RICcallProcessID;
-       // riccallprocessid_ie->buf = dinput.call_process_id;
-       // riccallprocessid_ie->size = dinput.call_process_id_size;
-       // ASN_SEQUENCE_ADD(&(ric_acknowledge->protocolIEs), ies_riccallprocessid);
-
-       ie_index = 2;
-       RICcontrolAcknowledge_IEs_t *ies_ric_cause = &IE_array[ie_index];
-       ies_ric_cause->criticality = Criticality_reject;
-       ies_ric_cause->id = ProtocolIE_ID_id_RICcontrolStatus;
-       ies_ric_cause->value.present = RICcontrolAcknowledge_IEs__value_PR_RICcontrolStatus;
-       ies_ric_cause->value.choice.RICcontrolStatus = dinput.control_status;
-       //ASN_SEQUENCE_ADD(&(ric_acknowledge->protocolIEs), ies_ric_cause);
-
-       return true;
-
-};
-
-bool ric_control_response::set_fields(UnsuccessfulOutcome_t *unsuccessMsg, ric_control_helper &dinput){
-       unsigned int ie_index;
-
-       if (unsuccessMsg == 0){
-               error_string = "Invalid reference for E2AP Control Failure in set_fields";
-               return false;
-       }
-
-       // for(i = 0; i < NUM_CONTROL_FAILURE_IES;i++){
-       //   memset(&(IE_failure_array[i]), 0, sizeof(RICcontrolFailure_IEs_t));
-       // }
-
-       //RICcontrolFailure_t * ric_failure = &(unsuccessMsg->value.choice.RICcontrolFailure);
-       //ric_failure->protocolIEs.list.count = 0;
-
-       ie_index = 0;
-       RICcontrolFailure_IEs_t *ies_ricreq = &IE_failure_array[ie_index];
-       ies_ricreq->criticality = Criticality_reject;
-       ies_ricreq->id = ProtocolIE_ID_id_RICrequestID;
-       ies_ricreq->value.present = RICcontrolFailure_IEs__value_PR_RICrequestID;
-       RICrequestID_t *ricrequest_ie = &(ies_ricreq->value.choice.RICrequestID);
-       ricrequest_ie->ricRequestorID = dinput.req_id;
-       //ricrequest_ie->ricRequestSequenceNumber = dinput.req_seq_no;
-       //ASN_SEQUENCE_ADD(&(ric_failure->protocolIEs), ies_ricreq);
-
-       ie_index = 1;
-       RICcontrolFailure_IEs_t *ies_ranfunc = &IE_failure_array[ie_index];
-       ies_ranfunc->criticality = Criticality_reject;
-       ies_ranfunc->id = ProtocolIE_ID_id_RANfunctionID;
-       ies_ranfunc->value.present = RICcontrolFailure_IEs__value_PR_RANfunctionID;
-       RANfunctionID_t *ranfunction_ie = &(ies_ranfunc->value.choice.RANfunctionID);
-       *ranfunction_ie = dinput.func_id;
-       //ASN_SEQUENCE_ADD(&(ric_failure->protocolIEs), ies_ranfunc);
-
-       // ie_index = 2;
-       // RICcontrolFailure_IEs_t *ies_riccallprocessid = &IE_failure_array[i];
-       // ies_riccallprocessid->criticality = Criticality_reject;
-       // ies_riccallprocessid->id = ProtocolIE_ID_id_RICcallProcessID;
-       // ies_riccallprocessid->value.present = RICcontrolFailure_IEs__value_PR_RICcallProcessID;
-       // RICcallProcessID_t *riccallprocessid_ie = &(ies_riccallprocessid->value.choice.RICcallProcessID);
-       // riccallprocessid_ie->buf = dinput.call_process_id;
-       // riccallprocessid_ie->size = dinput.call_process_id_size;
-       // ASN_SEQUENCE_ADD(&(ric_failure->protocolIEs), ies_riccallprocessid);
-
-       ie_index = 2;
-       RICcontrolFailure_IEs_t *ies_ric_cause = &IE_failure_array[ie_index];
-       ies_ric_cause->criticality = Criticality_ignore;
-       ies_ric_cause->id = ProtocolIE_ID_id_Cause;
-       ies_ric_cause->value.present = RICcontrolFailure_IEs__value_PR_Cause;
-       Cause_t * ric_cause = &(ies_ric_cause->value.choice.Cause);
-       ric_cause->present = (Cause_PR)dinput.cause;
-
-       switch(dinput.cause){
-       case Cause_PR_ricService:
-               ric_cause->choice.ricService = dinput.sub_cause;
-               break;
-       case Cause_PR_transport:
-               ric_cause->choice.transport = dinput.sub_cause;
-               break;
-       case Cause_PR_protocol:
-               ric_cause->choice.protocol= dinput.sub_cause;
-               break;
-       case Cause_PR_misc:
-               ric_cause->choice.misc = dinput.sub_cause;
-               break;
-       case Cause_PR_ricRequest:
-               ric_cause->choice.ricRequest = dinput.sub_cause;
-               break;
-       default:
-               std::cout <<"Error ! Illegal cause enum" << dinput.cause << std::endl;
-               return false;
-       }
-
-       //ASN_SEQUENCE_ADD(&(ric_failure->protocolIEs), ies_ric_cause);
-       return true;
-
-};
-
-
-
-
-bool ric_control_response:: get_fields(SuccessfulOutcome_t * success_msg,  ric_control_helper &dout)
-{
-       if (success_msg == 0){
-               error_string = "Invalid reference for E2AP Control Acknowledge message in get_fields";
-               return false;
-       }
-
-
-       for(int edx = 0; edx < success_msg->value.choice.RICcontrolAcknowledge.protocolIEs.list.count; edx++) {
-               RICcontrolAcknowledge_IEs_t *memb_ptr = success_msg->value.choice.RICcontrolAcknowledge.protocolIEs.list.array[edx];
-
-               switch(memb_ptr->id)
-               {
-
-               case (ProtocolIE_ID_id_RICcallProcessID):
-                       dout.call_process_id =  memb_ptr->value.choice.RICcallProcessID.buf;
-               dout.call_process_id_size = memb_ptr->value.choice.RICcallProcessID.size;
-               break;
-
-               case (ProtocolIE_ID_id_RICrequestID):
-                       dout.req_id = memb_ptr->value.choice.RICrequestID.ricRequestorID;
-               //dout.req_seq_no = memb_ptr->value.choice.RICrequestID.ricRequestSequenceNumber;
-               break;
-
-               case (ProtocolIE_ID_id_RANfunctionID):
-                       dout.func_id = memb_ptr->value.choice.RANfunctionID;
-               break;
-
-               case (ProtocolIE_ID_id_Cause):
-                       dout.control_status = memb_ptr->value.choice.RICcontrolStatus;
-               break;
-
-               }
-
-       }
-
-       return true;
-
-}
-
-
-bool ric_control_response:: get_fields(UnsuccessfulOutcome_t * unsuccess_msg,  ric_control_helper &dout)
-{
-       if (unsuccess_msg == 0){
-               error_string = "Invalid reference for E2AP Control Failure message in get_fields";
-               return false;
-       }
-
-
-       for(int edx = 0; edx < unsuccess_msg->value.choice.RICcontrolFailure.protocolIEs.list.count; edx++) {
-               RICcontrolFailure_IEs_t *memb_ptr = unsuccess_msg->value.choice.RICcontrolFailure.protocolIEs.list.array[edx];
-
-               switch(memb_ptr->id)
-               {
-
-               case (ProtocolIE_ID_id_RICcallProcessID):
-                       dout.call_process_id =  memb_ptr->value.choice.RICcallProcessID.buf;
-               dout.call_process_id_size = memb_ptr->value.choice.RICcallProcessID.size;
-               break;
-
-               case (ProtocolIE_ID_id_RICrequestID):
-                       dout.req_id = memb_ptr->value.choice.RICrequestID.ricRequestorID;
-               //dout.req_seq_no = memb_ptr->value.choice.RICrequestID.ricRequestSequenceNumber;
-               break;
-
-               case (ProtocolIE_ID_id_RANfunctionID):
-                       dout.func_id = memb_ptr->value.choice.RANfunctionID;
-               break;
-
-
-               case (ProtocolIE_ID_id_Cause):
-                       dout.cause = memb_ptr->value.choice.Cause.present;
-               switch(dout.cause){
-               case  Cause_PR_ricService :
-                       dout.sub_cause = memb_ptr->value.choice.Cause.choice.ricService;
-                       break;
-
-               case Cause_PR_transport :
-                       dout.sub_cause = memb_ptr->value.choice.Cause.choice.transport;
-                       break;
-
-               case  Cause_PR_protocol :
-                       dout.sub_cause = memb_ptr->value.choice.Cause.choice.protocol;
-                       break;
-
-               case Cause_PR_misc :
-                       dout.sub_cause = memb_ptr->value.choice.Cause.choice.misc;
-                       break;
-
-               case Cause_PR_ricRequest :
-                       dout.sub_cause = memb_ptr->value.choice.Cause.choice.ricRequest;
-                       break;
-
-               default:
-                       dout.sub_cause = -1;
-                       break;
-               }
-
-               default:
-                       break;
-               }
-
-       }
-
-       return true;
-
-}
-
diff --git a/src/xapp-asn/e2ap/e2ap_control_response.hpp b/src/xapp-asn/e2ap/e2ap_control_response.hpp
deleted file mode 100644 (file)
index 1d6af17..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-==================================================================================
-
-        Copyright (c) 2019-2020 AT&T Intellectual Property.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-/*
- * ric_indication.h
- *
- *  Created on: Jul 11, 2019
- *      Author: sjana, Ashwin Sridharan
- */
-
-#ifndef E2AP_RIC_CONTROL_RESPONSE_H_
-#define E2AP_RIC_CONTROL_RESPONSE_H_
-
-  
-#include <iostream>
-#include <errno.h>
-#include <mdclog/mdclog.h>
-#include <sstream>
-#include <E2AP-PDU.h>
-#include <SuccessfulOutcome.h>
-#include <UnsuccessfulOutcome.h>
-#include <RICcontrolAcknowledge.h>
-#include <RICcontrolFailure.h>
-#include <ProtocolIE-Field.h>
-#include "e2ap_control_helper.hpp"
-
-#define NUM_CONTROL_ACKNOWLEDGE_IES 3
-#define NUM_CONTROL_FAILURE_IES 3
-
-  
-class ric_control_response{
-    
-public:
-  ric_control_response(void);
-  ~ric_control_response(void);
-  
-  bool encode_e2ap_control_response(unsigned char *, size_t *,  ric_control_helper &, bool);
-
-
-  bool set_fields(SuccessfulOutcome_t *, ric_control_helper &);
-  bool get_fields(SuccessfulOutcome_t *, ric_control_helper &);
-
-  bool set_fields(UnsuccessfulOutcome_t *, ric_control_helper &);
-  bool get_fields(UnsuccessfulOutcome_t *, ric_control_helper &);
-  
-  std::string get_error(void) const {return error_string ; };
-
-private:
-  
-  E2AP_PDU_t * e2ap_pdu_obj;
-  SuccessfulOutcome_t * successMsg;
-  UnsuccessfulOutcome_t * unsuccessMsg;
-  
-  RICcontrolAcknowledge_IEs_t *IE_array;
-  RICcontrolFailure_IEs_t *IE_failure_array;
-  
-  std::string error_string;
-  
-  char errbuf[128];
-  size_t errbuf_len = 128;
-};
-
-
-#endif /* E2AP_RIC_CONTROL_RESPONSE_H_ */
index 4848598..87f08dc 100644 (file)
@@ -72,9 +72,7 @@ template <typename E2SMIndicationHeader, typename E2SMIndicationMessage>
 class E2APIndication{
 
 public:
 class E2APIndication{
 
 public:
-       E2APIndication();
-       E2APIndication(unsigned char *, size_t *, bool&);
-       ~E2APIndication(void);
+
        class IndicationIEs{
                private:
                        long int ricRequestorID, ranFunctionID, ricActionID, ricIndicationSN, ricIndicationType;
        class IndicationIEs{
                private:
                        long int ricRequestorID, ranFunctionID, ricActionID, ricIndicationSN, ricIndicationType;
@@ -87,28 +85,58 @@ public:
                        unsigned char ricCallProcessId[IE_SIZE];
                        size_t ricCallProcessId_size = IE_SIZE;
 
                        unsigned char ricCallProcessId[IE_SIZE];
                        size_t ricCallProcessId_size = IE_SIZE;
 
+                       bool is_callProcessID;
+
                public:
                public:
-                       IndicationIEs(void) : ricRequestorID(0), ranFunctionID(0), ricActionID(0),ricIndicationSN(0), ricIndicationType(0){};
+                       IndicationIEs(void) : ricRequestorID(0), ranFunctionID(0), ricActionID(0),ricIndicationSN(0), ricIndicationType(0),is_callProcessID(false){};
                        void* get_ricIndicationMessage(){return this->ricIndicationMessage; };
                        void* get_ricIndicationHeader(){return this->ricIndicationHeader; };
                        void* get_ricCallProcessId(){return this->ricCallProcessId;};
 
                        void* get_ricIndicationMessage(){return this->ricIndicationMessage; };
                        void* get_ricIndicationHeader(){return this->ricIndicationHeader; };
                        void* get_ricCallProcessId(){return this->ricCallProcessId;};
 
-                       size_t get_ricIndicationMessageSize(){return this->ricIndicationMessage_size; };
-                       size_t get_ricIndicationHeaderSize(){return this->ricIndicationHeader_size; };
-                       size_t get_ricCallProcessIdSize(){return this->ricCallProcessId_size;};
+                       size_t get_ricIndicationMessage_size(){return this->ricIndicationMessage_size; };
+                       size_t get_ricIndicationHeader_size(){return this->ricIndicationHeader_size; };
+                       size_t get_ricCallProcessId_size(){return this->ricCallProcessId_size;};
 
                        long int get_ricRequestorID(){return this->ricRequestorID;};
                        long int get_ranFunctionID(){return this->ranFunctionID;};
                        long int get_ricActionID(){return this->ricActionID;};
 
                        long int get_ricRequestorID(){return this->ricRequestorID;};
                        long int get_ranFunctionID(){return this->ranFunctionID;};
                        long int get_ricActionID(){return this->ricActionID;};
+                       long int get_ricIndicationType(){return this->ricIndicationType;}
                        long int get_ricIndicationSN(){return this->ricIndicationSN;};
 
                        long int get_ricIndicationSN(){return this->ricIndicationSN;};
 
-                       IndicationIEs& set_ricIndicationHeader(unsigned char* header, size_t header_size){
-                               memcpy(ricIndicationHeader,header,header_size); ricIndicationHeader_size = header_size; return *this;
+                       bool get_is_callProcessID(){return this->is_callProcessID;};
+
+                       IndicationIEs& set_ricIndicationHeader(E2SMIndicationHeader e2smObj){
+                               bool res = e2smObj.encode(&(this->ricIndicationHeader)[0],&this->ricIndicationHeader_size);
+                               if(!res){
+                                               mdclog_write(MDCLOG_ERR, "Failed to encode: %s","RIC Indication Header");
+                                               mdclog_write(MDCLOG_ERR, "Error during encode: %s",e2smObj.get_error());
+
+                                       } else {
+                                                mdclog_write(MDCLOG_INFO, "Successfully encoded: %s","RIC Indication Header");
+                               }
+                                       return *this;
+                       }
+                       IndicationIEs& set_ricIndicationMessage(E2SMIndicationMessage e2smObj){
+                               bool res = e2smObj.encode(&(this->ricIndicationMessage)[0],&this->ricIndicationMessage_size);
+                               if(!res){
+                                                       mdclog_write(MDCLOG_ERR, "Failed to encode: %s","RIC Indication Message");
+                                                       mdclog_write(MDCLOG_ERR, "Error during encode: %s",e2smObj.get_error());
+                                               } else {
+                                                   mdclog_write(MDCLOG_INFO, "Successfully encoded: %s","RIC Indication Message");
+                                               }
+
+                               return *this;
+
                        }
                        }
+
+                       IndicationIEs& set_ricIndicationHeader(unsigned char* header, size_t header_size){
+                                                       memcpy(ricIndicationHeader,header,header_size); ricIndicationHeader_size = header_size; return *this;
+                                               }
                        IndicationIEs& set_ricIndicationMessage(unsigned char* message, size_t message_size){
                        IndicationIEs& set_ricIndicationMessage(unsigned char* message, size_t message_size){
-                               memcpy(ricIndicationHeader,message,message_size); ricIndicationMessage_size = message_size; return *this;}
+                                                       memcpy(ricIndicationHeader,message,message_size); ricIndicationMessage_size = message_size; return *this;}
 
                        IndicationIEs& set_ricCallProcessID(unsigned char* callproc, size_t callproc_size){
 
                        IndicationIEs& set_ricCallProcessID(unsigned char* callproc, size_t callproc_size){
+                               is_callProcessID = true;
                                memcpy(ricCallProcessId, callproc, callproc_size); ricCallProcessId_size = callproc_size;
                                return *this;
                        }
                                memcpy(ricCallProcessId, callproc, callproc_size); ricCallProcessId_size = callproc_size;
                                return *this;
                        }
@@ -122,6 +150,9 @@ public:
 
        };
 
 
        };
 
+   E2APIndication(IndicationIEs&);
+   E2APIndication(unsigned char *, size_t *);
+  ~E2APIndication(void);
   IndicationIEs getIndicationIEs(){ return *_indicationIEs.get(); }
 
   std::string get_error(void) const {return _error_string ; };
   IndicationIEs getIndicationIEs(){ return *_indicationIEs.get(); }
 
   std::string get_error(void) const {return _error_string ; };
@@ -145,7 +176,7 @@ private:
 };
 
 template<typename T1, typename T2>
 };
 
 template<typename T1, typename T2>
-E2APIndication<T1,T2>::E2APIndication(){
+E2APIndication<T1,T2>::E2APIndication(IndicationIEs& ieObj){
 
   ricIndicationIEs_Count = 8;
 
 
   ricIndicationIEs_Count = 8;
 
@@ -165,17 +196,19 @@ E2APIndication<T1,T2>::E2APIndication(){
   e2ap_pdu_obj->choice.initiatingMessage = initMsg;
 
   _indicationIEs = std::make_unique<IndicationIEs>();
   e2ap_pdu_obj->choice.initiatingMessage = initMsg;
 
   _indicationIEs = std::make_unique<IndicationIEs>();
+  *_indicationIEs = ieObj;
 
 };
 template<typename T1, typename T2>
 
 };
 template<typename T1, typename T2>
-E2APIndication<T1,T2>::E2APIndication(unsigned char *buf, size_t *size, bool &status){
+E2APIndication<T1,T2>::E2APIndication(unsigned char *buf, size_t *size){
          e2ap_pdu_obj = 0;
          initMsg = 0;
          IE_array = 0;
 
          _indicationIEs = std::make_unique<IndicationIEs>();
          e2ap_pdu_obj = 0;
          initMsg = 0;
          IE_array = 0;
 
          _indicationIEs = std::make_unique<IndicationIEs>();
-          status =  this->decode(buf, size);
-
+          bool status =  this->decode(buf, size);
+          if(!status)
+                  throw "E2AP Indication Decode Failed: "+this->get_error();
 }
 
 
 }
 
 
@@ -331,7 +364,7 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_ricreq->id = ProtocolIE_ID_id_RICrequestID;
   ies_ricreq->value.present = RICindication_IEs__value_PR_RICrequestID;
   RICrequestID_t *ricrequest_ie = &ies_ricreq->value.choice.RICrequestID;
   ies_ricreq->id = ProtocolIE_ID_id_RICrequestID;
   ies_ricreq->value.present = RICindication_IEs__value_PR_RICrequestID;
   RICrequestID_t *ricrequest_ie = &ies_ricreq->value.choice.RICrequestID;
-  ricrequest_ie->ricRequestorID = _indicationIEs->ricRequestorID;
+  ricrequest_ie->ricRequestorID = _indicationIEs->get_ricRequestorID();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 1;
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 1;
@@ -340,7 +373,7 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_ranfunc->id = ProtocolIE_ID_id_RANfunctionID;
   ies_ranfunc->value.present = RICindication_IEs__value_PR_RANfunctionID;
   RANfunctionID_t *ranfunction_ie = &ies_ranfunc->value.choice.RANfunctionID;
   ies_ranfunc->id = ProtocolIE_ID_id_RANfunctionID;
   ies_ranfunc->value.present = RICindication_IEs__value_PR_RANfunctionID;
   RANfunctionID_t *ranfunction_ie = &ies_ranfunc->value.choice.RANfunctionID;
-  *ranfunction_ie = _indicationIEs->ranFunctionID;
+  *ranfunction_ie = _indicationIEs->get_ranFunctionID();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 2;
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 2;
@@ -349,7 +382,7 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_actid->id = ProtocolIE_ID_id_RICactionID;
   ies_actid->value.present = RICindication_IEs__value_PR_RICactionID;
   RICactionID_t *ricaction_ie = &ies_actid->value.choice.RICactionID;
   ies_actid->id = ProtocolIE_ID_id_RICactionID;
   ies_actid->value.present = RICindication_IEs__value_PR_RICactionID;
   RICactionID_t *ricaction_ie = &ies_actid->value.choice.RICactionID;
-  *ricaction_ie = _indicationIEs->ricActionID;
+  *ricaction_ie = _indicationIEs->get_ricActionID();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 3;
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 3;
@@ -358,7 +391,7 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_ricsn->id = ProtocolIE_ID_id_RICindicationSN;
   ies_ricsn->value.present = RICindication_IEs__value_PR_RICindicationSN;
   RICindicationSN_t *ricsn_ie = &ies_ricsn->value.choice.RICindicationSN;
   ies_ricsn->id = ProtocolIE_ID_id_RICindicationSN;
   ies_ricsn->value.present = RICindication_IEs__value_PR_RICindicationSN;
   RICindicationSN_t *ricsn_ie = &ies_ricsn->value.choice.RICindicationSN;
-  *ricsn_ie = _indicationIEs->ricIndicationSN;
+  *ricsn_ie = _indicationIEs->get_ricIndicationSN();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
 
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
 
@@ -368,7 +401,7 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_indtyp->id = ProtocolIE_ID_id_RICindicationType;
   ies_indtyp->value.present = RICindication_IEs__value_PR_RICindicationType;
   RICindicationType_t *rictype_ie = &ies_indtyp->value.choice.RICindicationType;
   ies_indtyp->id = ProtocolIE_ID_id_RICindicationType;
   ies_indtyp->value.present = RICindication_IEs__value_PR_RICindicationType;
   RICindicationType_t *rictype_ie = &ies_indtyp->value.choice.RICindicationType;
-  *rictype_ie = _indicationIEs->ricIndicationType;
+  *rictype_ie = _indicationIEs->get_ricIndicationType();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 5;
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 5;
@@ -377,8 +410,8 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_richead->id = ProtocolIE_ID_id_RICindicationHeader;
   ies_richead->value.present = RICindication_IEs__value_PR_RICindicationHeader;
   RICindicationHeader_t *richeader_ie = &ies_richead->value.choice.RICindicationHeader;
   ies_richead->id = ProtocolIE_ID_id_RICindicationHeader;
   ies_richead->value.present = RICindication_IEs__value_PR_RICindicationHeader;
   RICindicationHeader_t *richeader_ie = &ies_richead->value.choice.RICindicationHeader;
-  richeader_ie->buf = _indicationIEs->ricIndicationHeader;
-  richeader_ie->size = _indicationIEs->ricIndicationHeader_size;
+  richeader_ie->buf = (uint8_t*)_indicationIEs->get_ricIndicationHeader();
+  richeader_ie->size = _indicationIEs->get_ricIndicationHeader_size();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 6;
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
   ie_index = 6;
@@ -387,21 +420,21 @@ bool E2APIndication<T1,T2>::setfields(InitiatingMessage_t *initMsg){
   ies_indmsg->id = ProtocolIE_ID_id_RICindicationMessage;
   ies_indmsg->value.present = RICindication_IEs__value_PR_RICindicationMessage;
   RICindicationMessage_t *ricmsg_ie = &ies_indmsg->value.choice.RICindicationMessage;
   ies_indmsg->id = ProtocolIE_ID_id_RICindicationMessage;
   ies_indmsg->value.present = RICindication_IEs__value_PR_RICindicationMessage;
   RICindicationMessage_t *ricmsg_ie = &ies_indmsg->value.choice.RICindicationMessage;
-  ricmsg_ie->buf = _indicationIEs->ricIndicationMessage;
-  ricmsg_ie->size = _indicationIEs->ricIndicationMessage_size;
+  ricmsg_ie->buf = (uint8_t*)_indicationIEs->get_ricIndicationMessage();
+  ricmsg_ie->size = _indicationIEs->get_ricIndicationMessage_size();
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
 
   // optional call process id ..
   ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
 
 
   // optional call process id ..
-  if (_indicationIEs->call_process_id_size > 0){
+  if (_indicationIEs->get_is_callProcessID()){
     ie_index = 7;
     RICindication_IEs_t *ies_ind_callprocessid = &IE_array[ie_index];
     ies_ind_callprocessid->criticality = Criticality_reject;
     ies_ind_callprocessid->id = ProtocolIE_ID_id_RICcallProcessID;
     ies_ind_callprocessid->value.present = RICindication_IEs__value_PR_RICcallProcessID;
     RICcallProcessID_t *riccallprocessid_ie = &ies_ind_callprocessid->value.choice.RICcallProcessID;
     ie_index = 7;
     RICindication_IEs_t *ies_ind_callprocessid = &IE_array[ie_index];
     ies_ind_callprocessid->criticality = Criticality_reject;
     ies_ind_callprocessid->id = ProtocolIE_ID_id_RICcallProcessID;
     ies_ind_callprocessid->value.present = RICindication_IEs__value_PR_RICcallProcessID;
     RICcallProcessID_t *riccallprocessid_ie = &ies_ind_callprocessid->value.choice.RICcallProcessID;
-    riccallprocessid_ie->buf = _indicationIEs->call_process_id;
-    riccallprocessid_ie->size = _indicationIEs->call_process_id_size;
+    riccallprocessid_ie->buf = (uint8_t*)_indicationIEs->get_ricCallProcessId();
+    riccallprocessid_ie->size = _indicationIEs->get_ricCallProcessId_size();
     ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
   }
 
     ASN_SEQUENCE_ADD(&(ric_indication->protocolIEs), &(IE_array[ie_index]));
   }
 
diff --git a/src/xapp-asn/e2ap/e2ap_indication_helper.hpp b/src/xapp-asn/e2ap/e2ap_indication_helper.hpp
deleted file mode 100644 (file)
index e319c9f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-==================================================================================
-
-        Copyright (c) 2019-2020 AT&T Intellectual Property.
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-==================================================================================
-*/
-/*
- * ric_indication.h
- *
- *  Created on: Jul 11, 2019
- *      Author: sjana, Ashwin Sridharan
- */
-
-
-#ifndef E2AP_INDICATION_HELPER_
-#define E2AP_INDICATION_HELPER_
-
-typedef struct ric_indication_helper ric_indication_helper;
-
-struct ric_indication_helper{
-  ric_indication_helper(void) : req_id(1), req_seq_no(1), func_id(0), action_id(1), indication_type(0), indication_sn(0), indication_msg(0), indication_msg_size(0), indication_header(0), indication_header_size(0), call_process_id(0), call_process_id_size(0) {};
-  long int req_id, req_seq_no, func_id, action_id, indication_type, indication_sn;
-  
-  unsigned char* indication_msg;
-  size_t indication_msg_size;
-  
-  unsigned char* indication_header;
-  size_t indication_header_size;
-  
-  unsigned char *call_process_id;
-  size_t call_process_id_size;
-  
-};
-
-#endif
index 846704c..1201068 100644 (file)
        _message = 0;
     _message = (E2SM_HelloWorld_IndicationMessage_t*)calloc(1, sizeof(E2SM_HelloWorld_IndicationMessage_t));
     assert(_message !=0);
        _message = 0;
     _message = (E2SM_HelloWorld_IndicationMessage_t*)calloc(1, sizeof(E2SM_HelloWorld_IndicationMessage_t));
     assert(_message !=0);
-    _hw_msg = 0;
     _hw_msg_size = 0;
   };
 
  //initialize
     _hw_msg_size = 0;
   };
 
  //initialize
- HWIndicationMessage::HWIndicationMessage(unsigned char *buf, size_t *size, bool &status){
+ HWIndicationMessage::HWIndicationMessage(unsigned char *buf, size_t *size){
 
        _message = 0;
 
        _message = 0;
-    _hw_msg = 0;
     _hw_msg_size = 0;
 
     _hw_msg_size = 0;
 
-    status = this->decode(buf, size);
+    bool status = this->decode(buf, size);
+    if(!status)
+       throw "HWIndicationMessage: "+this->get_error();
+
 
  };
 
 
  };
 
    };
 
   //initialize
    };
 
   //initialize
-   HWIndicationHeader::HWIndicationHeader(unsigned char *buf, size_t *size, bool &status){
+   HWIndicationHeader::HWIndicationHeader(unsigned char *buf, size_t *size){
 
        _header = 0;
        _hw_header = 0;
 
 
        _header = 0;
        _hw_header = 0;
 
-      status = this->decode(buf, size);
+       bool status = this->decode(buf, size);
+   // if(!status)
+   // throw "HWIndicationHeader: "+this->get_error();
 
    };
 
 
    };
 
@@ -75,6 +78,7 @@
 
   mdclog_write(MDCLOG_DEBUG, "Freeing event trigger object memory");
   _message->choice.indicationMessage_Format1 = 0;
 
   mdclog_write(MDCLOG_DEBUG, "Freeing event trigger object memory");
   _message->choice.indicationMessage_Format1 = 0;
+
   ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_IndicationMessage, _message);
 
 
   ASN_STRUCT_FREE(asn_DEF_E2SM_HelloWorld_IndicationMessage, _message);
 
 
@@ -126,6 +130,8 @@ bool HWIndicationHeader::encode(unsigned char *buf, size_t *size){
 
 bool HWIndicationMessage::encode(unsigned char *buf, size_t *size){
 
 
 bool HWIndicationMessage::encode(unsigned char *buf, size_t *size){
 
+  ASN_STRUCT_RESET(asn_DEF_E2SM_HelloWorld_IndicationMessage, _message);
+
   bool res;
   res = setfields(_message);
   if (!res){
   bool res;
   res = setfields(_message);
   if (!res){
@@ -180,7 +186,6 @@ bool HWIndicationMessage::setfields(E2SM_HelloWorld_IndicationMessage_t * _messa
     return false;
   }
   _message->present = E2SM_HelloWorld_IndicationMessage_PR_indicationMessage_Format1;
     return false;
   }
   _message->present = E2SM_HelloWorld_IndicationMessage_PR_indicationMessage_Format1;
-
   _message_fmt1.indicationMsgParam.buf = this->get_hw_message();
   _message_fmt1.indicationMsgParam.size = this->get_hw_message_size();
   _message->choice.indicationMessage_Format1 = &_message_fmt1;
   _message_fmt1.indicationMsgParam.buf = this->get_hw_message();
   _message_fmt1.indicationMsgParam.size = this->get_hw_message_size();
   _message->choice.indicationMessage_Format1 = &_message_fmt1;
@@ -189,9 +194,13 @@ bool HWIndicationMessage::setfields(E2SM_HelloWorld_IndicationMessage_t * _messa
 };
 
 bool HWIndicationHeader::decode(unsigned char *buf, size_t *size){
 };
 
 bool HWIndicationHeader::decode(unsigned char *buf, size_t *size){
+       _header = 0;
+
        asn_dec_rval_t dec_res  = asn_decode(0,ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationHeader, (void**)&(_header), buf, *size);
        asn_dec_rval_t dec_res  = asn_decode(0,ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationHeader, (void**)&(_header), buf, *size);
-        if(dec_res.code != RC_OK){
+
+       if(dec_res.code != RC_OK){
                 mdclog_write(MDCLOG_ERR, "Failed to decode: %s","HW-E2SM RIC Indication Header");
                 mdclog_write(MDCLOG_ERR, "Failed to decode: %s","HW-E2SM RIC Indication Header");
+                _error_string = "Failed to decode HW-E2SM RIC Indication Header";
                 return false;
         } else {
                 mdclog_write(MDCLOG_INFO, "Successfully decoded: %s","HW-E2SM RIC Indication Header");
                 return false;
         } else {
                 mdclog_write(MDCLOG_INFO, "Successfully decoded: %s","HW-E2SM RIC Indication Header");
index 4d820b7..00c2a23 100644 (file)
@@ -29,7 +29,7 @@
 #include <sstream>
 #include <mdclog/mdclog.h>
 #include <vector>
 #include <sstream>
 #include <mdclog/mdclog.h>
 #include <vector>
-
+#include<iostream>
 #include <E2SM-HelloWorld-IndicationHeader.h>
 #include <E2SM-HelloWorld-IndicationMessage.h>
 #include <E2SM-HelloWorld-IndicationHeader-Format1.h>
 #include <E2SM-HelloWorld-IndicationHeader.h>
 #include <E2SM-HelloWorld-IndicationMessage.h>
 #include <E2SM-HelloWorld-IndicationHeader-Format1.h>
@@ -39,7 +39,7 @@
 class HWIndicationHeader {
 public:
        HWIndicationHeader(void);
 class HWIndicationHeader {
 public:
        HWIndicationHeader(void);
-       HWIndicationHeader(unsigned char*, size_t *, bool&);
+       HWIndicationHeader(unsigned char*, size_t *);
   ~HWIndicationHeader(void);
    std::string  get_error (void) const {return _error_string ;};
 
   ~HWIndicationHeader(void);
    std::string  get_error (void) const {return _error_string ;};
 
@@ -64,10 +64,11 @@ private:
   char _errbuf[128];
   std::string _error_string;
 };
   char _errbuf[128];
   std::string _error_string;
 };
+
 class HWIndicationMessage {
 public:
        HWIndicationMessage(void);
 class HWIndicationMessage {
 public:
        HWIndicationMessage(void);
-       HWIndicationMessage(unsigned char*, size_t *, bool&);
+       HWIndicationMessage(unsigned char*, size_t *);
   ~HWIndicationMessage(void);
 
   std::string  get_error (void) const {return _error_string ;};
   ~HWIndicationMessage(void);
 
   std::string  get_error (void) const {return _error_string ;};
@@ -76,11 +77,16 @@ public:
 
   size_t get_hw_message_size(){return this->_hw_msg_size;};
   unsigned char* get_hw_message(){return this->_hw_msg;};
 
   size_t get_hw_message_size(){return this->_hw_msg_size;};
   unsigned char* get_hw_message(){return this->_hw_msg;};
-  HWIndicationMessage& set_hw_message(unsigned char* msg, size_t *msg_size){return *this;}
+  HWIndicationMessage& set_hw_message(std::string msg)
+  {
+         _hw_msg_size=strlen(msg.c_str());
+          strncpy((char*)_hw_msg,msg.c_str(),_hw_msg_size);
+          return *this;
+  }
 private:
 
   size_t _hw_msg_size;
 private:
 
   size_t _hw_msg_size;
-  unsigned char* _hw_msg;
+  unsigned char _hw_msg[30];
 
   E2SM_HelloWorld_IndicationMessage_t* _message;
   E2SM_HelloWorld_IndicationMessage_Format1_t _message_fmt1;
 
   E2SM_HelloWorld_IndicationMessage_t* _message;
   E2SM_HelloWorld_IndicationMessage_Format1_t _message_fmt1;
index d4de3c7..6c5c9bd 100644 (file)
 
 #include "msgs_proc.hpp"
 
 
 #include "msgs_proc.hpp"
 
-/*
-bool XappMsgHandler::decode_subscription_response(unsigned char* data_buf, size_t data_size){
-
-       subscription_helper subhelper;
-       subscription_response subresponse;
-       bool res = true;
-       E2AP_PDU_t *e2pdu = 0;
-
-       asn_dec_rval_t rval;
-
-       ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, e2pdu);
-
-       rval = asn_decode(0,ATS_ALIGNED_BASIC_PER, &asn_DEF_E2AP_PDU, (void**)&e2pdu, data_buf, data_size);
-       switch(rval.code)
-       {
-               case RC_OK:
-                          //Put in Subscription Response Object.
-                          //asn_fprint(stdout, &asn_DEF_E2AP_PDU, e2pdu);
-                          break;
-               case RC_WMORE:
-                               mdclog_write(MDCLOG_ERR, "RC_WMORE");
-                               res = false;
-                               break;
-               case RC_FAIL:
-                               mdclog_write(MDCLOG_ERR, "RC_FAIL");
-                               res = false;
-                               break;
-               default:
-                               break;
-        }
-       ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, e2pdu);
-       return res;
-
-}*/
 
 bool  XappMsgHandler::a1_policy_handler(char * message, int *message_len, a1_policy_helper &helper){
 
 
 bool  XappMsgHandler::a1_policy_handler(char * message, int *message_len, a1_policy_helper &helper){
 
@@ -178,6 +144,11 @@ void XappMsgHandler::operator()(rmr_mbuf_t *message, bool *resend){
                                *resend = true;
                        }
                        break;
                                *resend = true;
                        }
                        break;
+       case RIC_INDICATION:
+
+               mdclog_write(MDCLOG_INFO, "Received Indication message of type = %d", message->mtype);
+               //pick the relevant decoding code from test_e2sm.h, section(E2SM, IndicationMessageDecode)
+               break;
 
        default:
                {
 
        default:
                {
index 2300303..82b0bfb 100644 (file)
 #include<iostream>
 #include<gtest/gtest.h>
 
 #include<iostream>
 #include<gtest/gtest.h>
 
-#include "subscription_request.hpp"
 #include "xapp.hpp"
 #include "xapp.hpp"
-#include "e2sm_helpers.hpp"
-#include "e2sm_subscription.hpp"
-#include "e2sm_indication.hpp"
 #include "e2sm_control.hpp"
 #include "e2sm_control.hpp"
+#include "e2ap_indication.hpp"
+#include "e2sm_indication.hpp"
+#include "e2ap_control.hpp"
 
 using namespace std;
 
 using namespace std;
-TEST(E2SM, SubscriptionRequest)
+TEST(E2SM, IndicationMessageEncode)
 {
 {
+       unsigned char buff[1024];
+       size_t buf_len = 1024;
 
 
-       unsigned char event_buf[128];
-       size_t event_buf_len = 128;
-
-       unsigned char act_buf[128];
-       size_t act_buf_len = 128;
-
-       bool res;
-
-
-       e2sm_subscription_helper e2sm_subsdata;
-       std::unique_ptr<ranparam_helper> *ranhelp;
-       e2sm_subscription e2sm_subs;
-
-
-       e2sm_subsdata.triger_nature = 0;
 
 
-       int param_id = 1;
-       unsigned char param_name[20];
-       strcpy((char*)param_name,"ParamName");
-       int param_name_len = strlen((const char*)param_name);
+       HWIndicationHeader headerObj;
+       headerObj.set_ricIndicationHeader(1);
+       std::cout << headerObj.get_error() << std::endl;
 
 
-       int param_test = 0;
-       unsigned char param_value[20];
-       strcpy((char*)param_value,"ParamValue");
-       int param_value_len = strlen((const char*)param_value);
+       HWIndicationMessage messageObj;
+       messageObj.set_hw_message("HelloWorld-E2SM");
+       std::cout << messageObj.get_error() << std::endl;
 
 
-       e2sm_subsdata.add_param(param_id, param_name, param_name_len, param_test, param_value, param_value_len);
+       E2APIndication<HWIndicationHeader,HWIndicationMessage>::IndicationIEs infoObj;
+       infoObj.set_ranFunctionID(1);
+       infoObj.set_ricActionID(1);
+       infoObj.set_ricRequestorID(1);
+       infoObj.set_ricIndicationHeader(headerObj);
+       infoObj.set_ricIndicationMessage(messageObj);
 
 
+       E2APIndication<HWIndicationHeader,HWIndicationMessage> e2obj(infoObj);
 
 
-       // Encode the event trigger definition
-       res = e2sm_subs.encode_event_trigger(&event_buf[0], &event_buf_len, e2sm_subsdata);
-       if(!res)
-               std::cout << e2sm_subs.get_error() << std::endl;
+       bool res = e2obj.encode(buff, &buf_len);
+                       if(!res)
+                       {
+                               std::cout << e2obj.get_error() << std::endl;
+                       }
+                       ASSERT_TRUE(res);
 
 
-       ASSERT_TRUE(res);
 
 
-       // Encode the action defintion
-       res = e2sm_subs.encode_action_defn(&act_buf[0], &act_buf_len, e2sm_subsdata);
-       if(!res)
-               std::cout << e2sm_subs.get_error() << std::endl;
-       ASSERT_TRUE(res);
+       FILE * pFile;
+       pFile = fopen ("indication2.per","w");
+       if (pFile!=NULL)
+        {
+             fputs ((const char*)buff,pFile);
+                 fclose (pFile);
+         }
 
 }
 
 }
-TEST(E2SM, IndicationMessage)
+TEST(E2SM, IndicationMessageDecode)
 {
 {
-
-       unsigned char header_buf[128];
-       size_t header_buf_len = 128;
-
-       unsigned char msg_buf[128];
-       size_t msg_buf_len = 128;
-
-       bool res;
-       asn_dec_rval_t retval;
-
-
-       e2sm_indication_helper e2sm_inddata;
-       e2sm_indication e2sm_inds;
-
-       unsigned char msg[20] = "HelloWorld";
-
-       e2sm_inddata.header = 1001;
-       e2sm_inddata.message = msg;
-       e2sm_inddata.message_len = strlen((const char*)e2sm_inddata.message);
-
-
-       // Encode the indication header
-       res = e2sm_inds.encode_indication_header(&header_buf[0], &header_buf_len, e2sm_inddata);
-       if(!res)
-               std::cout << e2sm_inds.get_error() << std::endl;
-
-       ASSERT_TRUE(res);
-
-       // Encode the indication message
-       res = e2sm_inds.encode_indication_message(&msg_buf[0], &msg_buf_len, e2sm_inddata);
-       if(!res)
-               std::cout << e2sm_inds.get_error() << std::endl;
-       ASSERT_TRUE(res);
-
-       //decode the indication header
-       e2sm_indication_helper e2sm_decodedata;
-
-
-       E2SM_HelloWorld_IndicationHeader_t *header = 0; // used for decoding
-       retval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationHeader, (void**)&(header), &header_buf[0], header_buf_len);
-
-       ASSERT_TRUE(retval.code == RC_OK);
-       res = e2sm_inds.get_fields(header, e2sm_decodedata);
-
-       //decode the indication message
-
-       E2SM_HelloWorld_IndicationMessage_t *mesg = 0; // used for decoding
-       retval = asn_decode(0, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_HelloWorld_IndicationMessage, (void**)&(mesg), &msg_buf[0], msg_buf_len);
-
-       ASSERT_TRUE(retval.code == RC_OK);
-       res = e2sm_inds.get_fields(mesg, e2sm_decodedata);
-
-
-       std::cout << "Indication Header:" << e2sm_decodedata.header << std::endl;
-       std::cout << "Indication Message:" << e2sm_decodedata.message << std::endl;
-       std::cout << "Indication Message Len:" << e2sm_decodedata.message_len << std::endl;
-
-       ASSERT_EQ(e2sm_inddata.header, e2sm_decodedata.header);
-       ASSERT_EQ(e2sm_inddata.message_len, e2sm_decodedata.message_len);
-       for (int i = 0; i < e2sm_inddata.message_len; ++i) {
-         EXPECT_EQ(e2sm_inddata.message[i], e2sm_decodedata.message[i]) << "Encoded and Decoded Msg differ at index " << i;
+       unsigned char e2ap_buff[4096];
+       char filename[100] = "indication2.per";
+       FILE *fp;
+       fp = fopen(filename,"rb");
+       if(!fp) {
+                    perror(filename);
+                    exit(1); }
+
+          size_t e2ap_buff_size = fread(e2ap_buff, 1, 4096, fp);
+          fclose(fp);
+       if(!e2ap_buff_size){
+             fprintf(stderr, "%s: Empty or broken\n", filename);
+              exit(1);
+                  } else {
+              fprintf(stderr, "e2ap buffer size: %ld \n", e2ap_buff_size);
+       }
+
+    bool decode_status = true;
+    try{
+       E2APIndication<HWIndicationHeader,HWIndicationMessage> e2obj(&e2ap_buff[0],&e2ap_buff_size);
+       E2APIndication<HWIndicationHeader,HWIndicationMessage>::IndicationIEs indIEs = e2obj.getIndicationIEs();
+       std::cout << indIEs.get_ricRequestorID() << std::endl;
+
+       size_t hsize = indIEs.get_ricIndicationHeader_size();
+       unsigned char* hvalue = (unsigned char*)indIEs.get_ricIndicationHeader();
+       HWIndicationHeader headerObj(&hvalue[0], &hsize);
+
+         size_t msize = indIEs.get_ricIndicationMessage_size();
+         auto mvalue = (unsigned char*)indIEs.get_ricIndicationMessage();
+         HWIndicationMessage msgObj(&mvalue[0], &msize);
+
+    } catch(const char* e){
+               decode_status = false;
+               std::cout << "Error Message: " << e << std::endl;
        }
 
 
        }
 
 
+       ASSERT_TRUE(decode_status);
+
 }
 
 TEST(E2SM, ControlMessage)
 {
 
 }
 
 TEST(E2SM, ControlMessage)
 {
 
-       unsigned char header_buf[128];
-       size_t header_buf_len = 128;
-
-       unsigned char msg_buf[128];
-       size_t msg_buf_len = 128;
-
-       bool res;
-       asn_dec_rval_t retval;
+       unsigned char buff[1024];
+       size_t buf_len = 1024;
 
 
 
 
-       e2sm_control_helper e2sm_cntrldata;
-       e2sm_control e2sm_cntrl;
 
 
-       unsigned char msg[20] = "HelloWorld";
+       HWControlMessage msgObj;
+       msgObj.set_ricControlMessage("ControlMessage");
 
 
-       e2sm_cntrldata.header = 1001;
-       e2sm_cntrldata.message = msg;
-       e2sm_cntrldata.message_len = strlen((const char*)e2sm_cntrldata.message);
+       HWControlHeader headObj;
+       headObj.set_ricControlHeader(1);
 
 
+       E2APControlMessage<HWControlHeader,HWControlMessage>::ControlRequestIEs infoObj;
+       infoObj.set_ranFunctionID(1);
+       infoObj.set_ricRequestorID(1);
+       infoObj.set_ricControlHeader(headObj);
+       infoObj.set_ricControlMessage(msgObj);
 
 
-       // Encode the indication header
-       res = e2sm_cntrl.encode_control_header(&header_buf[0], &header_buf_len, e2sm_cntrldata);
-       if(!res)
-               std::cout << e2sm_cntrl.get_error() << std::endl;
 
 
-       ASSERT_TRUE(res);
+       E2APControlMessage<HWControlHeader,HWControlMessage>  cntrlObj(infoObj);
 
 
-       // Encode the indication message
-       res = e2sm_cntrl.encode_control_message(&msg_buf[0], &msg_buf_len, e2sm_cntrldata);
-       if(!res)
-               std::cout << e2sm_cntrl.get_error() << std::endl;
-       ASSERT_TRUE(res);
+       bool res = cntrlObj.encode(buff, &buf_len);
+               if(!res)
+               {
+                       std::cout << cntrlObj.get_error() << std::endl;
+               }
+               ASSERT_TRUE(res);
 }
 
 #endif /* TEST_TEST_ASN_H_ */
 }
 
 #endif /* TEST_TEST_ASN_H_ */
index d831c96..e50a473 100644 (file)
 #define BUFFER_SIZE 1024
 
 using namespace std;
 #define BUFFER_SIZE 1024
 
 using namespace std;
+
 //generating a E2AP Subscription Message
 //generating a E2AP Subscription Message
-TEST(SUBSCRIPTION, Request){
+TEST(SubscriptionRequest, MultipleRANParameters)
+{
+       unsigned char buff[1024];
+       size_t buff_size = 1024;
+
+
+       //creating Action Definition
+       HWActionDefinition e2sm_actdefn1;
+       HWActionDefinition::RANParamIEs rparam1;
+
+       rparam1.set_param_id(1);
+       rparam1.set_param_name("ENodeBID");
+       rparam1.set_param_test(1);
+       rparam1.set_param_value("SR123");
+
+       e2sm_actdefn1.add(rparam1);
+
+       HWActionDefinition::RANParamIEs rparam2;
+
+       rparam2.set_param_id(1);
+       rparam2.set_param_name("UEID");
+       rparam2.set_param_test(2);
+       rparam2.set_param_value("UE123");
+
+       e2sm_actdefn1.add(rparam2);
 
 
 
 
-       subscription_helper  din;
-       subscription_helper  dout;
+       //first Action Object
 
 
-       subscription_request sub_req;
-       subscription_request sub_recv;
+       E2APAction<HWActionDefinition> actionObj;
+       E2APAction<HWActionDefinition>::ActionIEs ieobj;
+       ieobj.set_ricActionID(1);
+       ieobj.set_ricActionType(1);
+       ieobj.set_ricActionDefinition(e2sm_actdefn1);
 
 
-       unsigned char buf[BUFFER_SIZE];
-       size_t buf_size = BUFFER_SIZE;
-       bool res;
+       actionObj.add(ieobj);
 
 
+       HWEventTriggerDefinition eventObj;
+       eventObj.set_triggerNature(0);
 
 
-       //Random Data  for request
-       int request_id = 1;
-       int function_id = 0;
-       std::string event_def = "HelloWorld Event Definition";
+       //Now form the subscription.
 
 
-       din.set_request(request_id);
-       din.set_function_id(function_id);
-       din.set_event_def(event_def.c_str(), event_def.length());
+       E2APSubscriptionRequest<HWEventTriggerDefinition, HWActionDefinition>::SubscriptionRequestIEs infoObj;
 
 
-       std::string act_def = "HelloWorld Action Definition";
+       infoObj.set_ranFunctionID(1);
+       infoObj.set_ricInstanceID(1);
+       infoObj.set_ricRequestorID(3);
+       infoObj.set_ricAction_ToBeSetup_List(actionObj);
+       infoObj.set_ricEventTriggerDefinition(eventObj);
 
 
-       din.add_action(1,1,(void*)act_def.c_str(), act_def.length(), 0);
 
 
-       res = sub_req.encode_e2ap_subscription(&buf[0], &buf_size, din);
+       E2APSubscriptionRequest<HWEventTriggerDefinition, HWActionDefinition> requestObj(infoObj);
+
+       //Alternate way of implementation
+       //requestObj.add(E2APSubscriptionRequest<HWEventTriggerDefinition, HWActionDefinition>::SubscriptionRequestIEs().set_ranFunctionID(1).set_ricInstanceID(2).set_ricRequestorID(3).set_ricAction_ToBeSetup_List(actionObj));
+
+       bool res = requestObj.encode(buff, &buff_size);
        ASSERT_TRUE(res);
        ASSERT_TRUE(res);
+}
+
+TEST(SubscriptionRequest, MultipleActions)
+{
+       unsigned char buff[1024];
+       size_t buff_size = 1024;
+
+
+       //creating Action Definition 1
+       HWActionDefinition e2sm_actdefn1;
+       HWActionDefinition::RANParamIEs rparam1;
+
+       rparam1.set_param_id(1);
+       rparam1.set_param_name("ENodeBID");
+       rparam1.set_param_test(1);
+       rparam1.set_param_value("SR123");
 
 
+       e2sm_actdefn1.add(rparam1);
 
 
+       HWActionDefinition e2sm_actdefn2;
+       HWActionDefinition::RANParamIEs rparam2;
+
+       rparam2.set_param_id(1);
+       rparam2.set_param_name("UEID");
+       rparam2.set_param_test(2);
+       rparam2.set_param_value("UE123");
+
+       e2sm_actdefn2.add(rparam2);
+
+
+       //first Action Object
+
+       E2APAction<HWActionDefinition> actionObj;
+       E2APAction<HWActionDefinition>::ActionIEs ieobj;
+       ieobj.set_ricActionID(1);
+       ieobj.set_ricActionType(1);
+       ieobj.set_ricActionDefinition(e2sm_actdefn1);
+       ieobj.set_ricSubsequentAction(1,1);
+       actionObj.add(ieobj);
+
+       //Second Action object.
+       actionObj.add(E2APAction<HWActionDefinition>::ActionIEs().set_ricActionID(4).set_ricActionType(2).set_ricActionDefinition(e2sm_actdefn2));
+
+
+       HWEventTriggerDefinition eventObj;
+       eventObj.set_triggerNature(1);
+
+
+
+       E2APSubscriptionRequest<HWEventTriggerDefinition, HWActionDefinition>::SubscriptionRequestIEs dataObj;
+
+       dataObj.set_ranFunctionID(1);
+       dataObj.set_ricInstanceID(1);
+       dataObj.set_ricRequestorID(3);
+       dataObj.set_ricAction_ToBeSetup_List(actionObj);
+       dataObj.set_ricEventTriggerDefinition(eventObj);
+
+       E2APSubscriptionRequest<HWEventTriggerDefinition, HWActionDefinition> requestObj(dataObj);
+       bool res = requestObj.encode(buff, &buff_size);
+       if(!res)
+       {
+               std::cout << requestObj.get_error() << std::endl;
+       }
+       ASSERT_TRUE(res);
 
 }
 
 
 }