x2_reset_response.go was added 74/874/1
authoririna <ib565x@intl.att.com>
Tue, 3 Sep 2019 10:42:05 +0000 (13:42 +0300)
committeririna <ib565x@intl.att.com>
Tue, 3 Sep 2019 10:42:25 +0000 (13:42 +0300)
Change-Id: Ife9258b1c817757ae94cc772e5766621cc605d5d
Signed-off-by: irina <ib565x@intl.att.com>
E2Manager/e2pdus/endc_x2_setup_request_test.go
E2Manager/e2pdus/x2_reset_known_causes.go
E2Manager/e2pdus/x2_reset_known_causes_test.go
E2Manager/e2pdus/x2_reset_response.go
E2Manager/e2pdus/x2_reset_response_test.go
E2Manager/e2pdus/x2_setup_requests.go

index e288c18..776b9ae 100644 (file)
@@ -32,34 +32,32 @@ func TestPackEndcX2apSetupRequest(t *testing.T) {
        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 {
@@ -92,7 +90,7 @@ func TestPackEndcX2apSetupRequestPackError(t *testing.T) {
        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)
index 3575a12..df84a4b 100644 (file)
@@ -1,3 +1,20 @@
+/*******************************************************************************
+ *
+ *   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/
@@ -12,8 +29,8 @@ import (
 
 //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
@@ -97,16 +114,16 @@ var knownCauses = map[string]cause{
        "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))
        }
index 5a3d474..96de726 100644 (file)
@@ -1,3 +1,20 @@
+/*******************************************************************************
+ *
+ *   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 (
@@ -8,13 +25,13 @@ 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,
@@ -33,7 +50,6 @@ func TestKnownCausesToX2ResetPDU(t *testing.T) {
                        cause:     "radioNetwork:invalid-MME-groupid",
                        packedPdu: "00070009000001000540020680",
                },
-
        }
 
        for _, tc := range testCases {
@@ -56,33 +72,31 @@ func TestKnownCausesToX2ResetPDU(t *testing.T) {
        }
 }
 
-
 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
+}
index 19c6a67..8e1f3f4 100644 (file)
@@ -35,7 +35,7 @@ func prepareX2ResetResponsePDU(maxAsn1PackedBufferSize int, maxAsn1CodecMessageB
        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))
index 2463502..21eb846 100644 (file)
@@ -53,7 +53,7 @@ func TestPrepareX2ResetResponsePDUFailure(t *testing.T) {
                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)
        }
index 9f3d3f8..938506b 100644 (file)
@@ -1,3 +1,20 @@
+/*******************************************************************************
+ *
+ *   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/
@@ -23,27 +40,27 @@ var PackedX2setupRequest []byte
 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])
        }
@@ -51,7 +68,7 @@ func PreparePackedEndcX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMe
        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))
@@ -69,12 +86,11 @@ func PreparePackedX2SetupRequest(maxAsn1PackedBufferSize int, maxAsn1CodecMessag
                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
 }
-