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.
20 #include "x2ap_asn_codec.h"
21 #include "per_decoder.h"
22 #include "per_encoder.h"
24 /* Encode X2AP PDU ASN1 buffer*/
25 int X2AP_ASN_encode(X2AP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
30 assert(buffer != NULL);
33 encoded = aper_encode_to_new_buffer(&asn_DEF_X2AP_PDU, 0, pdu, (void **)buffer);
42 ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_X2AP_PDU, pdu);
46 /* Decode XASN1 buffer to X2AP PDU*/
47 int X2AP_ASN_decode(X2AP_PDU_t *pdu, const uint8_t *const buffer, const int len)
49 asn_dec_rval_t dec_ret;
51 assert(buffer != NULL);
53 dec_ret = aper_decode(NULL, &asn_DEF_X2AP_PDU, (void **)&pdu, buffer,
56 //xer_fprint(stdout, &asn_DEF_X2AP_PDU, pdu);
58 if (dec_ret.code != RC_OK) {
59 fprintf(stderr, "ERROR: Failed to decode pdu\n");