2 * Copyright 2019 AT&T Intellectual Property
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 * platform project (RICP).
28 #include <x2setup_request_wrapper.h>
30 void test_build_pack_x2setup_request();
31 void test_build_pack_endc_x2setup_request();
32 void test_unpack(void);
35 main(int argc, char* argv[])
37 test_build_pack_x2setup_request();
38 test_build_pack_endc_x2setup_request();
43 void test_build_pack_x2setup_request(){
44 size_t error_buf_size = 8192;
45 size_t packed_buf_size = 4096;
46 unsigned char responseDataBuf[packed_buf_size];
47 char responseErrorBuf[error_buf_size];
48 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
49 uint8_t ric_flag[] = {0xa,0xd,0xe};
50 uint8_t eNBId[] = {0xab, 0xcd, 0x7/*0xf,0x7,0x2*/};
53 unsigned int bitqty = 21;
54 /**********************************************************************************/
56 printf("\n----- ATS_ALIGNED_BASIC_PER ----\n");
57 packed_buf_size = 4096;
58 result = build_pack_x2setup_request_aux(
59 pLMN_Identity, eNBId, bitqty , ric_flag,
60 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER);
62 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
65 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
66 for (size_t i = 0; i < packed_buf_size; ++i)
67 printf("%02x",responseDataBuf[i]);
70 pdu =calloc(1, sizeof(E2AP_PDU_t));
71 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
72 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
74 responseErrorBuf[0] = 0;
75 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
76 printf("#%s: 21%s\n", __func__, responseErrorBuf);
78 printf("\n----- ATS_UNALIGNED_BASIC_PER ----\n");
79 packed_buf_size = 4096;
80 result = build_pack_x2setup_request_aux(
81 pLMN_Identity, eNBId, bitqty , ric_flag,
82 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER);
84 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
87 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
88 for (size_t i = 0; i < packed_buf_size; ++i)
89 printf("%02x",responseDataBuf[i]);
92 pdu =calloc(1, sizeof(E2AP_PDU_t));
93 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER)){
94 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
96 responseErrorBuf[0] = 0;
97 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
98 printf("#%s: 21%s\n", __func__, responseErrorBuf);
101 void test_build_pack_endc_x2setup_request(){
102 size_t error_buf_size = 8192;
103 size_t packed_buf_size = 4096;
104 unsigned char responseDataBuf[packed_buf_size];
105 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
106 uint8_t ric_flag[] = {0xa,0xd,0xe};
107 uint8_t eNBId[] = {0xf,0x7,0x2};
108 unsigned int bitqty=18;
110 char responseErrorBuf[error_buf_size];
111 bool result = build_pack_endc_x2setup_request(
112 pLMN_Identity, eNBId, bitqty , ric_flag,
113 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
115 printf("#%s. Packing error %s\n", __func__, responseErrorBuf);
118 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
119 for (size_t i = 0; i < packed_buf_size; ++i)
120 printf("%02x",responseDataBuf[i]);
124 void test_unpack(void)
126 return; // No need for now.
127 char responseErrorBuf[8192];
128 printf("\n--------------- case #1\n\n");
130 uint8_t buf[] = {0x00,0x24,0x00,0x32,0x00,0x00,0x01,0x00,0xf4,0x00,0x2b,0x00,0x00,0x02,0x00,0x15,0x00,0x09,0x00,0xbb,0xbc,0xcc,0x80,0x03,0xab,0xcd,0x80,0x00,0xfa,0x00,0x17,0x00,0x00,0x01,0xf7,0x00,0xbb,0xbc,0xcc,0xab,0xcd,0x80,0x00,0x00,0x00,0xbb,0xbc,0xcc,0x00,0x00,0x00,0x00,0x00,0x01};
131 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
132 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
133 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
136 responseErrorBuf[0] = 0;
137 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
138 printf("#%s: %s\n", __func__, responseErrorBuf);
141 printf("\n--------------- case #2\n\n");
143 uint8_t buf[] = {0x00,0x06,0x00,0x2b,0x00,0x00,0x02,0x00,0x15,0x00,0x09,0x00,0x0a,0x0b,0x0c,0x81,0x03,0xab,0xcd,0xc0,0x00,0x14,0x00,0x17,0x00,0x00,0x01,0xf7,0x00,0x0a,0x0b,0x0c,0xab,0xcd,0xc0,0x00,0x00,0x00,0x0a,0x0d,0x0e,0x00,0x00,0x00,0x00,0x00,0x01};
144 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
145 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
146 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
149 responseErrorBuf[0] = 0;
150 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
151 printf("#%s: %s\n", __func__, responseErrorBuf);