From 3c3529321278742332a150b4bc9c97b58e0c1786 Mon Sep 17 00:00:00 2001 From: "jinwei.fan" Date: Tue, 20 Oct 2020 11:52:56 +0800 Subject: [PATCH] Fix E2SM Indication message RANContainer parsing issue. Signed-off-by: jinwei.fan Change-Id: I31b74f8ef456a85588f7c75d12173dbc13542d39 --- control/control.go | 170 +++++++++++++++++++++++---------------------- control/e2sm.go | 101 ++++++++++++++------------- control/types.go | 28 ++++---- 3 files changed, 153 insertions(+), 146 deletions(-) diff --git a/control/control.go b/control/control.go index a4c10f2..4b8b90d 100644 --- a/control/control.go +++ b/control/control.go @@ -3,20 +3,21 @@ package control import ( "encoding/json" "errors" - "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" - "github.com/go-redis/redis" "log" "os" "strconv" "strings" "sync" "time" + + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" + "github.com/go-redis/redis" ) type Control struct { - ranList []string //nodeB list - eventCreateExpired int32 //maximum time for the RIC Subscription Request event creation procedure in the E2 Node - eventDeleteExpired int32 //maximum time for the RIC Subscription Request event deletion procedure in the E2 Node + ranList []string //nodeB list + eventCreateExpired int32 //maximum time for the RIC Subscription Request event creation procedure in the E2 Node + eventDeleteExpired int32 //maximum time for the RIC Subscription Request event deletion procedure in the E2 Node rcChan chan *xapp.RMRParams //channel for receiving rmr message client *redis.Client //redis client eventCreateExpiredMap map[string]bool //map for recording the RIC Subscription Request event creation procedure is expired or not @@ -43,7 +44,7 @@ func NewControl() Control { 5, 5, make(chan *xapp.RMRParams), redis.NewClient(&redis.Options{ - Addr: os.Getenv("redisAddr"), //"localhost:6379" + Addr: os.Getenv("DBAAS_SERVICE_HOST") + ":" + os.Getenv("DBAAS_SERVICE_PORT"), //"localhost:6379" Password: "", DB: 0, }), @@ -181,19 +182,19 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { log.Printf("-----------RIC Indication Header-----------") if indicationHdr.IndHdrType == 1 { log.Printf("RIC Indication Header Format: %d", indicationHdr.IndHdrType) - indHdrFormat1 := indicationHdr.IndHdr.(IndicationHeaderFormat1) + indHdrFormat1 := indicationHdr.IndHdr.(*IndicationHeaderFormat1) log.Printf("GlobalKPMnodeIDType: %d", indHdrFormat1.GlobalKPMnodeIDType) if indHdrFormat1.GlobalKPMnodeIDType == 1 { - globalKPMnodegNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodegNBIDType) + globalKPMnodegNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodegNBIDType) globalgNBID := globalKPMnodegNBID.GlobalgNBID log.Printf("PlmnID: %x", globalgNBID.PlmnID.Buf) log.Printf("gNB ID Type: %d", globalgNBID.GnbIDType) if globalgNBID.GnbIDType == 1 { - gNBID := globalgNBID.GnbID.(GNBID) + gNBID := globalgNBID.GnbID.(*GNBID) log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused) } @@ -205,45 +206,45 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { log.Printf("gNB-DU ID: %x", globalKPMnodegNBID.GnbDUID.Buf) } } else if indHdrFormat1.GlobalKPMnodeIDType == 2 { - globalKPMnodeengNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodeengNBIDType) + globalKPMnodeengNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodeengNBIDType) log.Printf("PlmnID: %x", globalKPMnodeengNBID.PlmnID.Buf) log.Printf("en-gNB ID Type: %d", globalKPMnodeengNBID.GnbIDType) if globalKPMnodeengNBID.GnbIDType == 1 { - engNBID := globalKPMnodeengNBID.GnbID.(ENGNBID) + engNBID := globalKPMnodeengNBID.GnbID.(*ENGNBID) log.Printf("en-gNB ID ID: %x, Unused: %d", engNBID.Buf, engNBID.BitsUnused) } } else if indHdrFormat1.GlobalKPMnodeIDType == 3 { - globalKPMnodengeNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodengeNBIDType) + globalKPMnodengeNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodengeNBIDType) log.Printf("PlmnID: %x", globalKPMnodengeNBID.PlmnID.Buf) log.Printf("ng-eNB ID Type: %d", globalKPMnodengeNBID.EnbIDType) if globalKPMnodengeNBID.EnbIDType == 1 { - ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_Macro) + ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_Macro) log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused) } else if globalKPMnodengeNBID.EnbIDType == 2 { - ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_ShortMacro) + ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_ShortMacro) log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused) } else if globalKPMnodengeNBID.EnbIDType == 3 { - ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_LongMacro) + ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_LongMacro) log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused) } } else if indHdrFormat1.GlobalKPMnodeIDType == 4 { - globalKPMnodeeNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodeeNBIDType) + globalKPMnodeeNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodeeNBIDType) log.Printf("PlmnID: %x", globalKPMnodeeNBID.PlmnID.Buf) log.Printf("eNB ID Type: %d", globalKPMnodeeNBID.EnbIDType) if globalKPMnodeeNBID.EnbIDType == 1 { - eNBID := globalKPMnodeeNBID.EnbID.(ENBID_Macro) + eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_Macro) log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused) } else if globalKPMnodeeNBID.EnbIDType == 2 { - eNBID := globalKPMnodeeNBID.EnbID.(ENBID_Home) + eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_Home) log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused) } else if globalKPMnodeeNBID.EnbIDType == 3 { - eNBID := globalKPMnodeeNBID.EnbID.(ENBID_ShortMacro) + eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_ShortMacro) log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused) } else if globalKPMnodeeNBID.EnbIDType == 4 { - eNBID := globalKPMnodeeNBID.EnbID.(ENBID_LongMacro) + eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_LongMacro) log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused) } @@ -312,18 +313,18 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { } if indHdrFormat1.GnbNameType == 1 { - log.Printf("gNB-DU-Name: %x", (indHdrFormat1.GnbName.(GNB_DU_Name)).Buf) + log.Printf("gNB-DU-Name: %x", (indHdrFormat1.GnbName.(*GNB_DU_Name)).Buf) } else if indHdrFormat1.GnbNameType == 2 { - log.Printf("gNB-CU-CP-Name: %x", (indHdrFormat1.GnbName.(GNB_CU_CP_Name)).Buf) + log.Printf("gNB-CU-CP-Name: %x", (indHdrFormat1.GnbName.(*GNB_CU_CP_Name)).Buf) } else if indHdrFormat1.GnbNameType == 3 { - log.Printf("gNB-CU-UP-Name: %x", (indHdrFormat1.GnbName.(GNB_CU_UP_Name)).Buf) + log.Printf("gNB-CU-UP-Name: %x", (indHdrFormat1.GnbName.(*GNB_CU_UP_Name)).Buf) } if indHdrFormat1.GlobalgNBID != nil { log.Printf("PlmnID: %x", indHdrFormat1.GlobalgNBID.PlmnID.Buf) log.Printf("gNB ID Type: %d", indHdrFormat1.GlobalgNBID.GnbIDType) if indHdrFormat1.GlobalgNBID.GnbIDType == 1 { - gNBID := indHdrFormat1.GlobalgNBID.GnbID.(GNBID) + gNBID := indHdrFormat1.GlobalgNBID.GnbID.(*GNBID) log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused) } } @@ -355,7 +356,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if indMsg.IndMsgType == 1 { log.Printf("RIC Indication Message Format: %d", indMsg.IndMsgType) - indMsgFormat1 := indMsg.IndMsg.(IndicationMessageFormat1) + indMsgFormat1 := indMsg.IndMsg.(*IndicationMessageFormat1) log.Printf("PMContainerCount: %d", indMsgFormat1.PMContainerCount) @@ -380,7 +381,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if containerType == 1 { log.Printf("oDU PF Container: ") - oDU := pmContainer.PFContainer.Container.(ODUPFContainerType) + oDU := pmContainer.PFContainer.Container.(*ODUPFContainerType) cellResourceReportCount := oDU.CellResourceReportCount log.Printf("CellResourceReportCount: %d", cellResourceReportCount) @@ -469,7 +470,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { } else if containerType == 2 { log.Printf("oCU-CP PF Container: ") - oCUCP := pmContainer.PFContainer.Container.(OCUCPPFContainerType) + oCUCP := pmContainer.PFContainer.Container.(*OCUCPPFContainerType) if oCUCP.GNBCUCPName != nil { log.Printf("gNB-CU-CP Name: %x", oCUCP.GNBCUCPName.Buf) @@ -479,7 +480,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { } else if containerType == 3 { log.Printf("oCU-UP PF Container: ") - oCUUP := pmContainer.PFContainer.Container.(OCUUPPFContainerType) + oCUUP := pmContainer.PFContainer.Container.(*OCUUPPFContainerType) if oCUUP.GNBCUUPName != nil { log.Printf("gNB-CU-UP Name: %x", oCUUP.GNBCUUPName.Buf) @@ -499,7 +500,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { log.Printf("CU-UP Plmn Count: %d", cuUPPlmnCount) for k := 0; k < cuUPPlmnCount; k++ { - log.Printf("CU-UP Plmn [%d]: ") + log.Printf("CU-UP Plmn [%d]: ", k) cuUPPlmn := cuUPPFContainerItem.OCUUPPMContainer.CUUPPlmns[k] @@ -582,7 +583,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { log.Printf("PerQCIReportCount: %d", cuUPPMEPCPerQCIReportCount) for l := 0; l < cuUPPMEPCPerQCIReportCount; l++ { - log.Printf("PerQCIReport[%d]: ") + log.Printf("PerQCIReport[%d]: ", l) cuUPPMEPCPerQCIReport := cuUPPlmn.CUUPPMEPC.CUUPPMEPCPerQCIReports[l] @@ -615,7 +616,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if containerType == 1 { log.Printf("DU Usage Report: ") - oDUUE := pmContainer.RANContainer.Container.(DUUsageReportType) + oDUUE := pmContainer.RANContainer.Container.(*DUUsageReportType) for j := 0; j < oDUUE.CellResourceReportItemCount; j++ { cellResourceReportItem := oDUUE.CellResourceReportItems[j] @@ -642,15 +643,14 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { continue } - var ueMetrics *UeMetricsEntry + var ueMetrics UeMetricsEntry if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 { ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result() - json.Unmarshal([]byte(ueJsonStr), ueMetrics) - } else { - ueMetrics = &UeMetricsEntry{} + json.Unmarshal([]byte(ueJsonStr), &ueMetrics) } ueMetrics.ServingCellID = servingCellID + log.Printf("ServingCellID: %s", ueMetrics.ServingCellID) if flag { timestampPRB = timestamp @@ -661,22 +661,24 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if ueResourceReportItem.PRBUsageDL != -1 { ueMetrics.PRBUsageDL = ueResourceReportItem.PRBUsageDL + log.Printf("PRBUsageDL: %d", ueMetrics.PRBUsageDL) } if ueResourceReportItem.PRBUsageUL != -1 { ueMetrics.PRBUsageUL = ueResourceReportItem.PRBUsageUL + log.Printf("PRBUsageUL: %d", ueMetrics.PRBUsageUL) } - newUeJsonStr, err := json.Marshal(ueMetrics) + newUeJsonStr, err := json.Marshal(&ueMetrics) if err != nil { - xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) continue } err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err() if err != nil { - xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) continue } } @@ -684,7 +686,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { } else if containerType == 2 { log.Printf("CU-CP Usage Report: ") - oCUCPUE := pmContainer.RANContainer.Container.(CUCPUsageReportType) + oCUCPUE := pmContainer.RANContainer.Container.(*CUCPUsageReportType) for j := 0; j < oCUCPUE.CellResourceReportItemCount; j++ { cellResourceReportItem := oCUCPUE.CellResourceReportItems[j] @@ -711,55 +713,58 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { continue } - var ueMetrics *UeMetricsEntry + var ueMetrics UeMetricsEntry if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 { ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result() - json.Unmarshal([]byte(ueJsonStr), ueMetrics) - } else { - ueMetrics = &UeMetricsEntry{} + json.Unmarshal([]byte(ueJsonStr), &ueMetrics) } ueMetrics.ServingCellID = servingCellID + log.Printf("ServingCellID: %s", ueMetrics.ServingCellID) ueMetrics.MeasTimeRF.TVsec = timestamp.TVsec ueMetrics.MeasTimeRF.TVnsec = timestamp.TVnsec if ueResourceReportItem.ServingCellRF != nil { err = json.Unmarshal(ueResourceReportItem.ServingCellRF.Buf, &ueMetrics.ServingCellRF) + log.Printf("ueMetrics.ServingCellRF: %+v", ueMetrics.ServingCellRF) if err != nil { - xapp.Logger.Error("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("ServingCellRF raw data: %x", ueResourceReportItem.ServingCellRF.Buf) continue } } if ueResourceReportItem.NeighborCellRF != nil { err = json.Unmarshal(ueResourceReportItem.NeighborCellRF.Buf, &ueMetrics.NeighborCellsRF) + log.Printf("ueMetrics.NeighborCellsRF: %+v", ueMetrics.NeighborCellsRF) if err != nil { - xapp.Logger.Error("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("NeighborCellRF raw data: %x", ueResourceReportItem.NeighborCellRF.Buf) continue } } - newUeJsonStr, err := json.Marshal(ueMetrics) + newUeJsonStr, err := json.Marshal(&ueMetrics) if err != nil { - xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) continue } err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err() if err != nil { - xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) continue } } } - } else if containerType == 6 { + } else if containerType == 3 { log.Printf("CU-UP Usage Report: ") - oCUUPUE := pmContainer.RANContainer.Container.(CUUPUsageReportType) + oCUUPUE := pmContainer.RANContainer.Container.(*CUUPUsageReportType) for j := 0; j < oCUUPUE.CellResourceReportItemCount; j++ { cellResourceReportItem := oCUUPUE.CellResourceReportItems[j] @@ -786,15 +791,14 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { continue } - var ueMetrics *UeMetricsEntry + var ueMetrics UeMetricsEntry if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 { ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result() - json.Unmarshal([]byte(ueJsonStr), ueMetrics) - } else { - ueMetrics = &UeMetricsEntry{} + json.Unmarshal([]byte(ueJsonStr), &ueMetrics) } ueMetrics.ServingCellID = servingCellID + log.Printf("ServingCellID: %s", ueMetrics.ServingCellID) if flag { timestampPDCPBytes = timestamp @@ -806,8 +810,8 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if ueResourceReportItem.PDCPBytesDL != nil { ueMetrics.PDCPBytesDL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesDL.Buf, ueResourceReportItem.PDCPBytesDL.Size) if err != nil { - xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err) continue } } @@ -815,22 +819,22 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { if ueResourceReportItem.PDCPBytesUL != nil { ueMetrics.PDCPBytesUL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesUL.Buf, ueResourceReportItem.PDCPBytesUL.Size) if err != nil { - xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err) continue } } - newUeJsonStr, err := json.Marshal(ueMetrics) + newUeJsonStr, err := json.Marshal(&ueMetrics) if err != nil { - xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err) continue } err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err() if err != nil { - xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) - log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err) + xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) + log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err) continue } } @@ -843,12 +847,10 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { } if flag { - var cellMetrics *CellMetricsEntry + var cellMetrics CellMetricsEntry if isCellExist, _ := c.client.Exists(cellIDHdr).Result(); isCellExist == 1 { cellJsonStr, _ := c.client.Get(cellIDHdr).Result() - json.Unmarshal([]byte(cellJsonStr), cellMetrics) - } else { - cellMetrics = &CellMetricsEntry{} + json.Unmarshal([]byte(cellJsonStr), &cellMetrics) } if timestampPDCPBytes != nil { @@ -872,7 +874,7 @@ func (c *Control) handleIndication(params *xapp.RMRParams) (err error) { cellMetrics.AvailPRBUL = availPRBUL } - newCellJsonStr, err := json.Marshal(cellMetrics) + newCellJsonStr, err := json.Marshal(&cellMetrics) if err != nil { xapp.Logger.Error("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err) log.Printf("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err) @@ -1094,7 +1096,6 @@ func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err e log.Printf("Failed to send RIC_SUB_REQ: %v", err) return err } - log.Printf("Set EventTriggerDefinition: %x", eventTriggerDefinition) var actionCount int = 1 @@ -1122,13 +1123,13 @@ func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err e } } - for index := 0; index < len(c.ranList); index++ { + for index := 0; index < 1; index++ { //len(c.ranList) params := &xapp.RMRParams{} params.Mtype = 12010 params.SubId = subID - xapp.Logger.Debug("Send RIC_SUB_REQ to {%s}", c.ranList[index]) - log.Printf("Send RIC_SUB_REQ to {%s}", c.ranList[index]) + //xapp.Logger.Debug("Send RIC_SUB_REQ to {%s}", c.ranList[index]) + //log.Printf("Send RIC_SUB_REQ to {%s}", c.ranList[index]) params.Payload = make([]byte, 1024) params.Payload, err = e2ap.SetSubscriptionRequestPayload(params.Payload, 1001, uint16(requestSN), uint16(funcID), eventTriggerDefinition, len(eventTriggerDefinition), actionCount, actionIds, actionTypes, actionDefinitions, subsequentActions) @@ -1140,7 +1141,8 @@ func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err e log.Printf("Set Payload: %x", params.Payload) - params.Meid = &xapp.RMRMeid{RanName: c.ranList[index]} + //params.Meid = &xapp.RMRMeid{RanName: c.ranList[index]} + params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"} xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId) log.Printf("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId) @@ -1152,8 +1154,8 @@ func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err e } c.setEventCreateExpiredTimer(params.Meid.RanName) - c.ranList = append(c.ranList[:index], c.ranList[index+1:]...) - index-- + //c.ranList = append(c.ranList[:index], c.ranList[index+1:]...) + //index-- } return nil @@ -1175,9 +1177,11 @@ func (c *Control) sendRicSubDelRequest(subID int, requestSN int, funcID int) (er log.Printf("Set Payload: %x", params.Payload) if funcID == 0 { - params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "0"} + //params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "0"} + params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"} } else { - params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "3"} + //params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "3"} + params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"} } xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId) diff --git a/control/e2sm.go b/control/e2sm.go index 67b773c..d6a4157 100644 --- a/control/e2sm.go +++ b/control/e2sm.go @@ -70,7 +70,7 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err indHdr.IndHdrType = int32(decodedHdr.present) if indHdr.IndHdrType == 1 { indHdrFormat1 := &IndicationHeaderFormat1{} - indHdrFormat1_C := (*C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.choice[0])) + indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.choice[0])) if indHdrFormat1_C.id_GlobalKPMnode_ID != nil { globalKPMnodeID_C := (*C.GlobalKPMnode_ID_t)(indHdrFormat1_C.id_GlobalKPMnode_ID) @@ -78,7 +78,7 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err indHdrFormat1.GlobalKPMnodeIDType = int32(globalKPMnodeID_C.present) if indHdrFormat1.GlobalKPMnodeIDType == 1 { globalgNBID := &GlobalKPMnodegNBIDType{} - globalgNBID_C := (*C.GlobalKPMnode_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) + globalgNBID_C := *(**C.GlobalKPMnode_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) plmnID_C := globalgNBID_C.global_gNB_ID.plmn_id globalgNBID.GlobalgNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size)) @@ -112,7 +112,7 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err indHdrFormat1.GlobalKPMnodeID = globalgNBID } else if indHdrFormat1.GlobalKPMnodeIDType == 2 { globalengNBID := &GlobalKPMnodeengNBIDType{} - globalengNBID_C := (*C.GlobalKPMnode_en_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) + globalengNBID_C := *(**C.GlobalKPMnode_en_gNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) plmnID_C := globalengNBID_C.global_gNB_ID.pLMN_Identity globalengNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size)) @@ -134,7 +134,7 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err indHdrFormat1.GlobalKPMnodeID = globalengNBID } else if indHdrFormat1.GlobalKPMnodeIDType == 3 { globalngeNBID := &GlobalKPMnodengeNBIDType{} - globalngeNBID_C := (*C.GlobalKPMnode_ng_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) + globalngeNBID_C := *(**C.GlobalKPMnode_ng_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) plmnID_C := globalngeNBID_C.global_ng_eNB_ID.plmn_id globalngeNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size)) @@ -174,7 +174,7 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err indHdrFormat1.GlobalKPMnodeID = globalngeNBID } else if indHdrFormat1.GlobalKPMnodeIDType == 4 { globaleNBID := &GlobalKPMnodeeNBIDType{} - globaleNBID_C := (*C.GlobalKPMnode_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) + globaleNBID_C := *(**C.GlobalKPMnode_eNB_ID_t)(unsafe.Pointer(&globalKPMnodeID_C.choice[0])) plmnID_C := globaleNBID_C.global_eNB_ID.pLMN_Identity globaleNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size)) @@ -319,6 +319,8 @@ func (c *E2sm) GetIndicationHeader(buffer []byte) (indHdr *IndicationHeader, err } if indHdrFormat1_C.global_GNB_ID != nil { + indHdrFormat1.GlobalgNBID = &GlobalgNBIDType{} + plmnID_C := indHdrFormat1_C.global_GNB_ID.plmn_id indHdrFormat1.GlobalgNBID.PlmnID.Buf = C.GoBytes(unsafe.Pointer(plmnID_C.buf), C.int(plmnID_C.size)) indHdrFormat1.GlobalgNBID.PlmnID.Size = int(plmnID_C.size) @@ -360,13 +362,13 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e if indMsg.IndMsgType == 1 { indMsgFormat1 := &IndicationMessageFormat1{} - indMsgFormat1_C := (*C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&decodedMsg.indicationMessage.choice[0])) + indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&decodedMsg.indicationMessage.choice[0])) indMsgFormat1.PMContainerCount = int(indMsgFormat1_C.pm_Containers.list.count) for i := 0; i < indMsgFormat1.PMContainerCount; i++ { - pmContainer := indMsgFormat1.PMContainers[i] + pmContainer := &indMsgFormat1.PMContainers[i] var sizeof_PM_Containers_List_t *C.PM_Containers_List_t - pmContainer_C := (*C.PM_Containers_List_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(indMsgFormat1_C.pm_Containers.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_PM_Containers_List_t))) + pmContainer_C := *(**C.PM_Containers_List_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.pm_Containers.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_PM_Containers_List_t))) if pmContainer_C.performanceContainer != nil { pfContainer := &PFContainerType{} @@ -375,13 +377,13 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e if pfContainer.ContainerType == 1 { oDU_PF := &ODUPFContainerType{} - oDU_PF_C := (*C.ODU_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) + oDU_PF_C := *(**C.ODU_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) oDU_PF.CellResourceReportCount = int(oDU_PF_C.cellResourceReportList.list.count) for j := 0; j < oDU_PF.CellResourceReportCount; j++ { - cellResourceReport := oDU_PF.CellResourceReports[j] + cellResourceReport := &oDU_PF.CellResourceReports[j] var sizeof_CellResourceReportListItem_t *C.CellResourceReportListItem_t - cellResourceReport_C := (*C.CellResourceReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_PF_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CellResourceReportListItem_t))) + cellResourceReport_C := *(**C.CellResourceReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_PF_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CellResourceReportListItem_t))) cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size)) cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size) @@ -406,7 +408,7 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e for k := 0; k < cellResourceReport.ServedPlmnPerCellCount; k++ { servedPlmnPerCell := cellResourceReport.ServedPlmnPerCells[k] var sizeof_ServedPlmnPerCellListItem_t *C.ServedPlmnPerCellListItem_t - servedPlmnPerCell_C := (*C.ServedPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.servedPlmnPerCellList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_ServedPlmnPerCellListItem_t))) + servedPlmnPerCell_C := *(**C.ServedPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.servedPlmnPerCellList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_ServedPlmnPerCellListItem_t))) servedPlmnPerCell.PlmnID.Buf = C.GoBytes(unsafe.Pointer(servedPlmnPerCell_C.pLMN_Identity.buf), C.int(servedPlmnPerCell_C.pLMN_Identity.size)) servedPlmnPerCell.PlmnID.Size = int(servedPlmnPerCell_C.pLMN_Identity.size) @@ -417,9 +419,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e duPM5GC.SlicePerPlmnPerCellCount = int(duPM5GC_C.slicePerPlmnPerCellList.list.count) for l := 0; l < duPM5GC.SlicePerPlmnPerCellCount; l++ { - slicePerPlmnPerCell := duPM5GC.SlicePerPlmnPerCells[l] + slicePerPlmnPerCell := &duPM5GC.SlicePerPlmnPerCells[l] var sizeof_SlicePerPlmnPerCellListItem_t *C.SlicePerPlmnPerCellListItem_t - slicePerPlmnPerCell_C := (*C.SlicePerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPM5GC_C.slicePerPlmnPerCellList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SlicePerPlmnPerCellListItem_t))) + slicePerPlmnPerCell_C := *(**C.SlicePerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPM5GC_C.slicePerPlmnPerCellList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SlicePerPlmnPerCellListItem_t))) slicePerPlmnPerCell.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(slicePerPlmnPerCell_C.sliceID.sST.buf), C.int(slicePerPlmnPerCell_C.sliceID.sST.size)) slicePerPlmnPerCell.SliceID.SST.Size = int(slicePerPlmnPerCell_C.sliceID.sST.size) @@ -432,9 +434,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount = int(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.count) for m := 0; m < slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount; m++ { - fQIPerSlicesPerPlmnPerCell := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m] + fQIPerSlicesPerPlmnPerCell := &slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m] var sizeof_FQIPERSlicesPerPlmnPerCellListItem_t *C.FQIPERSlicesPerPlmnPerCellListItem_t - fQIPerSlicesPerPlmnPerCell_C := (*C.FQIPERSlicesPerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnPerCellListItem_t))) + fQIPerSlicesPerPlmnPerCell_C := *(**C.FQIPERSlicesPerPlmnPerCellListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(slicePerPlmnPerCell_C.fQIPERSlicesPerPlmnPerCellList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnPerCellListItem_t))) fQIPerSlicesPerPlmnPerCell.FiveQI = int64(fQIPerSlicesPerPlmnPerCell_C.fiveQI) @@ -461,9 +463,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e duPMEPC.PerQCIReportCount = int(duPMEPC_C.perQCIReportList.list.count) for l := 0; l < duPMEPC.PerQCIReportCount; l++ { - perQCIReport := duPMEPC.PerQCIReports[l] + perQCIReport := &duPMEPC.PerQCIReports[l] var sizeof_PerQCIReportListItem_t *C.PerQCIReportListItem_t - perQCIReport_C := (*C.PerQCIReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItem_t))) + perQCIReport_C := *(**C.PerQCIReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(duPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItem_t))) perQCIReport.QCI = int64(perQCIReport_C.qci) @@ -488,7 +490,7 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e pfContainer.Container = oDU_PF } else if pfContainer.ContainerType == 2 { oCU_CP_PF := &OCUCPPFContainerType{} - oCU_CP_PF_C := (*C.OCUCP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) + oCU_CP_PF_C := *(**C.OCUCP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) if oCU_CP_PF_C.gNB_CU_CP_Name != nil { oCU_CP_PF.GNBCUCPName = &PrintableString{} @@ -503,7 +505,7 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e pfContainer.Container = oCU_CP_PF } else if pfContainer.ContainerType == 3 { oCU_UP_PF := &OCUUPPFContainerType{} - oCU_UP_PF_C := (*C.OCUUP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) + oCU_UP_PF_C := *(**C.OCUUP_PF_Container_t)(unsafe.Pointer(&pmContainer_C.performanceContainer.choice[0])) if oCU_UP_PF_C.gNB_CU_UP_Name != nil { oCU_UP_PF.GNBCUUPName = &PrintableString{} @@ -513,17 +515,17 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e oCU_UP_PF.CUUPPFContainerItemCount = int(oCU_UP_PF_C.pf_ContainerList.list.count) for j := 0; j < oCU_UP_PF.CUUPPFContainerItemCount; j++ { - cuUPPFContainer := oCU_UP_PF.CUUPPFContainerItems[j] + cuUPPFContainer := &oCU_UP_PF.CUUPPFContainerItems[j] var sizeof_PF_ContainerListItem_t *C.PF_ContainerListItem_t - cuUPPFContainer_C := (*C.PF_ContainerListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_PF_C.pf_ContainerList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_PF_ContainerListItem_t))) + cuUPPFContainer_C := *(**C.PF_ContainerListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_PF_C.pf_ContainerList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_PF_ContainerListItem_t))) cuUPPFContainer.InterfaceType = int64(cuUPPFContainer_C.interface_type) cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount = int(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.count) for k := 0; k < cuUPPFContainer.OCUUPPMContainer.CUUPPlmnCount; k++ { - cuUPPlmn := cuUPPFContainer.OCUUPPMContainer.CUUPPlmns[k] + cuUPPlmn := &cuUPPFContainer.OCUUPPMContainer.CUUPPlmns[k] var sizeof_PlmnID_List_t *C.PlmnID_List_t - cuUPPlmn_C := (*C.PlmnID_List_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_PlmnID_List_t))) + cuUPPlmn_C := *(**C.PlmnID_List_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPFContainer_C.o_CU_UP_PM_Container.plmnList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_PlmnID_List_t))) cuUPPlmn.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cuUPPlmn_C.pLMN_Identity.buf), C.int(cuUPPlmn_C.pLMN_Identity.size)) cuUPPlmn.PlmnID.Size = int(cuUPPlmn_C.pLMN_Identity.size) @@ -534,9 +536,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e cuUPPM5GC.SliceToReportCount = int(cuUPPM5GC_C.sliceToReportList.list.count) for l := 0; l < cuUPPM5GC.SliceToReportCount; l++ { - sliceToReport := cuUPPM5GC.SliceToReports[l] + sliceToReport := &cuUPPM5GC.SliceToReports[l] var sizeof_SliceToReportListItem_t *C.SliceToReportListItem_t - sliceToReport_C := (*C.SliceToReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPM5GC_C.sliceToReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SliceToReportListItem_t))) + sliceToReport_C := *(**C.SliceToReportListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPM5GC_C.sliceToReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_SliceToReportListItem_t))) sliceToReport.SliceID.SST.Buf = C.GoBytes(unsafe.Pointer(sliceToReport_C.sliceID.sST.buf), C.int(sliceToReport_C.sliceID.sST.size)) sliceToReport.SliceID.SST.Size = int(sliceToReport_C.sliceID.sST.size) @@ -549,9 +551,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e sliceToReport.FQIPERSlicesPerPlmnCount = int(sliceToReport_C.fQIPERSlicesPerPlmnList.list.count) for m := 0; m < sliceToReport.FQIPERSlicesPerPlmnCount; m++ { - fQIPerSlicesPerPlmn := sliceToReport.FQIPERSlicesPerPlmns[m] + fQIPerSlicesPerPlmn := &sliceToReport.FQIPERSlicesPerPlmns[m] var sizeof_FQIPERSlicesPerPlmnListItem_t *C.FQIPERSlicesPerPlmnListItem_t - fQIPerSlicesPerPlmn_C := (*C.FQIPERSlicesPerPlmnListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(sliceToReport_C.fQIPERSlicesPerPlmnList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnListItem_t))) + fQIPerSlicesPerPlmn_C := *(**C.FQIPERSlicesPerPlmnListItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(sliceToReport_C.fQIPERSlicesPerPlmnList.list.array)) + (uintptr)(m)*unsafe.Sizeof(sizeof_FQIPERSlicesPerPlmnListItem_t))) fQIPerSlicesPerPlmn.FiveQI = int64(fQIPerSlicesPerPlmn_C.fiveQI) @@ -578,9 +580,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e cuUPPMEPC.CUUPPMEPCPerQCIReportCount = int(cuUPPMEPC_C.perQCIReportList.list.count) for l := 0; l < cuUPPMEPC.CUUPPMEPCPerQCIReportCount; l++ { - perQCIReport := cuUPPMEPC.CUUPPMEPCPerQCIReports[l] + perQCIReport := &cuUPPMEPC.CUUPPMEPCPerQCIReports[l] var sizeof_PerQCIReportListItemFormat_t *C.PerQCIReportListItemFormat_t - perQCIReport_C := (*C.PerQCIReportListItemFormat_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItemFormat_t))) + perQCIReport_C := *(**C.PerQCIReportListItemFormat_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cuUPPMEPC_C.perQCIReportList.list.array)) + (uintptr)(l)*unsafe.Sizeof(sizeof_PerQCIReportListItemFormat_t))) perQCIReport.QCI = int64(perQCIReport_C.qci) @@ -620,13 +622,13 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e if ranContainer.ContainerType == 1 { oDU_UE := &DUUsageReportType{} - oDU_UE_C := (*C.DU_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) + oDU_UE_C := *(**C.DU_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) oDU_UE.CellResourceReportItemCount = int(oDU_UE_C.cellResourceReportList.list.count) for j := 0; j < oDU_UE.CellResourceReportItemCount; j++ { - cellResourceReport := oDU_UE.CellResourceReportItems[j] + cellResourceReport := &oDU_UE.CellResourceReportItems[j] var sizeof_DU_Usage_Report_CellResourceReportItem_t *C.DU_Usage_Report_CellResourceReportItem_t - cellResourceReport_C := (*C.DU_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_DU_Usage_Report_CellResourceReportItem_t))) + cellResourceReport_C := *(**C.DU_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oDU_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_DU_Usage_Report_CellResourceReportItem_t))) cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size)) cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size) @@ -637,9 +639,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count) for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ { - ueResourceReport := cellResourceReport.UeResourceReportItems[k] + ueResourceReport := &cellResourceReport.UeResourceReportItems[k] var sizeof_DU_Usage_Report_UeResourceReportItem_t *C.DU_Usage_Report_UeResourceReportItem_t - ueResourceReport_C := (*C.DU_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_DU_Usage_Report_UeResourceReportItem_t))) + ueResourceReport_C := *(**C.DU_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_DU_Usage_Report_UeResourceReportItem_t))) ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size)) ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size) @@ -661,13 +663,13 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e ranContainer.Container = oDU_UE } else if ranContainer.ContainerType == 2 { oCU_CP_UE := &CUCPUsageReportType{} - oCU_CP_UE_C := (*C.CU_CP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) + oCU_CP_UE_C := *(**C.CU_CP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) oCU_CP_UE.CellResourceReportItemCount = int(oCU_CP_UE_C.cellResourceReportList.list.count) for j := 0; j < oCU_CP_UE.CellResourceReportItemCount; j++ { - cellResourceReport := oCU_CP_UE.CellResourceReportItems[j] + cellResourceReport := &oCU_CP_UE.CellResourceReportItems[j] var sizeof_CU_CP_Usage_Report_CellResourceReportItem_t *C.CU_CP_Usage_Report_CellResourceReportItem_t - cellResourceReport_C := (*C.CU_CP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_CP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_CellResourceReportItem_t))) + cellResourceReport_C := *(**C.CU_CP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_CP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_CellResourceReportItem_t))) cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size)) cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size) @@ -678,9 +680,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count) for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ { - ueResourceReport := cellResourceReport.UeResourceReportItems[k] + ueResourceReport := &cellResourceReport.UeResourceReportItems[k] var sizeof_CU_CP_Usage_Report_UeResourceReportItem_t *C.CU_CP_Usage_Report_UeResourceReportItem_t - ueResourceReport_C := (*C.CU_CP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_UeResourceReportItem_t))) + ueResourceReport_C := *(**C.CU_CP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_CP_Usage_Report_UeResourceReportItem_t))) ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size)) ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size) @@ -702,13 +704,13 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e ranContainer.Container = oCU_CP_UE } else if ranContainer.ContainerType == 3 { oCU_UP_UE := &CUUPUsageReportType{} - oCU_UP_UE_C := (*C.CU_UP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) + oCU_UP_UE_C := *(**C.CU_UP_Usage_Report_Per_UE_t)(unsafe.Pointer(&pmContainer_C.theRANContainer.reportContainer.choice[0])) oCU_UP_UE.CellResourceReportItemCount = int(oCU_UP_UE_C.cellResourceReportList.list.count) for j := 0; j < oCU_UP_UE.CellResourceReportItemCount; j++ { - cellResourceReport := oCU_UP_UE.CellResourceReportItems[j] + cellResourceReport := &oCU_UP_UE.CellResourceReportItems[j] var sizeof_CU_UP_Usage_Report_CellResourceReportItem_t *C.CU_UP_Usage_Report_CellResourceReportItem_t - cellResourceReport_C := (*C.CU_UP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_CellResourceReportItem_t))) + cellResourceReport_C := *(**C.CU_UP_Usage_Report_CellResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(oCU_UP_UE_C.cellResourceReportList.list.array)) + (uintptr)(j)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_CellResourceReportItem_t))) cellResourceReport.NRCGI.PlmnID.Buf = C.GoBytes(unsafe.Pointer(cellResourceReport_C.nRCGI.pLMN_Identity.buf), C.int(cellResourceReport_C.nRCGI.pLMN_Identity.size)) cellResourceReport.NRCGI.PlmnID.Size = int(cellResourceReport_C.nRCGI.pLMN_Identity.size) @@ -719,9 +721,9 @@ func (c *E2sm) GetIndicationMessage(buffer []byte) (indMsg *IndicationMessage, e cellResourceReport.UeResourceReportItemCount = int(cellResourceReport_C.ueResourceReportList.list.count) for k := 0; k < cellResourceReport.UeResourceReportItemCount; k++ { - ueResourceReport := cellResourceReport.UeResourceReportItems[k] + ueResourceReport := &cellResourceReport.UeResourceReportItems[k] var sizeof_CU_UP_Usage_Report_UeResourceReportItem_t *C.CU_UP_Usage_Report_UeResourceReportItem_t - ueResourceReport_C := (*C.CU_UP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_UeResourceReportItem_t))) + ueResourceReport_C := *(**C.CU_UP_Usage_Report_UeResourceReportItem_t)(unsafe.Pointer((uintptr)(unsafe.Pointer(cellResourceReport_C.ueResourceReportList.list.array)) + (uintptr)(k)*unsafe.Sizeof(sizeof_CU_UP_Usage_Report_UeResourceReportItem_t))) ueResourceReport.CRNTI.Buf = C.GoBytes(unsafe.Pointer(ueResourceReport_C.c_RNTI.buf), C.int(ueResourceReport_C.c_RNTI.size)) ueResourceReport.CRNTI.Size = int(ueResourceReport_C.c_RNTI.size) @@ -761,14 +763,15 @@ func (c *E2sm) ParseNRCGI(nRCGI NRCGIType) (CellID string, err error) { var plmnID OctetString var nrCellID BitString - if plmnID.Size != 3 || nrCellID.Size != 5 { - return "", errors.New("Invalid input: illegal length of NRCGI") - } - plmnID = nRCGI.PlmnID CellID, _ = c.ParsePLMNIdentity(plmnID.Buf, plmnID.Size) nrCellID = nRCGI.NRCellID + + if plmnID.Size != 3 || nrCellID.Size != 5 { + return "", errors.New("Invalid input: illegal length of NRCGI") + } + var former []uint8 = make([]uint8, 3) var latter []uint8 = make([]uint8, 6) diff --git a/control/types.go b/control/types.go index c6fef14..387c137 100644 --- a/control/types.go +++ b/control/types.go @@ -349,9 +349,9 @@ type CellMetricsEntry struct { } type CellRFType struct { - RSRP int `json:"rsrp"` - RSRQ int `json:"rsrq"` - RSSINR int `json:"rsSinr"` + RSRP int `json:"rsrp"` + RSRQ int `json:"rsrq"` + RSSINR int `json:"rssinr"` } type NeighborCellRFType struct { @@ -360,15 +360,15 @@ type NeighborCellRFType struct { } type UeMetricsEntry struct { - UeID string `json:"UE ID"` - ServingCellID string `json:"Serving Cell ID"` - MeasTimestampPDCPBytes Timestamp `json:"Meas-Timestamp-PDCP-Bytes"` - PDCPBytesDL int64 `json:"PDCP-Bytes-DL"` - PDCPBytesUL int64 `json:"PDCP-Bytes-UL"` - MeasTimestampPRB Timestamp `json:"Meas-Timestamp-PRB"` - PRBUsageDL int64 `json:"PRB-Usage-DL"` - PRBUsageUL int64 `json:"PRB-Usage-UL"` - MeasTimeRF Timestamp `json:"Meas-Time-RF"` - ServingCellRF CellRFType `json:"Serving-Cell-RF"` - NeighborCellsRF []NeighborCellRFType `json:"Neighbor-Cell-RF"` + UeID string `json:"UE ID"` + ServingCellID string `json:"Serving Cell ID"` + MeasTimestampPDCPBytes Timestamp `json:"Meas-Timestamp-PDCP-Bytes"` + PDCPBytesDL int64 `json:"PDCP-Bytes-DL"` + PDCPBytesUL int64 `json:"PDCP-Bytes-UL"` + MeasTimestampPRB Timestamp `json:"Meas-Timestamp-PRB"` + PRBUsageDL int64 `json:"PRB-Usage-DL"` + PRBUsageUL int64 `json:"PRB-Usage-UL"` + MeasTimeRF Timestamp `json:"Meas-Time-RF"` + ServingCellRF CellRFType `json:"servingCellRfReport"` + NeighborCellsRF []NeighborCellRFType `json:"neighbourCellList"` }