3 // #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
4 // #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
5 // #include <asn1codec_utils.h>
6 // #include <x2setup_request_wrapper.h>
10 "github.com/pkg/errors"
15 ShortMacro_eNB_ID = 18
21 var PackedEndcX2setupRequest []byte
22 var PackedX2setupRequest []byte
23 var PackedEndcX2setupRequestAsString string
24 var PackedX2setupRequestAsString string
26 func PreparePackedEndcX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int,pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
27 packedBuf := make([]byte, maxAsn1PackedBufferSize)
28 errBuf := make([]C.char, maxAsn1CodecMessageBufferSize)
29 packedBufSize := C.ulong(len(packedBuf))
32 if !C.build_pack_endc_x2setup_request(
33 (*C.uchar)(unsafe.Pointer(&pLMNId[0])) /*pLMN_Identity*/,
34 (*C.uchar)(unsafe.Pointer(&eNB_Id[0])),
36 (*C.uchar)(unsafe.Pointer(&ricFlag[0])) /*pLMN_Identity*/,
38 (*C.uchar)(unsafe.Pointer(&packedBuf[0])),
41 return nil, "", errors.New(fmt.Sprintf("packing error: %s", C.GoString(&errBuf[0])))
44 pdu:= C.new_pdu(C.size_t(1)) //TODO: change signature
45 defer C.delete_pdu(pdu)
46 if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])),C.size_t(len(errBuf)), &errBuf[0]){
47 C.asn1_pdu_printer(pdu, C.size_t(len(errBuf)), &errBuf[0])
48 pduAsString = C.GoString(&errBuf[0])
51 return packedBuf[:packedBufSize], pduAsString, nil
54 func PreparePackedX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int,pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
55 packedBuf := make([]byte, maxAsn1PackedBufferSize)
56 errBuf := make([]C.char, maxAsn1CodecMessageBufferSize)
57 packedBufSize := C.ulong(len(packedBuf))
60 if !C.build_pack_x2setup_request(
61 (*C.uchar)(unsafe.Pointer(&pLMNId[0])) /*pLMN_Identity*/,
62 (*C.uchar)(unsafe.Pointer(&eNB_Id[0])),
64 (*C.uchar)(unsafe.Pointer(&ricFlag[0])) /*pLMN_Identity*/,
66 (*C.uchar)(unsafe.Pointer(&packedBuf[0])),
69 return nil, "", errors.New(fmt.Sprintf("packing error: %s", C.GoString(&errBuf[0])))
72 pdu:= C.new_pdu(C.size_t(1)) //TODO: change signature
73 defer C.delete_pdu(pdu)
74 if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])),C.size_t(len(errBuf)), &errBuf[0]){
75 C.asn1_pdu_printer(pdu, C.size_t(len(errBuf)), &errBuf[0])
76 pduAsString = C.GoString(&errBuf[0])
78 return packedBuf[:packedBufSize], pduAsString, nil