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).
27 #include <asn1codec_utils.h>
30 main(int argc, char* argv[])
32 char responseErrorBuf[1<< 16];
34 size_t count = fread(buf, 1, sizeof(buf), stdin);
35 if (count == sizeof(buf)) {
36 printf("#%s failed. Input is too big\n", __func__);
40 printf("#%s failed. Error while reading input: %s\n", __func__, strerror(errno));
44 E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
45 if (!unpack_pdu_aux(pdu, count, buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_BASIC_XER)){
46 printf("#%s failed. Unpacking error %s\n", __func__, responseErrorBuf);
50 responseErrorBuf[0] = 0;
51 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
52 printf("#%s: %s\n", __func__, responseErrorBuf);
55 size_t per_packed_buf_size;
56 uint8_t per_packed_buf[1 << 16];
58 responseErrorBuf[0] = 0;
59 per_packed_buf_size = sizeof(per_packed_buf);
61 if (!pack_pdu_aux(pdu,&per_packed_buf_size, per_packed_buf,sizeof(responseErrorBuf), responseErrorBuf, ATS_ALIGNED_BASIC_PER)){
62 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
65 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
66 printf("#%s packed size:%zu\nPayload:\n", __func__, per_packed_buf_size);
67 for (size_t i= 0; i < per_packed_buf_size; i++)
68 printf("%02x",per_packed_buf[i]);
71 pdu =calloc(1, sizeof(E2AP_PDU_t));
72 if (!unpack_pdu_aux(pdu, per_packed_buf_size, per_packed_buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
73 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
76 responseErrorBuf[0] = 0;
77 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
78 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
79 printf("#%s: %s\n", __func__, responseErrorBuf);