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.
24 #include <x2setup_request_wrapper.h>
26 void test_build_pack_x2setup_request();
27 void test_build_pack_endc_x2setup_request();
28 void test_unpack(void);
31 main(int argc, char* argv[])
33 test_build_pack_x2setup_request();
34 test_build_pack_endc_x2setup_request();
39 void test_build_pack_x2setup_request(){
40 size_t error_buf_size = 8192;
41 size_t packed_buf_size = 4096;
42 unsigned char responseDataBuf[packed_buf_size];
43 char responseErrorBuf[error_buf_size];
44 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
45 uint8_t ric_flag[] = {0xa,0xd,0xe};
46 uint8_t eNBId[] = {0xab, 0xcd, 0x7/*0xf,0x7,0x2*/};
49 unsigned int bitqty = 21;
50 /**********************************************************************************/
52 printf("\n----- ATS_ALIGNED_BASIC_PER ----\n");
53 packed_buf_size = 4096;
54 result = build_pack_x2setup_request_aux(
55 pLMN_Identity, eNBId, bitqty , ric_flag,
56 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER);
58 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
61 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
62 for (size_t i = 0; i < packed_buf_size; ++i)
63 printf("%02x",responseDataBuf[i]);
66 pdu =calloc(1, sizeof(E2AP_PDU_t));
67 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
68 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
70 responseErrorBuf[0] = 0;
71 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
72 printf("#%s: 21%s\n", __func__, responseErrorBuf);
74 printf("\n----- ATS_UNALIGNED_BASIC_PER ----\n");
75 packed_buf_size = 4096;
76 result = build_pack_x2setup_request_aux(
77 pLMN_Identity, eNBId, bitqty , ric_flag,
78 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER);
80 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
83 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
84 for (size_t i = 0; i < packed_buf_size; ++i)
85 printf("%02x",responseDataBuf[i]);
88 pdu =calloc(1, sizeof(E2AP_PDU_t));
89 if (!unpack_pdu_aux(pdu, packed_buf_size, responseDataBuf,error_buf_size, responseErrorBuf,ATS_UNALIGNED_BASIC_PER)){
90 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
92 responseErrorBuf[0] = 0;
93 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
94 printf("#%s: 21%s\n", __func__, responseErrorBuf);
97 void test_build_pack_endc_x2setup_request(){
98 size_t error_buf_size = 8192;
99 size_t packed_buf_size = 4096;
100 unsigned char responseDataBuf[packed_buf_size];
101 uint8_t pLMN_Identity[] = {0xa,0xb,0xc};
102 uint8_t ric_flag[] = {0xa,0xd,0xe};
103 uint8_t eNBId[] = {0xf,0x7,0x2};
104 unsigned int bitqty=18;
106 char responseErrorBuf[error_buf_size];
107 bool result = build_pack_endc_x2setup_request(
108 pLMN_Identity, eNBId, bitqty , ric_flag,
109 &packed_buf_size, responseDataBuf, error_buf_size, responseErrorBuf);
111 printf("#%s. Packing error %s\n", __func__, responseErrorBuf);
114 printf("#%s packed size:%lu\nPayload:\n", __func__, packed_buf_size);
115 for (size_t i = 0; i < packed_buf_size; ++i)
116 printf("%02x",responseDataBuf[i]);
120 void test_unpack(void)
122 return; // No need for now.
123 char responseErrorBuf[8192];
124 printf("\n--------------- case #1\n\n");
126 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};
127 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
128 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
129 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
132 responseErrorBuf[0] = 0;
133 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
134 printf("#%s: %s\n", __func__, responseErrorBuf);
137 printf("\n--------------- case #2\n\n");
139 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};
140 E2AP_PDU_t *pdu =calloc(1, sizeof(E2AP_PDU_t));
141 if (!unpack_pdu_aux(pdu, sizeof(buf), buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
142 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
145 responseErrorBuf[0] = 0;
146 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
147 printf("#%s: %s\n", __func__, responseErrorBuf);