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.
23 #include <asn1codec_utils.h>
26 main(int argc, char* argv[])
28 char responseErrorBuf[1<< 16];
30 size_t count = fread(buf, 1, sizeof(buf), stdin);
31 if (count == sizeof(buf)) {
32 printf("#%s failed. Input is too big\n", __func__);
36 printf("#%s failed. Error while reading input: %s\n", __func__, strerror(errno));
40 E2AP_PDU_t *pdu = calloc(1, sizeof(E2AP_PDU_t));
41 if (!unpack_pdu_aux(pdu, count, buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_BASIC_XER)){
42 printf("#%s failed. Unpacking error %s\n", __func__, responseErrorBuf);
46 responseErrorBuf[0] = 0;
47 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
48 printf("#%s: %s\n", __func__, responseErrorBuf);
51 size_t per_packed_buf_size;
52 uint8_t per_packed_buf[1 << 16];
54 responseErrorBuf[0] = 0;
55 per_packed_buf_size = sizeof(per_packed_buf);
57 if (!pack_pdu_aux(pdu,&per_packed_buf_size, per_packed_buf,sizeof(responseErrorBuf), responseErrorBuf, ATS_ALIGNED_BASIC_PER)){
58 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
61 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
62 printf("#%s packed size:%zu\nPayload:\n", __func__, per_packed_buf_size);
63 for (size_t i= 0; i < per_packed_buf_size; i++)
64 printf("%02x",per_packed_buf[i]);
67 pdu =calloc(1, sizeof(E2AP_PDU_t));
68 if (!unpack_pdu_aux(pdu, per_packed_buf_size, per_packed_buf ,sizeof(responseErrorBuf), responseErrorBuf,ATS_ALIGNED_BASIC_PER)){
69 printf("#%s failed. Packing error %s\n", __func__, responseErrorBuf);
72 responseErrorBuf[0] = 0;
73 asn1_pdu_printer(pdu, sizeof(responseErrorBuf), responseErrorBuf);
74 ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
75 printf("#%s: %s\n", __func__, responseErrorBuf);