}
func (h E2SetupRequestNotificationHandler) setGnbFunctions(nodebInfo *entities.NodebInfo, setupRequest *models.E2SetupRequestMessage) error {
- ranFunctions, err := setupRequest.ExtractRanFunctionsList()
+ ranFunctions := setupRequest.ExtractRanFunctionsList()
- if err != nil {
- h.logger.Errorf("#E2SetupRequestNotificationHandler.setGnbFunctions - RAN name: %s - failed to update nodebInfo entity. Error: %s", nodebInfo.GetRanName(), err)
- return err
+ if ranFunctions != nil {
+ nodebInfo.GetGnb().RanFunctions = ranFunctions
}
- nodebInfo.GetGnb().RanFunctions = ranFunctions
return nil
}
responsePayload = replaceEmptyTagsWithSelfClosing(responsePayload)
+ h.logger.Infof("#E2SetupRequestNotificationHandler.handleUnsuccessfulResponse - payload: %s", 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)
+ plmnId := buildPlmnId(h.config.GlobalRicId.Mcc, h.config.GlobalRicId.Mnc)
+
+ ricNearRtId, err := convertTo20BitString(h.config.GlobalRicId.RicId)
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(plmnId, ricNearRtId, setupRequest)
h.logger.Debugf("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - E2_SETUP_RESPONSE has been built successfully %+v", successResponse)
responsePayload, err := xml.Marshal(&successResponse.E2APPDU)
responsePayload = replaceEmptyTagsWithSelfClosing(responsePayload)
+ h.logger.Infof("#E2SetupRequestNotificationHandler.handleSuccessfulResponse - payload: %s", responsePayload)
+
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 buildPlmnId(mmc string, mnc string) string{
+ var b strings.Builder
+
+ b.WriteByte(mmc[1])
+ b.WriteByte(mmc[0])
+ if len(mnc) == 2 {
+ b.WriteString("F")
+ } else {
+ b.WriteByte(mnc[2])
+ }
+ b.WriteByte(mmc[2])
+ b.WriteByte(mnc[1])
+ b.WriteByte(mnc[0])
+
+ return b.String()
+}
+
func replaceEmptyTagsWithSelfClosing(responsePayload []byte) []byte {
responseString := strings.NewReplacer(
"<reject></reject>", "<reject/>",
h.logger.Infof("#E2SetupRequestNotificationHandler.parseSetupRequest - payload: %s", payload[pipInd+1:])
setupRequest := &models.E2SetupRequestMessage{}
- err := xml.Unmarshal(payload[pipInd+1:], &setupRequest.E2APPDU)
+ err := xml.Unmarshal(normalizeXml(payload[pipInd+1:]), &setupRequest.E2APPDU)
if err != nil {
return nil, "", errors.New(fmt.Sprintf("#E2SetupRequestNotificationHandler.parseSetupRequest - Error unmarshalling E2 Setup Request payload: %x", payload))
}
- ranFunctionsList := setupRequest.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList.ProtocolIESingleContainer
-
- for i := 0; i < len(ranFunctionsList); i++ {
- def := models.E2smGnbNrtRanFunctionDefinition{}
- err = xml.Unmarshal([]byte(ranFunctionsList[i].Value.RANfunctionItem.RanFunctionDefinition.Text), &def)
- ranFunctionsList[i].Value.RANfunctionItem.RanFunctionDefinition.E2smGnbNrtRanFunctionDefinition = def
- }
-
return setupRequest, e2tIpAddress, nil
}
+func normalizeXml(payload []byte) []byte {
+ xmlStr := string(payload)
+ normalized := strings.NewReplacer("<", "<", ">", ">").Replace(xmlStr)
+ return []byte(normalized)
+}
+
func (h E2SetupRequestNotificationHandler) buildNodebInfo(ranName string, e2tAddress string, request *models.E2SetupRequestMessage) (*entities.NodebInfo, error) {
var err error