Merge "Completed test with Viavi data"
[sim/e2-interface.git] / e2sim / previous / e2apv1sim / ricsim / test / Misc / test_asn1c.cpp
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2019 AT&T Intellectual Property                                  *
4 # Copyright 2019 Nokia                                                       *
5 #                                                                            *
6 # Licensed under the Apache License, Version 2.0 (the "License");            *
7 # you may not use this file except in compliance with the License.           *
8 # You may obtain a copy of the License at                                    *
9 #                                                                            *
10 #      http://www.apache.org/licenses/LICENSE-2.0                            *
11 #                                                                            *
12 # Unless required by applicable law or agreed to in writing, software        *
13 # distributed under the License is distributed on an "AS IS" BASIS,          *
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
15 # See the License for the specific language governing permissions and        *
16 # limitations under the License.                                             *
17 #                                                                            *
18 ******************************************************************************/
19
20 #include <stdio.h>
21 #include <unistd.h>
22 #include <assert.h>
23 #include <string>
24 #include <iostream>
25
26 extern "C" {
27   #include "e2sim_defs.h"
28   #include "E2AP-PDU.h"
29   #include "e2ap_asn1c_codec.h"
30   #include "e2sm.h"
31
32 }
33
34 using namespace std;
35
36 int main(int argc, char* argv[]){
37
38   LOG_I("Test ASN1c");
39
40   test_eventTriggerDefinition();
41   return 0;
42
43   E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupRequest.xml");
44   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupResponse.xml");
45   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_X2SetupFailure.xml");
46
47   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupRequest.xml");
48   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupResponse.xml");
49   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ENDCX2SetupFailure.xml");
50
51   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionRequest.xml");
52   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_RICsubscriptionResponse.xml");
53   // E2AP_PDU_t* pdu = e2ap_xml_to_pdu("E2AP_ErrorIndication.xml");
54
55   e2ap_asn1c_print_pdu(pdu);
56
57   /* Test encoding */
58   uint8_t       *buf;
59   sctp_buffer_t data;
60
61   data.len = e2ap_asn1c_encode_pdu(pdu, &buf);
62   memcpy(data.buffer, buf, min(data.len, MAX_SCTP_BUFFER));
63
64   /* Test decoding */
65   E2AP_PDU_t* pdu1 = new E2AP_PDU_t();
66
67   e2ap_asn1c_decode_pdu(pdu1, data.buffer, data.len);
68
69   e2ap_asn1c_print_pdu(pdu1);
70
71   int index = (int)pdu1->present;
72
73   int pCode = e2ap_asn1c_get_procedureCode(pdu1);
74
75   LOG_I("Index = %d, procedureCode = %d", index, pCode);
76
77
78   return 0;
79 }