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.
20 // #cgo CFLAGS: -I../3rdparty/asn1codec/inc/ -I../3rdparty/asn1codec/e2ap_engine/
21 // #cgo LDFLAGS: -L ../3rdparty/asn1codec/lib/ -L../3rdparty/asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
22 // #include <asn1codec_utils.h>
23 // #include <load_information_wrapper.h>
28 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
35 NaxNoOfCompHypothesisSet = 256
40 type EnbLoadInformationExtractor struct {
44 type IEnbLoadInformationExtractor interface {
45 ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error
48 func NewEnbLoadInformationExtractor(logger *logger.Logger) *EnbLoadInformationExtractor {
49 return &EnbLoadInformationExtractor{
54 var populators = map[C.CellInformation_Item_ExtIEs__extensionValue_PR]func(string, *entities.CellLoadInformation, *C.CellInformation_Item_ExtIEs_t) error{
55 C.CellInformation_Item_ExtIEs__extensionValue_PR_ABSInformation: populateAbsInformation,
56 C.CellInformation_Item_ExtIEs__extensionValue_PR_InvokeIndication: populateInvokeIndication,
57 C.CellInformation_Item_ExtIEs__extensionValue_PR_SubframeAssignment: populateIntendedUlDlConfiguration,
58 C.CellInformation_Item_ExtIEs__extensionValue_PR_ExtendedULInterferenceOverloadInfo: populateExtendedUlInterferenceOverloadInfo,
59 C.CellInformation_Item_ExtIEs__extensionValue_PR_CoMPInformation: populateCompInformation,
60 C.CellInformation_Item_ExtIEs__extensionValue_PR_DynamicDLTransmissionInformation: populateDynamicDLTransmissionInformation,
63 func extractPduCellInformationItemIEs(pdu *C.E2AP_PDU_t) ([]*C.CellInformation_ItemIEs_t, error) {
65 if pdu.present != C.E2AP_PDU_PR_initiatingMessage {
66 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid E2AP_PDU value")
69 initiatingMessage := *(**C.InitiatingMessage_t)(unsafe.Pointer(&pdu.choice[0]))
71 if initiatingMessage == nil || initiatingMessage.value.present != C.InitiatingMessage__value_PR_LoadInformation {
72 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid InitiatingMessage value")
75 loadInformationMessage := (*C.LoadInformation_t)(unsafe.Pointer(&initiatingMessage.value.choice[0]))
77 if loadInformationMessage == nil {
78 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid LoadInformation container")
81 protocolIEsListCount := loadInformationMessage.protocolIEs.list.count
83 if protocolIEsListCount != 1 {
84 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs list count")
87 loadInformationIEs := (*[1 << 30]*C.LoadInformation_IEs_t)(unsafe.Pointer(loadInformationMessage.protocolIEs.list.array))[:int(protocolIEsListCount):int(protocolIEsListCount)]
89 loadInformationIE := loadInformationIEs[0]
91 if loadInformationIE.value.present != C.LoadInformation_IEs__value_PR_CellInformation_List {
92 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs value")
95 loadInformationCellList := (*C.CellInformation_List_t)(unsafe.Pointer(&loadInformationIE.value.choice[0]))
97 loadInformationCellListCount := loadInformationCellList.list.count
99 if loadInformationCellListCount == 0 || loadInformationCellListCount > MaxCellsInEnb {
100 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid CellInformation list count")
103 return (*[1 << 30]*C.CellInformation_ItemIEs_t)(unsafe.Pointer(loadInformationCellList.list.array))[:int(loadInformationCellListCount):int(loadInformationCellListCount)], nil
106 func populateCellLoadInformation(pduCellInformationItemIE *C.CellInformation_ItemIEs_t, ranLoadInformation *entities.RanLoadInformation) error {
108 pduCellInformationItem, err := extractPduCellInformationItem(pduCellInformationItemIE)
114 cellLoadInformation := entities.CellLoadInformation{}
115 err = buildCellLoadInformation(&cellLoadInformation, pduCellInformationItem)
121 ranLoadInformation.CellLoadInfos = append(ranLoadInformation.CellLoadInfos, &cellLoadInformation)
126 func extractPduCellInformationItem(cell *C.CellInformation_ItemIEs_t) (*C.CellInformation_Item_t, error) {
128 if cell.value.present != C.CellInformation_ItemIEs__value_PR_CellInformation_Item {
129 return nil, fmt.Errorf("#extractPduCellInformationItem - Failed extracting pdu cell information item")
132 return (*C.CellInformation_Item_t)(unsafe.Pointer(&cell.value.choice[0])), nil
135 func buildCellLoadInformation(cellLoadInformation *entities.CellLoadInformation, cellInformationItem *C.CellInformation_Item_t) error {
137 cellId := buildCellId(cellInformationItem.cell_ID)
138 cellLoadInformation.CellId = cellId
140 pduUlInterferenceOverloadIndicationItems, err := extractPduUlInterferenceOverloadIndicationItems(cellId, cellInformationItem)
146 if (pduUlInterferenceOverloadIndicationItems != nil) {
147 cellLoadInformation.UlInterferenceOverloadIndications = buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems)
150 pduUlHighInterferenceIndicationInfoItems, err := extractPduUlHighInterferenceIndicationInfoItems(cellId, cellInformationItem)
156 if pduUlHighInterferenceIndicationInfoItems != nil {
157 cellLoadInformation.UlHighInterferenceInfos = buildUlHighInterferenceIndicationInfoList(pduUlHighInterferenceIndicationInfoItems)
160 pduRelativeNarrowbandTxPower := extractPduRelativeNarrowbandTxPower(cellInformationItem)
162 if pduRelativeNarrowbandTxPower != nil {
163 pduEnhancedRntp, err := extractPduEnhancedRntp(cellId, pduRelativeNarrowbandTxPower)
169 cellLoadInformation.RelativeNarrowbandTxPower = buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower, pduEnhancedRntp)
172 pduCellInformationItemExtensionIEs := extractPduCellInformationItemExtensionIEs(cellInformationItem)
174 if (pduCellInformationItemExtensionIEs == nil) {
178 err = populateCellLoadInformationExtensionIEs(cellId, cellLoadInformation, pduCellInformationItemExtensionIEs)
188 func buildCellId(cellId C.ECGI_t) string {
189 plmnId := cUcharArrayToGoByteSlice(cellId.pLMN_Identity.buf, cellId.pLMN_Identity.size)
190 eutranCellIdentifier := cUcharArrayToGoByteSlice(cellId.eUTRANcellIdentifier.buf, cellId.eUTRANcellIdentifier.size)
191 return fmt.Sprintf("%x:%x", plmnId, eutranCellIdentifier)
194 func buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems []*C.UL_InterferenceOverloadIndication_Item_t) []entities.UlInterferenceOverloadIndication {
195 indications := make([]entities.UlInterferenceOverloadIndication, len(pduUlInterferenceOverloadIndicationItems))
196 for i, ci := range pduUlInterferenceOverloadIndicationItems {
197 indications[i] = entities.UlInterferenceOverloadIndication(*ci + 1)
203 func extractPduUlInterferenceOverloadIndicationItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_InterferenceOverloadIndication_Item_t, error) {
205 if cellInformationItem.ul_InterferenceOverloadIndication == nil {
209 ulInterferenceOverLoadIndicationCount := cellInformationItem.ul_InterferenceOverloadIndication.list.count
211 if ulInterferenceOverLoadIndicationCount == 0 || ulInterferenceOverLoadIndicationCount > MaxNoOfPrbs {
212 return nil, fmt.Errorf("#extractPduUlInterferenceOverloadIndicationItems - cellId: %s - Invalid UL Interference OverLoad Indication list count", cellId)
215 pduUlInterferenceOverloadIndicationItems := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(cellInformationItem.ul_InterferenceOverloadIndication.list.array))[:int(ulInterferenceOverLoadIndicationCount):int(ulInterferenceOverLoadIndicationCount)]
217 return pduUlInterferenceOverloadIndicationItems, nil
220 func NewStartTime(startSfn C.long, startSubframeNumber C.long) *entities.StartTime {
221 return &entities.StartTime{
222 StartSfn: int32(startSfn),
223 StartSubframeNumber: int32(startSubframeNumber),
227 func buildEnhancedRntp(pduEnhancedRntp *C.EnhancedRNTP_t) *entities.EnhancedRntp {
229 enhancedRntp := entities.EnhancedRntp{
230 EnhancedRntpBitmap: NewHexString(pduEnhancedRntp.enhancedRNTPBitmap.buf, pduEnhancedRntp.enhancedRNTPBitmap.size),
231 RntpHighPowerThreshold: entities.RntpThreshold(pduEnhancedRntp.rNTP_High_Power_Threshold + 1),
234 pduEnhancedRntpStartTime := (*C.EnhancedRNTPStartTime_t)(unsafe.Pointer(pduEnhancedRntp.enhancedRNTPStartTime))
236 if pduEnhancedRntpStartTime != nil {
237 enhancedRntp.EnhancedRntpStartTime = NewStartTime(pduEnhancedRntpStartTime.startSFN, pduEnhancedRntpStartTime.startSubframeNumber)
243 func cUcharArrayToGoByteSlice(buf *C.uchar, size C.ulong) []byte {
244 return C.GoBytes(unsafe.Pointer(buf), C.int(size))
247 func NewHexString(buf *C.uchar, size C.ulong) string {
248 return fmt.Sprintf("%x", cUcharArrayToGoByteSlice(buf, size))
251 func buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t, pduEnhancedRntp *C.EnhancedRNTP_t) *entities.RelativeNarrowbandTxPower {
253 relativeNarrowbandTxPower := entities.RelativeNarrowbandTxPower{
254 RntpThreshold: entities.RntpThreshold(pduRelativeNarrowbandTxPower.rNTP_Threshold + 1),
255 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduRelativeNarrowbandTxPower.numberOfCellSpecificAntennaPorts + 1),
256 PB: uint32(pduRelativeNarrowbandTxPower.p_B),
257 PdcchInterferenceImpact: uint32(pduRelativeNarrowbandTxPower.pDCCH_InterferenceImpact),
258 RntpPerPrb: NewHexString(pduRelativeNarrowbandTxPower.rNTP_PerPRB.buf, pduRelativeNarrowbandTxPower.rNTP_PerPRB.size),
261 if pduEnhancedRntp != nil {
262 relativeNarrowbandTxPower.EnhancedRntp = buildEnhancedRntp(pduEnhancedRntp)
265 return &relativeNarrowbandTxPower
268 func extractPduRelativeNarrowbandTxPower(cellInformationItem *C.CellInformation_Item_t) *C.RelativeNarrowbandTxPower_t {
270 if cellInformationItem.relativeNarrowbandTxPower == nil {
274 return (*C.RelativeNarrowbandTxPower_t)(unsafe.Pointer(cellInformationItem.relativeNarrowbandTxPower))
277 func buildUlHighInterferenceIndicationInfoList(ulHighInterferenceIndicationInfoList []*C.UL_HighInterferenceIndicationInfo_Item_t) []*entities.UlHighInterferenceInformation {
278 infos := make([]*entities.UlHighInterferenceInformation, len(ulHighInterferenceIndicationInfoList))
280 for i, v := range ulHighInterferenceIndicationInfoList {
282 infos[i] = &entities.UlHighInterferenceInformation{
283 TargetCellId: buildCellId(v.target_Cell_ID),
284 UlHighInterferenceIndication: NewHexString(v.ul_interferenceindication.buf, v.ul_interferenceindication.size),
291 func extractPduUlHighInterferenceIndicationInfoItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_HighInterferenceIndicationInfo_Item_t, error) {
292 pduUlHighInterferenceIndicationInfo := (*C.UL_HighInterferenceIndicationInfo_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo))
294 if (pduUlHighInterferenceIndicationInfo == nil) {
298 pduUlHighInterferenceIndicationInfoListCount := pduUlHighInterferenceIndicationInfo.list.count
300 if pduUlHighInterferenceIndicationInfoListCount == 0 || pduUlHighInterferenceIndicationInfoListCount > MaxCellsInEnb {
301 return nil, fmt.Errorf("#extractPduUlHighInterferenceIndicationInfoItems - cellId: %s - Invalid UL High Interference Indication info list count", cellId)
304 pduUlHighInterferenceIndicationInfoItems := (*[1 << 30]*C.UL_HighInterferenceIndicationInfo_Item_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo.list.array))[:int(pduUlHighInterferenceIndicationInfoListCount):int(pduUlHighInterferenceIndicationInfoListCount)]
306 return pduUlHighInterferenceIndicationInfoItems, nil
309 func extractPduCellInformationItemExtensionIEs(cellInformationItem *C.CellInformation_Item_t) []*C.CellInformation_Item_ExtIEs_t {
310 extIEs := (*C.ProtocolExtensionContainer_170P7_t)(unsafe.Pointer(cellInformationItem.iE_Extensions))
316 extIEsCount := int(extIEs.list.count)
318 if extIEsCount == 0 {
322 return (*[1 << 30]*C.CellInformation_Item_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
325 func extractPduEnhancedRntp(cellId string, pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t) (*C.EnhancedRNTP_t, error) {
327 extIEs := (*C.ProtocolExtensionContainer_170P184_t)(unsafe.Pointer(pduRelativeNarrowbandTxPower.iE_Extensions))
333 extIEsCount := int(extIEs.list.count)
335 if extIEsCount != 1 {
336 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
339 enhancedRntpExtIEs := (*[1 << 30]*C.RelativeNarrowbandTxPower_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
341 enhancedRntpExtIE := enhancedRntpExtIEs[0]
343 if enhancedRntpExtIE.extensionValue.present != C.RelativeNarrowbandTxPower_ExtIEs__extensionValue_PR_EnhancedRNTP {
344 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
347 return (*C.EnhancedRNTP_t)(unsafe.Pointer(&enhancedRntpExtIE.extensionValue.choice[0])), nil
350 func buildAbsInformationFdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
351 pduAbsInformationFdd := *(**C.ABSInformationFDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
353 if pduAbsInformationFdd == nil {
354 return nil, fmt.Errorf("#buildAbsInformationFdd - cellId: %s - Invalid FDD Abs Information", cellId)
357 absInformation := entities.AbsInformation{
358 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
359 AbsPatternInfo: NewHexString(pduAbsInformationFdd.abs_pattern_info.buf, pduAbsInformationFdd.abs_pattern_info.size),
360 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationFdd.numberOfCellSpecificAntennaPorts + 1),
361 MeasurementSubset: NewHexString(pduAbsInformationFdd.measurement_subset.buf, pduAbsInformationFdd.measurement_subset.size),
364 return &absInformation, nil
367 func buildAbsInformationTdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
368 pduAbsInformationTdd := *(**C.ABSInformationTDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
370 if pduAbsInformationTdd == nil {
371 return nil, fmt.Errorf("#buildAbsInformationTdd - cellId: %s - Invalid TDD Abs Information", cellId)
374 absInformation := entities.AbsInformation{
375 Mode: entities.AbsInformationMode_ABS_INFO_TDD,
376 AbsPatternInfo: NewHexString(pduAbsInformationTdd.abs_pattern_info.buf, pduAbsInformationTdd.abs_pattern_info.size),
377 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationTdd.numberOfCellSpecificAntennaPorts + 1),
378 MeasurementSubset: NewHexString(pduAbsInformationTdd.measurement_subset.buf, pduAbsInformationTdd.measurement_subset.size),
381 return &absInformation, nil
384 func extractAndBuildCellLoadInformationAbsInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.AbsInformation, error) {
385 pduAbsInformation := (*C.ABSInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
387 switch pduAbsInformation.present {
388 case C.ABSInformation_PR_fdd:
389 return buildAbsInformationFdd(cellId, pduAbsInformation)
390 case C.ABSInformation_PR_tdd:
391 return buildAbsInformationTdd(cellId, pduAbsInformation)
392 case C.ABSInformation_PR_abs_inactive:
393 return &entities.AbsInformation{Mode: entities.AbsInformationMode_ABS_INACTIVE}, nil
396 return nil, fmt.Errorf("#extractAndBuildCellLoadInformationAbsInformation - cellId: %s - Failed extracting AbsInformation", cellId)
399 func extractExtendedUlInterferenceOverloadIndicationList(extendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) []*C.UL_InterferenceOverloadIndication_Item_t {
401 extendedUlInterferenceOverLoadIndicationCount := extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.count
403 if extendedUlInterferenceOverLoadIndicationCount == 0 {
407 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.array))[:int(extendedUlInterferenceOverLoadIndicationCount):int(extendedUlInterferenceOverLoadIndicationCount)]
409 if (extendedUlInterferenceOverLoadIndicationList == nil) {
413 return extendedUlInterferenceOverLoadIndicationList
416 func buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) *entities.ExtendedUlInterferenceOverloadInfo {
417 associatedSubframes := NewHexString(pduExtendedULInterferenceOverloadInfo.associatedSubframes.buf, pduExtendedULInterferenceOverloadInfo.associatedSubframes.size)
418 indications := extractExtendedUlInterferenceOverloadIndicationList(pduExtendedULInterferenceOverloadInfo)
420 return &entities.ExtendedUlInterferenceOverloadInfo{
421 AssociatedSubframes: associatedSubframes,
422 ExtendedUlInterferenceOverloadIndications: buildUlInterferenceOverloadIndicationList(indications),
426 func extractPaListFromDynamicNaicsInformation(cellId string, dynamicNAICSInformation *C.DynamicNAICSInformation_t) ([]*C.long, error) {
428 paListCount := dynamicNAICSInformation.pA_list.list.count
430 if paListCount == 0 {
434 if paListCount > MaxNoOfPa {
435 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Invalid PA list count", cellId)
438 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.long)(unsafe.Pointer(dynamicNAICSInformation.pA_list.list.array))[:int(paListCount):int(paListCount)]
440 if (extendedUlInterferenceOverLoadIndicationList == nil) {
441 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Extended Ul Interference OverLoad Indication List is nil", cellId)
444 return extendedUlInterferenceOverLoadIndicationList, nil
447 func buildPaList(paList []*C.long) []entities.PA {
448 pas := make([]entities.PA, len(paList))
449 for i, pi := range paList {
450 pas[i] = entities.PA(*pi + 1)
456 func extractAndBuildActiveDynamicDlTransmissionInformation(cellId string, pduDynamicDlTransmissionInformation *C.DynamicDLTransmissionInformation_t) (*entities.DynamicDlTransmissionInformation, error) {
457 dynamicNaicsInformation := *(**C.DynamicNAICSInformation_t)(unsafe.Pointer(&pduDynamicDlTransmissionInformation.choice[0]))
459 if dynamicNaicsInformation == nil {
460 return nil, fmt.Errorf("#extractAndBuildActiveDynamicDlTransmissionInformation - cellId: %s - Invalid NAICS Information value", cellId)
463 dynamicDlTransmissionInformation := entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_ACTIVE}
465 if dynamicNaicsInformation.transmissionModes != nil {
466 transmissionModes := NewHexString(dynamicNaicsInformation.transmissionModes.buf, dynamicNaicsInformation.transmissionModes.size)
467 dynamicDlTransmissionInformation.TransmissionModes = transmissionModes
470 if dynamicNaicsInformation.pB_information != nil {
471 dynamicDlTransmissionInformation.PB = uint32(*dynamicNaicsInformation.pB_information)
474 paList, err := extractPaListFromDynamicNaicsInformation(cellId, dynamicNaicsInformation)
481 dynamicDlTransmissionInformation.PAList = buildPaList(paList)
484 return &dynamicDlTransmissionInformation, nil
487 func extractAndBuildDynamicDlTransmissionInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.DynamicDlTransmissionInformation, error) {
488 pduDynamicDlTransmissionInformation := (*C.DynamicDLTransmissionInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
490 if pduDynamicDlTransmissionInformation.present == C.DynamicDLTransmissionInformation_PR_naics_inactive {
491 return &entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_INACTIVE}, nil
494 if pduDynamicDlTransmissionInformation.present != C.DynamicDLTransmissionInformation_PR_naics_active {
495 return nil, fmt.Errorf("#extractAndBuildDynamicDlTransmissionInformation - cellId: %s - Invalid Dynamic Dl Transmission Information value", cellId)
498 return extractAndBuildActiveDynamicDlTransmissionInformation(cellId, pduDynamicDlTransmissionInformation)
501 func extractCompInformationStartTime(cellId string, compInformation *C.CoMPInformation_t) (*C.CoMPInformationStartTime__Member, error) {
502 compInformationStartTimeListCount := compInformation.coMPInformationStartTime.list.count
504 if compInformationStartTimeListCount == 0 {
508 compInformationStartTimeList := (*[1 << 30]*C.CoMPInformationStartTime__Member)(unsafe.Pointer(compInformation.coMPInformationStartTime.list.array))[:int(compInformationStartTimeListCount):int(compInformationStartTimeListCount)]
510 if len(compInformationStartTimeList) != 1 {
511 return nil, fmt.Errorf("#extractCompInformationStartTime - cellId: %s - Invalid Comp Information StartTime list count", cellId)
514 return compInformationStartTimeList[0], nil
517 func buildCompHypothesisSet(pduCompHypothesisSetItem *C.CoMPHypothesisSetItem_t) *entities.CompHypothesisSet {
518 return &entities.CompHypothesisSet{
519 CellId: buildCellId(pduCompHypothesisSetItem.coMPCellID),
520 CompHypothesis: NewHexString(pduCompHypothesisSetItem.coMPHypothesis.buf, pduCompHypothesisSetItem.coMPHypothesis.size),
524 func buildCompHypothesisSets(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) ([]*entities.CompHypothesisSet, error) {
526 compHypothesisSets := []*entities.CompHypothesisSet{}
528 pduCompHypothesisSetItemsListCount := pduCompInformationItemMember.coMPHypothesisSet.list.count
530 if pduCompHypothesisSetItemsListCount == 0 || pduCompHypothesisSetItemsListCount > NaxNoOfCompCells {
531 return nil, fmt.Errorf("#buildCompHypothesisSets - cellId: %s - Invalid Comp Hypothesis Set Items list count", cellId)
534 pduCompHypothesisSetItems := (*[1 << 30]*C.CoMPHypothesisSetItem_t)(unsafe.Pointer(pduCompInformationItemMember.coMPHypothesisSet.list.array))[:int(pduCompHypothesisSetItemsListCount):int(pduCompHypothesisSetItemsListCount)]
536 for _, pduCompHypothesisSetItem := range pduCompHypothesisSetItems {
537 compHypothesisSet := buildCompHypothesisSet(pduCompHypothesisSetItem)
538 compHypothesisSets = append(compHypothesisSets, compHypothesisSet)
541 return compHypothesisSets, nil
544 func buildCompInformationItem(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) (*entities.CompInformationItem, error) {
546 compHypothesisSets, err := buildCompHypothesisSets(cellId, pduCompInformationItemMember)
552 compInformation := entities.CompInformationItem{
553 CompHypothesisSets: compHypothesisSets,
554 BenefitMetric: int32(pduCompInformationItemMember.benefitMetric),
557 return &compInformation, nil
560 func extractAndBuildCompInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.CompInformation, error) {
562 pduCompInformation := (*C.CoMPInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
564 compInformation := entities.CompInformation{}
565 pduCompInformationStartTime, err := extractCompInformationStartTime(cellId, pduCompInformation)
571 if pduCompInformationStartTime != nil {
572 compInformation.CompInformationStartTime = NewStartTime(pduCompInformationStartTime.startSFN, pduCompInformationStartTime.startSubframeNumber)
575 pduCompInformationItemsListCount := pduCompInformation.coMPInformationItem.list.count
577 if pduCompInformationItemsListCount == 0 || pduCompInformationItemsListCount > NaxNoOfCompHypothesisSet {
578 return nil, fmt.Errorf("#extractAndBuildCompInformation - cellId: %s - Invalid Comp Information Items list count", cellId)
581 pduCompInformationItems := (*[1 << 30]*C.CoMPInformationItem__Member)(unsafe.Pointer(pduCompInformation.coMPInformationItem.list.array))[:int(pduCompInformationItemsListCount):int(pduCompInformationItemsListCount)]
583 for _, pduCompInformationItem := range pduCompInformationItems {
584 compInformationItem, err := buildCompInformationItem(cellId, pduCompInformationItem)
590 compInformation.CompInformationItems = append(compInformation.CompInformationItems, compInformationItem)
593 return &compInformation, nil
596 func populateAbsInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
597 absInformation, err := extractAndBuildCellLoadInformationAbsInformation(cellId, extIE)
603 cellLoadInformation.AbsInformation = absInformation
607 func populateInvokeIndication(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
608 pduInvokeIndication := (*C.InvokeIndication_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
609 cellLoadInformation.InvokeIndication = entities.InvokeIndication(*pduInvokeIndication + 1)
613 func populateIntendedUlDlConfiguration(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
614 pduSubframeAssignment := (*C.SubframeAssignment_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
615 cellLoadInformation.IntendedUlDlConfiguration = entities.SubframeAssignment(*pduSubframeAssignment + 1)
619 func populateExtendedUlInterferenceOverloadInfo(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
620 pduExtendedULInterferenceOverloadInfo := (*C.ExtendedULInterferenceOverloadInfo_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
621 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo)
625 func populateCompInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
626 pduCompInformation, err := extractAndBuildCompInformation(cellId, extIE)
632 cellLoadInformation.CompInformation = pduCompInformation
636 func populateDynamicDLTransmissionInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
637 dynamicDLTransmissionInformation, err := extractAndBuildDynamicDlTransmissionInformation(cellId, extIE)
643 cellLoadInformation.DynamicDlTransmissionInformation = dynamicDLTransmissionInformation
647 func populateCellLoadInformationExtensionIEs(cellId string, cellLoadInformation *entities.CellLoadInformation, extIEs []*C.CellInformation_Item_ExtIEs_t) error {
648 for _, extIE := range extIEs {
650 populator, ok := populators[extIE.extensionValue.present]
656 err := populator(cellId, cellLoadInformation, extIE)
667 func (*EnbLoadInformationExtractor) ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error {
669 defer C.delete_pdu(pdu)
671 pduCellInformationItemIEs, err := extractPduCellInformationItemIEs(pdu)
677 for _, pduCellInformationItemIE := range pduCellInformationItemIEs {
678 err = populateCellLoadInformation(pduCellInformationItemIE, ranLoadInformation)