X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fhandlers%2Frmrmsghandlers%2Fe2_setup_request_notification_handler.go;h=b71129f3b59e346d662938e553e395230a0b84cb;hb=refs%2Fchanges%2F83%2F3383%2F1;hp=8ec18eb4ec9fcfed2ecae6070f53bfb01e72d3bf;hpb=70a16499e8c7042383f3fe115e6180f398dbab7d;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go index 8ec18eb..b71129f 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler.go @@ -22,6 +22,7 @@ package rmrmsghandlers import ( "bytes" "e2mgr/configuration" + "e2mgr/e2managererrors" "e2mgr/logger" "e2mgr/managers" "e2mgr/models" @@ -109,36 +110,69 @@ func (h E2SetupRequestNotificationHandler) Handle(request *models.NotificationRe return } } - nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED 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) + 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){ + 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{ + h.logger.Warnf("#E2SetupRequestNotificationHandler.handleUnsuccessfulResponse - RAN name: %s - Error marshalling RIC_E2_SETUP_RESP. Payload: %s", nodebInfo.RanName, responsePayload) + } + + responsePayload = replaceEmptyTagsWithSelfClosing(responsePayload) + + msg := models.NewRmrMessage(rmrCgo.RIC_E2_SETUP_FAILURE, nodebInfo.RanName, responsePayload, req.TransactionId, req.GetMsgSrc()) + h.logger.Infof("#E2SetupRequestNotificationHandler.handleUnsuccessfulResponse - RAN name: %s - RIC_E2_SETUP_RESP message has been built successfully. Message: %x", nodebInfo.RanName, msg) + _ = h.rmrSender.WhSend(msg) + +} + +func (h E2SetupRequestNotificationHandler) handleSuccessfulResponse(ranName string, req *models.NotificationRequest, setupRequest *models.E2SetupRequestMessage){ ricNearRtId, err := convertTo20BitString(h.config.GlobalRicId.RicNearRtId) if err != nil{ - h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - failed to convert RicNearRtId value %s to 20 bit string . Error: %s", ranName, h.config.GlobalRicId.RicNearRtId, err) + 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) - h.logger.Debugf("#E2SetupRequestNotificationHandler.Handle - E2_SETUP_RESPONSE has been built successfully %+v", successResponse) + h.logger.Debugf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - E2_SETUP_RESPONSE has been built successfully %+v", successResponse) responsePayload, err := xml.Marshal(&successResponse.E2APPDU) if err != nil{ - h.logger.Warnf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - Error marshalling RIC_E2_SETUP_RESP. Payload: %s", ranName, responsePayload) + h.logger.Warnf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - RAN name: %s - Error marshalling RIC_E2_SETUP_RESP. Payload: %s", ranName, responsePayload) } - responsePayload = replaceCriticalityTagsWithSelfClosing(responsePayload) + responsePayload = replaceEmptyTagsWithSelfClosing(responsePayload) - msg := models.NewRmrMessage(rmrCgo.RIC_E2_SETUP_RESP, ranName, responsePayload, request.TransactionId) - h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - RIC_E2_SETUP_RESP message has been built successfully. Message: %x", ranName, msg) + msg := models.NewRmrMessage(rmrCgo.RIC_E2_SETUP_RESP, ranName, responsePayload, req.TransactionId, req.GetMsgSrc()) + h.logger.Infof("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - RAN name: %s - RIC_E2_SETUP_RESP message has been built successfully. Message: %x", ranName, msg) _ = h.rmrSender.Send(msg) } -func replaceCriticalityTagsWithSelfClosing(responsePayload []byte) []byte { - responseString := strings.Replace(string(responsePayload), "", "", -1) - responseString = strings.Replace(responseString, "", "", -1) + +func replaceEmptyTagsWithSelfClosing(responsePayload []byte) []byte { + responseString := strings.NewReplacer( + "", "", + "", "", + "", "", + "", "", + "", "", + "", "", + "", "", + "", "", + "", "", + ).Replace(string(responsePayload)) return []byte(responseString) } @@ -178,6 +212,10 @@ func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAdd 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() return nodebInfo, err