nm755n | 15d3982 | 2019-11-28 16:56:00 +0000 | [diff] [blame] | 1 | /* |
irina | 79fa3a3 | 2019-09-03 12:24:01 +0300 | [diff] [blame] | 2 | * Copyright (c) 2019 AT&T Intellectual Property. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
nm755n | 15d3982 | 2019-11-28 16:56:00 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 19 | * platform project (RICP). |
| 20 | */ |
| 21 | |
irina | 79fa3a3 | 2019-09-03 12:24:01 +0300 | [diff] [blame] | 22 | package e2pdus |
| 23 | |
ss412g | 6df73c6 | 2019-11-13 01:03:50 +0200 | [diff] [blame] | 24 | // #cgo CFLAGS: -I../3rdparty/asn1codec/inc/ -I../3rdparty/asn1codec/e2ap_engine/ |
| 25 | // #cgo LDFLAGS: -L ../3rdparty/asn1codec/lib/ -L../3rdparty/asn1codec/e2ap_engine/ -le2ap_codec -lasncodec |
irina | 79fa3a3 | 2019-09-03 12:24:01 +0300 | [diff] [blame] | 26 | // #include <x2reset_response_wrapper.h> |
| 27 | import "C" |
| 28 | import ( |
| 29 | "fmt" |
| 30 | "unsafe" |
| 31 | ) |
| 32 | |
| 33 | var PackedX2ResetResponse []byte |
| 34 | |
| 35 | func prepareX2ResetResponsePDU(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int) error { |
| 36 | |
| 37 | packedBuffer := make([]C.uchar, maxAsn1PackedBufferSize) |
| 38 | errorBuffer := make([]C.char, maxAsn1CodecMessageBufferSize) |
| 39 | var payloadSize = C.ulong(maxAsn1PackedBufferSize) |
| 40 | |
| 41 | if status := C.build_pack_x2reset_response(&payloadSize, &packedBuffer[0], C.ulong(maxAsn1CodecMessageBufferSize), &errorBuffer[0]); !status { |
irina | b2e5e2b | 2019-09-03 13:42:05 +0300 | [diff] [blame] | 42 | return fmt.Errorf("#x2_reset_response.prepareX2ResetResponsePDU - failed to build and pack the reset response message %s ", C.GoString(&errorBuffer[0])) |
irina | 79fa3a3 | 2019-09-03 12:24:01 +0300 | [diff] [blame] | 43 | |
| 44 | } |
| 45 | PackedX2ResetResponse = C.GoBytes(unsafe.Pointer(&packedBuffer[0]), C.int(payloadSize)) |
| 46 | |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | func init() { |
| 51 | if err := prepareX2ResetResponsePDU(MaxAsn1PackedBufferSize, MaxAsn1CodecMessageBufferSize); err != nil { |
| 52 | panic(err) |
| 53 | } |
| 54 | } |