Ric-193 - On Success, return Setup Response 41/2941/1
authorns019t <ns019t@intl.att.com>
Tue, 24 Mar 2020 12:34:06 +0000 (14:34 +0200)
committerns019t <ns019t@intl.att.com>
Tue, 24 Mar 2020 12:34:18 +0000 (14:34 +0200)
Change-Id: I990bb007f7fb74e6c250d790c3b9818cc13f75b6
Signed-off-by: ns019t <ns019t@intl.att.com>
E2Manager/configuration/configuration.go
E2Manager/go.mod
E2Manager/go.sum
E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go
E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go
E2Manager/models/e2_setup_request_message.go
E2Manager/models/e2_setup_success_response_message.go
E2Manager/providers/rmrmsghandlerprovider/notification_handler_provider.go
E2Manager/tests/resources/setupRequest_en-gNB.xml
E2Manager/tests/resources/setupRequest_gnb.xml
E2Manager/tests/resources/setupRequest_ng-eNB.xml

index 06a8a11..439d4ba 100644 (file)
@@ -39,6 +39,10 @@ type Configuration struct {
        RoutingManager struct {
                BaseUrl    string
        }
+       RicId struct {
+               PlmnId string
+               RicNearRtId string
+       }
        NotificationResponseBuffer   int
        BigRedButtonTimeoutSec       int
        MaxConnectionAttempts        int
index 39966d0..a15e96a 100644 (file)
@@ -1,9 +1,9 @@
 module e2mgr
 
 require (
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.32
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.32
-       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.32
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.33
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.33
+       gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.33
        gerrit.o-ran-sc.org/r/ric-plt/sdlgo v0.5.2
        github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
        github.com/go-ozzo/ozzo-validation v3.5.0+incompatible
index a72c008..06cbede 100644 (file)
@@ -1,10 +1,12 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.32 h1:rth8ETFAQxKd5LzB/j8Xic5gDU/NQ4K9LBioBXBMMb4=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.32/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.32 h1:9xffoKE1Y4FR6KzncK/FhjbljoshPT90kDSeU78H6G8=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.33 h1:QqWDNf3E8OpevC8swnZFxd56oW/7+5kVa9Ps4LWAZy8=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.33/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.32/go.mod h1:G+4sUBMbLfQ+RrGS65U15tKmbnP+/1b5oLTPmMfyfT4=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.32 h1:TSpWWIccJhSyvqBibXQFgyP13KqhsFA14auTSqvEpz0=
-gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.32/go.mod h1:oPHTwdTeaOEuvqVRAog9WoCTW7O6ynE6rOyFB/sp9C0=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.33 h1:VwfmU5yww6nejkRK2qYD/+VYy6+RBHWHihInHwgK1EE=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.33/go.mod h1:G+4sUBMbLfQ+RrGS65U15tKmbnP+/1b5oLTPmMfyfT4=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.33 h1:dUTtIlG3F1+qyDZ1OIVsVFwygAioLNUkjiMzxTaHV9o=
+gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.33/go.mod h1:oPHTwdTeaOEuvqVRAog9WoCTW7O6ynE6rOyFB/sp9C0=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2 h1:UK7awyRKIkVdokWvvkYvazlg3EWIfMnIqCcJxTnLlDA=
 gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.2/go.mod h1:y2WhrCvdLkAKdH+ySdHSOSehACJkTMyZghCGVcqoZzc=
 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
index 603458e..b35058d 100644 (file)
@@ -21,6 +21,7 @@ package rmrmsghandlers
 
 import (
        "bytes"
+       "e2mgr/configuration"
        "e2mgr/logger"
        "e2mgr/managers"
        "e2mgr/models"
@@ -37,15 +38,17 @@ import (
 
 type E2SetupRequestNotificationHandler struct {
        logger                 *logger.Logger
+       config                 *configuration.Configuration
        e2tInstancesManager    managers.IE2TInstancesManager
        rmrSender              *rmrsender.RmrSender
        rNibDataService       services.RNibDataService
        e2tAssociationManager *managers.E2TAssociationManager
 }
 
-func NewE2SetupRequestNotificationHandler(logger *logger.Logger, e2tInstancesManager managers.IE2TInstancesManager, rmrSender *rmrsender.RmrSender, rNibDataService services.RNibDataService, e2tAssociationManager *managers.E2TAssociationManager) E2SetupRequestNotificationHandler {
+func NewE2SetupRequestNotificationHandler(logger *logger.Logger, config *configuration.Configuration, e2tInstancesManager managers.IE2TInstancesManager, rmrSender *rmrsender.RmrSender, rNibDataService services.RNibDataService, e2tAssociationManager *managers.E2TAssociationManager) E2SetupRequestNotificationHandler {
        return E2SetupRequestNotificationHandler{
                logger:                 logger,
+               config:                 config,
                e2tInstancesManager:    e2tInstancesManager,
                rmrSender: rmrSender,
                rNibDataService: rNibDataService,
@@ -76,7 +79,11 @@ func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRe
        if err != nil{
                if _, ok := err.(*common.ResourceNotFoundError); ok{
                        nbIdentity := h.buildNbIdentity(ranName, setupRequest)
-                       nodebInfo = h.buildNodebInfo(ranName, e2tIpAddress, setupRequest)
+                       nodebInfo, err = h.buildNodebInfo(ranName, e2tIpAddress, setupRequest)
+                       if err != nil{
+                               h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to build nodebInfo entity. Error: %s", ranName, err)
+                               return
+                       }
                        err = h.rNibDataService.SaveNodeb(nbIdentity, nodebInfo)
                        if err != nil{
                                h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to save nodebInfo entity. Error: %s", ranName, err)
@@ -93,24 +100,29 @@ func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRe
                        h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - Summary: elapsed time for receiving and handling setup request message from E2 terminator: %f ms", utils.ElapsedTime(request.StartTime))
                        return
                }
-               h.updateNodeBFunctions(nodebInfo, setupRequest)
+               nodebInfo.GetGnb().RanFunctions, err = setupRequest.GetExtractRanFunctionsList()
+               if err != nil{
+                       h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to update nodebInfo entity. Error: %s", ranName, err)
+                       return
+               }
        }
        err = h.e2tAssociationManager.AssociateRan(e2tIpAddress, nodebInfo)
        if err != nil{
                h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to associate E2T to nodeB entity. Error: %s", ranName, err)
                return
        }
-       successResponse := &models.E2SetupSuccessResponseMessage{}
-       successResponse.SetPlmnId(setupRequest.GetPlmnId())
-       successResponse.SetNbId("&" + fmt.Sprintf("%020b", 0xf0))
+       successResponse := models.NewE2SetupSuccessResponseMessage()
+       successResponse.SetPlmnId(h.config.RicId.PlmnId)
+       successResponse.SetRicId(h.config.RicId.RicNearRtId)
+       successResponse.SetExtractRanFunctionsIDList(setupRequest)
        responsePayload, err := xml.Marshal(successResponse)
+
        if err != nil{
                h.logger.Warnf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - Error marshalling E2 Setup Response. Response: %x", ranName, responsePayload)
        }
        msg := models.NewRmrMessage(rmrCgo.RIC_E2_SETUP_RESP, ranName, responsePayload, request.TransactionId)
        h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - E2 Setup Request has been built. Message: %x", ranName, msg)
-       //TODO err = h.rmrSender.Send(msg)
-
+       err = h.rmrSender.Send(msg)
 }
 
 func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte)(*models.E2SetupRequestMessage, string, error){
@@ -133,17 +145,14 @@ func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte)(*mo
        setupRequest := &models.E2SetupRequestMessage{}
        err := xml.Unmarshal(payload[pipInd + 1:], &setupRequest)
        if err != nil {
-               return nil, "", errors.New("#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: %s")
+               return nil, "", errors.New(fmt.Sprintf("#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: %x", payload))
        }
 
        return setupRequest, e2tIpAddress, nil
 }
 
-func (h E2SetupRequestNotificationHandler) updateNodeBFunctions(nodeB *entities.NodebInfo, request *models.E2SetupRequestMessage){
-       //TODO the function should be implemented in the scope of the US 192 "Save the entire Setup request in RNIB"
-}
-
-func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAddress string, request *models.E2SetupRequestMessage) *entities.NodebInfo{
+func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAddress string, request *models.E2SetupRequestMessage) (*entities.NodebInfo, error){
+       var err error
        nodebInfo := &entities.NodebInfo{
                AssociatedE2TInstanceAddress: e2tAddress,
                ConnectionStatus: entities.ConnectionStatus_CONNECTED,
@@ -151,8 +160,8 @@ func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAdd
                NodeType: entities.Node_GNB,
                Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
        }
-       h.updateNodeBFunctions(nodebInfo, request)
-       return nodebInfo
+       nodebInfo.GetGnb().RanFunctions, err = request.GetExtractRanFunctionsList()
+       return nodebInfo, err
 }
 
 func (h E2SetupRequestNotificationHandler) buildNbIdentity(ranName string, setupRequest *models.E2SetupRequestMessage)*entities.NbIdentity{
index ad3d0ca..74cc347 100644 (file)
@@ -26,6 +26,7 @@ import (
        "e2mgr/managers"
        "e2mgr/mocks"
        "e2mgr/models"
+       "e2mgr/rmrCgo"
        "e2mgr/services"
        "e2mgr/tests"
        "errors"
@@ -47,6 +48,65 @@ const (
        nodebRanName = "gnb:310-410-b5c67788"
 )
 
+func TestParseSetupRequest_Success(t *testing.T){
+       path, err :=filepath.Abs("../../tests/resources/setupRequest_gnb.xml")
+       if err != nil {
+               t.Fatal(err)
+       }
+       xmlGnb, err := ioutil.ReadFile(path)
+       if err != nil {
+               t.Fatal(err)
+       }
+       handler := stubMockSuccessFlowNewNodeb(t)
+       prefBytes := []byte(prefix)
+       request, _, err := handler.parseSetupRequest(append(prefBytes, xmlGnb...))
+       assert.Equal(t, request.GetPlmnId(), "131014")
+       assert.Equal(t, request.GetNbId(), "10110101110001100111011110001000")
+}
+
+func TestParseSetupRequest_ColonFailure(t *testing.T){
+       path, err :=filepath.Abs("../../tests/resources/setupRequest_gnb.xml")
+       if err != nil {
+               t.Fatal(err)
+       }
+       xmlGnb, err := ioutil.ReadFile(path)
+       if err != nil {
+               t.Fatal(err)
+       }
+       handler := stubMockSuccessFlowNewNodeb(t)
+       prefBytes := []byte("10.0.2.15;9999|")
+       request, _, err := handler.parseSetupRequest(append(prefBytes, xmlGnb...))
+       assert.Nil(t, request)
+       assert.NotNil(t, err)
+       assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error parsing E2 Setup Request, failed extract E2T IP Address: no ':' separator found")
+}
+
+func TestParseSetupRequest_PipFailure(t *testing.T){
+       path, err :=filepath.Abs("../../tests/resources/setupRequest_gnb.xml")
+       if err != nil {
+               t.Fatal(err)
+       }
+       xmlGnb, err := ioutil.ReadFile(path)
+       if err != nil {
+               t.Fatal(err)
+       }
+       handler := stubMockSuccessFlowNewNodeb(t)
+       prefBytes := []byte("10.0.2.15:9999")
+       request, _, err := handler.parseSetupRequest(append(prefBytes, xmlGnb...))
+       assert.Nil(t, request)
+       assert.NotNil(t, err)
+       assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error parsing E2 Setup Request failed extract Payload: no | separator found")
+}
+
+func TestParseSetupRequest_UnmarshalFailure(t *testing.T){
+       handler := stubMockSuccessFlowNewNodeb(t)
+       prefBytes := []byte(prefix)
+       request, _, err := handler.parseSetupRequest(append(prefBytes, 1,2,3))
+       assert.Nil(t, request)
+       assert.NotNil(t, err)
+       assert.EqualError(t, err, "#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: 31302e302e322e31353a393939397c010203")
+}
+
 func TestE2SetupRequestNotificationHandler_HandleNewGnbSuccess(t *testing.T) {
        path, err :=filepath.Abs("../../tests/resources/setupRequest_gnb.xml")
        if err != nil {
@@ -394,6 +454,7 @@ func assertSuccessFlowNewNodebLogs(t *testing.T){
        assertNewNodebSavedLog(buf, t)
        assertAssociatedLog(buf, t)
        assertRequestBuiltLog(buf, t)
+       assertRequestSentLog(buf, t)
        assertNoMoreRecordsLog(buf, t)
 }
 
@@ -403,6 +464,7 @@ func assertSuccessFlowExistingNodebLogs(t *testing.T){
        assertExistingNodebRetrievedLog(buf, t)
        assertAssociatedLog(buf, t)
        assertRequestBuiltLog(buf, t)
+       assertRequestSentLog(buf, t)
        assertNoMoreRecordsLog(buf, t)
 }
 
@@ -446,6 +508,10 @@ func assertAssociatedLog(buf *bytes.Buffer, t *testing.T){
        assert.Contains(t, record, "#E2TAssociationManager.AssociateRan - successfully associated RAN")
 }
 
+func assertRequestSentLog(buf *bytes.Buffer, t *testing.T) {
+       record, _ := buf.ReadString('\n')
+       assert.Contains(t, record, "uccessfully sent RMR message")
+}
 func assertRequestBuiltLog(buf *bytes.Buffer, t *testing.T) {
        record, _ := buf.ReadString('\n')
        assert.Contains(t, record, "E2 Setup Request has been built")
@@ -457,7 +523,7 @@ func assertNoMoreRecordsLog(buf *bytes.Buffer, t *testing.T) {
 }
 
 func stubMockSuccessFlowNewNodeb(t *testing.T) E2SetupRequestNotificationHandler{
-       _, handler, readerMock, writerMock, _, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
        var e2tInstance = &entities.E2TInstance{}
        e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
        var gnb *entities.NodebInfo
@@ -466,18 +532,30 @@ func stubMockSuccessFlowNewNodeb(t *testing.T) E2SetupRequestNotificationHandler
        routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceAddress, mock.Anything).Return(nil)
        writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
        e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
+       var err error
+       rmrMessage := &rmrCgo.MBuf{}
+       rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(rmrMessage, err)
        return handler
 }
 
 func stubMockSuccessFlowExistingNodeb(t *testing.T) E2SetupRequestNotificationHandler{
-       _, handler, readerMock, writerMock, _, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
+       _, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
        var e2tInstance = &entities.E2TInstance{}
        e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceAddress).Return(e2tInstance, nil)
-       var gnb = &entities.NodebInfo{RanName: nodebRanName}
+       var gnb = &entities.NodebInfo{
+               RanName: nodebRanName,
+               AssociatedE2TInstanceAddress: e2tAddress,
+               ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+               NodeType: entities.Node_GNB,
+               Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
+       }
        readerMock.On("GetNodeb", mock.Anything).Return(gnb, nil)
        routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceAddress, mock.Anything).Return(nil)
        writerMock.On("UpdateNodebInfo", mock.Anything).Return(nil)
        e2tInstancesManagerMock.On("AddRansToInstance", mock.Anything, mock.Anything).Return(nil)
+       var err error
+       rmrMessage := &rmrCgo.MBuf{}
+       rmrMessengerMock.On("SendMsg", mock.Anything, mock.Anything).Return(rmrMessage, err)
        return handler
 }
 
@@ -501,7 +579,7 @@ func initMocks(t *testing.T) (*logger.Logger, E2SetupRequestNotificationHandler,
        rnibDataService := services.NewRnibDataService(logger, config, readerMock, writerMock)
        e2tInstancesManagerMock := &mocks.E2TInstancesManagerMock{}
        e2tAssociationManager := managers.NewE2TAssociationManager(logger, rnibDataService, e2tInstancesManagerMock, routingManagerClientMock)
-       handler := NewE2SetupRequestNotificationHandler(logger, e2tInstancesManagerMock, rmrSender, rnibDataService, e2tAssociationManager)
+       handler := NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManagerMock, rmrSender, rnibDataService, e2tAssociationManager)
        return logger, handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock
 }
 
index d07f4df..41aea81 100644 (file)
@@ -21,7 +21,10 @@ package models
 
 import (
        "encoding/xml"
+       "errors"
+       "fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+       "strconv"
 )
 
 type E2SetupRequestMessage struct {
@@ -98,26 +101,7 @@ type E2SetupRequestMessage struct {
                                                                                } `xml:"global-eNB-ID"`
                                                                        } `xml:"eNB"`
                                                                } `xml:"GlobalE2node-ID"`
-                                                               RANfunctionsList struct {
-                                                                       Text                      string `xml:",chardata"`
-                                                                       ProtocolIESingleContainer []struct {
-                                                                               Text        string `xml:",chardata"`
-                                                                               ID          string `xml:"id"`
-                                                                               Criticality struct {
-                                                                                       Text   string `xml:",chardata"`
-                                                                                       Reject string `xml:"reject"`
-                                                                               } `xml:"criticality"`
-                                                                               Value struct {
-                                                                                       Text            string `xml:",chardata"`
-                                                                                       RANfunctionItem struct {
-                                                                                               Text                  string `xml:",chardata"`
-                                                                                               RanFunctionID         string `xml:"ranFunctionID"`
-                                                                                               RanFunctionDefinition string `xml:"ranFunctionDefinition"`
-                                                                                               RanFunctionRevision   string `xml:"ranFunctionRevision"`
-                                                                                       } `xml:"RANfunction-Item"`
-                                                                               } `xml:"value"`
-                                                                       } `xml:"ProtocolIE-SingleContainer"`
-                                                               } `xml:"RANfunctions-List"`
+                                                               RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
                                                        } `xml:"value"`
                                                } `xml:"E2setupRequestIEs"`
                                        } `xml:"protocolIEs"`
@@ -127,6 +111,47 @@ type E2SetupRequestMessage struct {
        } `xml:"E2AP-PDU"`
 }
 
+type RANfunctionsList struct {
+    Text                      string `xml:",chardata"`
+    ProtocolIESingleContainer []struct {
+               Text        string `xml:",chardata"`
+               ID          string `xml:"id"`
+               Criticality struct {
+                       Text   string `xml:",chardata"`
+                       Reject string `xml:"reject"`
+               } `xml:"criticality"`
+               Value struct {
+                       Text            string `xml:",chardata"`
+                       RANfunctionItem struct {
+                               Text                  string `xml:",chardata"`
+                               RanFunctionID         string `xml:"ranFunctionID"`
+                               RanFunctionDefinition string `xml:"ranFunctionDefinition"`
+                               RanFunctionRevision   string `xml:"ranFunctionRevision"`
+                       } `xml:"RANfunction-Item"`
+               } `xml:"value"`
+    } `xml:"ProtocolIE-SingleContainer"`
+}
+
+func (m *E2SetupRequestMessage) GetExtractRanFunctionsList()([]*entities.RanFunction, error){
+       list :=m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList.ProtocolIESingleContainer
+       funcs := make([]*entities.RanFunction, len(list))
+       for i:=0; i < len(funcs); i++{
+               funcs[i] = &entities.RanFunction{}
+               id, err := strconv.ParseUint(list[i].Value.RANfunctionItem.RanFunctionID, 10, 32)
+               if err != nil {
+                       return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.GetExtractRanFunctionsList - Failed parse uint RanFunctionID from %s", list[i].Value.RANfunctionItem.RanFunctionID))
+               }
+               funcs[i].RanFunctionId = uint32(id)
+               rev, err := strconv.ParseUint(list[i].Value.RANfunctionItem.RanFunctionRevision, 10, 32)
+               if err != nil {
+                       return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.GetExtractRanFunctionsList - Failed parse uint RanFunctionRevision from %s", list[i].Value.RANfunctionItem.RanFunctionRevision))
+               }
+               funcs[i].RanFunctionDefinition = list[i].Value.RANfunctionItem.RanFunctionDefinition
+               funcs[i].RanFunctionRevision = uint32(rev)
+       }
+       return funcs, nil
+}
+
 func (m *E2SetupRequestMessage) GetNodeType() entities.Node_Type{
        if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.GNB.GlobalGNBID.PlmnID; id!= ""{
                return entities.Node_GNB
index 5e58de0..23410fc 100644 (file)
@@ -40,22 +40,7 @@ type E2SetupSuccessResponseMessage struct {
                                        Text        string `xml:",chardata"`
                                        ProtocolIEs struct {
                                                Text               string `xml:",chardata"`
-                                               E2setupResponseIEs struct {
-                                                       Text        string `xml:",chardata"`
-                                                       ID          string `xml:"id"`
-                                                       Criticality struct {
-                                                               Text   string `xml:",chardata"`
-                                                               Reject string `xml:"reject"`
-                                                       } `xml:"criticality"`
-                                                       Value struct {
-                                                               Text        string `xml:",chardata"`
-                                                               GlobalRICID struct {
-                                                                       Text         string `xml:",chardata"`
-                                                                       PLMNIdentity string `xml:"pLMN-Identity"`
-                                                                       RicID        string `xml:"ric-ID"`
-                                                               } `xml:"GlobalRIC-ID"`
-                                                       } `xml:"value"`
-                                               } `xml:"E2setupResponseIEs"`
+                                               E2setupResponseIEs []E2setupResponseIEs`xml:"E2setupResponseIEs"`
                                        } `xml:"protocolIEs"`
                                } `xml:"E2setupResponse"`
                        } `xml:"value"`
@@ -63,11 +48,70 @@ type E2SetupSuccessResponseMessage struct {
        } `xml:"E2AP-PDU"`
 }
 
+type E2setupResponseIEs struct {
+       Text        string `xml:",chardata"`
+       ID          string `xml:"id"`
+       Criticality struct {
+               Text   string `xml:",chardata"`
+               Reject string `xml:"reject"`
+       } `xml:"criticality"`
+       Value struct {
+               Text        string `xml:",chardata"`
+               GlobalRICID struct {
+                       Text         string `xml:",chardata"`
+                       PLMNIdentity string `xml:"pLMN-Identity"`
+                       RicID        string `xml:"ric-ID"`
+               } `xml:"GlobalRIC-ID"`
+               RANfunctionsIDList struct {
+                       Text                      string `xml:",chardata"`
+                       ProtocolIESingleContainer []ProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
+               } `xml:"RANfunctionsID-List"`
+       } `xml:"value"`
+}
+
+type ProtocolIESingleContainer struct {
+       Text        string `xml:",chardata"`
+       ID          string `xml:"id"`
+       Criticality struct {
+               Text   string `xml:",chardata"`
+               Ignore string `xml:"ignore"`
+       } `xml:"criticality"`
+       Value struct {
+               Text              string `xml:",chardata"`
+               RANfunctionIDItem struct {
+                       Text                string `xml:",chardata"`
+                       RanFunctionID       string `xml:"ranFunctionID"`
+                       RanFunctionRevision string `xml:"ranFunctionRevision"`
+               } `xml:"RANfunctionID-Item"`
+       } `xml:"value"`
+}
+
+func NewE2SetupSuccessResponseMessage() *E2SetupSuccessResponseMessage{
+       msg := &E2SetupSuccessResponseMessage{}
+       msg.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs = make([]E2setupResponseIEs, 2)
+       return msg
+}
+
+func (m *E2SetupSuccessResponseMessage) SetExtractRanFunctionsIDList(request *E2SetupRequestMessage) {
+       list := &request.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList
+       ids := make([]ProtocolIESingleContainer,len(list.ProtocolIESingleContainer))
+       for i := 0; i< len(ids); i++{
+               ids[i] = m.convertToRANfunctionID(list, i)
+       }
+       m.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[1].Value.RANfunctionsIDList.ProtocolIESingleContainer = ids
+}
+
+func (m *E2SetupSuccessResponseMessage) convertToRANfunctionID(list *RANfunctionsList, i int) ProtocolIESingleContainer{
+       id := ProtocolIESingleContainer{}
+       id.Value.RANfunctionIDItem.RanFunctionID = list.ProtocolIESingleContainer[i].Value.RANfunctionItem.RanFunctionID
+       id.Value.RANfunctionIDItem.RanFunctionRevision = list.ProtocolIESingleContainer[i].Value.RANfunctionItem.RanFunctionRevision
+       return id
+}
 
 func (m *E2SetupSuccessResponseMessage) SetPlmnId(plmnId string){
-       m.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs.Value.GlobalRICID.PLMNIdentity = plmnId
+       m.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[0].Value.GlobalRICID.PLMNIdentity = plmnId
 }
 
-func (m *E2SetupSuccessResponseMessage) SetNbId(ricID string){
-       m.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs.Value.GlobalRICID.RicID = ricID
+func (m *E2SetupSuccessResponseMessage) SetRicId(ricId string){
+       m.E2APPDU.SuccessfulOutcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[0].Value.GlobalRICID.RicID = ricId
 }
\ No newline at end of file
index b161841..d0b730c 100644 (file)
@@ -88,7 +88,7 @@ func (provider *NotificationHandlerProvider) Init(logger *logger.Logger, config
        x2ResetRequestNotificationHandler := rmrmsghandlers.NewX2ResetRequestNotificationHandler(logger, rnibDataService, ranStatusChangeManager, rmrSender)
        e2TermInitNotificationHandler := rmrmsghandlers.NewE2TermInitNotificationHandler(logger, ranReconnectionManager, e2tInstancesManager, routingManagerClient)
        e2TKeepAliveResponseHandler := rmrmsghandlers.NewE2TKeepAliveResponseHandler(logger, rnibDataService, e2tInstancesManager)
-       e2SetupRequestNotificationHandler := rmrmsghandlers.NewE2SetupRequestNotificationHandler(logger, e2tInstancesManager, rmrSender, rnibDataService, e2tAssociationManager)
+       e2SetupRequestNotificationHandler := rmrmsghandlers.NewE2SetupRequestNotificationHandler(logger, config, e2tInstancesManager, rmrSender, rnibDataService, e2tAssociationManager)
 
        provider.Register(rmrCgo.RIC_X2_SETUP_RESP, x2SetupResponseHandler)
        provider.Register(rmrCgo.RIC_X2_SETUP_FAILURE, x2SetupFailureResponseHandler)
index 95b137a..4fde3e9 100644 (file)
                             <GlobalE2node-ID>\r
                                 <en-gNB>\r
                                     <global-gNB-ID>\r
-                                        <plmn-id>13 10 14</plmn-id>\r
+                                        <plmn-id>131014</plmn-id>\r
                                         <gnb-id>\r
-                                            <gnb-ID>\r
-                                                10110101110001100111011110001000\r
-                                            </gnb-ID>\r
+                                            <gnb-ID>10110101110001100111011110001000</gnb-ID>\r
                                         </gnb-id>\r
                                     </global-gNB-ID>\r
                                 </en-gNB>\r
@@ -35,7 +33,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r
@@ -46,7 +44,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r
index 1a74a2a..3b27b75 100644 (file)
@@ -13,7 +13,7 @@
                             <GlobalE2node-ID>\r
                                 <gNB>\r
                                     <global-gNB-ID>\r
-                                        <plmn-id>13 10 14</plmn-id>\r
+                                        <plmn-id>131014</plmn-id>\r
                                         <gnb-id>\r
                                             <gnb-ID>10110101110001100111011110001000</gnb-ID>\r
                                         </gnb-id>\r
@@ -33,7 +33,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r
@@ -44,7 +44,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r
index c60775c..ba2795c 100644 (file)
@@ -13,7 +13,7 @@
                             <GlobalE2node-ID>\r
                                 <ng-eNB>\r
                                     <global-ng-eNB-ID>\r
-                                        <plmn-id>13 10 14</plmn-id>\r
+                                        <plmn-id>131014</plmn-id>\r
                                         <gnb-id>\r
                                             <gnb-ID>10110101110001100111011110001000</gnb-ID>\r
                                         </gnb-id>\r
@@ -33,7 +33,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r
@@ -44,7 +44,7 @@
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r
-                                            <ranFunctionDefinition>33 44 55</ranFunctionDefinition>\r
+                                            <ranFunctionDefinition>334455</ranFunctionDefinition>\r
                                             <ranFunctionRevision>0</ranFunctionRevision>\r
                                         </RANfunction-Item>\r
                                     </value>\r