1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
4 # Copyright 2019 Nokia *
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. *
18 ******************************************************************************/
19 #ifndef ASN_X2AP_PDU_WRAPPER_HPP
20 #define ASN_X2AP_PDU_WRAPPER_HPP
22 #include <asn/per/codec.hpp>
23 #include <asn/printer.hpp>
24 #include <asn/utility.hpp>
26 #include <X2AP-CommonDataTypes.hpp>
27 #include <X2AP-Constants.hpp>
28 #include <X2AP-Containers.hpp>
29 #include <X2AP-IEs.hpp>
30 #include <X2AP-PDU-Contents.hpp>
31 #include <X2AP-PDU-Descriptions.hpp>
33 #define X2AP_PDU_DEFAULT_BUFFER_SIZE 4096
35 //Credit: copied from E2-Manager
38 unsigned char* m_allocation_buffer;
39 size_t m_allocation_buffer_size;
41 X2APpduWrapper(size_t allocation_buffer_size = X2AP_PDU_DEFAULT_BUFFER_SIZE)
43 m_allocation_buffer_size = allocation_buffer_size;
44 m_allocation_buffer = 0;
45 if (allocation_buffer_size) {
47 new (std::nothrow) unsigned char[allocation_buffer_size];
50 m_allocation_buffer_size); // initialized correctly on
51 // allocation failure.
57 if (m_allocation_buffer)
58 delete[] m_allocation_buffer;
61 asn::allocator& ref_allocator() { return m_allocator; }
63 X2AP_PDU& ref_pdu() { return m_pdu; }
65 // reset pdu and allocation buffer. Allows reusing.
69 m_allocator.reset(m_allocation_buffer, m_allocation_buffer_size);
74 asn::allocator m_allocator;