2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
23 // #cgo CFLAGS: -I../3rdparty/asn1codec/inc/ -I../3rdparty/asn1codec/e2ap_engine/
24 // #cgo LDFLAGS: -L ../3rdparty/asn1codec/lib/ -L../3rdparty/asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
25 // #include <asn1codec_utils.h>
26 // #include <load_information_wrapper.h>
31 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
38 NaxNoOfCompHypothesisSet = 256
43 type EnbLoadInformationExtractor struct {
47 type IEnbLoadInformationExtractor interface {
48 ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error
51 func NewEnbLoadInformationExtractor(logger *logger.Logger) *EnbLoadInformationExtractor {
52 return &EnbLoadInformationExtractor{
57 var populators = map[C.CellInformation_Item_ExtIEs__extensionValue_PR]func(string, *entities.CellLoadInformation, *C.CellInformation_Item_ExtIEs_t) error{
58 C.CellInformation_Item_ExtIEs__extensionValue_PR_ABSInformation: populateAbsInformation,
59 C.CellInformation_Item_ExtIEs__extensionValue_PR_InvokeIndication: populateInvokeIndication,
60 C.CellInformation_Item_ExtIEs__extensionValue_PR_SubframeAssignment: populateIntendedUlDlConfiguration,
61 C.CellInformation_Item_ExtIEs__extensionValue_PR_ExtendedULInterferenceOverloadInfo: populateExtendedUlInterferenceOverloadInfo,
62 C.CellInformation_Item_ExtIEs__extensionValue_PR_CoMPInformation: populateCompInformation,
63 C.CellInformation_Item_ExtIEs__extensionValue_PR_DynamicDLTransmissionInformation: populateDynamicDLTransmissionInformation,
66 func extractPduCellInformationItemIEs(pdu *C.E2AP_PDU_t) ([]*C.CellInformation_ItemIEs_t, error) {
68 if pdu.present != C.E2AP_PDU_PR_initiatingMessage {
69 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid E2AP_PDU value")
72 initiatingMessage := *(**C.InitiatingMessage_t)(unsafe.Pointer(&pdu.choice[0]))
74 if initiatingMessage == nil || initiatingMessage.value.present != C.InitiatingMessage__value_PR_LoadInformation {
75 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid InitiatingMessage value")
78 loadInformationMessage := (*C.LoadInformation_t)(unsafe.Pointer(&initiatingMessage.value.choice[0]))
80 if loadInformationMessage == nil {
81 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid LoadInformation container")
84 protocolIEsListCount := loadInformationMessage.protocolIEs.list.count
86 if protocolIEsListCount != 1 {
87 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs list count")
90 loadInformationIEs := (*[1 << 30]*C.LoadInformation_IEs_t)(unsafe.Pointer(loadInformationMessage.protocolIEs.list.array))[:int(protocolIEsListCount):int(protocolIEsListCount)]
92 loadInformationIE := loadInformationIEs[0]
94 if loadInformationIE.value.present != C.LoadInformation_IEs__value_PR_CellInformation_List {
95 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs value")
98 loadInformationCellList := (*C.CellInformation_List_t)(unsafe.Pointer(&loadInformationIE.value.choice[0]))
100 loadInformationCellListCount := loadInformationCellList.list.count
102 if loadInformationCellListCount == 0 || loadInformationCellListCount > MaxCellsInEnb {
103 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid CellInformation list count")
106 return (*[1 << 30]*C.CellInformation_ItemIEs_t)(unsafe.Pointer(loadInformationCellList.list.array))[:int(loadInformationCellListCount):int(loadInformationCellListCount)], nil
109 func populateCellLoadInformation(pduCellInformationItemIE *C.CellInformation_ItemIEs_t, ranLoadInformation *entities.RanLoadInformation) error {
111 pduCellInformationItem, err := extractPduCellInformationItem(pduCellInformationItemIE)
117 cellLoadInformation := entities.CellLoadInformation{}
118 err = buildCellLoadInformation(&cellLoadInformation, pduCellInformationItem)
124 ranLoadInformation.CellLoadInfos = append(ranLoadInformation.CellLoadInfos, &cellLoadInformation)
129 func extractPduCellInformationItem(cell *C.CellInformation_ItemIEs_t) (*C.CellInformation_Item_t, error) {
131 if cell.value.present != C.CellInformation_ItemIEs__value_PR_CellInformation_Item {
132 return nil, fmt.Errorf("#extractPduCellInformationItem - Failed extracting pdu cell information item")
135 return (*C.CellInformation_Item_t)(unsafe.Pointer(&cell.value.choice[0])), nil
138 func buildCellLoadInformation(cellLoadInformation *entities.CellLoadInformation, cellInformationItem *C.CellInformation_Item_t) error {
140 cellId := buildCellId(cellInformationItem.cell_ID)
141 cellLoadInformation.CellId = cellId
143 pduUlInterferenceOverloadIndicationItems, err := extractPduUlInterferenceOverloadIndicationItems(cellId, cellInformationItem)
149 if (pduUlInterferenceOverloadIndicationItems != nil) {
150 cellLoadInformation.UlInterferenceOverloadIndications = buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems)
153 pduUlHighInterferenceIndicationInfoItems, err := extractPduUlHighInterferenceIndicationInfoItems(cellId, cellInformationItem)
159 if pduUlHighInterferenceIndicationInfoItems != nil {
160 cellLoadInformation.UlHighInterferenceInfos = buildUlHighInterferenceIndicationInfoList(pduUlHighInterferenceIndicationInfoItems)
163 pduRelativeNarrowbandTxPower := extractPduRelativeNarrowbandTxPower(cellInformationItem)
165 if pduRelativeNarrowbandTxPower != nil {
166 pduEnhancedRntp, err := extractPduEnhancedRntp(cellId, pduRelativeNarrowbandTxPower)
172 cellLoadInformation.RelativeNarrowbandTxPower = buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower, pduEnhancedRntp)
175 pduCellInformationItemExtensionIEs := extractPduCellInformationItemExtensionIEs(cellInformationItem)
177 if (pduCellInformationItemExtensionIEs == nil) {
181 err = populateCellLoadInformationExtensionIEs(cellId, cellLoadInformation, pduCellInformationItemExtensionIEs)
191 func buildCellId(cellId C.ECGI_t) string {
192 plmnId := cUcharArrayToGoByteSlice(cellId.pLMN_Identity.buf, cellId.pLMN_Identity.size)
193 eutranCellIdentifier := cUcharArrayToGoByteSlice(cellId.eUTRANcellIdentifier.buf, cellId.eUTRANcellIdentifier.size)
194 return fmt.Sprintf("%x:%x", plmnId, eutranCellIdentifier)
197 func buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems []*C.UL_InterferenceOverloadIndication_Item_t) []entities.UlInterferenceOverloadIndication {
198 indications := make([]entities.UlInterferenceOverloadIndication, len(pduUlInterferenceOverloadIndicationItems))
199 for i, ci := range pduUlInterferenceOverloadIndicationItems {
200 indications[i] = entities.UlInterferenceOverloadIndication(*ci + 1)
206 func extractPduUlInterferenceOverloadIndicationItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_InterferenceOverloadIndication_Item_t, error) {
208 if cellInformationItem.ul_InterferenceOverloadIndication == nil {
212 ulInterferenceOverLoadIndicationCount := cellInformationItem.ul_InterferenceOverloadIndication.list.count
214 if ulInterferenceOverLoadIndicationCount == 0 || ulInterferenceOverLoadIndicationCount > MaxNoOfPrbs {
215 return nil, fmt.Errorf("#extractPduUlInterferenceOverloadIndicationItems - cellId: %s - Invalid UL Interference OverLoad Indication list count", cellId)
218 pduUlInterferenceOverloadIndicationItems := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(cellInformationItem.ul_InterferenceOverloadIndication.list.array))[:int(ulInterferenceOverLoadIndicationCount):int(ulInterferenceOverLoadIndicationCount)]
220 return pduUlInterferenceOverloadIndicationItems, nil
223 func NewStartTime(startSfn C.long, startSubframeNumber C.long) *entities.StartTime {
224 return &entities.StartTime{
225 StartSfn: int32(startSfn),
226 StartSubframeNumber: int32(startSubframeNumber),
230 func buildEnhancedRntp(pduEnhancedRntp *C.EnhancedRNTP_t) *entities.EnhancedRntp {
232 enhancedRntp := entities.EnhancedRntp{
233 EnhancedRntpBitmap: NewHexString(pduEnhancedRntp.enhancedRNTPBitmap.buf, pduEnhancedRntp.enhancedRNTPBitmap.size),
234 RntpHighPowerThreshold: entities.RntpThreshold(pduEnhancedRntp.rNTP_High_Power_Threshold + 1),
237 pduEnhancedRntpStartTime := (*C.EnhancedRNTPStartTime_t)(unsafe.Pointer(pduEnhancedRntp.enhancedRNTPStartTime))
239 if pduEnhancedRntpStartTime != nil {
240 enhancedRntp.EnhancedRntpStartTime = NewStartTime(pduEnhancedRntpStartTime.startSFN, pduEnhancedRntpStartTime.startSubframeNumber)
246 func cUcharArrayToGoByteSlice(buf *C.uchar, size C.ulong) []byte {
247 return C.GoBytes(unsafe.Pointer(buf), C.int(size))
250 func NewHexString(buf *C.uchar, size C.ulong) string {
251 return fmt.Sprintf("%x", cUcharArrayToGoByteSlice(buf, size))
254 func buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t, pduEnhancedRntp *C.EnhancedRNTP_t) *entities.RelativeNarrowbandTxPower {
256 relativeNarrowbandTxPower := entities.RelativeNarrowbandTxPower{
257 RntpThreshold: entities.RntpThreshold(pduRelativeNarrowbandTxPower.rNTP_Threshold + 1),
258 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduRelativeNarrowbandTxPower.numberOfCellSpecificAntennaPorts + 1),
259 PB: uint32(pduRelativeNarrowbandTxPower.p_B),
260 PdcchInterferenceImpact: uint32(pduRelativeNarrowbandTxPower.pDCCH_InterferenceImpact),
261 RntpPerPrb: NewHexString(pduRelativeNarrowbandTxPower.rNTP_PerPRB.buf, pduRelativeNarrowbandTxPower.rNTP_PerPRB.size),
264 if pduEnhancedRntp != nil {
265 relativeNarrowbandTxPower.EnhancedRntp = buildEnhancedRntp(pduEnhancedRntp)
268 return &relativeNarrowbandTxPower
271 func extractPduRelativeNarrowbandTxPower(cellInformationItem *C.CellInformation_Item_t) *C.RelativeNarrowbandTxPower_t {
273 if cellInformationItem.relativeNarrowbandTxPower == nil {
277 return (*C.RelativeNarrowbandTxPower_t)(unsafe.Pointer(cellInformationItem.relativeNarrowbandTxPower))
280 func buildUlHighInterferenceIndicationInfoList(ulHighInterferenceIndicationInfoList []*C.UL_HighInterferenceIndicationInfo_Item_t) []*entities.UlHighInterferenceInformation {
281 infos := make([]*entities.UlHighInterferenceInformation, len(ulHighInterferenceIndicationInfoList))
283 for i, v := range ulHighInterferenceIndicationInfoList {
285 infos[i] = &entities.UlHighInterferenceInformation{
286 TargetCellId: buildCellId(v.target_Cell_ID),
287 UlHighInterferenceIndication: NewHexString(v.ul_interferenceindication.buf, v.ul_interferenceindication.size),
294 func extractPduUlHighInterferenceIndicationInfoItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_HighInterferenceIndicationInfo_Item_t, error) {
295 pduUlHighInterferenceIndicationInfo := (*C.UL_HighInterferenceIndicationInfo_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo))
297 if (pduUlHighInterferenceIndicationInfo == nil) {
301 pduUlHighInterferenceIndicationInfoListCount := pduUlHighInterferenceIndicationInfo.list.count
303 if pduUlHighInterferenceIndicationInfoListCount == 0 || pduUlHighInterferenceIndicationInfoListCount > MaxCellsInEnb {
304 return nil, fmt.Errorf("#extractPduUlHighInterferenceIndicationInfoItems - cellId: %s - Invalid UL High Interference Indication info list count", cellId)
307 pduUlHighInterferenceIndicationInfoItems := (*[1 << 30]*C.UL_HighInterferenceIndicationInfo_Item_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo.list.array))[:int(pduUlHighInterferenceIndicationInfoListCount):int(pduUlHighInterferenceIndicationInfoListCount)]
309 return pduUlHighInterferenceIndicationInfoItems, nil
312 func extractPduCellInformationItemExtensionIEs(cellInformationItem *C.CellInformation_Item_t) []*C.CellInformation_Item_ExtIEs_t {
313 extIEs := (*C.ProtocolExtensionContainer_170P7_t)(unsafe.Pointer(cellInformationItem.iE_Extensions))
319 extIEsCount := int(extIEs.list.count)
321 if extIEsCount == 0 {
325 return (*[1 << 30]*C.CellInformation_Item_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
328 func extractPduEnhancedRntp(cellId string, pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t) (*C.EnhancedRNTP_t, error) {
330 extIEs := (*C.ProtocolExtensionContainer_170P184_t)(unsafe.Pointer(pduRelativeNarrowbandTxPower.iE_Extensions))
336 extIEsCount := int(extIEs.list.count)
338 if extIEsCount != 1 {
339 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
342 enhancedRntpExtIEs := (*[1 << 30]*C.RelativeNarrowbandTxPower_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
344 enhancedRntpExtIE := enhancedRntpExtIEs[0]
346 if enhancedRntpExtIE.extensionValue.present != C.RelativeNarrowbandTxPower_ExtIEs__extensionValue_PR_EnhancedRNTP {
347 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
350 return (*C.EnhancedRNTP_t)(unsafe.Pointer(&enhancedRntpExtIE.extensionValue.choice[0])), nil
353 func buildAbsInformationFdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
354 pduAbsInformationFdd := *(**C.ABSInformationFDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
356 if pduAbsInformationFdd == nil {
357 return nil, fmt.Errorf("#buildAbsInformationFdd - cellId: %s - Invalid FDD Abs Information", cellId)
360 absInformation := entities.AbsInformation{
361 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
362 AbsPatternInfo: NewHexString(pduAbsInformationFdd.abs_pattern_info.buf, pduAbsInformationFdd.abs_pattern_info.size),
363 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationFdd.numberOfCellSpecificAntennaPorts + 1),
364 MeasurementSubset: NewHexString(pduAbsInformationFdd.measurement_subset.buf, pduAbsInformationFdd.measurement_subset.size),
367 return &absInformation, nil
370 func buildAbsInformationTdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
371 pduAbsInformationTdd := *(**C.ABSInformationTDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
373 if pduAbsInformationTdd == nil {
374 return nil, fmt.Errorf("#buildAbsInformationTdd - cellId: %s - Invalid TDD Abs Information", cellId)
377 absInformation := entities.AbsInformation{
378 Mode: entities.AbsInformationMode_ABS_INFO_TDD,
379 AbsPatternInfo: NewHexString(pduAbsInformationTdd.abs_pattern_info.buf, pduAbsInformationTdd.abs_pattern_info.size),
380 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationTdd.numberOfCellSpecificAntennaPorts + 1),
381 MeasurementSubset: NewHexString(pduAbsInformationTdd.measurement_subset.buf, pduAbsInformationTdd.measurement_subset.size),
384 return &absInformation, nil
387 func extractAndBuildCellLoadInformationAbsInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.AbsInformation, error) {
388 pduAbsInformation := (*C.ABSInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
390 switch pduAbsInformation.present {
391 case C.ABSInformation_PR_fdd:
392 return buildAbsInformationFdd(cellId, pduAbsInformation)
393 case C.ABSInformation_PR_tdd:
394 return buildAbsInformationTdd(cellId, pduAbsInformation)
395 case C.ABSInformation_PR_abs_inactive:
396 return &entities.AbsInformation{Mode: entities.AbsInformationMode_ABS_INACTIVE}, nil
399 return nil, fmt.Errorf("#extractAndBuildCellLoadInformationAbsInformation - cellId: %s - Failed extracting AbsInformation", cellId)
402 func extractExtendedUlInterferenceOverloadIndicationList(extendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) []*C.UL_InterferenceOverloadIndication_Item_t {
404 extendedUlInterferenceOverLoadIndicationCount := extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.count
406 if extendedUlInterferenceOverLoadIndicationCount == 0 {
410 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.array))[:int(extendedUlInterferenceOverLoadIndicationCount):int(extendedUlInterferenceOverLoadIndicationCount)]
412 if (extendedUlInterferenceOverLoadIndicationList == nil) {
416 return extendedUlInterferenceOverLoadIndicationList
419 func buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) *entities.ExtendedUlInterferenceOverloadInfo {
420 associatedSubframes := NewHexString(pduExtendedULInterferenceOverloadInfo.associatedSubframes.buf, pduExtendedULInterferenceOverloadInfo.associatedSubframes.size)
421 indications := extractExtendedUlInterferenceOverloadIndicationList(pduExtendedULInterferenceOverloadInfo)
423 return &entities.ExtendedUlInterferenceOverloadInfo{
424 AssociatedSubframes: associatedSubframes,
425 ExtendedUlInterferenceOverloadIndications: buildUlInterferenceOverloadIndicationList(indications),
429 func extractPaListFromDynamicNaicsInformation(cellId string, dynamicNAICSInformation *C.DynamicNAICSInformation_t) ([]*C.long, error) {
431 paListCount := dynamicNAICSInformation.pA_list.list.count
433 if paListCount == 0 {
437 if paListCount > MaxNoOfPa {
438 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Invalid PA list count", cellId)
441 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.long)(unsafe.Pointer(dynamicNAICSInformation.pA_list.list.array))[:int(paListCount):int(paListCount)]
443 if (extendedUlInterferenceOverLoadIndicationList == nil) {
444 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Extended Ul Interference OverLoad Indication List is nil", cellId)
447 return extendedUlInterferenceOverLoadIndicationList, nil
450 func buildPaList(paList []*C.long) []entities.PA {
451 pas := make([]entities.PA, len(paList))
452 for i, pi := range paList {
453 pas[i] = entities.PA(*pi + 1)
459 func extractAndBuildActiveDynamicDlTransmissionInformation(cellId string, pduDynamicDlTransmissionInformation *C.DynamicDLTransmissionInformation_t) (*entities.DynamicDlTransmissionInformation, error) {
460 dynamicNaicsInformation := *(**C.DynamicNAICSInformation_t)(unsafe.Pointer(&pduDynamicDlTransmissionInformation.choice[0]))
462 if dynamicNaicsInformation == nil {
463 return nil, fmt.Errorf("#extractAndBuildActiveDynamicDlTransmissionInformation - cellId: %s - Invalid NAICS Information value", cellId)
466 dynamicDlTransmissionInformation := entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_ACTIVE}
468 if dynamicNaicsInformation.transmissionModes != nil {
469 transmissionModes := NewHexString(dynamicNaicsInformation.transmissionModes.buf, dynamicNaicsInformation.transmissionModes.size)
470 dynamicDlTransmissionInformation.TransmissionModes = transmissionModes
473 if dynamicNaicsInformation.pB_information != nil {
474 dynamicDlTransmissionInformation.PB = uint32(*dynamicNaicsInformation.pB_information)
477 paList, err := extractPaListFromDynamicNaicsInformation(cellId, dynamicNaicsInformation)
484 dynamicDlTransmissionInformation.PAList = buildPaList(paList)
487 return &dynamicDlTransmissionInformation, nil
490 func extractAndBuildDynamicDlTransmissionInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.DynamicDlTransmissionInformation, error) {
491 pduDynamicDlTransmissionInformation := (*C.DynamicDLTransmissionInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
493 if pduDynamicDlTransmissionInformation.present == C.DynamicDLTransmissionInformation_PR_naics_inactive {
494 return &entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_INACTIVE}, nil
497 if pduDynamicDlTransmissionInformation.present != C.DynamicDLTransmissionInformation_PR_naics_active {
498 return nil, fmt.Errorf("#extractAndBuildDynamicDlTransmissionInformation - cellId: %s - Invalid Dynamic Dl Transmission Information value", cellId)
501 return extractAndBuildActiveDynamicDlTransmissionInformation(cellId, pduDynamicDlTransmissionInformation)
504 func extractCompInformationStartTime(cellId string, compInformation *C.CoMPInformation_t) (*C.CoMPInformationStartTime__Member, error) {
505 compInformationStartTimeListCount := compInformation.coMPInformationStartTime.list.count
507 if compInformationStartTimeListCount == 0 {
511 compInformationStartTimeList := (*[1 << 30]*C.CoMPInformationStartTime__Member)(unsafe.Pointer(compInformation.coMPInformationStartTime.list.array))[:int(compInformationStartTimeListCount):int(compInformationStartTimeListCount)]
513 if len(compInformationStartTimeList) != 1 {
514 return nil, fmt.Errorf("#extractCompInformationStartTime - cellId: %s - Invalid Comp Information StartTime list count", cellId)
517 return compInformationStartTimeList[0], nil
520 func buildCompHypothesisSet(pduCompHypothesisSetItem *C.CoMPHypothesisSetItem_t) *entities.CompHypothesisSet {
521 return &entities.CompHypothesisSet{
522 CellId: buildCellId(pduCompHypothesisSetItem.coMPCellID),
523 CompHypothesis: NewHexString(pduCompHypothesisSetItem.coMPHypothesis.buf, pduCompHypothesisSetItem.coMPHypothesis.size),
527 func buildCompHypothesisSets(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) ([]*entities.CompHypothesisSet, error) {
529 compHypothesisSets := []*entities.CompHypothesisSet{}
531 pduCompHypothesisSetItemsListCount := pduCompInformationItemMember.coMPHypothesisSet.list.count
533 if pduCompHypothesisSetItemsListCount == 0 || pduCompHypothesisSetItemsListCount > NaxNoOfCompCells {
534 return nil, fmt.Errorf("#buildCompHypothesisSets - cellId: %s - Invalid Comp Hypothesis Set Items list count", cellId)
537 pduCompHypothesisSetItems := (*[1 << 30]*C.CoMPHypothesisSetItem_t)(unsafe.Pointer(pduCompInformationItemMember.coMPHypothesisSet.list.array))[:int(pduCompHypothesisSetItemsListCount):int(pduCompHypothesisSetItemsListCount)]
539 for _, pduCompHypothesisSetItem := range pduCompHypothesisSetItems {
540 compHypothesisSet := buildCompHypothesisSet(pduCompHypothesisSetItem)
541 compHypothesisSets = append(compHypothesisSets, compHypothesisSet)
544 return compHypothesisSets, nil
547 func buildCompInformationItem(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) (*entities.CompInformationItem, error) {
549 compHypothesisSets, err := buildCompHypothesisSets(cellId, pduCompInformationItemMember)
555 compInformation := entities.CompInformationItem{
556 CompHypothesisSets: compHypothesisSets,
557 BenefitMetric: int32(pduCompInformationItemMember.benefitMetric),
560 return &compInformation, nil
563 func extractAndBuildCompInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.CompInformation, error) {
565 pduCompInformation := (*C.CoMPInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
567 compInformation := entities.CompInformation{}
568 pduCompInformationStartTime, err := extractCompInformationStartTime(cellId, pduCompInformation)
574 if pduCompInformationStartTime != nil {
575 compInformation.CompInformationStartTime = NewStartTime(pduCompInformationStartTime.startSFN, pduCompInformationStartTime.startSubframeNumber)
578 pduCompInformationItemsListCount := pduCompInformation.coMPInformationItem.list.count
580 if pduCompInformationItemsListCount == 0 || pduCompInformationItemsListCount > NaxNoOfCompHypothesisSet {
581 return nil, fmt.Errorf("#extractAndBuildCompInformation - cellId: %s - Invalid Comp Information Items list count", cellId)
584 pduCompInformationItems := (*[1 << 30]*C.CoMPInformationItem__Member)(unsafe.Pointer(pduCompInformation.coMPInformationItem.list.array))[:int(pduCompInformationItemsListCount):int(pduCompInformationItemsListCount)]
586 for _, pduCompInformationItem := range pduCompInformationItems {
587 compInformationItem, err := buildCompInformationItem(cellId, pduCompInformationItem)
593 compInformation.CompInformationItems = append(compInformation.CompInformationItems, compInformationItem)
596 return &compInformation, nil
599 func populateAbsInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
600 absInformation, err := extractAndBuildCellLoadInformationAbsInformation(cellId, extIE)
606 cellLoadInformation.AbsInformation = absInformation
610 func populateInvokeIndication(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
611 pduInvokeIndication := (*C.InvokeIndication_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
612 cellLoadInformation.InvokeIndication = entities.InvokeIndication(*pduInvokeIndication + 1)
616 func populateIntendedUlDlConfiguration(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
617 pduSubframeAssignment := (*C.SubframeAssignment_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
618 cellLoadInformation.IntendedUlDlConfiguration = entities.SubframeAssignment(*pduSubframeAssignment + 1)
622 func populateExtendedUlInterferenceOverloadInfo(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
623 pduExtendedULInterferenceOverloadInfo := (*C.ExtendedULInterferenceOverloadInfo_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
624 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo)
628 func populateCompInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
629 pduCompInformation, err := extractAndBuildCompInformation(cellId, extIE)
635 cellLoadInformation.CompInformation = pduCompInformation
639 func populateDynamicDLTransmissionInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
640 dynamicDLTransmissionInformation, err := extractAndBuildDynamicDlTransmissionInformation(cellId, extIE)
646 cellLoadInformation.DynamicDlTransmissionInformation = dynamicDLTransmissionInformation
650 func populateCellLoadInformationExtensionIEs(cellId string, cellLoadInformation *entities.CellLoadInformation, extIEs []*C.CellInformation_Item_ExtIEs_t) error {
651 for _, extIE := range extIEs {
653 populator, ok := populators[extIE.extensionValue.present]
659 err := populator(cellId, cellLoadInformation, extIE)
670 func (*EnbLoadInformationExtractor) ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error {
672 defer C.delete_pdu(pdu)
674 pduCellInformationItemIEs, err := extractPduCellInformationItemIEs(pdu)
680 for _, pduCellInformationItemIE := range pduCellInformationItemIEs {
681 err = populateCellLoadInformation(pduCellInformationItemIE, ranLoadInformation)