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_E2AP_PDU_WRAPPER_HPP
20 #define ASN_E2AP_PDU_WRAPPER_HPP
22 #include <asn/per/codec.hpp>
23 #include <asn/printer.hpp>
24 #include <asn/utility.hpp>
26 // #include <X2AP-CommonDataTypes.hpp>
28 // #include <X2AP-Constants.hpp>
29 // #include <X2AP-Containers.hpp>
30 // #include <X2AP-IEs.hpp>
31 // #include <X2AP-PDU-Contents.hpp>
32 // #include <X2AP-PDU-Descriptions.hpp>
34 #include <E2AP-Constants.hpp>
35 // #include <E2AP-Containers.hpp>
36 #include <E2AP-IEs.hpp>
37 #include <E2AP-PDU-Contents.hpp>
38 #include <E2AP-PDU-Descriptions.hpp>
40 #define E2AP_PDU_DEFAULT_BUFFER_SIZE 4096
42 //Credit: copied from E2-Manager
45 unsigned char* m_allocation_buffer;
46 size_t m_allocation_buffer_size;
48 E2APpduWrapper(size_t allocation_buffer_size = E2AP_PDU_DEFAULT_BUFFER_SIZE)
50 m_allocation_buffer_size = allocation_buffer_size;
51 m_allocation_buffer = 0;
52 if (allocation_buffer_size) {
54 new (std::nothrow) unsigned char[allocation_buffer_size];
57 m_allocation_buffer_size); // initialized correctly on
58 // allocation failure.
64 if (m_allocation_buffer)
65 delete[] m_allocation_buffer;
68 asn::allocator& ref_allocator() { return m_allocator; }
70 E2AP_PDU& ref_pdu() { return m_pdu; }
72 // reset pdu and allocation buffer. Allows reusing.
76 m_allocator.reset(m_allocation_buffer, m_allocation_buffer_size);
81 asn::allocator m_allocator;