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../asn1codec/inc/ -I../asn1codec/e2ap_engine/
21 // #cgo LDFLAGS: -L ../asn1codec/lib/ -L../asn1codec/e2ap_engine/ -le2ap_codec -lasncodec
22 // #include <asn1codec_utils.h>
23 // #include <load_information_wrapper.h>
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
34 NaxNoOfCompHypothesisSet = 256
39 var populators = map[C.CellInformation_Item_ExtIEs__extensionValue_PR]func(string, *entities.CellLoadInformation, *C.CellInformation_Item_ExtIEs_t) error{
40 C.CellInformation_Item_ExtIEs__extensionValue_PR_ABSInformation: populateAbsInformation,
41 C.CellInformation_Item_ExtIEs__extensionValue_PR_InvokeIndication: populateInvokeIndication,
42 C.CellInformation_Item_ExtIEs__extensionValue_PR_SubframeAssignment: populateIntendedUlDlConfiguration,
43 C.CellInformation_Item_ExtIEs__extensionValue_PR_ExtendedULInterferenceOverloadInfo: populateExtendedUlInterferenceOverloadInfo,
44 C.CellInformation_Item_ExtIEs__extensionValue_PR_CoMPInformation: populateCompInformation,
45 C.CellInformation_Item_ExtIEs__extensionValue_PR_DynamicDLTransmissionInformation: populateDynamicDLTransmissionInformation,
48 func extractPduCellInformationItemIEs(pdu *C.E2AP_PDU_t) ([]*C.CellInformation_ItemIEs_t, error) {
50 if pdu.present != C.E2AP_PDU_PR_initiatingMessage {
51 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid E2AP_PDU value")
54 initiatingMessage := *(**C.InitiatingMessage_t)(unsafe.Pointer(&pdu.choice[0]))
56 if initiatingMessage == nil || initiatingMessage.value.present != C.InitiatingMessage__value_PR_LoadInformation {
57 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid InitiatingMessage value")
60 loadInformationMessage := (*C.LoadInformation_t)(unsafe.Pointer(&initiatingMessage.value.choice[0]))
62 if loadInformationMessage == nil {
63 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid LoadInformation container")
66 protocolIEsListCount := loadInformationMessage.protocolIEs.list.count
68 if protocolIEsListCount != 1 {
69 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs list count")
72 loadInformationIEs := (*[1 << 30]*C.LoadInformation_IEs_t)(unsafe.Pointer(loadInformationMessage.protocolIEs.list.array))[:int(protocolIEsListCount):int(protocolIEsListCount)]
74 loadInformationIE := loadInformationIEs[0]
76 if loadInformationIE.value.present != C.LoadInformation_IEs__value_PR_CellInformation_List {
77 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid protocolIEs value")
80 loadInformationCellList := (*C.CellInformation_List_t)(unsafe.Pointer(&loadInformationIE.value.choice[0]))
82 loadInformationCellListCount := loadInformationCellList.list.count
84 if loadInformationCellListCount == 0 || loadInformationCellListCount > MaxCellsInEnb {
85 return nil, fmt.Errorf("#extractPduCellInformationItemIEs - Invalid CellInformation list count")
88 return (*[1 << 30]*C.CellInformation_ItemIEs_t)(unsafe.Pointer(loadInformationCellList.list.array))[:int(loadInformationCellListCount):int(loadInformationCellListCount)], nil
91 func populateCellLoadInformation(pduCellInformationItemIE *C.CellInformation_ItemIEs_t, ranLoadInformation *entities.RanLoadInformation) error {
93 pduCellInformationItem, err := extractPduCellInformationItem(pduCellInformationItemIE)
99 cellLoadInformation := entities.CellLoadInformation{}
100 err = buildCellLoadInformation(&cellLoadInformation, pduCellInformationItem)
106 ranLoadInformation.CellLoadInfos = append(ranLoadInformation.CellLoadInfos, &cellLoadInformation)
111 func extractPduCellInformationItem(cell *C.CellInformation_ItemIEs_t) (*C.CellInformation_Item_t, error) {
113 if cell.value.present != C.CellInformation_ItemIEs__value_PR_CellInformation_Item {
114 return nil, fmt.Errorf("#extractPduCellInformationItem - Failed extracting pdu cell information item")
117 return (*C.CellInformation_Item_t)(unsafe.Pointer(&cell.value.choice[0])), nil
120 func buildCellLoadInformation(cellLoadInformation *entities.CellLoadInformation, cellInformationItem *C.CellInformation_Item_t) error {
122 cellId := buildCellId(cellInformationItem.cell_ID)
123 cellLoadInformation.CellId = cellId
125 pduUlInterferenceOverloadIndicationItems, err := extractPduUlInterferenceOverloadIndicationItems(cellId, cellInformationItem)
131 if (pduUlInterferenceOverloadIndicationItems != nil) {
132 cellLoadInformation.UlInterferenceOverloadIndications = buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems)
135 pduUlHighInterferenceIndicationInfoItems, err := extractPduUlHighInterferenceIndicationInfoItems(cellId, cellInformationItem)
141 if pduUlHighInterferenceIndicationInfoItems != nil {
142 cellLoadInformation.UlHighInterferenceInfos = buildUlHighInterferenceIndicationInfoList(pduUlHighInterferenceIndicationInfoItems)
145 pduRelativeNarrowbandTxPower := extractPduRelativeNarrowbandTxPower(cellInformationItem)
147 if pduRelativeNarrowbandTxPower != nil {
148 pduEnhancedRntp, err := extractPduEnhancedRntp(cellId, pduRelativeNarrowbandTxPower)
154 cellLoadInformation.RelativeNarrowbandTxPower = buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower, pduEnhancedRntp)
157 pduCellInformationItemExtensionIEs := extractPduCellInformationItemExtensionIEs(cellInformationItem)
159 if (pduCellInformationItemExtensionIEs == nil) {
163 err = populateCellLoadInformationExtensionIEs(cellId, cellLoadInformation, pduCellInformationItemExtensionIEs)
173 func buildCellId(cellId C.ECGI_t) string {
174 plmnId := cUcharArrayToGoByteSlice(cellId.pLMN_Identity.buf, cellId.pLMN_Identity.size)
175 eutranCellIdentifier := cUcharArrayToGoByteSlice(cellId.eUTRANcellIdentifier.buf, cellId.eUTRANcellIdentifier.size)
176 return fmt.Sprintf("%x:%x", plmnId, eutranCellIdentifier)
179 func buildUlInterferenceOverloadIndicationList(pduUlInterferenceOverloadIndicationItems []*C.UL_InterferenceOverloadIndication_Item_t) []entities.UlInterferenceOverloadIndication {
180 indications := make([]entities.UlInterferenceOverloadIndication, len(pduUlInterferenceOverloadIndicationItems))
181 for i, ci := range pduUlInterferenceOverloadIndicationItems {
182 indications[i] = entities.UlInterferenceOverloadIndication(*ci + 1)
188 func extractPduUlInterferenceOverloadIndicationItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_InterferenceOverloadIndication_Item_t, error) {
190 if cellInformationItem.ul_InterferenceOverloadIndication == nil {
194 ulInterferenceOverLoadIndicationCount := cellInformationItem.ul_InterferenceOverloadIndication.list.count
196 if ulInterferenceOverLoadIndicationCount == 0 || ulInterferenceOverLoadIndicationCount > MaxNoOfPrbs {
197 return nil, fmt.Errorf("#extractPduUlInterferenceOverloadIndicationItems - cellId: %s - Invalid UL Interference OverLoad Indication list count", cellId)
200 pduUlInterferenceOverloadIndicationItems := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(cellInformationItem.ul_InterferenceOverloadIndication.list.array))[:int(ulInterferenceOverLoadIndicationCount):int(ulInterferenceOverLoadIndicationCount)]
202 return pduUlInterferenceOverloadIndicationItems, nil
205 func NewStartTime(startSfn C.long, startSubframeNumber C.long) *entities.StartTime {
206 return &entities.StartTime{
207 StartSfn: int32(startSfn),
208 StartSubframeNumber: int32(startSubframeNumber),
212 func buildEnhancedRntp(pduEnhancedRntp *C.EnhancedRNTP_t) *entities.EnhancedRntp {
214 enhancedRntp := entities.EnhancedRntp{
215 EnhancedRntpBitmap: NewHexString(pduEnhancedRntp.enhancedRNTPBitmap.buf, pduEnhancedRntp.enhancedRNTPBitmap.size),
216 RntpHighPowerThreshold: entities.RntpThreshold(pduEnhancedRntp.rNTP_High_Power_Threshold + 1),
219 pduEnhancedRntpStartTime := (*C.EnhancedRNTPStartTime_t)(unsafe.Pointer(pduEnhancedRntp.enhancedRNTPStartTime))
221 if pduEnhancedRntpStartTime != nil {
222 enhancedRntp.EnhancedRntpStartTime = NewStartTime(pduEnhancedRntpStartTime.startSFN, pduEnhancedRntpStartTime.startSubframeNumber)
228 func cUcharArrayToGoByteSlice(buf *C.uchar, size C.ulong) []byte {
229 return C.GoBytes(unsafe.Pointer(buf), C.int(size))
232 func NewHexString(buf *C.uchar, size C.ulong) string {
233 return fmt.Sprintf("%x", cUcharArrayToGoByteSlice(buf, size))
236 func buildRelativeNarrowbandTxPower(pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t, pduEnhancedRntp *C.EnhancedRNTP_t) *entities.RelativeNarrowbandTxPower {
238 relativeNarrowbandTxPower := entities.RelativeNarrowbandTxPower{
239 RntpThreshold: entities.RntpThreshold(pduRelativeNarrowbandTxPower.rNTP_Threshold + 1),
240 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduRelativeNarrowbandTxPower.numberOfCellSpecificAntennaPorts + 1),
241 PB: uint32(pduRelativeNarrowbandTxPower.p_B),
242 PdcchInterferenceImpact: uint32(pduRelativeNarrowbandTxPower.pDCCH_InterferenceImpact),
243 RntpPerPrb: NewHexString(pduRelativeNarrowbandTxPower.rNTP_PerPRB.buf, pduRelativeNarrowbandTxPower.rNTP_PerPRB.size),
246 if pduEnhancedRntp != nil {
247 relativeNarrowbandTxPower.EnhancedRntp = buildEnhancedRntp(pduEnhancedRntp)
250 return &relativeNarrowbandTxPower
253 func extractPduRelativeNarrowbandTxPower(cellInformationItem *C.CellInformation_Item_t) *C.RelativeNarrowbandTxPower_t {
255 if cellInformationItem.relativeNarrowbandTxPower == nil {
259 return (*C.RelativeNarrowbandTxPower_t)(unsafe.Pointer(cellInformationItem.relativeNarrowbandTxPower))
262 func buildUlHighInterferenceIndicationInfoList(ulHighInterferenceIndicationInfoList []*C.UL_HighInterferenceIndicationInfo_Item_t) []*entities.UlHighInterferenceInformation {
263 infos := make([]*entities.UlHighInterferenceInformation, len(ulHighInterferenceIndicationInfoList))
265 for i, v := range ulHighInterferenceIndicationInfoList {
267 infos[i] = &entities.UlHighInterferenceInformation{
268 TargetCellId: buildCellId(v.target_Cell_ID),
269 UlHighInterferenceIndication: NewHexString(v.ul_interferenceindication.buf, v.ul_interferenceindication.size),
276 func extractPduUlHighInterferenceIndicationInfoItems(cellId string, cellInformationItem *C.CellInformation_Item_t) ([]*C.UL_HighInterferenceIndicationInfo_Item_t, error) {
277 pduUlHighInterferenceIndicationInfo := (*C.UL_HighInterferenceIndicationInfo_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo))
279 if (pduUlHighInterferenceIndicationInfo == nil) {
283 pduUlHighInterferenceIndicationInfoListCount := pduUlHighInterferenceIndicationInfo.list.count
285 if pduUlHighInterferenceIndicationInfoListCount == 0 || pduUlHighInterferenceIndicationInfoListCount > MaxCellsInEnb {
286 return nil, fmt.Errorf("#extractPduUlHighInterferenceIndicationInfoItems - cellId: %s - Invalid UL High Interference Indication info list count", cellId)
289 pduUlHighInterferenceIndicationInfoItems := (*[1 << 30]*C.UL_HighInterferenceIndicationInfo_Item_t)(unsafe.Pointer(cellInformationItem.ul_HighInterferenceIndicationInfo.list.array))[:int(pduUlHighInterferenceIndicationInfoListCount):int(pduUlHighInterferenceIndicationInfoListCount)]
291 return pduUlHighInterferenceIndicationInfoItems, nil
294 func extractPduCellInformationItemExtensionIEs(cellInformationItem *C.CellInformation_Item_t) []*C.CellInformation_Item_ExtIEs_t {
295 extIEs := (*C.ProtocolExtensionContainer_170P7_t)(unsafe.Pointer(cellInformationItem.iE_Extensions))
301 extIEsCount := int(extIEs.list.count)
303 if extIEsCount == 0 {
307 return (*[1 << 30]*C.CellInformation_Item_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
310 func extractPduEnhancedRntp(cellId string, pduRelativeNarrowbandTxPower *C.RelativeNarrowbandTxPower_t) (*C.EnhancedRNTP_t, error) {
312 extIEs := (*C.ProtocolExtensionContainer_170P184_t)(unsafe.Pointer(pduRelativeNarrowbandTxPower.iE_Extensions))
318 extIEsCount := int(extIEs.list.count)
320 if extIEsCount != 1 {
321 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
324 enhancedRntpExtIEs := (*[1 << 30]*C.RelativeNarrowbandTxPower_ExtIEs_t)(unsafe.Pointer(extIEs.list.array))[:extIEsCount:extIEsCount]
326 enhancedRntpExtIE := enhancedRntpExtIEs[0]
328 if enhancedRntpExtIE.extensionValue.present != C.RelativeNarrowbandTxPower_ExtIEs__extensionValue_PR_EnhancedRNTP {
329 return nil, fmt.Errorf("#extractPduEnhancedRntp - cellId: %s - Invalid Enhanced RNTP container", cellId)
332 return (*C.EnhancedRNTP_t)(unsafe.Pointer(&enhancedRntpExtIE.extensionValue.choice[0])), nil
335 func buildAbsInformationFdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
336 pduAbsInformationFdd := *(**C.ABSInformationFDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
338 if pduAbsInformationFdd == nil {
339 return nil, fmt.Errorf("#buildAbsInformationFdd - cellId: %s - Invalid FDD Abs Information", cellId)
342 absInformation := entities.AbsInformation{
343 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
344 AbsPatternInfo: NewHexString(pduAbsInformationFdd.abs_pattern_info.buf, pduAbsInformationFdd.abs_pattern_info.size),
345 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationFdd.numberOfCellSpecificAntennaPorts + 1),
346 MeasurementSubset: NewHexString(pduAbsInformationFdd.measurement_subset.buf, pduAbsInformationFdd.measurement_subset.size),
349 return &absInformation, nil
352 func buildAbsInformationTdd(cellId string, pduAbsInformation *C.ABSInformation_t) (*entities.AbsInformation, error) {
353 pduAbsInformationTdd := *(**C.ABSInformationTDD_t)(unsafe.Pointer(&pduAbsInformation.choice[0]))
355 if pduAbsInformationTdd == nil {
356 return nil, fmt.Errorf("#buildAbsInformationTdd - cellId: %s - Invalid TDD Abs Information", cellId)
359 absInformation := entities.AbsInformation{
360 Mode: entities.AbsInformationMode_ABS_INFO_TDD,
361 AbsPatternInfo: NewHexString(pduAbsInformationTdd.abs_pattern_info.buf, pduAbsInformationTdd.abs_pattern_info.size),
362 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts(pduAbsInformationTdd.numberOfCellSpecificAntennaPorts + 1),
363 MeasurementSubset: NewHexString(pduAbsInformationTdd.measurement_subset.buf, pduAbsInformationTdd.measurement_subset.size),
366 return &absInformation, nil
369 func extractAndBuildCellLoadInformationAbsInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.AbsInformation, error) {
370 pduAbsInformation := (*C.ABSInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
372 switch pduAbsInformation.present {
373 case C.ABSInformation_PR_fdd:
374 return buildAbsInformationFdd(cellId, pduAbsInformation)
375 case C.ABSInformation_PR_tdd:
376 return buildAbsInformationTdd(cellId, pduAbsInformation)
377 case C.ABSInformation_PR_abs_inactive:
378 return &entities.AbsInformation{Mode: entities.AbsInformationMode_ABS_INACTIVE}, nil
381 return nil, fmt.Errorf("#extractAndBuildCellLoadInformationAbsInformation - cellId: %s - Failed extracting AbsInformation", cellId)
384 func extractExtendedUlInterferenceOverloadIndicationList(extendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) []*C.UL_InterferenceOverloadIndication_Item_t {
386 extendedUlInterferenceOverLoadIndicationCount := extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.count
388 if extendedUlInterferenceOverLoadIndicationCount == 0 {
392 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.UL_InterferenceOverloadIndication_Item_t)(unsafe.Pointer(extendedULInterferenceOverloadInfo.extended_ul_InterferenceOverloadIndication.list.array))[:int(extendedUlInterferenceOverLoadIndicationCount):int(extendedUlInterferenceOverLoadIndicationCount)]
394 if (extendedUlInterferenceOverLoadIndicationList == nil) {
398 return extendedUlInterferenceOverLoadIndicationList
401 func buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo *C.ExtendedULInterferenceOverloadInfo_t) *entities.ExtendedUlInterferenceOverloadInfo {
402 associatedSubframes := NewHexString(pduExtendedULInterferenceOverloadInfo.associatedSubframes.buf, pduExtendedULInterferenceOverloadInfo.associatedSubframes.size)
403 indications := extractExtendedUlInterferenceOverloadIndicationList(pduExtendedULInterferenceOverloadInfo)
405 return &entities.ExtendedUlInterferenceOverloadInfo{
406 AssociatedSubframes: associatedSubframes,
407 ExtendedUlInterferenceOverloadIndications: buildUlInterferenceOverloadIndicationList(indications),
411 func extractPaListFromDynamicNaicsInformation(cellId string, dynamicNAICSInformation *C.DynamicNAICSInformation_t) ([]*C.long, error) {
413 paListCount := dynamicNAICSInformation.pA_list.list.count
415 if paListCount == 0 {
419 if paListCount > MaxNoOfPa {
420 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Invalid PA list count", cellId)
423 extendedUlInterferenceOverLoadIndicationList := (*[1 << 30]*C.long)(unsafe.Pointer(dynamicNAICSInformation.pA_list.list.array))[:int(paListCount):int(paListCount)]
425 if (extendedUlInterferenceOverLoadIndicationList == nil) {
426 return nil, fmt.Errorf("#extractPaListFromDynamicNaicsInformation - cellId: %s - Extended Ul Interference OverLoad Indication List is nil", cellId)
429 return extendedUlInterferenceOverLoadIndicationList, nil
432 func buildPaList(paList []*C.long) []entities.PA {
433 pas := make([]entities.PA, len(paList))
434 for i, pi := range paList {
435 pas[i] = entities.PA(*pi + 1)
441 func extractAndBuildActiveDynamicDlTransmissionInformation(cellId string, pduDynamicDlTransmissionInformation *C.DynamicDLTransmissionInformation_t) (*entities.DynamicDlTransmissionInformation, error) {
442 dynamicNaicsInformation := *(**C.DynamicNAICSInformation_t)(unsafe.Pointer(&pduDynamicDlTransmissionInformation.choice[0]))
444 if dynamicNaicsInformation == nil {
445 return nil, fmt.Errorf("#extractAndBuildActiveDynamicDlTransmissionInformation - cellId: %s - Invalid NAICS Information value", cellId)
448 dynamicDlTransmissionInformation := entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_ACTIVE}
450 if dynamicNaicsInformation.transmissionModes != nil {
451 transmissionModes := NewHexString(dynamicNaicsInformation.transmissionModes.buf, dynamicNaicsInformation.transmissionModes.size)
452 dynamicDlTransmissionInformation.TransmissionModes = transmissionModes
455 if dynamicNaicsInformation.pB_information != nil {
456 dynamicDlTransmissionInformation.PB = uint32(*dynamicNaicsInformation.pB_information)
459 paList, err := extractPaListFromDynamicNaicsInformation(cellId, dynamicNaicsInformation)
466 dynamicDlTransmissionInformation.PAList = buildPaList(paList)
469 return &dynamicDlTransmissionInformation, nil
472 func extractAndBuildDynamicDlTransmissionInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.DynamicDlTransmissionInformation, error) {
473 pduDynamicDlTransmissionInformation := (*C.DynamicDLTransmissionInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
475 if pduDynamicDlTransmissionInformation.present == C.DynamicDLTransmissionInformation_PR_naics_inactive {
476 return &entities.DynamicDlTransmissionInformation{State: entities.NaicsState_NAICS_INACTIVE}, nil
479 if pduDynamicDlTransmissionInformation.present != C.DynamicDLTransmissionInformation_PR_naics_active {
480 return nil, fmt.Errorf("#extractAndBuildDynamicDlTransmissionInformation - cellId: %s - Invalid Dynamic Dl Transmission Information value", cellId)
483 return extractAndBuildActiveDynamicDlTransmissionInformation(cellId, pduDynamicDlTransmissionInformation)
486 func extractCompInformationStartTime(cellId string, compInformation *C.CoMPInformation_t) (*C.CoMPInformationStartTime__Member, error) {
487 compInformationStartTimeListCount := compInformation.coMPInformationStartTime.list.count
489 if compInformationStartTimeListCount == 0 {
493 compInformationStartTimeList := (*[1 << 30]*C.CoMPInformationStartTime__Member)(unsafe.Pointer(compInformation.coMPInformationStartTime.list.array))[:int(compInformationStartTimeListCount):int(compInformationStartTimeListCount)]
495 if len(compInformationStartTimeList) != 1 {
496 return nil, fmt.Errorf("#extractCompInformationStartTime - cellId: %s - Invalid Comp Information StartTime list count", cellId)
499 return compInformationStartTimeList[0], nil
502 func buildCompHypothesisSet(pduCompHypothesisSetItem *C.CoMPHypothesisSetItem_t) *entities.CompHypothesisSet {
503 return &entities.CompHypothesisSet{
504 CellId: buildCellId(pduCompHypothesisSetItem.coMPCellID),
505 CompHypothesis: NewHexString(pduCompHypothesisSetItem.coMPHypothesis.buf, pduCompHypothesisSetItem.coMPHypothesis.size),
509 func buildCompHypothesisSets(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) ([]*entities.CompHypothesisSet, error) {
511 compHypothesisSets := []*entities.CompHypothesisSet{}
513 pduCompHypothesisSetItemsListCount := pduCompInformationItemMember.coMPHypothesisSet.list.count
515 if pduCompHypothesisSetItemsListCount == 0 || pduCompHypothesisSetItemsListCount > NaxNoOfCompCells {
516 return nil, fmt.Errorf("#buildCompHypothesisSets - cellId: %s - Invalid Comp Hypothesis Set Items list count", cellId)
519 pduCompHypothesisSetItems := (*[1 << 30]*C.CoMPHypothesisSetItem_t)(unsafe.Pointer(pduCompInformationItemMember.coMPHypothesisSet.list.array))[:int(pduCompHypothesisSetItemsListCount):int(pduCompHypothesisSetItemsListCount)]
521 for _, pduCompHypothesisSetItem := range pduCompHypothesisSetItems {
522 compHypothesisSet := buildCompHypothesisSet(pduCompHypothesisSetItem)
523 compHypothesisSets = append(compHypothesisSets, compHypothesisSet)
526 return compHypothesisSets, nil
529 func buildCompInformationItem(cellId string, pduCompInformationItemMember *C.CoMPInformationItem__Member) (*entities.CompInformationItem, error) {
531 compHypothesisSets, err := buildCompHypothesisSets(cellId, pduCompInformationItemMember)
537 compInformation := entities.CompInformationItem{
538 CompHypothesisSets: compHypothesisSets,
539 BenefitMetric: int32(pduCompInformationItemMember.benefitMetric),
542 return &compInformation, nil
545 func extractAndBuildCompInformation(cellId string, extIE *C.CellInformation_Item_ExtIEs_t) (*entities.CompInformation, error) {
547 pduCompInformation := (*C.CoMPInformation_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
549 compInformation := entities.CompInformation{}
550 pduCompInformationStartTime, err := extractCompInformationStartTime(cellId, pduCompInformation)
556 if pduCompInformationStartTime != nil {
557 compInformation.CompInformationStartTime = NewStartTime(pduCompInformationStartTime.startSFN, pduCompInformationStartTime.startSubframeNumber)
560 pduCompInformationItemsListCount := pduCompInformation.coMPInformationItem.list.count
562 if pduCompInformationItemsListCount == 0 || pduCompInformationItemsListCount > NaxNoOfCompHypothesisSet {
563 return nil, fmt.Errorf("#extractAndBuildCompInformation - cellId: %s - Invalid Comp Information Items list count", cellId)
566 pduCompInformationItems := (*[1 << 30]*C.CoMPInformationItem__Member)(unsafe.Pointer(pduCompInformation.coMPInformationItem.list.array))[:int(pduCompInformationItemsListCount):int(pduCompInformationItemsListCount)]
568 for _, pduCompInformationItem := range pduCompInformationItems {
569 compInformationItem, err := buildCompInformationItem(cellId, pduCompInformationItem)
575 compInformation.CompInformationItems = append(compInformation.CompInformationItems, compInformationItem)
578 return &compInformation, nil
581 func populateAbsInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
582 absInformation, err := extractAndBuildCellLoadInformationAbsInformation(cellId, extIE)
588 cellLoadInformation.AbsInformation = absInformation
592 func populateInvokeIndication(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
593 pduInvokeIndication := (*C.InvokeIndication_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
594 cellLoadInformation.InvokeIndication = entities.InvokeIndication(*pduInvokeIndication + 1)
598 func populateIntendedUlDlConfiguration(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
599 pduSubframeAssignment := (*C.SubframeAssignment_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
600 cellLoadInformation.IntendedUlDlConfiguration = entities.SubframeAssignment(*pduSubframeAssignment + 1)
604 func populateExtendedUlInterferenceOverloadInfo(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
605 pduExtendedULInterferenceOverloadInfo := (*C.ExtendedULInterferenceOverloadInfo_t)(unsafe.Pointer(&extIE.extensionValue.choice[0]))
606 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = buildExtendedULInterferenceOverloadInfo(pduExtendedULInterferenceOverloadInfo)
610 func populateCompInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
611 pduCompInformation, err := extractAndBuildCompInformation(cellId, extIE)
617 cellLoadInformation.CompInformation = pduCompInformation
621 func populateDynamicDLTransmissionInformation(cellId string, cellLoadInformation *entities.CellLoadInformation, extIE *C.CellInformation_Item_ExtIEs_t) error {
622 dynamicDLTransmissionInformation, err := extractAndBuildDynamicDlTransmissionInformation(cellId, extIE)
628 cellLoadInformation.DynamicDlTransmissionInformation = dynamicDLTransmissionInformation
632 func populateCellLoadInformationExtensionIEs(cellId string, cellLoadInformation *entities.CellLoadInformation, extIEs []*C.CellInformation_Item_ExtIEs_t) error {
633 for _, extIE := range extIEs {
635 populator, ok := populators[extIE.extensionValue.present]
641 err := populator(cellId, cellLoadInformation, extIE)
652 func ExtractAndBuildRanLoadInformation(pdu *C.E2AP_PDU_t, ranLoadInformation *entities.RanLoadInformation) error {
654 defer C.delete_pdu(pdu)
656 pduCellInformationItemIEs, err := extractPduCellInformationItemIEs(pdu)
662 for _, pduCellInformationItemIE := range pduCellInformationItemIEs {
663 err = populateCellLoadInformation(pduCellInformationItemIE, ranLoadInformation)