ricFlag := []byte{0xbb, 0xbc, 0xcc} /*pLMNId [3]bytes*/
var testCases = []struct {
- eNBId []byte
- eNBIdBitqty uint
- packedPdu string
+ eNBId []byte
+ eNBIdBitqty uint
+ packedPdu string
}{
{
- eNBId : []byte{0xab, 0xcd, 0x2}, /*00000010 -> 10000000*/
+ eNBId: []byte{0xab, 0xcd, 0x2}, /*00000010 -> 10000000*/
eNBIdBitqty: ShortMacro_eNB_ID,
packedPdu: "0024003200000100f4002b0000020015000900bbbccc8003abcd8000fa0017000001f700bbbcccabcd80000000bbbccc000000000001",
},
{
- eNBId : []byte{0xab, 0xcd, 0xe},
+ eNBId: []byte{0xab, 0xcd, 0xe},
eNBIdBitqty: Macro_eNB_ID,
packedPdu: "0024003100000100f4002a0000020015000800bbbccc00abcde000fa0017000001f700bbbcccabcde0000000bbbccc000000000001",
},
{
- eNBId : []byte{0xab, 0xcd, 0x7}, /*00000111 -> 00111000*/
+ eNBId: []byte{0xab, 0xcd, 0x7}, /*00000111 -> 00111000*/
eNBIdBitqty: LongMacro_eNB_ID,
//packedPdu: "0024003200000100f4002b0000020015000900bbbccc8103abcd3800fa0017000001f700bbbcccabcd38000000bbbccc000000000001",
packedPdu: "0024003200000100f4002b0000020015000900bbbcccc003abcd3800fa0017000001f700bbbcccabcd38000000bbbccc000000000001",
},
{
- eNBId : []byte{0xab, 0xcd, 0xef, 0x8},
+ eNBId: []byte{0xab, 0xcd, 0xef, 0x8},
eNBIdBitqty: Home_eNB_ID,
packedPdu: "0024003200000100f4002b0000020015000900bbbccc40abcdef8000fa0017000001f700bbbcccabcdef800000bbbccc000000000001",
},
-
-
}
for _, tc := range testCases {
eNBIdBitqty := uint(Macro_eNB_ID)
wantError := "packing error: #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big:53"
- _, _, err :=PreparePackedEndcX2SetupRequest(40 /*max packed buffer*/, MaxAsn1CodecMessageBufferSize /*max message buffer*/, pLMNId, eNBId, eNBIdBitqty, ricFlag)
+ _, _, err := PreparePackedEndcX2SetupRequest(40 /*max packed buffer*/, MaxAsn1CodecMessageBufferSize /*max message buffer*/, pLMNId, eNBId, eNBIdBitqty, ricFlag)
if err != nil {
if 0 != strings.Compare(fmt.Sprintf("%s", err), wantError) {
t.Errorf("want failure: %s, got: %s", wantError, err)
+/*******************************************************************************
+ *
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
package e2pdus
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
//TODO: replace the constant in setup_request_handler.go
const (
- MaxAsn1PackedBufferSize = 4096
- MaxAsn1CodecMessageBufferSize = 4096
+ MaxAsn1PackedBufferSize = 4096
+ MaxAsn1CodecMessageBufferSize = 4096
)
// Used as default by the x2_reset_request
"radioNetwork:pdcp-Overload": {causeGroup: C.Cause_PR_radioNetwork, cause: C.CauseRadioNetwork_pDCP_Overload},
}
-var knownCausesToX2ResetPDUs = map[string][]byte{}
+var knownCausesToX2ResetPDUs = map[string][]byte{}
func prepareX2ResetPDUs(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int) error {
- packedBuffer := make([]C.uchar,maxAsn1PackedBufferSize)
- errorBuffer := make([]C.char,maxAsn1CodecMessageBufferSize)
+ packedBuffer := make([]C.uchar, maxAsn1PackedBufferSize)
+ errorBuffer := make([]C.char, maxAsn1CodecMessageBufferSize)
for k, cause := range knownCauses {
var payloadSize = C.ulong(maxAsn1PackedBufferSize)
if status := C.build_pack_x2reset_request(cause.causeGroup, C.int(cause.cause), &payloadSize, &packedBuffer[0], C.ulong(maxAsn1CodecMessageBufferSize), &errorBuffer[0]); !status {
- return fmt.Errorf("#reset_request_handler.Handle - failed to build and pack the reset message %s ", C.GoString(&errorBuffer[0]))
+ return fmt.Errorf("#x2_reset_known_causes.prepareX2ResetPDUs - failed to build and pack the reset message %s ", C.GoString(&errorBuffer[0]))
}
knownCausesToX2ResetPDUs[strings.ToLower(k)] = C.GoBytes(unsafe.Pointer(&packedBuffer[0]), C.int(payloadSize))
}
+/*******************************************************************************
+ *
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
package e2pdus
import (
)
func TestKnownCausesToX2ResetPDU(t *testing.T) {
- _,err := logger.InitLogger(logger.InfoLevel)
- if err!=nil{
+ _, err := logger.InitLogger(logger.InfoLevel)
+ if err != nil {
t.Errorf("failed to initialize logger, error: %s", err)
}
var testCases = []struct {
- cause string
- packedPdu string
+ cause string
+ packedPdu string
}{
{
cause: OmInterventionCause,
cause: "radioNetwork:invalid-MME-groupid",
packedPdu: "00070009000001000540020680",
},
-
}
for _, tc := range testCases {
}
}
-
func TestKnownCausesToX2ResetPDUFailure(t *testing.T) {
_, err := logger.InitLogger(logger.InfoLevel)
if err != nil {
t.Errorf("failed to initialize logger, error: %s", err)
}
- _, ok := KnownCausesToX2ResetPDU("xxxx")
+ _, ok := KnownCausesToX2ResetPDU("xxxx")
if ok {
t.Errorf("want: not found, got: success.\n")
}
}
-
func TestPrepareX2ResetPDUsFailure(t *testing.T) {
_, err := logger.InitLogger(logger.InfoLevel)
if err != nil {
t.Errorf("failed to initialize logger, error: %s", err)
}
- err = prepareX2ResetPDUs(1, 4096)
+ err = prepareX2ResetPDUs(1, 4096)
if err == nil {
t.Errorf("want: error, got: success.\n")
}
- expected:= "#reset_request_handler.Handle - failed to build and pack the reset message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big:"
+ expected := "#x2_reset_known_causes_test.TestPrepareX2ResetPDUsFailure - failed to build and pack the reset message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big:"
if !strings.Contains(err.Error(), expected) {
t.Errorf("want :[%s], got: [%s]\n", expected, err)
}
-}
\ No newline at end of file
+}
var payloadSize = C.ulong(maxAsn1PackedBufferSize)
if status := C.build_pack_x2reset_response(&payloadSize, &packedBuffer[0], C.ulong(maxAsn1CodecMessageBufferSize), &errorBuffer[0]); !status {
- return fmt.Errorf("#reset_response.prepareX2ResetResponsePDU - failed to build and pack the reset response message %s ", C.GoString(&errorBuffer[0]))
+ return fmt.Errorf("#x2_reset_response.prepareX2ResetResponsePDU - failed to build and pack the reset response message %s ", C.GoString(&errorBuffer[0]))
}
PackedX2ResetResponse = C.GoBytes(unsafe.Pointer(&packedBuffer[0]), C.int(payloadSize))
t.Errorf("want: error, got: success.\n")
}
- expected:= "#reset_response.prepareX2ResetResponsePDU - failed to build and pack the reset response message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big"
+ expected:= "#x2_reset_response.prepareX2ResetResponsePDU - failed to build and pack the reset response message #src/asn1codec_utils.c.pack_pdu_aux - Encoded output of E2AP-PDU, is too big"
if !strings.Contains(err.Error(), expected) {
t.Errorf("want :[%s], got: [%s]\n", expected, err)
}
+/*******************************************************************************
+ *
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *******************************************************************************/
package e2pdus
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
var PackedEndcX2setupRequestAsString string
var PackedX2setupRequestAsString string
-func PreparePackedEndcX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int,pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
+func PreparePackedEndcX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int, pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
packedBuf := make([]byte, maxAsn1PackedBufferSize)
errBuf := make([]C.char, maxAsn1CodecMessageBufferSize)
packedBufSize := C.ulong(len(packedBuf))
pduAsString := ""
if !C.build_pack_endc_x2setup_request(
- (*C.uchar)(unsafe.Pointer(&pLMNId[0])) /*pLMN_Identity*/,
- (*C.uchar)(unsafe.Pointer(&eNB_Id[0])),
- C.uint(bitqty),
- (*C.uchar)(unsafe.Pointer(&ricFlag[0])) /*pLMN_Identity*/,
- &packedBufSize,
- (*C.uchar)(unsafe.Pointer(&packedBuf[0])),
- C.ulong(len(errBuf)),
- &errBuf[0]) {
+ (*C.uchar)(unsafe.Pointer(&pLMNId[0])) /*pLMN_Identity*/,
+ (*C.uchar)(unsafe.Pointer(&eNB_Id[0])),
+ C.uint(bitqty),
+ (*C.uchar)(unsafe.Pointer(&ricFlag[0])) /*pLMN_Identity*/,
+ &packedBufSize,
+ (*C.uchar)(unsafe.Pointer(&packedBuf[0])),
+ C.ulong(len(errBuf)),
+ &errBuf[0]) {
return nil, "", errors.New(fmt.Sprintf("packing error: %s", C.GoString(&errBuf[0])))
}
- pdu:= C.new_pdu(C.size_t(1)) //TODO: change signature
+ pdu := C.new_pdu(C.size_t(1)) //TODO: change signature
defer C.delete_pdu(pdu)
- if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])),C.size_t(len(errBuf)), &errBuf[0]){
+ if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])), C.size_t(len(errBuf)), &errBuf[0]) {
C.asn1_pdu_printer(pdu, C.size_t(len(errBuf)), &errBuf[0])
pduAsString = C.GoString(&errBuf[0])
}
return packedBuf[:packedBufSize], pduAsString, nil
}
-func PreparePackedX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int,pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
+func PreparePackedX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessageBufferSize int, pLMNId []byte, eNB_Id []byte /*18, 20, 21, 28 bits length*/, bitqty uint, ricFlag []byte) ([]byte, string, error) {
packedBuf := make([]byte, maxAsn1PackedBufferSize)
errBuf := make([]C.char, maxAsn1CodecMessageBufferSize)
packedBufSize := C.ulong(len(packedBuf))
return nil, "", errors.New(fmt.Sprintf("packing error: %s", C.GoString(&errBuf[0])))
}
- pdu:= C.new_pdu(C.size_t(1)) //TODO: change signature
+ pdu := C.new_pdu(C.size_t(1)) //TODO: change signature
defer C.delete_pdu(pdu)
- if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])),C.size_t(len(errBuf)), &errBuf[0]){
+ if C.per_unpack_pdu(pdu, packedBufSize, (*C.uchar)(unsafe.Pointer(&packedBuf[0])), C.size_t(len(errBuf)), &errBuf[0]) {
C.asn1_pdu_printer(pdu, C.size_t(len(errBuf)), &errBuf[0])
pduAsString = C.GoString(&errBuf[0])
}
return packedBuf[:packedBufSize], pduAsString, nil
}
-