# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 2.0.4
+tag: 2.0.5
}
decoder := json.NewDecoder(r.Body)
- if err := decoder.Decode(request); err != nil {
- if err != nil {
- c.logger.Errorf("[Client -> E2 Manager] #controller.extractJsonBody - unable to extract json body - error: %s", err)
- c.handleErrorResponse(e2managererrors.NewInvalidJsonError(), writer)
- return false
- }
+
+ err := decoder.Decode(request)
+
+ if err != nil {
+ c.logger.Errorf("[Client -> E2 Manager] #controller.extractJsonBody - unable to extract json body - error: %s", err)
+ c.handleErrorResponse(e2managererrors.NewInvalidJsonError(), writer)
+ return false
}
return true
}
handler, err := c.handlerProvider.GetHandler(requestName)
+
if err != nil {
c.handleErrorResponse(err, writer)
return
rnibWriterProvider func() rNibWriter.RNibWriter
}
-func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibReaderProvider func() reader.RNibReader,
- rnibWriterProvider func() rNibWriter.RNibWriter) *NodebController {
+func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) *NodebController {
messageChannel = make(chan *models.E2RequestMessage)
errorChannel = make(chan error)
return &NodebController{
-package handlers
+package converters
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
return nil
}
-func extractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error {
+func ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error {
defer C.delete_pdu(pdu)
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
//
// actualRanLoadInformation := &entities.RanLoadInformation{LoadTimestamp: LoadTimestamp}
//
-// err = extractAndBuildRanLoadInformation(pdu, actualRanLoadInformation)
+// err = ExtractAndBuildRanLoadInformation(pdu, actualRanLoadInformation)
//
// if err != nil {
// t.Errorf("want: success, got: error: %v\n", err)
// limitations under the License.
//
-package handlers
+package converters
-// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
+// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
// #include <asn1codec_utils.h>
// #include <x2setup_response_wrapper.h>
return &setupFailure, nil
}
-func unpackEndcX2SetupFailureResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.SetupFailure, error) {
- pdu, err := unpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
+func UnpackEndcX2SetupFailureResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.SetupFailure, error) {
+ pdu, err := UnpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
if err != nil {
return nil, err
}
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/rNibWriter"
"fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
"testing"
)
/*
Test permutations of x2 setup response to protobuf enb
- */
+*/
func TestUnpackEndcX2SetupFailureResponseAndExtract(t *testing.T) {
logger, _ := logger.InitLogger(logger.InfoLevel)
var testCases = []struct {
- saveToRNib bool
- response string
- packedPdu string
- failure error
+ saveToRNib bool
+ response string
+ packedPdu string
+ failure error
}{
{
saveToRNib: false, //TODO: use MOCK?
- response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
+ response: "CONNECTED_SETUP_FAILED network_layer_cause:HANDOVER_DESIRABLE_FOR_RADIO_REASONS time_to_wait:V1S criticality_diagnostics:<procedure_code:33 triggering_message:UNSUCCESSFUL_OUTCOME procedure_criticality:NOTIFY information_element_criticality_diagnostics:<ie_criticality:REJECT ie_id:128 type_of_error:MISSING > > ",
/*
- E2AP-PDU:
- unsuccessfulOutcome_t
- procedureCode_t = 0x24
- criticality_t = 0
- ENDCX2SetupFailure
- protocolIEs_t:
- ProtocolIE_Container_elm
- id_t = 0x5
- criticality_t = 0x1
- Cause:
- radioNetwork_t = 0
- ProtocolIE_Container_elm
- id_t = 0x16
- criticality_t = 0x1
- TimeToWait = 0
- ProtocolIE_Container_elm
- id_t = 0x11
- criticality_t = 0x1
- CriticalityDiagnostics
- procedureCode_t = 0x21
- triggeringMessage_t = 0x2
- procedureCriticality_t = 0x2
- iEsCriticalityDiagnostics_t:
- CriticalityDiagnostics_IE_List_elm
- iECriticality_t = 0
- iE_ID_t = 0x80
- typeOfError_t = 0x1
+ E2AP-PDU:
+ unsuccessfulOutcome_t
+ procedureCode_t = 0x24
+ criticality_t = 0
+ ENDCX2SetupFailure
+ protocolIEs_t:
+ ProtocolIE_Container_elm
+ id_t = 0x5
+ criticality_t = 0x1
+ Cause:
+ radioNetwork_t = 0
+ ProtocolIE_Container_elm
+ id_t = 0x16
+ criticality_t = 0x1
+ TimeToWait = 0
+ ProtocolIE_Container_elm
+ id_t = 0x11
+ criticality_t = 0x1
+ CriticalityDiagnostics
+ procedureCode_t = 0x21
+ triggeringMessage_t = 0x2
+ procedureCriticality_t = 0x2
+ iEsCriticalityDiagnostics_t:
+ CriticalityDiagnostics_IE_List_elm
+ iECriticality_t = 0
+ iE_ID_t = 0x80
+ typeOfError_t = 0x1
*/
packedPdu: "4024001a0000030005400200000016400100001140087821a00000008040"},
- /**** shares the same code with x2setup failure response to protobuf ****/
+ /**** shares the same code with x2setup failure response to protobuf ****/
}
- initDb_f := true
+ initDb_f := true
for _, tc := range testCases {
t.Run(tc.packedPdu, func(t *testing.T) {
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- response, err := unpackEndcX2SetupFailureResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ response, err := UnpackEndcX2SetupFailureResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
if tc.failure == nil {
} else {
nb := &entities.NodebInfo{}
nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED_SETUP_FAILED
- nb.SetupFailure = response
+ nb.SetupFailure = response
nb.FailureType = entities.Failure_X2_SETUP_FAILURE
respStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, response)
if !strings.EqualFold(respStr, tc.response) {
rNibWriter.Init("e2Manager", 1)
initDb_f = false
}
- nbIdentity := &entities.NbIdentity{InventoryName:"RanName"}
+ nbIdentity := &entities.NbIdentity{InventoryName: "RanName"}
if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
if tc.failure == nil {
t.Errorf("rNibWriter failed to save ENB. Error: %s\n", rNibErr.Error())
})
}
}
-
// limitations under the License.
//
-package handlers
+package converters
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
return globalNbId, gnb, nil
}
-func unpackEndcX2SetupResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.GlobalNbId, *entities.Gnb, error) {
- pdu, err := unpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
+func UnpackEndcX2SetupResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.GlobalNbId, *entities.Gnb, error) {
+ pdu, err := UnpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
if err != nil {
return nil, nil, err
}
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/rNibWriter"
"fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
"testing"
)
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- key, gnb, err := unpackEndcX2SetupResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ key, gnb, err := UnpackEndcX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
if err != nil {
if tc.failure == nil {
// limitations under the License.
//
-package handlers
+package converters
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
)
type X2PduRefinedResponse struct {
- pduPrint string
+ PduPrint string
}
//func unpackX2apPduUPer(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*C.E2AP_PDU_t, error) {
// return pdu, nil
//}
-func unpackX2apPdu(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*C.E2AP_PDU_t, error) {
+func UnpackX2apPdu(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*C.E2AP_PDU_t, error) {
pdu := C.new_pdu(C.ulong(allocationBufferSize))
if pdu == nil {
return nil, errors.New("allocation failure (pdu)")
}
- logger.Infof("#x2apPdu_asn1_unpacker.unpackX2apPdu - Packed pdu(%d):%x", packedBufferSize, packedBuf)
+ logger.Infof("#x2apPdu_asn1_unpacker.UnpackX2apPdu - Packed pdu(%d):%x", packedBufferSize, packedBuf)
errBuf := make([]C.char, maxMessageBufferSize)
if !C.per_unpack_pdu(pdu, C.ulong(packedBufferSize), (*C.uchar)(unsafe.Pointer(&packedBuf[0])), C.ulong(len(errBuf)), &errBuf[0]) {
if logger.DebugEnabled() {
C.asn1_pdu_printer(pdu, C.size_t(len(errBuf)), &errBuf[0])
- logger.Debugf("#x2apPdu_asn1_unpacker.unpackX2apPdu - PDU: %v packed size:%d", C.GoString(&errBuf[0]), packedBufferSize)
+ logger.Debugf("#x2apPdu_asn1_unpacker.UnpackX2apPdu - PDU: %v packed size:%d", C.GoString(&errBuf[0]), packedBufferSize)
}
return pdu, nil
}
-func unpackX2apPduAndRefine(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*X2PduRefinedResponse, error) {
- pdu, err := unpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
+func UnpackX2apPduAndRefine(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*X2PduRefinedResponse, error) {
+ pdu, err := UnpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
if err != nil {
return nil, err
}
refinedResponse = C.GoString(&buf[0])
}
- return &X2PduRefinedResponse{pduPrint: refinedResponse}, nil
+ return &X2PduRefinedResponse{PduPrint: refinedResponse}, nil
}
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
+ "e2mgr/e2pdus"
"e2mgr/logger"
"fmt"
"strings"
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- response, err := unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ response, err := UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
t.Errorf("want: success, got: unpack failed. Error: %v\n", err)
}
- want:= strings.Fields(wantPduAsStr)
- got:= strings.Fields(response.pduPrint)
+ want := strings.Fields(wantPduAsStr)
+ got := strings.Fields(response.PduPrint)
if len(want) != len(got) {
- t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", wantPduAsStr, response.pduPrint)
+ t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", wantPduAsStr, response.PduPrint)
}
- for i:=0; i < len(want); i++ {
- if strings.Compare(want[i], got[i] ) != 0 {
- t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", wantPduAsStr, strings.TrimSpace(response.pduPrint))
+ for i := 0; i < len(want); i++ {
+ if strings.Compare(want[i], got[i]) != 0 {
+ t.Errorf("\nwant :\t[%s]\n got: \t\t[%s]\n", wantPduAsStr, strings.TrimSpace(response.PduPrint))
}
}
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- _, err = unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ _, err = UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
if 0 != strings.Compare(fmt.Sprintf("%s", err), wantError) {
t.Errorf("want failure: %s, got: %s", wantError, err)
}
}
-
-
// limitations under the License.
//
-package handlers
+package converters
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
return &setupFailure, nil
}
-func unpackX2SetupFailureResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.SetupFailure, error) {
- pdu, err := unpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
+func UnpackX2SetupFailureResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.SetupFailure, error) {
+ pdu, err := UnpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
if err != nil {
return nil, err
}
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/rNibWriter"
"fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
"testing"
)
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- response, err := unpackX2SetupFailureResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ response, err := UnpackX2SetupFailureResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
if tc.failure == nil {
// limitations under the License.
//
-package handlers
+package converters
// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
// #include <x2setup_response_wrapper.h>
import "C"
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"e2mgr/logger"
"fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"github.com/pkg/errors"
"unsafe"
)
return globalNbId, &enb, nil
}
-func unpackX2SetupResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.GlobalNbId, *entities.Enb, error) {
- pdu, err := unpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
+func UnpackX2SetupResponseAndExtract(logger *logger.Logger, allocationBufferSize int, packedBufferSize int, packedBuf []byte, maxMessageBufferSize int) (*entities.GlobalNbId, *entities.Enb, error) {
+ pdu, err := UnpackX2apPdu(logger, allocationBufferSize, packedBufferSize, packedBuf, maxMessageBufferSize)
if err != nil {
return nil, nil, err
}
* limitations under the License.
*
*******************************************************************************/
-package handlers
+package converters
import (
- "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/rNibWriter"
"fmt"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strings"
"testing"
)
t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
}
- key, enb, err := unpackX2SetupResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ key, enb, err := UnpackX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
if tc.failure == nil {
const (
MaxAsn1PackedBufferSize = 4096
MaxAsn1CodecMessageBufferSize = 4096
+ MaxAsn1CodecAllocationBufferSize = 4096 // TODO: remove later
)
// Used as default by the x2_reset_request
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import "C"
import (
config *configuration.Configuration
}
-func NewDeleteAllRequestHandler(rmrService *services.RmrService, config *configuration.Configuration, writerProvider func() rNibWriter.RNibWriter,
- readerProvider func() reader.RNibReader) *DeleteAllRequestHandler {
+func NewDeleteAllRequestHandler(rmrService *services.RmrService, config *configuration.Configuration, writerProvider func() rNibWriter.RNibWriter, readerProvider func() reader.RNibReader) *DeleteAllRequestHandler {
return &DeleteAllRequestHandler {
readerProvider: readerProvider,
writerProvider: writerProvider,
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/configuration"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/e2pdus"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/e2pdus"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"bytes"
// limitations under the License.
//
-package handlers
+package httpmsghandlers
import (
"e2mgr/configuration"
-package handlers
+package httpmsghandlers
import (
"e2mgr/configuration"
rmrMessengerMock.On("SendMsg",msg,mock.Anything).Return(msg,nil)
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED }
rmrMessengerMock.On("SendMsg",msg,mock.Anything).Return(msg,nil)
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED }
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED }
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_DISCONNECTED }
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
readerMock.On("GetNodeb",ranName).Return(&entities.NodebInfo{}, common.NewResourceNotFoundError("nodeb not found"))
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
readerMock.On("GetNodeb",ranName).Return(&entities.NodebInfo{}, common.NewInternalError(fmt.Errorf("internal error")))
rmrMessengerMock.On("SendMsg",msg,mock.Anything).Return(&rmrCgo.MBuf{},fmt.Errorf("rmr error"))
config := configuration.ParseConfiguration()
- rmrService:=getRmrService(rmrMessengerMock, log)
+ rmrService:= getRmrService(rmrMessengerMock, log)
handler := NewX2ResetRequestHandler(rmrService, config, writerProvider, readerProvider)
var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED }
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
}
}
-func (handler E2TermInitNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
- request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+func (handler E2TermInitNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
- logger.Infof("#E2TermInitNotificationHandler.Handle - Handling E2_TERM_INIT")
+logger.Infof("#E2TermInitNotificationHandler.Handle - Handling E2_TERM_INIT")
nbIdentityList, err := handler.rnibReaderProvider().GetListNodebIds()
if err != nil {
-package handlers
+package rmrmsghandlers
import (
"e2mgr/configuration"
"e2mgr/models"
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
+ "e2mgr/services"
+ "e2mgr/sessions"
+ "e2mgr/tests"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
return readerMock
}
- ids := []*entities.NbIdentity {{InventoryName:"test1"}}
+ ids := []*entities.NbIdentity{{InventoryName: "test1"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
var initialNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
return readerMock
}
- ids := []*entities.NbIdentity {{InventoryName:"test1"}, {InventoryName:"test2"} }
+ ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
var initialNodeb0 = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
var argNodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
writerMock.On("UpdateNodebInfo", argNodeb).Return(rnibErr)
-
payload := e2pdus.PackedX2setupRequest
xaction := []byte(ids[0].InventoryName)
msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
return readerMock
}
- ids := []*entities.NbIdentity {{InventoryName:"test1"}, {InventoryName:"test2"},{InventoryName:"test3"} }
+ ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
var initialNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
readerMock.On("GetNodeb", ids[1].InventoryName).Return(initialNodeb1, rnibErr)
readerMock.On("GetNodeb", ids[2].InventoryName).Return(initialNodeb2, rnibErr)
- var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
- var argNodeb0Fail = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 0}
+ var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb0Fail = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 0}
writerMock.On("UpdateNodebInfo", argNodeb0).Return(rnibErr)
writerMock.On("UpdateNodebInfo", argNodeb0Fail).Return(rnibErr)
-
- payload :=models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0,ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
+ payload := models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0, ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
xaction := []byte(ids[0].InventoryName)
msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
//xaction = []byte(ids[1].InventoryName)
//msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
- rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, fmt.Errorf("RMR Error"))
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, fmt.Errorf("RMR Error"))
handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil, nil)
return readerMock
}
- ids := []*entities.NbIdentity {{InventoryName:"test1"}, {InventoryName:"test2"},{InventoryName:"test3"} }
+ ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
var initialNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
readerMock.On("GetNodeb", ids[1].InventoryName).Return(initialNodeb1, common.NewResourceNotFoundError("not found"))
readerMock.On("GetNodeb", ids[2].InventoryName).Return(initialNodeb2, rnibErr)
- var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
- var argNodeb0Success = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb0Success = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
writerMock.On("UpdateNodebInfo", argNodeb0).Return(rnibErr)
writerMock.On("UpdateNodebInfo", argNodeb0Success).Return(rnibErr)
- var argNodeb2 = &entities.NodebInfo{RanName: ids[2].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
- var argNodeb2Success = &entities.NodebInfo{RanName: ids[2].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb2 = &entities.NodebInfo{RanName: ids[2].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb2Success = &entities.NodebInfo{RanName: ids[2].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
writerMock.On("UpdateNodebInfo", argNodeb2).Return(rnibErr)
writerMock.On("UpdateNodebInfo", argNodeb2Success).Return(rnibErr)
-
- payload :=models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0,ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
+ payload := models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0, ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
xaction := []byte(ids[0].InventoryName)
msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
//xaction = []byte(ids[1].InventoryName)
//msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
- rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil, nil)
rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 2)
}
-
func TestE2TerminInitHandlerSuccessThreeRansSecondRnibInternalErrorFailure(t *testing.T) {
log, readerMock, writerMock, rmrMessengerMock, ranReconnectMgr := initRanLostConnectionTest(t)
var rnibErr error
return readerMock
}
- ids := []*entities.NbIdentity {{InventoryName:"test1"}, {InventoryName:"test2"},{InventoryName:"test3"} }
+ ids := []*entities.NbIdentity{{InventoryName: "test1"}, {InventoryName: "test2"}, {InventoryName: "test3"}}
readerMock.On("GetListNodebIds").Return(ids, rnibErr)
var initialNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST}
readerMock.On("GetNodeb", ids[1].InventoryName).Return(initialNodeb1, common.NewInternalError(fmt.Errorf("internal error")))
readerMock.On("GetNodeb", ids[2].InventoryName).Return(initialNodeb2, rnibErr)
- var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
- var argNodeb0Success = &entities.NodebInfo{RanName: ids[0].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb0 = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb0Success = &entities.NodebInfo{RanName: ids[0].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
writerMock.On("UpdateNodebInfo", argNodeb0).Return(rnibErr)
writerMock.On("UpdateNodebInfo", argNodeb0Success).Return(rnibErr)
- var argNodeb2 = &entities.NodebInfo{RanName: ids[2].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
- var argNodeb2Success = &entities.NodebInfo{RanName: ids[2].InventoryName,ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb2 = &entities.NodebInfo{RanName: ids[2].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTING, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
+ var argNodeb2Success = &entities.NodebInfo{RanName: ids[2].InventoryName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, E2ApplicationProtocol: entities.E2ApplicationProtocol_X2_SETUP_REQUEST, ConnectionAttempts: 1}
writerMock.On("UpdateNodebInfo", argNodeb2).Return(rnibErr)
writerMock.On("UpdateNodebInfo", argNodeb2Success).Return(rnibErr)
-
- payload :=models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0,ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
+ payload := models.NewE2RequestMessage(ids[0].InventoryName /*tid*/, "", 0, ids[0].InventoryName, e2pdus.PackedX2setupRequest).GetMessageAsBytes(log)
xaction := []byte(ids[0].InventoryName)
msg0 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[0].InventoryName, &payload, &xaction)
//xaction = []byte(ids[1].InventoryName)
//msg1 := rmrCgo.NewMBuf(rmrCgo.RIC_X2_SETUP_REQ, len(payload), ids[1].InventoryName, &payload, &xaction)
- rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
+ rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(msg0, nil)
handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil, nil)
return readerMock
}
- readerMock.On("GetListNodebIds").Return( []*entities.NbIdentity{} , rnibErr)
+ readerMock.On("GetListNodebIds").Return([]*entities.NbIdentity{}, rnibErr)
handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil, nil)
return readerMock
}
- readerMock.On("GetListNodebIds").Return( []*entities.NbIdentity{} , common.NewInternalError(fmt.Errorf("internal error")))
+ readerMock.On("GetListNodebIds").Return([]*entities.NbIdentity{}, common.NewInternalError(fmt.Errorf("internal error")))
handler := NewE2TermInitNotificationHandler(ranReconnectMgr, readerProvider)
handler.Handle(log, nil, nil, nil)
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 0)
rmrMessengerMock.AssertNumberOfCalls(t, "SendMsg", 0)
}
+
+// TODO: extract to test_utils
+func getRmrService(rmrMessengerMock *mocks.RmrMessengerMock, log *logger.Logger) *services.RmrService {
+ rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
+ messageChannel := make(chan *models.NotificationResponse)
+ rmrMessengerMock.On("Init", tests.GetPort(), tests.MaxMsgSize, tests.Flags, log).Return(&rmrMessenger)
+ return services.NewRmrService(services.NewRmrConfig(tests.Port, tests.MaxMsgSize, tests.Flags, log), rmrMessenger, make(sessions.E2Sessions), messageChannel)
+}
+
+// TODO: extract to test_utils
+func initLog(t *testing.T) *logger.Logger {
+ log, err := logger.InitLogger(logger.InfoLevel)
+ if err != nil {
+ t.Errorf("#delete_all_request_handler_test.TestHandleSuccessFlow - failed to initialize logger, error: %s", err)
+ }
+ return log
+}
-package handlers
+package rmrmsghandlers
import "C"
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
"e2mgr/rNibWriter"
func (src EnbLoadInformationNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
- pdu, err := unpackX2apPdu(logger, MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize)
+ pdu, err := converters.UnpackX2apPdu(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
if err != nil {
logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Unpack failed. Error: %v", request.RanName, err)
ranLoadInformation := &entities.RanLoadInformation{LoadTimestamp: uint64(request.StartTime.UnixNano())}
- err = extractAndBuildRanLoadInformation(pdu, ranLoadInformation)
+ err = converters.ExtractAndBuildRanLoadInformation(pdu, ranLoadInformation)
if (err != nil) {
- logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed at extractAndBuildRanLoadInformation. Error: %v", request.RanName, err)
+ logger.Errorf("#EnbLoadInformationNotificationHandler.Handle - RAN name: %s - Failed at ExtractAndBuildRanLoadInformation. Error: %v", request.RanName, err)
return
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
-// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
-// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
+// #cgo CFLAGS: -I../../asn1codec/inc/ -I../../asn1codec/e2ap_engine/
+// #cgo LDFLAGS: -L ../../asn1codec/lib/ -L../../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
// #include <asn1codec_utils.h>
// #include <configuration_update_wrapper.h>
import "C"
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
"e2mgr/rmrCgo"
messageChannel chan<- *models.NotificationResponse) {
var payloadSize C.ulong
- payloadSize = MaxAsn1PackedBufferSize
- packedBuffer := [MaxAsn1PackedBufferSize]C.uchar{}
- errorBuffer := [MaxAsn1PackedBufferSize]C.char{}
- refinedMessage, err := unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ payloadSize = e2pdus.MaxAsn1PackedBufferSize
+ packedBuffer := [e2pdus.MaxAsn1PackedBufferSize]C.uchar{}
+ errorBuffer := [e2pdus.MaxAsn1PackedBufferSize]C.char{}
+ refinedMessage, err := converters.UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
- status := C.build_pack_endc_configuration_update_failure(&payloadSize, &packedBuffer[0], MaxAsn1PackedBufferSize, &errorBuffer[0])
+ status := C.build_pack_endc_configuration_update_failure(&payloadSize, &packedBuffer[0], e2pdus.MaxAsn1PackedBufferSize, &errorBuffer[0])
if status {
payload := (*[1 << 30]byte)(unsafe.Pointer(&packedBuffer))[:payloadSize:payloadSize]
logger.Debugf("#endc_configuration_update_handler.Handle - Endc configuration update negative ack message payload: (%d) %02x", len(payload), payload)
logger.Errorf("#endc_configuration_update_handler.Handle - unpack failed. Error: %v", err)
} else {
logger.Infof("#endc_configuration_update_handler.Handle - Endc configuration update initiating message received")
- logger.Debugf("#endc_configuration_update_handler.Handle - Endc configuration update initiating message payload: %s", refinedMessage.pduPrint)
- status := C.build_pack_endc_configuration_update_ack(&payloadSize, &packedBuffer[0], MaxAsn1PackedBufferSize, &errorBuffer[0])
+ logger.Debugf("#endc_configuration_update_handler.Handle - Endc configuration update initiating message payload: %s", refinedMessage.PduPrint)
+ status := C.build_pack_endc_configuration_update_ack(&payloadSize, &packedBuffer[0], e2pdus.MaxAsn1PackedBufferSize, &errorBuffer[0])
if status {
payload := (*[1 << 30]byte)(unsafe.Pointer(&packedBuffer))[:payloadSize:payloadSize]
logger.Debugf("#endc_configuration_update_handler.Handle - Endc configuration update positive ack message payload: (%d) %02x", len(payload), payload)
// See the License for the specific language governing permissions and
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
+ "e2mgr/logger"
"e2mgr/models"
"e2mgr/rNibWriter"
+ "e2mgr/sessions"
"fmt"
-
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
-
- "e2mgr/logger"
- "e2mgr/sessions"
)
type EndcX2SetupResponseNotificationHandler struct{}
-func (src EndcX2SetupResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
- request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+func (src EndcX2SetupResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
e2session, ok := e2Sessions[request.TransactionId]
- gnbId, gnb, err := unpackEndcX2SetupResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
-
+ gnbId, gnb, err := converters.UnpackEndcX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
logger.Errorf("#endc_setup_response_notification_handler.Handle - unpack failed. Error: %v", err)
delete(e2Sessions, request.TransactionId) // Avoid pinning memory (help GC)
}
-
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/rNibWriter"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
e2session, ok := e2Sessions[request.TransactionId]
- failureResponse, err := unpackEndcX2SetupFailureResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ failureResponse, err := converters.UnpackEndcX2SetupFailureResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
logger.Errorf("#endc_x2Setup_failure_response_notification_handler.Handle - unpack failed. Error: %v", err)
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
//// See the License for the specific language governing permissions and
//// limitations under the License.
////
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// 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 rmrmsghandlers
+
+import (
+ "e2mgr/logger"
+ "e2mgr/managers"
+ "e2mgr/models"
+ "e2mgr/rNibWriter"
+ "e2mgr/sessions"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
+)
+
+type SetupResponseNotificationHandler struct {
+ rnibReaderProvider func() reader.RNibReader
+ rnibWriterProvider func() rNibWriter.RNibWriter
+ setupResponseManager managers.ISetupResponseManager
+}
+
+func NewSetupResponseNotificationHandler(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, setupResponseManager managers.ISetupResponseManager) SetupResponseNotificationHandler {
+ return SetupResponseNotificationHandler{
+ rnibReaderProvider: rnibReaderProvider,
+ rnibWriterProvider: rnibWriterProvider,
+ setupResponseManager: setupResponseManager,
+ }
+}
+
+func (h SetupResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+ logger.Infof("#SetupResponseNotificationHandler - RAN name : %s - Received X2 Setup Response Notification", request.RanName)
+
+ nodebInfo, rnibErr := h.rnibReaderProvider().GetNodeb(request.RanName)
+
+ if rnibErr != nil {
+ logger.Errorf("#X2SetupResponseNotificationHandler - RAN name : %s - Error fetching ran from rNib: %v", request.RanName, rnibErr)
+ return
+ }
+
+ if !isConnectionStatusValid(nodebInfo.ConnectionStatus) {
+ logger.Errorf("#X2SetupResponseNotificationHandler - RAN name : %s - Invalid connection status: %s", request.RanName, nodebInfo.ConnectionStatus)
+ return
+ }
+
+ nbIdentity := &entities.NbIdentity{}
+
+ err := h.setupResponseManager.SetNodeb(logger, nbIdentity, nodebInfo, request.Payload)
+
+ if err != nil {
+ return
+ }
+
+ rnibErr = h.rnibWriterProvider().SaveNodeb(nbIdentity, nodebInfo)
+
+ if rnibErr != nil {
+ logger.Errorf("#X2SetupResponseNotificationHandler - RAN name : %s - Error saving RAN to rNib: %v", request.RanName, rnibErr)
+ return
+ }
+
+ logger.Infof("#X2SetupResponseNotificationHandler - RAN name : %s - Successfully saved RAN to rNib", request.RanName)
+}
+
+func isConnectionStatusValid(connectionStatus entities.ConnectionStatus) bool {
+ return connectionStatus == entities.ConnectionStatus_CONNECTING || connectionStatus == entities.ConnectionStatus_CONNECTED
+}
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// 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 rmrmsghandlers
+
+import (
+ "e2mgr/logger"
+ "time"
+)
+
+//import "C"
+
+//type SetupResponseNotificationHandler struct{}
+//
+//func (src SetupResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
+// request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+//
+// refinedResponse, err := UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
+// if err != nil {
+// logger.Errorf("#setup_response_notification_handler_bak.Handle - unpack failed. Error: %v", err)
+// }
+//
+// e2session, ok := e2Sessions[request.TransactionId]
+// printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#setupResponseNotificationHandler.handle - transactionId %s: Summary: Elapsed time for receiving and handling setup response from E2 terminator", request.TransactionId), request.StartTime)
+// if ok {
+// printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#setupResponseNotificationHandler.handle - transactionId %s: Summary: Total roundtrip elapsed time", request.TransactionId), e2session.SessionStart)
+// delete(e2Sessions, request.TransactionId) // Avoid pinning memory (help GC)
+// }
+// logger.Debugf("#setupResponseNotificationHandler.handle - transactionId %s: PDU: %v", request.TransactionId, refinedResponse.PduPrint)
+//}
+//
+func printHandlingSetupResponseElapsedTimeInMs(logger *logger.Logger, msg string, startTime time.Time) {
+ logger.Infof("%s: %f ms", msg, float64(time.Since(startTime))/float64(time.Millisecond))
+}
--- /dev/null
+////
+//// Copyright 2019 AT&T Intellectual Property
+//// Copyright 2019 Nokia
+////
+//// 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 rmrmsghandlers
+//
+//import (
+// "e2mgr/logger"
+// "e2mgr/models"
+// "e2mgr/rmrCgo"
+// "e2mgr/sessions"
+// "e2mgr/tests"
+// "github.com/stretchr/testify/assert"
+// "testing"
+// "time"
+//)
+//
+//func TestHandleSuccess(t *testing.T){
+// log, err := logger.InitLogger(logger.InfoLevel)
+// if err!=nil{
+// t.Errorf("#setup_request_handler_test.TestHandleSuccess - failed to initialize logger, error: %s", err)
+// }
+// h := SetupResponseNotificationHandler{}
+// E2Sessions := make(sessions.E2Sessions)
+//
+// payload := tests.GetPackedPayload(t)
+// mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &tests.DummyXAction)
+// notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
+// var messageChannel chan<- *models.NotificationResponse
+//
+// assert.NotPanics(t, func(){ h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)})
+//}
+//
+//func TestHandleFailure(t *testing.T){
+// log, err := logger.InitLogger(logger.InfoLevel)
+// if err!=nil{
+// t.Errorf("#setup_request_handler_test.TestHandleFailure - failed to initialize logger, error: %s", err)
+// }
+// h := SetupResponseNotificationHandler{}
+// E2Sessions := make(sessions.E2Sessions)
+//
+// mBuf := rmrCgo.NewMBuf(tests.MessageType, 4,"RanName", &tests.DummyPayload, &tests.DummyXAction)
+// notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
+// var messageChannel chan<- *models.NotificationResponse
+//
+// assert.Panics(t, func(){ h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)})
+//}
\ No newline at end of file
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
"e2mgr/rNibWriter"
e2session, ok := e2Sessions[request.TransactionId]
- failureResponse, err := unpackX2SetupFailureResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ failureResponse, err := converters.UnpackX2SetupFailureResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize)
if err != nil {
logger.Errorf("#x2Setup_failure_response_notification_handler.Handle - unpack failed. Error: %v", err)
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
+// #cgo CFLAGS: -I../../asn1codec/inc/ -I../../asn1codec/e2ap_engine/
+// #cgo LDFLAGS: -L ../../asn1codec/lib/ -L../../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
+// #include <asn1codec_utils.h>
+// #include <x2reset_response_wrapper.h>
+import "C"
import (
"e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/sessions"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
+ "unsafe"
)
type X2ResetRequestNotificationHandler struct {
}
}
-func (src X2ResetRequestNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
- request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+func (src X2ResetRequestNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
logger.Debugf("#X2ResetRequestNotificationHandler.Handle - Ran name: %s", request.RanName)
return
}
- response := models.NotificationResponse{RanName: request.RanName, Payload: e2pdus.PackedX2ResetResponse, MgsType: rmrCgo.RIC_X2_RESET_RESP}
- messageChannel <- &response
+ src.createAndAddToChannel(logger, request, messageChannel)
//TODO change name of printHandlingSetupResponseElapsedTimeInMs (remove setup response) and move to utils?
printHandlingSetupResponseElapsedTimeInMs(logger, "#X2ResetRequestNotificationHandler.Handle - Summary: Elapsed time for receiving and handling reset request message from E2 terminator", request.StartTime)
-}
\ No newline at end of file
+}
+
+func (src X2ResetRequestNotificationHandler) createAndAddToChannel(logger *logger.Logger, request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
+
+ packedBuffer := make([]C.uchar, e2pdus.MaxAsn1PackedBufferSize)
+ errorBuffer := make([]C.char, e2pdus.MaxAsn1CodecMessageBufferSize)
+ var payloadSize = C.ulong(e2pdus.MaxAsn1PackedBufferSize)
+
+ if status := C.build_pack_x2reset_response(&payloadSize, &packedBuffer[0], C.ulong(e2pdus.MaxAsn1CodecMessageBufferSize), &errorBuffer[0]); !status {
+ logger.Errorf("#X2ResetRequestNotificationHandler.createAndAddToChannel - failed to build and pack the reset response message %s ", C.GoString(&errorBuffer[0]))
+ return
+ }
+ payload := C.GoBytes(unsafe.Pointer(&packedBuffer[0]), C.int(payloadSize))
+ response := models.NotificationResponse{RanName: request.RanName, Payload: payload, MgsType: rmrCgo.RIC_X2_RESET_RESP}
+
+ messageChannel <- &response
+}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/mocks"
readerMock.On("GetNodeb", mBuf.Meid).Return(nb, rnibErr)
h.Handle(log,nil, ¬ificationRequest, nil)
-}
+}
\ No newline at end of file
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
-// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
-// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
+// #cgo CFLAGS: -I../../asn1codec/inc/ -I../../asn1codec/e2ap_engine/
+// #cgo LDFLAGS: -L ../../asn1codec/lib/ -L../../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
// #include <asn1codec_utils.h>
import "C"
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
"e2mgr/sessions"
logger.Errorf("#x2ResetResponseHandler.Handle - failed to retrieve nb entity. RanName: %s. Error: %s", request.RanName, rNibErr.Error())
} else {
logger.Debugf("#x2ResetResponseHandler.Handle - nb entity retrieved. RanName %s, ConnectionStatus %s", nb.RanName, nb.ConnectionStatus)
- refinedMessage, err := unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ refinedMessage, err := converters.UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
logger.Errorf("#x2ResetResponseHandler.Handle - failed to unpack reset response message. RanName %s, Payload: %s", request.RanName, request.Payload)
} else {
- logger.Debugf("#x2ResetResponseHandler.Handle - reset response message payload unpacked. RanName %s, Message: %s", request.RanName, refinedMessage.pduPrint)
+ logger.Debugf("#x2ResetResponseHandler.Handle - reset response message payload unpacked. RanName %s, Message: %s", request.RanName, refinedMessage.PduPrint)
}
}
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/models"
"e2mgr/rNibWriter"
"fmt"
e2session, ok := e2Sessions[request.TransactionId]
- enbId, enb, err := unpackX2SetupResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ enbId, enb, err := converters.UnpackX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize /*message buffer*/)
if err != nil {
logger.Errorf("#x2apSetup_response_notification_handler.Handle - unpack failed. Error: %v", err)
}
printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#x2apSetup_response_notification_handler.handle - transactionId %s: Summary: Total roundtrip elapsed time", request.TransactionId), e2session.SessionStart)
delete(e2Sessions, request.TransactionId) // Avoid pinning memory (help GC)
}
-
-
-
}
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
-// #cgo CFLAGS: -I../asn1codec/inc/ -I../asn1codec/e2ap_engine/
-// #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
+// #cgo CFLAGS: -I../../asn1codec/inc/ -I../../asn1codec/e2ap_engine/
+// #cgo LDFLAGS: -L ../../asn1codec/lib/ -L../../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
// #include <asn1codec_utils.h>
// #include <configuration_update_wrapper.h>
import "C"
import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
"e2mgr/logger"
"e2mgr/models"
"e2mgr/rmrCgo"
messageChannel chan<- *models.NotificationResponse) {
var payloadSize C.ulong
- payloadSize = MaxAsn1PackedBufferSize
- packedBuffer := [MaxAsn1PackedBufferSize]C.uchar{}
- errorBuffer := [MaxAsn1PackedBufferSize]C.char{}
- refinedMessage, err := unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
+ payloadSize = e2pdus.MaxAsn1PackedBufferSize
+ packedBuffer := [e2pdus.MaxAsn1PackedBufferSize]C.uchar{}
+ errorBuffer := [e2pdus.MaxAsn1PackedBufferSize]C.char{}
+ refinedMessage, err := converters.UnpackX2apPduAndRefine(logger, e2pdus.MaxAsn1CodecAllocationBufferSize , request.Len, request.Payload, e2pdus.MaxAsn1CodecMessageBufferSize )
if err != nil {
- status := C.build_pack_x2enb_configuration_update_failure( &payloadSize, &packedBuffer[0], MaxAsn1PackedBufferSize, &errorBuffer[0])
+ status := C.build_pack_x2enb_configuration_update_failure( &payloadSize, &packedBuffer[0], e2pdus.MaxAsn1PackedBufferSize, &errorBuffer[0])
if status{
payload := (*[1<<30]byte)(unsafe.Pointer(&packedBuffer))[:payloadSize:payloadSize]
logger.Debugf("#x2enb_configuration_update_handler.Handle - Enb configuration update negative ack message payload: (%d) %02x", len(payload), payload)
logger.Errorf("#x2enb_configuration_update_handler.Handle - unpack failed. Error: %v", err)
} else {
logger.Infof("#x2enb_configuration_update_handler.Handle - Enb configuration update initiating message received")
- logger.Debugf("#x2enb_configuration_update_handler.Handle - Enb configuration update initiating message payload: %s", refinedMessage.pduPrint)
+ logger.Debugf("#x2enb_configuration_update_handler.Handle - Enb configuration update initiating message payload: %s", refinedMessage.PduPrint)
- status := C.build_pack_x2enb_configuration_update_ack( &payloadSize, &packedBuffer[0], MaxAsn1PackedBufferSize, &errorBuffer[0])
+ status := C.build_pack_x2enb_configuration_update_ack( &payloadSize, &packedBuffer[0], e2pdus.MaxAsn1PackedBufferSize, &errorBuffer[0])
if status {
payload := (*[1 << 30]byte)(unsafe.Pointer(&packedBuffer))[:payloadSize:payloadSize]
logger.Debugf("#x2enb_configuration_update_handler.Handle - Enb configuration update positive ack message payload: (%d) %02x", len(payload), payload)
// See the License for the specific language governing permissions and
// limitations under the License.
//
-package handlers
+package rmrmsghandlers
import (
"e2mgr/logger"
+++ /dev/null
-//
-// Copyright 2019 AT&T Intellectual Property
-// Copyright 2019 Nokia
-//
-// 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 handlers
-
-import "C"
-import (
- "e2mgr/models"
- "fmt"
- "time"
-
- "e2mgr/logger"
- "e2mgr/sessions"
-)
-
-type SetupResponseNotificationHandler struct{}
-
-func (src SetupResponseNotificationHandler) Handle(logger *logger.Logger, e2Sessions sessions.E2Sessions,
- request *models.NotificationRequest, messageChannel chan<- *models.NotificationResponse) {
-
- refinedResponse, err := unpackX2apPduAndRefine(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, request.Len, request.Payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
- if err != nil {
- logger.Errorf("#setup_response_notification_handler.Handle - unpack failed. Error: %v", err)
- }
-
- e2session, ok := e2Sessions[request.TransactionId]
- printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#setupResponseNotificationHandler.handle - transactionId %s: Summary: Elapsed time for receiving and handling setup response from E2 terminator", request.TransactionId), request.StartTime)
- if ok {
- printHandlingSetupResponseElapsedTimeInMs(logger, fmt.Sprintf("#setupResponseNotificationHandler.handle - transactionId %s: Summary: Total roundtrip elapsed time", request.TransactionId), e2session.SessionStart)
- delete(e2Sessions, request.TransactionId) // Avoid pinning memory (help GC)
- }
- logger.Debugf("#setupResponseNotificationHandler.handle - transactionId %s: PDU: %v", request.TransactionId, refinedResponse.pduPrint)
-}
-
-func printHandlingSetupResponseElapsedTimeInMs(logger *logger.Logger, msg string, startTime time.Time) {
- logger.Infof("%s: %f ms", msg, float64(time.Since(startTime))/float64(time.Millisecond))
-}
+++ /dev/null
-//
-// Copyright 2019 AT&T Intellectual Property
-// Copyright 2019 Nokia
-//
-// 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 handlers
-
-import (
- "e2mgr/logger"
- "e2mgr/models"
- "e2mgr/rmrCgo"
- "e2mgr/sessions"
- "e2mgr/tests"
- "github.com/stretchr/testify/assert"
- "testing"
- "time"
-)
-
-func TestHandleSuccess(t *testing.T){
- log, err := logger.InitLogger(logger.InfoLevel)
- if err!=nil{
- t.Errorf("#setup_request_handler_test.TestHandleSuccess - failed to initialize logger, error: %s", err)
- }
- h := SetupResponseNotificationHandler{}
- E2Sessions := make(sessions.E2Sessions)
-
- payload := tests.GetPackedPayload(t)
- mBuf := rmrCgo.NewMBuf(tests.MessageType, len(payload),"RanName", &payload, &tests.DummyXAction)
- notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
- var messageChannel chan<- *models.NotificationResponse
-
- assert.NotPanics(t, func(){h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)})
-}
-
-func TestHandleFailure(t *testing.T){
- log, err := logger.InitLogger(logger.InfoLevel)
- if err!=nil{
- t.Errorf("#setup_request_handler_test.TestHandleFailure - failed to initialize logger, error: %s", err)
- }
- h := SetupResponseNotificationHandler{}
- E2Sessions := make(sessions.E2Sessions)
-
- mBuf := rmrCgo.NewMBuf(tests.MessageType, 4,"RanName", &tests.DummyPayload, &tests.DummyXAction)
- notificationRequest := models.NotificationRequest{RanName: mBuf.Meid, Len: mBuf.Len, Payload: *mBuf.Payload, StartTime: time.Now()}
- var messageChannel chan<- *models.NotificationResponse
-
- assert.Panics(t, func(){h.Handle(log, E2Sessions, ¬ificationRequest, messageChannel)})
-}
\ No newline at end of file
--- /dev/null
+package managers
--- /dev/null
+package managers
--- /dev/null
+package managers
+
+import (
+ "e2mgr/logger"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+)
+
+type ISetupResponseManager interface {
+ SetNodeb(logger *logger.Logger, nbIdentity *entities.NbIdentity, nodebInfo *entities.NodebInfo, payload []byte) error
+}
--- /dev/null
+package managers
+
+import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
+ "e2mgr/logger"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+)
+
+type X2SetupFailureResponseManager struct{}
+
+func NewX2SetupFailureResponseManager() *X2SetupFailureResponseManager {
+ return &X2SetupFailureResponseManager{}
+}
+
+func (m *X2SetupFailureResponseManager) SetNodeb(logger *logger.Logger, nbIdentity *entities.NbIdentity, nodebInfo *entities.NodebInfo, payload []byte) error {
+
+ failureResponse, err := converters.UnpackX2SetupFailureResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
+
+ if err != nil {
+ logger.Errorf("#x2Setup_failure_response_notification_handler.Handle - unpack failed. Error: %v", err)
+ return err
+ }
+
+ nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED_SETUP_FAILED
+ nodebInfo.E2ApplicationProtocol = entities.E2ApplicationProtocol_X2_SETUP_REQUEST
+ nodebInfo.SetupFailure = failureResponse
+ nodebInfo.FailureType = entities.Failure_X2_SETUP_FAILURE
+ return nil
+}
\ No newline at end of file
--- /dev/null
+package managers
+
+import (
+ "e2mgr/converters"
+ "e2mgr/e2pdus"
+ "e2mgr/logger"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+)
+
+type X2SetupResponseManager struct {}
+
+func NewX2SetupResponseManager() *X2SetupResponseManager {
+ return &X2SetupResponseManager{}
+}
+
+func (m *X2SetupResponseManager) SetNodeb(logger *logger.Logger, nbIdentity *entities.NbIdentity, nodebInfo *entities.NodebInfo, payload []byte) error {
+ enbId, enb, err := converters.UnpackX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
+
+ if err != nil || enbId == nil || enb == nil {
+ logger.Errorf("#X2SetupResponseNotificationHandler.SetNodeb - Unpack failed. Error: %v", err)
+ return err
+ }
+
+ nbIdentity.InventoryName = nodebInfo.RanName
+ nbIdentity.GlobalNbId = enbId
+ nodebInfo.GlobalNbId = nbIdentity.GlobalNbId
+ nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED
+ nodebInfo.E2ApplicationProtocol = entities.E2ApplicationProtocol_X2_SETUP_REQUEST
+ nodebInfo.NodeType = entities.Node_ENB
+ nodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: enb}
+
+ return nil
+}
+
import (
"e2mgr/configuration"
"e2mgr/e2managererrors"
- "e2mgr/handlers"
+ "e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/rNibWriter"
"e2mgr/services"
)
type IncomingRequestHandlerProvider struct {
- requestMap map[IncomingRequest]handlers.RequestHandler
+ requestMap map[IncomingRequest]httpmsghandlers.RequestHandler
logger *logger.Logger
}
-func NewIncomingRequestHandlerProvider(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibWriterProvider func() rNibWriter.RNibWriter,
- rNibReaderProvider func() reader.RNibReader) *IncomingRequestHandlerProvider {
+func NewIncomingRequestHandlerProvider(logger *logger.Logger, rmrService *services.RmrService, config *configuration.Configuration, rNibWriterProvider func() rNibWriter.RNibWriter, rNibReaderProvider func() reader.RNibReader) *IncomingRequestHandlerProvider {
return &IncomingRequestHandlerProvider{
requestMap: initRequestHandlerMap(rmrService, config, rNibWriterProvider, rNibReaderProvider),
}
func initRequestHandlerMap(rmrService *services.RmrService, config *configuration.Configuration, rNibWriterProvider func() rNibWriter.RNibWriter,
- rNibReaderProvider func() reader.RNibReader) map[IncomingRequest]handlers.RequestHandler {
+ rNibReaderProvider func() reader.RNibReader) map[IncomingRequest]httpmsghandlers.RequestHandler {
- return map[IncomingRequest]handlers.RequestHandler{
- ShutdownRequest: handlers.NewDeleteAllRequestHandler(rmrService, config, rNibWriterProvider, rNibReaderProvider), //TODO change to pointer
- ResetRequest: handlers.NewX2ResetRequestHandler(rmrService, config, rNibWriterProvider, rNibReaderProvider), //TODO change to pointer
+ return map[IncomingRequest]httpmsghandlers.RequestHandler{
+ ShutdownRequest: httpmsghandlers.NewDeleteAllRequestHandler(rmrService, config, rNibWriterProvider, rNibReaderProvider), //TODO change to pointer
+ ResetRequest: httpmsghandlers.NewX2ResetRequestHandler(rmrService, config, rNibWriterProvider, rNibReaderProvider), //TODO change to pointer
}
}
-func (provider IncomingRequestHandlerProvider) GetHandler(requestType IncomingRequest) (handlers.RequestHandler, error) {
+func (provider IncomingRequestHandlerProvider) GetHandler(requestType IncomingRequest) (httpmsghandlers.RequestHandler, error) {
handler, ok := provider.requestMap[requestType]
if !ok {
import (
"e2mgr/configuration"
"e2mgr/e2managererrors"
- "e2mgr/handlers"
+ "e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/models"
assert.NotNil(t, provider)
assert.Nil(t, err)
- _, ok := handler.(*handlers.DeleteAllRequestHandler)
+ _, ok := handler.(*httpmsghandlers.DeleteAllRequestHandler)
assert.True(t, ok)
/*if !ok {
package httpmsghandlerprovider
import (
- "e2mgr/handlers"
+ "e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/rNibWriter"
"errors"
"fmt"
)
-var requestMap map[string]handlers.Handler
+var requestMap map[string]httpmsghandlers.Handler
type RequestHandlerProvider struct{}
return &RequestHandlerProvider{}
}
-func initRequestMap(rnibWriterProvider func() rNibWriter.RNibWriter) map[string]handlers.Handler {
- return map[string]handlers.Handler{
- "x2-setup": handlers.NewSetupRequestHandler(rnibWriterProvider),
- "endc-setup": handlers.NewEndcSetupRequestHandler(rnibWriterProvider),
+func initRequestMap(rnibWriterProvider func() rNibWriter.RNibWriter) map[string]httpmsghandlers.Handler {
+ return map[string]httpmsghandlers.Handler{
+ "x2-setup": httpmsghandlers.NewSetupRequestHandler(rnibWriterProvider),
+ "endc-setup": httpmsghandlers.NewEndcSetupRequestHandler(rnibWriterProvider),
}
}
-func (provider RequestHandlerProvider) GetHandler(logger *logger.Logger, requestType string) (handlers.Handler, error) {
+func (provider RequestHandlerProvider) GetHandler(logger *logger.Logger, requestType string) (httpmsghandlers.Handler, error) {
handler, ok := requestMap[requestType]
if !ok {
package httpmsghandlerprovider
import (
- "e2mgr/handlers"
+ "e2mgr/handlers/httpmsghandlers"
"e2mgr/logger"
"e2mgr/mocks"
"e2mgr/rNibWriter"
t.Errorf("failed to get x2 setup handler")
}
- _, ok := handler.(*handlers.SetupRequestHandler)
+ _, ok := handler.(*httpmsghandlers.SetupRequestHandler)
if !ok {
t.Errorf("failed to get x2 setup handler")
t.Errorf("failed to get endc setup handler")
}
- _, ok := handler.(*handlers.EndcSetupRequestHandler)
+ _, ok := handler.(*httpmsghandlers.EndcSetupRequestHandler)
if !ok {
t.Errorf("failed to get endc setup handler")
package rmrmsghandlerprovider
import (
- "e2mgr/handlers"
+ "e2mgr/handlers/rmrmsghandlers"
"e2mgr/managers"
"e2mgr/rNibWriter"
"e2mgr/rmrCgo"
)
type NotificationHandlerProvider struct {
- notificationHandlers map[int]handlers.NotificationHandler
+ notificationHandlers map[int]rmrmsghandlers.NotificationHandler
}
func NewNotificationHandlerProvider(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) *NotificationHandlerProvider {
}
}
-func initNotificationHandlersMap(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) map[int]handlers.NotificationHandler {
- return map[int]handlers.NotificationHandler{
+func initNotificationHandlersMap(rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter, ranReconnectionManager *managers.RanReconnectionManager) map[int]rmrmsghandlers.NotificationHandler {
+ return map[int]rmrmsghandlers.NotificationHandler{
//TODO change handlers.NotificationHandler to *handlers.NotificationHandler
- rmrCgo.RIC_X2_SETUP_RESP: handlers.X2SetupResponseNotificationHandler{},
- rmrCgo.RIC_X2_SETUP_FAILURE: handlers.X2SetupFailureResponseNotificationHandler{},
- rmrCgo.RIC_ENDC_X2_SETUP_RESP: handlers.EndcX2SetupResponseNotificationHandler{},
- rmrCgo.RIC_ENDC_X2_SETUP_FAILURE: handlers.EndcX2SetupFailureResponseNotificationHandler{},
- rmrCgo.RIC_SCTP_CONNECTION_FAILURE: handlers.NewRanLostConnectionHandler(ranReconnectionManager),
- rmrCgo.RIC_ENB_LOAD_INFORMATION: handlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider),
- rmrCgo.RIC_ENB_CONF_UPDATE: handlers.X2EnbConfigurationUpdateHandler{},
- rmrCgo.RIC_ENDC_CONF_UPDATE: handlers.EndcConfigurationUpdateHandler{},
- rmrCgo.RIC_X2_RESET_RESP: handlers.NewX2ResetResponseHandler(rnibReaderProvider),
- rmrCgo.RIC_X2_RESET: handlers.NewX2ResetRequestNotificationHandler(rnibReaderProvider),
- rmrCgo.RIC_E2_TERM_INIT: handlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider ),
+ rmrCgo.RIC_X2_SETUP_RESP: rmrmsghandlers.X2SetupResponseNotificationHandler{},
+ rmrCgo.RIC_X2_SETUP_FAILURE: rmrmsghandlers.X2SetupFailureResponseNotificationHandler{},
+ rmrCgo.RIC_ENDC_X2_SETUP_RESP: rmrmsghandlers.EndcX2SetupResponseNotificationHandler{},
+ rmrCgo.RIC_ENDC_X2_SETUP_FAILURE: rmrmsghandlers.EndcX2SetupFailureResponseNotificationHandler{},
+ rmrCgo.RIC_SCTP_CONNECTION_FAILURE: rmrmsghandlers.NewRanLostConnectionHandler(ranReconnectionManager),
+ rmrCgo.RIC_ENB_LOAD_INFORMATION: rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider),
+ rmrCgo.RIC_ENB_CONF_UPDATE: rmrmsghandlers.X2EnbConfigurationUpdateHandler{},
+ rmrCgo.RIC_ENDC_CONF_UPDATE: rmrmsghandlers.EndcConfigurationUpdateHandler{},
+ rmrCgo.RIC_X2_RESET_RESP: rmrmsghandlers.NewX2ResetResponseHandler(rnibReaderProvider),
+ rmrCgo.RIC_X2_RESET: rmrmsghandlers.NewX2ResetRequestNotificationHandler(rnibReaderProvider),
+ rmrCgo.RIC_E2_TERM_INIT: rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider ),
}
}
-func (provider NotificationHandlerProvider) GetNotificationHandler(messageType int) (handlers.NotificationHandler, error) {
+func (provider NotificationHandlerProvider) GetNotificationHandler(messageType int) (rmrmsghandlers.NotificationHandler, error) {
handler, ok := provider.notificationHandlers[messageType]
if !ok {
import (
"e2mgr/configuration"
+ "e2mgr/handlers/rmrmsghandlers"
"e2mgr/logger"
"e2mgr/managers"
"e2mgr/mocks"
"strings"
"testing"
- "e2mgr/handlers"
"e2mgr/rmrCgo"
)
var testCases = []struct {
msgType int
- handler handlers.NotificationHandler
+ handler rmrmsghandlers.NotificationHandler
}{
- {rmrCgo.RIC_X2_SETUP_RESP /*successful x2 setup response*/, handlers.X2SetupResponseNotificationHandler{}},
- {rmrCgo.RIC_X2_SETUP_FAILURE /*unsuccessful x2 setup response*/, handlers.X2SetupFailureResponseNotificationHandler{}},
- {rmrCgo.RIC_ENDC_X2_SETUP_RESP /*successful en-dc x2 setup response*/, handlers.EndcX2SetupResponseNotificationHandler{}},
- {rmrCgo.RIC_ENDC_X2_SETUP_FAILURE /*unsuccessful en-dc x2 setup response*/, handlers.EndcX2SetupFailureResponseNotificationHandler{}},
- {rmrCgo.RIC_SCTP_CONNECTION_FAILURE /*sctp errors*/, handlers.NewRanLostConnectionHandler(ranReconnectionManager)},
- {rmrCgo.RIC_ENB_LOAD_INFORMATION, handlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider)},
- {rmrCgo.RIC_ENB_CONF_UPDATE, handlers.X2EnbConfigurationUpdateHandler{}},
- {rmrCgo.RIC_ENDC_CONF_UPDATE, handlers.EndcConfigurationUpdateHandler{}},
- {rmrCgo.RIC_E2_TERM_INIT, handlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider)},
+ {rmrCgo.RIC_X2_SETUP_RESP /*successful x2 setup response*/, rmrmsghandlers.X2SetupResponseNotificationHandler{}},
+ {rmrCgo.RIC_X2_SETUP_FAILURE /*unsuccessful x2 setup response*/, rmrmsghandlers.X2SetupFailureResponseNotificationHandler{}},
+ {rmrCgo.RIC_ENDC_X2_SETUP_RESP /*successful en-dc x2 setup response*/, rmrmsghandlers.EndcX2SetupResponseNotificationHandler{}},
+ {rmrCgo.RIC_ENDC_X2_SETUP_FAILURE /*unsuccessful en-dc x2 setup response*/, rmrmsghandlers.EndcX2SetupFailureResponseNotificationHandler{}},
+ {rmrCgo.RIC_SCTP_CONNECTION_FAILURE /*sctp errors*/, rmrmsghandlers.NewRanLostConnectionHandler(ranReconnectionManager)},
+ {rmrCgo.RIC_ENB_LOAD_INFORMATION, rmrmsghandlers.NewEnbLoadInformationNotificationHandler(rnibWriterProvider)},
+ {rmrCgo.RIC_ENB_CONF_UPDATE, rmrmsghandlers.X2EnbConfigurationUpdateHandler{}},
+ {rmrCgo.RIC_ENDC_CONF_UPDATE, rmrmsghandlers.EndcConfigurationUpdateHandler{}},
+ {rmrCgo.RIC_E2_TERM_INIT, rmrmsghandlers.NewE2TermInitNotificationHandler(ranReconnectionManager, rnibReaderProvider)},
}
for _, tc := range testCases {