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 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
24 "github.com/pkg/errors"
27 type NodebValidator struct {
30 func NewNodebValidator() *NodebValidator {
31 return &NodebValidator{}
34 func (h *NodebValidator) IsGnbValid(gnb *entities.Gnb) error {
35 if len(gnb.ServedNrCells) == 0 {
36 return errors.New("gnb.servedNrCells")
39 for _, servedNrCell := range gnb.ServedNrCells {
40 if servedNrCell.ServedNrCellInformation == nil {
41 return errors.New("gnb.servedNrCellInformation")
44 err := isServedNrCellInformationValid(servedNrCell.ServedNrCellInformation)
50 if len(servedNrCell.NrNeighbourInfos) == 0 {
54 for _, nrNeighbourInformation := range servedNrCell.NrNeighbourInfos {
56 err := isNrNeighbourInformationValid(nrNeighbourInformation)
68 func isServedNrCellInformationValid(servedNrCellInformation *entities.ServedNRCellInformation) error {
69 if servedNrCellInformation.CellId == "" {
70 return errors.New("servedNrCellInformation.cellId")
73 if servedNrCellInformation.ChoiceNrMode == nil {
74 return errors.New("servedNrCellInformation.choiceNrMode")
77 if servedNrCellInformation.NrMode == entities.Nr_UNKNOWN {
78 return errors.New("servedNrCellInformation.nrMode")
81 if len(servedNrCellInformation.ServedPlmns) == 0 {
82 return errors.New("servedNrCellInformation.servedPlmns")
85 return isServedNrCellInfoChoiceNrModeValid(servedNrCellInformation.ChoiceNrMode)
88 func isServedNrCellInfoChoiceNrModeValid(choiceNrMode *entities.ServedNRCellInformation_ChoiceNRMode) error {
89 if choiceNrMode.Fdd != nil {
90 return isServedNrCellInfoFddValid(choiceNrMode.Fdd)
93 if choiceNrMode.Tdd != nil {
94 return isServedNrCellInfoTddValid(choiceNrMode.Tdd)
97 return errors.New("servedNrCellInformation.choiceNrMode.fdd / servedNrCellInformation.choiceNrMode.tdd")
100 func isServedNrCellInfoTddValid(tdd *entities.ServedNRCellInformation_ChoiceNRMode_TddInfo) error {
104 func isServedNrCellInfoFddValid(fdd *entities.ServedNRCellInformation_ChoiceNRMode_FddInfo) error {
108 func isNrNeighbourInformationValid(nrNeighbourInformation *entities.NrNeighbourInformation) error {
109 if nrNeighbourInformation.NrCgi == "" {
110 return errors.New("nrNeighbourInformation.nrCgi")
113 if nrNeighbourInformation.ChoiceNrMode == nil {
114 return errors.New("nrNeighbourInformation.choiceNrMode")
117 if nrNeighbourInformation.NrMode == entities.Nr_UNKNOWN {
118 return errors.New("nrNeighbourInformation.nrMode")
121 return isNrNeighbourInfoChoiceNrModeValid(nrNeighbourInformation.ChoiceNrMode)
124 func isNrNeighbourInfoChoiceNrModeValid(choiceNrMode *entities.NrNeighbourInformation_ChoiceNRMode) error {
125 if choiceNrMode.Fdd != nil {
126 return isNrNeighbourInfoFddValid(choiceNrMode.Fdd)
129 if choiceNrMode.Tdd != nil {
130 return isNrNeighbourInfoTddValid(choiceNrMode.Tdd)
133 return errors.New("nrNeighbourInformation.choiceNrMode.fdd / nrNeighbourInformation.choiceNrMode.tdd")
136 func isNrNeighbourInfoTddValid(tdd *entities.NrNeighbourInformation_ChoiceNRMode_TddInfo) error {
140 func isNrNeighbourInfoFddValid(fdd *entities.NrNeighbourInformation_ChoiceNRMode_FddInfo) error {
144 func (h *NodebValidator) IsEnbValid(enb *entities.Enb) error {
145 if enb.EnbType == entities.EnbType_UNKNOWN_ENB_TYPE {
146 return errors.New("enb.enbType")
149 if enb.ServedCells == nil || len(enb.ServedCells) == 0 {
150 return errors.New("enb.servedCells")
153 for _, servedCell := range enb.ServedCells {
154 err := isServedCellValid(servedCell)
164 func isServedCellValid(servedCell *entities.ServedCellInfo) error {
166 if servedCell.CellId == "" {
167 return errors.New("servedCell.cellId")
170 if servedCell.EutraMode == entities.Eutra_UNKNOWN {
171 return errors.New("servedCell.eutraMode")
174 if servedCell.Tac == "" {
175 return errors.New("servedCell.tac")
178 if servedCell.BroadcastPlmns == nil || len(servedCell.BroadcastPlmns) == 0 {
179 return errors.New("servedCell.broadcastPlmns")
182 if servedCell.ChoiceEutraMode == nil {
183 return errors.New("servedCell.choiceEutraMode")
186 return isChoiceEutraModeValid(servedCell.ChoiceEutraMode)
189 func isChoiceEutraModeValid(choiceEutraMode *entities.ChoiceEUTRAMode) error {
190 if choiceEutraMode.Fdd != nil {
191 return isFddInfoValid(choiceEutraMode.Fdd)
194 if choiceEutraMode.Tdd != nil {
195 return isTddInfoValid(choiceEutraMode.Tdd)
198 return errors.New("servedCell.fdd / servedCell.tdd")
201 func isTddInfoValid(tdd *entities.TddInfo) error {
205 func isFddInfoValid(fdd *entities.FddInfo) error {