[RIC-346] Refactor E2 Setup flow and update EnGnb xml 79/3479/1
authoridanshal <idan.shalom@intl.att.com>
Mon, 27 Apr 2020 11:12:54 +0000 (14:12 +0300)
committeridanshal <idan.shalom@intl.att.com>
Mon, 27 Apr 2020 11:13:00 +0000 (14:13 +0300)
Change-Id: I109cd86f9c5592fcc291931237fdd018c2d09ea2
Signed-off-by: idanshal <idan.shalom@intl.att.com>
E2Manager/container-tag.yaml
E2Manager/controllers/nodeb_controller_test.go
E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go
E2Manager/models/e2_setup_request_message.go
E2Manager/tests/resources/setupRequest_en-gNB.xml
E2Manager/tests/resources/setupRequest_gnb.xml
E2Manager/tests/resources/setupRequest_ng-eNB.xml

index 97b7f02..40417c8 100644 (file)
@@ -1,4 +1,4 @@
 # The Jenkins job requires a tag to build the Docker image.
 # Global-JJB script assumes this file is in the repo root.
 ---
-tag: 4.4.8
+tag: 4.4.9
index c61249e..a9bccdc 100644 (file)
@@ -92,16 +92,16 @@ type updateGnbCellsParams struct {
 
 type removeServedNrCellsParams struct {
        servedNrCells []*entities.ServedNRCell
-       err error
+       err           error
 }
 
 type controllerUpdateGnbTestContext struct {
-       getNodebInfoResult   *getNodebInfoResult
+       getNodebInfoResult        *getNodebInfoResult
        removeServedNrCellsParams *removeServedNrCellsParams
-       updateGnbCellsParams *updateGnbCellsParams
-       requestBody          map[string]interface{}
-       expectedStatusCode   int
-       expectedJsonResponse string
+       updateGnbCellsParams      *updateGnbCellsParams
+       requestBody               map[string]interface{}
+       expectedStatusCode        int
+       expectedJsonResponse      string
 }
 
 func generateServedNrCells(cellIds ...string) []*entities.ServedNRCell {
@@ -545,10 +545,10 @@ func TestControllerUpdateGnbGetNodebSuccessInvalidGnbConfiguration(t *testing.T)
 }
 
 func TestControllerUpdateGnbGetNodebSuccessRemoveServedNrCellsFailure(t *testing.T) {
-       oldServedNrCells := generateServedNrCells("whatever1","whatever2")
+       oldServedNrCells := generateServedNrCells("whatever1", "whatever2")
        context := controllerUpdateGnbTestContext{
                removeServedNrCellsParams: &removeServedNrCellsParams{
-                       err: common.NewInternalError(errors.New("#writer.UpdateGnbCells - Internal Error")),
+                       err:           common.NewInternalError(errors.New("#writer.UpdateGnbCells - Internal Error")),
                        servedNrCells: oldServedNrCells,
                },
                getNodebInfoResult: &getNodebInfoResult{
@@ -578,10 +578,10 @@ func TestControllerUpdateGnbGetNodebSuccessRemoveServedNrCellsFailure(t *testing
 }
 
 func TestControllerUpdateGnbGetNodebSuccessUpdateGnbCellsFailure(t *testing.T) {
-       oldServedNrCells := generateServedNrCells("whatever1","whatever2")
+       oldServedNrCells := generateServedNrCells("whatever1", "whatever2")
        context := controllerUpdateGnbTestContext{
                removeServedNrCellsParams: &removeServedNrCellsParams{
-                       err: nil,
+                       err:           nil,
                        servedNrCells: oldServedNrCells,
                },
                updateGnbCellsParams: &updateGnbCellsParams{
@@ -647,7 +647,7 @@ func TestControllerUpdateGnbSuccess(t *testing.T) {
 func getJsonRequestAsBuffer(requestJson map[string]interface{}) *bytes.Buffer {
        b := new(bytes.Buffer)
        _ = json.NewEncoder(b).Encode(requestJson)
-       return b;
+       return b
 }
 
 func TestControllerGetNodebSuccess(t *testing.T) {
@@ -835,7 +835,7 @@ func parseJsonRequest(t *testing.T, r io.Reader) models.ErrorResponse {
        if err != nil {
                t.Errorf("Error cannot deserialize json request")
        }
-       _ =json.Unmarshal(body, &errorResponse)
+       _ = json.Unmarshal(body, &errorResponse)
 
        return errorResponse
 }
index b71129f..d71810e 100644 (file)
@@ -29,7 +29,6 @@ import (
        "e2mgr/rmrCgo"
        "e2mgr/services"
        "e2mgr/services/rmrsender"
-       "e2mgr/utils"
        "encoding/xml"
        "errors"
        "fmt"
@@ -40,26 +39,26 @@ import (
 )
 
 type E2SetupRequestNotificationHandler struct {
-       logger                 *logger.Logger
-       config                 *configuration.Configuration
-       e2tInstancesManager    managers.IE2TInstancesManager
-       rmrSender              *rmrsender.RmrSender
+       logger                *logger.Logger
+       config                *configuration.Configuration
+       e2tInstancesManager   managers.IE2TInstancesManager
+       rmrSender             *rmrsender.RmrSender
        rNibDataService       services.RNibDataService
        e2tAssociationManager *managers.E2TAssociationManager
 }
 
 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,
+               logger:                logger,
+               config:                config,
+               e2tInstancesManager:   e2tInstancesManager,
+               rmrSender:             rmrSender,
+               rNibDataService:       rNibDataService,
                e2tAssociationManager: e2tAssociationManager,
        }
 }
 
-func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRequest){
+func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRequest) {
        ranName := request.RanName
        h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - received E2_SETUP_REQUEST. Payload: %x", ranName, request.Payload)
 
@@ -80,53 +79,82 @@ func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRe
        }
 
        nodebInfo, err := h.rNibDataService.GetNodeb(ranName)
-       if err != nil{
-               if _, ok := err.(*common.ResourceNotFoundError); ok{
-                       nbIdentity := h.buildNbIdentity(ranName, 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)
-                               return
-                       }
-               } else{
+
+       if err != nil {
+
+               if _, ok := err.(*common.ResourceNotFoundError); !ok {
                        h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to retrieve nodebInfo entity. Error: %s", ranName, err)
                        return
+
                }
 
-       } else {
-               if nodebInfo.ConnectionStatus == entities.ConnectionStatus_SHUTTING_DOWN {
-                       h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity in incorrect state", nodebInfo.RanName, nodebInfo.ConnectionStatus)
-                       h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - Summary: elapsed time for receiving and handling setup request message from E2 terminator: %f ms", utils.ElapsedTime(request.StartTime))
+               if nodebInfo, err = h.handleNewRan(ranName, e2tIpAddress, setupRequest); err != nil {
                        return
                }
-               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)
+
+       } else {
+               if err = h.handleExistingRan(ranName, nodebInfo, setupRequest); err != nil {
                        return
                }
        }
+
        err = h.e2tAssociationManager.AssociateRan(e2tIpAddress, nodebInfo)
-       if err != nil{
+
+       if err != nil {
+
                h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to associate E2T to nodeB entity. Error: %s", ranName, err)
-               if _, ok := err.(*e2managererrors.RoutingManagerError); ok{
+               if _, ok := err.(*e2managererrors.RoutingManagerError); ok {
                        h.handleUnsuccessfulResponse(nodebInfo, request)
                }
                return
        }
+
        h.handleSuccessfulResponse(ranName, request, setupRequest)
 }
 
-func (h E2SetupRequestNotificationHandler) handleUnsuccessfulResponse(nodebInfo *entities.NodebInfo, req *models.NotificationRequest){
+func (h E2SetupRequestNotificationHandler) handleNewRan(ranName string, e2tIpAddress string, setupRequest *models.E2SetupRequestMessage) (*entities.NodebInfo, error) {
+
+       nodebInfo, err := h.buildNodebInfo(ranName, e2tIpAddress, setupRequest)
+
+       if err != nil {
+               h.logger.Errorf("#E2SetupRequestNotificationHandler.handleNewRan - RAN name: %s - failed to build nodebInfo entity. Error: %s", ranName, err)
+               return nil, err
+       }
+
+       nbIdentity := h.buildNbIdentity(ranName, setupRequest)
+       err = h.rNibDataService.SaveNodeb(nbIdentity, nodebInfo)
+
+       if err != nil {
+               h.logger.Errorf("#E2SetupRequestNotificationHandler.handleNewRan - RAN name: %s - failed to save nodebInfo entity. Error: %s", ranName, err)
+               return nil, err
+       }
+
+       return nodebInfo, nil
+}
+
+func (h E2SetupRequestNotificationHandler) handleExistingRan(ranName string, nodebInfo *entities.NodebInfo, setupRequest *models.E2SetupRequestMessage) error {
+       if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_SHUTTING_DOWN {
+               h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity in incorrect state", ranName, nodebInfo.ConnectionStatus)
+               return errors.New("nodeB entity in incorrect state")
+       }
+
+       ranFunctions, err := setupRequest.ExtractRanFunctionsList()
+
+       if err != nil {
+               h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to update nodebInfo entity. Error: %s", ranName, err)
+               return err
+       }
+
+       nodebInfo.GetGnb().RanFunctions = ranFunctions
+       return nil
+}
+
+func (h E2SetupRequestNotificationHandler) handleUnsuccessfulResponse(nodebInfo *entities.NodebInfo, req *models.NotificationRequest) {
        failureResponse := models.NewE2SetupFailureResponseMessage(models.TimeToWaitEnum.V60s)
        h.logger.Debugf("#E2SetupRequestNotificationHandler.handleUnsuccessfulResponse - E2_SETUP_RESPONSE has been built successfully %+v", failureResponse)
 
        responsePayload, err := xml.Marshal(&failureResponse.E2APPDU)
-       if err != nil{
+       if err != nil {
                h.logger.Warnf("#E2SetupRequestNotificationHandler.handleUnsuccessfulResponse - RAN name: %s - Error marshalling RIC_E2_SETUP_RESP. Payload: %s", nodebInfo.RanName, responsePayload)
        }
 
@@ -138,18 +166,18 @@ func (h E2SetupRequestNotificationHandler) handleUnsuccessfulResponse(nodebInfo
 
 }
 
-func (h E2SetupRequestNotificationHandler) handleSuccessfulResponse(ranName string, req *models.NotificationRequest, setupRequest *models.E2SetupRequestMessage){
+func (h E2SetupRequestNotificationHandler) handleSuccessfulResponse(ranName string, req *models.NotificationRequest, setupRequest *models.E2SetupRequestMessage) {
 
        ricNearRtId, err := convertTo20BitString(h.config.GlobalRicId.RicNearRtId)
-       if err != nil{
+       if err != nil {
                h.logger.Errorf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - RAN name: %s - failed to convert RicNearRtId value %s to 20 bit string . Error: %s", ranName, h.config.GlobalRicId.RicNearRtId, err)
                return
        }
-       successResponse := models.NewE2SetupSuccessResponseMessage(h.config.GlobalRicId.PlmnId, ricNearRtId,setupRequest)
+       successResponse := models.NewE2SetupSuccessResponseMessage(h.config.GlobalRicId.PlmnId, ricNearRtId, setupRequest)
        h.logger.Debugf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - E2_SETUP_RESPONSE has been built successfully %+v", successResponse)
 
        responsePayload, err := xml.Marshal(&successResponse.E2APPDU)
-       if err != nil{
+       if err != nil {
                h.logger.Warnf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - RAN name: %s - Error marshalling RIC_E2_SETUP_RESP. Payload: %s", ranName, responsePayload)
        }
 
@@ -160,7 +188,6 @@ func (h E2SetupRequestNotificationHandler) handleSuccessfulResponse(ranName stri
        _ = h.rmrSender.Send(msg)
 }
 
-
 func replaceEmptyTagsWithSelfClosing(responsePayload []byte) []byte {
        responseString := strings.NewReplacer(
                "<reject></reject>", "<reject/>",
@@ -172,23 +199,23 @@ func replaceEmptyTagsWithSelfClosing(responsePayload []byte) []byte {
                "<v5s></v5s>", "<v5s/>",
                "<v2s></v2s>", "<v2s/>",
                "<v1s></v1s>", "<v1s/>",
-               ).Replace(string(responsePayload))
+       ).Replace(string(responsePayload))
        return []byte(responseString)
 }
 
-func convertTo20BitString(ricNearRtId string) (string, error){
+func convertTo20BitString(ricNearRtId string) (string, error) {
        r, err := strconv.ParseUint(ricNearRtId, 16, 32)
-       if err != nil{
+       if err != nil {
                return "", err
        }
        return fmt.Sprintf("%020b", r)[:20], nil
 }
 
-func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte)(*models.E2SetupRequestMessage, string, error){
+func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte) (*models.E2SetupRequestMessage, string, error) {
 
        pipInd := bytes.IndexByte(payload, '|')
        if pipInd < 0 {
-               return nil, "", errors.New( "#E2SetupRequestNotificationHandler.parseSetupRequest - Error parsing E2 Setup Request failed extract Payload: no | separator found")
+               return nil, "", errors.New("#E2SetupRequestNotificationHandler.parseSetupRequest - Error parsing E2 Setup Request failed extract Payload: no | separator found")
        }
 
        e2tIpAddress := string(payload[:pipInd])
@@ -196,7 +223,7 @@ func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte)(*mo
                return nil, "", errors.New("#E2SetupRequestNotificationHandler.parseSetupRequest - Empty E2T Address received")
        }
        setupRequest := &models.E2SetupRequestMessage{}
-       err := xml.Unmarshal(payload[pipInd + 1:], &setupRequest.E2APPDU)
+       err := xml.Unmarshal(payload[pipInd+1:], &setupRequest.E2APPDU)
        if err != nil {
                return nil, "", errors.New(fmt.Sprintf("#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: %x", payload))
        }
@@ -204,29 +231,29 @@ func (h E2SetupRequestNotificationHandler) parseSetupRequest(payload []byte)(*mo
        return setupRequest, e2tIpAddress, nil
 }
 
-func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAddress string, request *models.E2SetupRequestMessage) (*entities.NodebInfo, error){
+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,
-               RanName: ranName,
-               NodeType: entities.Node_GNB,
-               Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
-               GlobalNbId:  &entities.GlobalNbId{
+               ConnectionStatus:             entities.ConnectionStatus_CONNECTED,
+               RanName:                      ranName,
+               NodeType:                     entities.Node_GNB,
+               Configuration:                &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
+               GlobalNbId: &entities.GlobalNbId{
                        PlmnId: request.GetPlmnId(),
                        NbId:   request.GetNbId(),
                },
        }
-       nodebInfo.GetGnb().RanFunctions, err = request.GetExtractRanFunctionsList()
+       nodebInfo.GetGnb().RanFunctions, err = request.ExtractRanFunctionsList()
        return nodebInfo, err
 }
 
-func (h E2SetupRequestNotificationHandler) buildNbIdentity(ranName string, setupRequest *models.E2SetupRequestMessage)*entities.NbIdentity{
+func (h E2SetupRequestNotificationHandler) buildNbIdentity(ranName string, setupRequest *models.E2SetupRequestMessage) *entities.NbIdentity {
        return &entities.NbIdentity{
-               InventoryName:ranName,
+               InventoryName: ranName,
                GlobalNbId: &entities.GlobalNbId{
                        PlmnId: setupRequest.GetPlmnId(),
                        NbId:   setupRequest.GetNbId(),
                },
        }
-}
\ No newline at end of file
+}
index 1803a73..8193b17 100644 (file)
@@ -28,6 +28,82 @@ import (
        "strings"
 )
 
+type Gnb struct {
+       Text        string `xml:",chardata"`
+       GlobalGNBID struct {
+               Text   string `xml:",chardata"`
+               PlmnID string `xml:"plmn-id"`
+               GnbID  struct {
+                       Text  string `xml:",chardata"`
+                       GnbID string `xml:"gnb-ID"`
+               } `xml:"gnb-id"`
+       } `xml:"global-gNB-ID"`
+}
+
+type EnGnb struct {
+       Text        string `xml:",chardata"`
+       GlobalGNBID struct {
+               Text   string `xml:",chardata"`
+               PlmnID string `xml:"pLMN-Identity"`
+               GnbID  struct {
+                       Text  string `xml:",chardata"`
+                       GnbID string `xml:"gNB-ID"`
+               } `xml:"gNB-ID"`
+       } `xml:"global-gNB-ID"`
+}
+
+type NgEnb struct {
+       Text          string `xml:",chardata"`
+       GlobalNgENBID struct {
+               Text   string `xml:",chardata"`
+               PlmnID string `xml:"plmn-id"`
+               GnbID  struct {
+                       Text  string `xml:",chardata"`
+                       GnbID string `xml:"gnb-ID"`
+               } `xml:"gnb-id"`
+       } `xml:"global-ng-eNB-ID"`
+}
+
+type Enb struct {
+       Text        string `xml:",chardata"`
+       GlobalENBID struct {
+               Text   string `xml:",chardata"`
+               PlmnID string `xml:"plmn-id"`
+               GnbID  struct {
+                       Text  string `xml:",chardata"`
+                       GnbID string `xml:"gnb-ID"`
+               } `xml:"gnb-id"`
+       } `xml:"global-eNB-ID"`
+}
+
+type GlobalE2NodeId struct {
+       Text  string `xml:",chardata"`
+       GNB   Gnb    `xml:"gNB"`
+       EnGNB EnGnb  `xml:"en-gNB"`
+       NgENB NgEnb  `xml:"ng-eNB"`
+       ENB   Enb    `xml:"eNB"`
+}
+
+type E2SetupRequest struct {
+       Text        string `xml:",chardata"`
+       ProtocolIEs struct {
+               Text              string `xml:",chardata"`
+               E2setupRequestIEs []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"`
+                               GlobalE2nodeID   GlobalE2NodeId   `xml:"GlobalE2node-ID"`
+                               RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
+                       } `xml:"value"`
+               } `xml:"E2setupRequestIEs"`
+       } `xml:"protocolIEs"`
+}
+
 type E2SetupRequestMessage struct {
        XMLName xml.Name `xml:"E2SetupRequestMessage"`
        Text    string   `xml:",chardata"`
@@ -41,80 +117,23 @@ type E2SetupRequestMessage struct {
                                Reject string `xml:"reject"`
                        } `xml:"criticality"`
                        Value struct {
-                               Text           string `xml:",chardata"`
-                               E2setupRequest struct {
-                                       Text        string `xml:",chardata"`
-                                       ProtocolIEs struct {
-                                               Text              string `xml:",chardata"`
-                                               E2setupRequestIEs []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"`
-                                                               GlobalE2nodeID struct {
-                                                                       Text string `xml:",chardata"`
-                                                                       GNB  struct {
-                                                                               Text        string `xml:",chardata"`
-                                                                               GlobalGNBID struct {
-                                                                                       Text   string `xml:",chardata"`
-                                                                                       PlmnID string `xml:"plmn-id"`
-                                                                                       GnbID  struct {
-                                                                                               Text  string `xml:",chardata"`
-                                                                                               GnbID string `xml:"gnb-ID"`
-                                                                                       } `xml:"gnb-id"`
-                                                                               } `xml:"global-gNB-ID"`
-                                                                       } `xml:"gNB"`
-                                                                       EnGNB struct {
-                                                                               Text        string `xml:",chardata"`
-                                                                               GlobalGNBID struct {
-                                                                                       Text   string `xml:",chardata"`
-                                                                                       PlmnID string `xml:"plmn-id"`
-                                                                                       GnbID  struct {
-                                                                                               Text  string `xml:",chardata"`
-                                                                                               GnbID string `xml:"gnb-ID"`
-                                                                                       } `xml:"gnb-id"`
-                                                                               } `xml:"global-gNB-ID"`
-                                                                       } `xml:"en-gNB"`
-                                                                       NgENB struct {
-                                                                               Text          string `xml:",chardata"`
-                                                                               GlobalNgENBID struct {
-                                                                                       Text   string `xml:",chardata"`
-                                                                                       PlmnID string `xml:"plmn-id"`
-                                                                                       GnbID  struct {
-                                                                                               Text  string `xml:",chardata"`
-                                                                                               GnbID string `xml:"gnb-ID"`
-                                                                                       } `xml:"gnb-id"`
-                                                                               } `xml:"global-ng-eNB-ID"`
-                                                                       } `xml:"ng-eNB"`
-                                                                       ENB struct {
-                                                                               Text        string `xml:",chardata"`
-                                                                               GlobalENBID struct {
-                                                                                       Text   string `xml:",chardata"`
-                                                                                       PlmnID string `xml:"plmn-id"`
-                                                                                       GnbID  struct {
-                                                                                               Text  string `xml:",chardata"`
-                                                                                               GnbID string `xml:"gnb-ID"`
-                                                                                       } `xml:"gnb-id"`
-                                                                               } `xml:"global-eNB-ID"`
-                                                                       } `xml:"eNB"`
-                                                               } `xml:"GlobalE2node-ID"`
-                                                               RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
-                                                       } `xml:"value"`
-                                               } `xml:"E2setupRequestIEs"`
-                                       } `xml:"protocolIEs"`
-                               } `xml:"E2setupRequest"`
+                               Text           string         `xml:",chardata"`
+                               E2setupRequest E2SetupRequest `xml:"E2setupRequest"`
                        } `xml:"value"`
                } `xml:"initiatingMessage"`
        } `xml:"E2AP-PDU"`
 }
 
+type RanFunctionItem struct {
+       Text                  string `xml:",chardata"`
+       RanFunctionID         string `xml:"ranFunctionID"`
+       RanFunctionDefinition string `xml:"ranFunctionDefinition"`
+       RanFunctionRevision   string `xml:"ranFunctionRevision"`
+}
+
 type RANfunctionsList struct {
-    Text                      string `xml:",chardata"`
-    ProtocolIESingleContainer []struct {
+       Text                      string `xml:",chardata"`
+       ProtocolIESingleContainer []struct {
                Text        string `xml:",chardata"`
                ID          string `xml:"id"`
                Criticality struct {
@@ -122,30 +141,25 @@ type RANfunctionsList struct {
                        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"`
+                       Text            string          `xml:",chardata"`
+                       RANfunctionItem RanFunctionItem `xml:"RANfunction-Item"`
                } `xml:"value"`
-    } `xml:"ProtocolIE-SingleContainer"`
+       } `xml:"ProtocolIE-SingleContainer"`
 }
 
-func (m *E2SetupRequestMessage) GetExtractRanFunctionsList()([]*entities.RanFunction, error){
-       list :=m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList.ProtocolIESingleContainer
+func (m *E2SetupRequestMessage) ExtractRanFunctionsList() ([]*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++{
+       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))
+                       return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.ExtractRanFunctionsList - 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))
+                       return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.ExtractRanFunctionsList - Failed parse uint RanFunctionRevision from %s", list[i].Value.RANfunctionItem.RanFunctionRevision))
                }
                funcs[i].RanFunctionDefinition = m.trimSpaces(list[i].Value.RANfunctionItem.RanFunctionDefinition)
                funcs[i].RanFunctionRevision = uint32(rev)
@@ -153,49 +167,56 @@ func (m *E2SetupRequestMessage) GetExtractRanFunctionsList()([]*entities.RanFunc
        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!= ""{
+func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
+       return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
+}
+
+func (m *E2SetupRequestMessage) GetNodeType() entities.Node_Type {
+       globalE2NodeId := m.getGlobalE2NodeId()
+       if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
                return entities.Node_GNB
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.EnGNB.GlobalGNBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
                return entities.Node_GNB
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.ENB.GlobalENBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
                return entities.Node_ENB
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.NgENB.GlobalNgENBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
                return entities.Node_GNB
        }
        return entities.Node_UNKNOWN
 }
 
-func (m *E2SetupRequestMessage) GetPlmnId() string{
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.GNB.GlobalGNBID.PlmnID; id!= ""{
+func (m *E2SetupRequestMessage) GetPlmnId() string {
+       globalE2NodeId := m.getGlobalE2NodeId()
+       if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.EnGNB.GlobalGNBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.ENB.GlobalENBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.NgENB.GlobalNgENBID.PlmnID; id!= ""{
+       if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
                return m.trimSpaces(id)
        }
        return ""
 }
 
-func (m *E2SetupRequestMessage) GetNbId() string{
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.GNB.GlobalGNBID.GnbID.GnbID; id!= ""{
+func (m *E2SetupRequestMessage) GetNbId() string {
+       globalE2NodeId := m.getGlobalE2NodeId()
+       if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.EnGNB.GlobalGNBID.GnbID.GnbID; id!= ""{
+       if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.ENB.GlobalENBID.GnbID.GnbID; id!= ""{
+       if id := globalE2NodeId.ENB.GlobalENBID.GnbID.GnbID; id != "" {
                return m.trimSpaces(id)
        }
-       if id := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID.NgENB.GlobalNgENBID.GnbID.GnbID; id!= ""{
+       if id := globalE2NodeId.NgENB.GlobalNgENBID.GnbID.GnbID; id != "" {
                return m.trimSpaces(id)
        }
        return ""
@@ -203,4 +224,4 @@ func (m *E2SetupRequestMessage) GetNbId() string{
 
 func (m *E2SetupRequestMessage) trimSpaces(str string) string {
        return strings.NewReplacer(" ", "", "\n", "").Replace(str)
-}
\ No newline at end of file
+}
index b7b216a..8d49521 100644 (file)
@@ -1,21 +1,25 @@
 <E2AP-PDU>\r
     <initiatingMessage>\r
         <procedureCode>1</procedureCode>\r
-        <criticality><reject/></criticality>\r
+        <criticality>\r
+            <reject/>\r
+        </criticality>\r
         <value>\r
             <E2setupRequest>\r
                 <protocolIEs>\r
                     <E2setupRequestIEs>\r
                         <id>3</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <GlobalE2node-ID>\r
                                 <en-gNB>\r
                                     <global-gNB-ID>\r
-                                        <plmn-id>13 10 14</plmn-id>\r
-                                        <gnb-id>\r
-                                            <gnb-ID>10011001101010101011</gnb-ID>\r
-                                        </gnb-id>\r
+                                        <pLMN-Identity>13 10 14</pLMN-Identity>\r
+                                        <gNB-ID>\r
+                                            <gNB-ID>11000101110001101100011111111000</gNB-ID>\r
+                                        </gNB-ID>\r
                                     </global-gNB-ID>\r
                                 </en-gNB>\r
                             </GlobalE2node-ID>\r
                     </E2setupRequestIEs>\r
                     <E2setupRequestIEs>\r
                         <id>10</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <RANfunctions-List>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
@@ -39,7 +47,9 @@
                                 </ProtocolIE-SingleContainer>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r
index 549a672..b947ae2 100644 (file)
@@ -1,13 +1,17 @@
 <E2AP-PDU>\r
     <initiatingMessage>\r
         <procedureCode>1</procedureCode>\r
-        <criticality><reject/></criticality>\r
+        <criticality>\r
+            <reject/>\r
+        </criticality>\r
         <value>\r
             <E2setupRequest>\r
                 <protocolIEs>\r
                     <E2setupRequestIEs>\r
                         <id>3</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <GlobalE2node-ID>\r
                                 <gNB>\r
                     </E2setupRequestIEs>\r
                     <E2setupRequestIEs>\r
                         <id>10</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <RANfunctions-List>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
@@ -39,7 +47,9 @@
                                 </ProtocolIE-SingleContainer>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r
index 1766493..5686930 100644 (file)
@@ -1,13 +1,17 @@
 <E2AP-PDU>\r
     <initiatingMessage>\r
         <procedureCode>1</procedureCode>\r
-        <criticality><reject/></criticality>\r
+        <criticality>\r
+            <reject/>\r
+        </criticality>\r
         <value>\r
             <E2setupRequest>\r
                 <protocolIEs>\r
                     <E2setupRequestIEs>\r
                         <id>3</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <GlobalE2node-ID>\r
                                 <ng-eNB>\r
                     </E2setupRequestIEs>\r
                     <E2setupRequestIEs>\r
                         <id>10</id>\r
-                        <criticality><reject/></criticality>\r
+                        <criticality>\r
+                            <reject/>\r
+                        </criticality>\r
                         <value>\r
                             <RANfunctions-List>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>1</ranFunctionID>\r
@@ -39,7 +47,9 @@
                                 </ProtocolIE-SingleContainer>\r
                                 <ProtocolIE-SingleContainer>\r
                                     <id>8</id>\r
-                                    <criticality><reject/></criticality>\r
+                                    <criticality>\r
+                                        <reject/>\r
+                                    </criticality>\r
                                     <value>\r
                                         <RANfunction-Item>\r
                                             <ranFunctionID>7</ranFunctionID>\r