// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
// Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+// Copyright 2023 Capgemini
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
"fmt"
"strconv"
"strings"
+ "time"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
)
+const cleanUpDurationNanoSec uint64 = 10000000000 // cleanUpDuration = 10sec (value in nanoSecond=10000000000)
+
var (
emptyTagsToReplaceToSelfClosingTags = []string{"reject", "ignore", "transport-resource-unavailable", "om-intervention", "request-id-unknown",
+ "unspecified", "message-not-compatible-with-receiver-state", "control-processing-overload",
"v60s", "v20s", "v10s", "v5s", "v2s", "v1s", "ng", "xn", "e1", "f1", "w1", "s1", "x2", "success", "failure"}
gnbTypesMap = map[string]entities.GnbType{
"gnb": entities.GnbType_GNB,
func (h *E2SetupRequestNotificationHandler) Handle(request *models.NotificationRequest) {
ranName := request.RanName
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureNotInitiated)
h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s - received E2_SETUP_REQUEST. Payload: %x", ranName, request.Payload)
generalConfiguration, err := h.rNibDataService.GetGeneralConfiguration()
if !generalConfiguration.EnableRic {
cause := models.Cause{Misc: &models.CauseMisc{OmIntervention: &struct{}{}}}
h.handleUnsuccessfulResponse(ranName, request, cause, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureFailure)
return
}
if _, ok := err.(*e2managererrors.UnknownSetupRequestRanNameError); ok {
cause := models.Cause{RicRequest: &models.CauseRic{RequestIdUnknown: &struct{}{}}}
h.handleUnsuccessfulResponse(ranName, request, cause, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureFailure)
}
return
}
functionsModified, err = h.handleExistingRan(ranName, nodebInfo, setupRequest)
if err != nil {
+ h.fillCauseAndSendUnsuccessfulResponse(nodebInfo, request, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureFailure)
return
}
}
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureOngoing)
ranStatusChangePublished, err := h.e2tAssociationManager.AssociateRan(e2tIpAddress, nodebInfo)
cause := models.Cause{Transport: &models.CauseTransport{TransportResourceUnavailable: &struct{}{}}}
h.handleUnsuccessfulResponse(nodebInfo.RanName, request, cause, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureFailure)
}
return
}
}
h.handleSuccessfulResponse(ranName, request, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureCompleted)
+ h.logger.Debugf("#E2SetupRequestNotificationHandler.Handle - updating the enum value to e2setup request completed")
}
func (h *E2SetupRequestNotificationHandler) handleUpdateAndPublishNodebInfo(functionsModified bool, ranStatusChangePublished bool, nodebInfo *entities.NodebInfo) error {
}
func (h *E2SetupRequestNotificationHandler) handleExistingRan(ranName string, nodebInfo *entities.NodebInfo, setupRequest *models.E2SetupRequestMessage) (bool, error) {
- if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_SHUTTING_DOWN {
+ if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_DISCONNECTED {
+ delta_in_nano := uint64(time.Now().UnixNano()) - nodebInfo.StatusUpdateTimeStamp
+ //The duration from last Disconnection for which a new request is to be rejected (currently 10 sec)
+ if delta_in_nano < cleanUpDurationNanoSec {
+ h.logger.Errorf("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity disconnection in progress", ranName, nodebInfo.ConnectionStatus)
+ return false, errors.New("nodeB entity disconnection in progress")
+ }
+ h.logger.Infof("#E2SetupRequestNotificationHandler.Handle - RAN name: %s, connection status: %s - nodeB entity in disconnected state", ranName, nodebInfo.ConnectionStatus)
+ } else 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 false, errors.New("nodeB entity in incorrect state")
}
}
nodebInfo.GetGnb().NodeConfigs = e2NodeConfig
+ if nodebInfo.NodeType == entities.Node_GNB {
+ h.logger.Debugf("#E2SetupRequestNotificationHandler buildNodebInfo - entities.Node_GNB %d", entities.Node_GNB)
+
+ gnbNodetype := h.setGnbNodeType(request)
+ h.logger.Debugf("#E2SetupRequestNotificationHandler buildNodebInfo -gnbNodetype %s", gnbNodetype)
+ nodebInfo.GnbNodeType = gnbNodetype
+ nodebInfo.CuUpId = request.GetCuupId()
+ nodebInfo.DuId = request.GetDuId()
+ h.logger.Debugf("#E2SetupRequestNotificationHandler buildNodebInfo -cuupid%s", request.GetCuupId())
+ h.logger.Debugf("#E2SetupRequestNotificationHandler buildNodebInfo -duid %s", request.GetDuId())
+ }
+
ranFuncs := request.ExtractRanFunctionsList()
if ranFuncs != nil {
return nodebInfo, nil
}
+
+func (h *E2SetupRequestNotificationHandler) setGnbNodeType(setupRequest *models.E2SetupRequestMessage) string {
+ gnbNodetype := "gNB"
+ /*Note: Deployment where CU-UP and DU are combined
+ (but do not include the CP-CP) and have a single E2 connection
+ is not supported. The combination of CU-CP, CU-UP, and DU will be
+ treated as a single gNB and expect it to have only the
+ global gNB ID in its E2 Setup ID*/
+ if setupRequest.GetCuupId() != "" && setupRequest.GetDuId() != "" {
+ gnbNodetype = "gNB"
+ } else if setupRequest.GetCuupId() != "" {
+ gnbNodetype = "gNB_CU_UP"
+ } else if setupRequest.GetDuId() != "" {
+ gnbNodetype = "gNB_DU"
+ }
+ return gnbNodetype
+}
+
func (h *E2SetupRequestNotificationHandler) setNodeTypeAndConfiguration(nodebInfo *entities.NodebInfo) error {
for k, v := range gnbTypesMap {
if strings.HasPrefix(nodebInfo.RanName, k) {
GlobalNbId: h.buildGlobalNbId(setupRequest),
}
}
+
+func (h *E2SetupRequestNotificationHandler) fillCauseAndSendUnsuccessfulResponse(nodebInfo *entities.NodebInfo, request *models.NotificationRequest, setupRequest *models.E2SetupRequestMessage) {
+ ranName := request.RanName
+ if nodebInfo.GetConnectionStatus() == entities.ConnectionStatus_DISCONNECTED {
+ cause := models.Cause{Misc: &models.CauseMisc{ControlProcessingOverload: &struct{}{}}}
+ h.handleUnsuccessfulResponse(nodebInfo.RanName, request, cause, setupRequest)
+ models.UpdateProcedureType(ranName, models.E2SetupProcedureFailure)
+ }
+}