3 * Copyright 2019 AT&T Intellectual Property
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 // Copyright 2019 AT&T Intellectual Property
22 // Copyright 2019 Nokia
24 // Licensed under the Apache License, Version 2.0 (the "License");
25 // you may not use this file except in compliance with the License.
26 // You may obtain a copy of the License at
28 // http://www.apache.org/licenses/LICENSE-2.0
30 // Unless required by applicable law or agreed to in writing, software
31 // distributed under the License is distributed on an "AS IS" BASIS,
32 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 // See the License for the specific language governing permissions and
34 // limitations under the License.
39 #include <x2setup_request_wrapper.h>
41 void test_build_pack_x2setup_request();
42 void test_build_pack_endc_x2setup_request();
43 void test_unpack(void);
46 main(int argc, char* argv[])
48 test_build_pack_x2setup_request();
49 test_build_pack_endc_x2setup_request();
54 void test_build_pack_x2setup_request(){
55 size_t error_buf_size = 8192;
56 size_t packed_buf_size = 4096;
57 unsigned char responseDataBuf[packed_buf_size];
58 char responseErrorBuf[error_buf_size];
59 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
60 uint8_t ric_flag[] = {0xa,0xd,0xe};
61 uint8_t eNBId[] = {0xab, 0xcd, 0x7/*0xf,0x7,0x2*/};
64 unsigned int bitqty = 21;
65 /**********************************************************************************/
67 printf("\n----- ATS_ALIGNED_BASIC_PER ----\n");
68 packed_buf_size = 4096;
69 result = build_pack_x2setup_request_aux(
70 pLMN_Identity, eNBId, bitqty , ric_flag,
71 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER);
73 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
76 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
77 for (size_t i = 0; i < packed_buf_size; ++i)
78 printf("%02x",responseDataBuf[i]);
81 pdu =calloc(1, sizeof(E2AP_PDU_t));
82 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
83 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
85 responseErrorBuf[0] = 0;
86 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
87 printf("#%s: 21%s\n", __func__, responseErrorBuf);
89 printf("\n----- ATS_UNALIGNED_BASIC_PER ----\n");
90 packed_buf_size = 4096;
91 result = build_pack_x2setup_request_aux(
92 pLMN_Identity, eNBId, bitqty , ric_flag,
93 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER);
95 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
98 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
99 for (size_t i = 0; i < packed_buf_size; ++i)
100 printf("%02x",responseDataBuf[i]);
103 pdu =calloc(1, sizeof(E2AP_PDU_t));
104 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER)){
105 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
107 responseErrorBuf[0] = 0;
108 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
109 printf("#%s: 21%s\n", __func__, responseErrorBuf);
112 void test_build_pack_endc_x2setup_request(){
113 size_t error_buf_size = 8192;
114 size_t packed_buf_size = 4096;
115 unsigned char responseDataBuf[packed_buf_size];
116 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
117 uint8_t ric_flag[] = {0xa,0xd,0xe};
118 uint8_t eNBId[] = {0xf,0x7,0x2};
119 unsigned int bitqty=18;
121 char responseErrorBuf[error_buf_size];
122 bool result = build_pack_endc_x2setup_request(
123 pLMN_Identity, eNBId, bitqty , ric_flag,
124 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
126 printf("#%s. Packing error %s\n", __func__, responseErrorBuf);
129 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
130 for (size_t i = 0; i < packed_buf_size; ++i)
131 printf("%02x",responseDataBuf[i]);
135 void test_unpack(void)
137 return; // No need for now.
138 char responseErrorBuf[8192];
139 printf("\n--------------- case #1\n\n");
141 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};
142 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
143 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
144 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
147 responseErrorBuf[0] = 0;
148 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
149 printf("#%s: %s\n", __func__, responseErrorBuf);
152 printf("\n--------------- case #2\n\n");
154 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};
155 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
156 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
157 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
160 responseErrorBuf[0] = 0;
161 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
162 printf("#%s: %s\n", __func__, responseErrorBuf);