First commit

This commit is contained in:
Leonardo Bonati
2021-12-08 20:17:46 +00:00
commit 60dffad583
2923 changed files with 463894 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/logger"
"fmt"
)
type E2RequestMessage struct {
transactionId string
ranIp string
ranPort uint16
ranName string
payload []byte
}
func (e2RequestMessage E2RequestMessage) RanName() string {
return e2RequestMessage.ranName
}
func (e2RequestMessage E2RequestMessage) TransactionId() string {
return e2RequestMessage.transactionId
}
func NewE2RequestMessage(transactionId string, ranIp string, ranPort uint16, ranName string, payload []byte) *E2RequestMessage {
return &E2RequestMessage{transactionId: transactionId, ranIp: ranIp, ranPort: ranPort, ranName: ranName, payload: payload}
}
// TODO: this shouldn't receive logger
func (e2RequestMessage E2RequestMessage) GetMessageAsBytes(logger *logger.Logger) []byte {
messageStringWithoutPayload := fmt.Sprintf("%s|%d|%s|%d|", e2RequestMessage.ranIp, e2RequestMessage.ranPort, e2RequestMessage.ranName, len(e2RequestMessage.payload))
logger.Debugf("#e2_request_message.GetMessageAsBytes - messageStringWithoutPayload: %s", messageStringWithoutPayload)
messageBytesWithoutPayload := []byte(messageStringWithoutPayload)
return append(messageBytesWithoutPayload, e2RequestMessage.payload...)
}

View File

@@ -0,0 +1,52 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models_test
import (
"e2mgr/logger"
"e2mgr/models"
"e2mgr/tests"
"encoding/hex"
"github.com/stretchr/testify/assert"
"testing"
)
const transactionId = "transactionId"
const expectedMessageAsBytesHex = "31302e302e302e337c333830317c746573747c347c01020304"
func TestNewE2RequestMessage(t *testing.T){
e2 :=models.NewE2RequestMessage(transactionId, tests.RanIp, uint16(tests.Port), tests.RanName, tests.DummyPayload)
assert.NotNil(t, e2)
assert.IsType(t, *e2, models.E2RequestMessage{})
assert.Equal(t, tests.RanName, e2.RanName())
assert.Equal(t, transactionId, e2.TransactionId())
}
func TestGetMessageAsBytes(t *testing.T){
log, err := logger.InitLogger(logger.InfoLevel)
if err != nil {
t.Errorf("#nodeb_controller_test.TestHandleRequestSuccess - failed to initialize logger, error: %s", err)
}
e2 := models.NewE2RequestMessage(transactionId, tests.RanIp, uint16(tests.Port), tests.RanName, tests.DummyPayload)
bytes := e2.GetMessageAsBytes(log)
assert.Equal(t, expectedMessageAsBytesHex, hex.EncodeToString(bytes))
}

View File

@@ -0,0 +1,285 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"encoding/xml"
"errors"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"strconv"
"strings"
)
type Gnb struct {
Text string `xml:",chardata"`
GlobalGNBID struct {
Text string `xml:",chardata"`
PlmnID string `xml:"plmn-id"`
GnbID struct {
Text string `xml:",chardata"`
GnbID string `xml:"gnb-ID"`
} `xml:"gnb-id"`
} `xml:"global-gNB-ID"`
}
type EnGnb struct {
Text string `xml:",chardata"`
GlobalGNBID struct {
Text string `xml:",chardata"`
PlmnID string `xml:"pLMN-Identity"`
GnbID struct {
Text string `xml:",chardata"`
GnbID string `xml:"gNB-ID"`
} `xml:"gNB-ID"`
} `xml:"global-gNB-ID"`
}
type NgEnbId struct {
Text string `xml:",chardata"`
EnbIdMacro string `xml:"enb-ID-macro"`
EnbIdShortMacro string `xml:"enb-ID-shortmacro"`
EnbIdLongMacro string `xml:"enb-ID-longmacro"`
}
type NgEnb struct {
Text string `xml:",chardata"`
GlobalNgENBID struct {
Text string `xml:",chardata"`
PlmnID string `xml:"plmn-id"`
EnbID NgEnbId `xml:"enb-id"`
} `xml:"global-ng-eNB-ID"`
}
type EnbId struct {
Text string `xml:",chardata"`
MacroEnbId string `xml:"macro-eNB-ID"`
HomeEnbId string `xml:"home-eNB-ID"`
ShortMacroEnbId string `xml:"short-Macro-eNB-ID"`
LongMacroEnbId string `xml:"long-Macro-eNB-ID"`
}
type Enb struct {
Text string `xml:",chardata"`
GlobalENBID struct {
Text string `xml:",chardata"`
PlmnID string `xml:"pLMN-Identity"`
EnbID EnbId `xml:"eNB-ID"`
} `xml:"global-eNB-ID"`
}
type GlobalE2NodeId struct {
Text string `xml:",chardata"`
GNB Gnb `xml:"gNB"`
EnGNB EnGnb `xml:"en-gNB"`
NgENB NgEnb `xml:"ng-eNB"`
ENB Enb `xml:"eNB"`
}
type E2SetupRequest struct {
Text string `xml:",chardata"`
ProtocolIEs struct {
Text string `xml:",chardata"`
E2setupRequestIEs []struct {
Text string `xml:",chardata"`
ID string `xml:"id"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
GlobalE2nodeID GlobalE2NodeId `xml:"GlobalE2node-ID"`
RANfunctionsList RANfunctionsList `xml:"RANfunctions-List"`
} `xml:"value"`
} `xml:"E2setupRequestIEs"`
} `xml:"protocolIEs"`
}
type E2SetupRequestMessage struct {
XMLName xml.Name `xml:"E2SetupRequestMessage"`
Text string `xml:",chardata"`
E2APPDU struct {
Text string `xml:",chardata"`
InitiatingMessage struct {
Text string `xml:",chardata"`
ProcedureCode string `xml:"procedureCode"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
E2setupRequest E2SetupRequest `xml:"E2setupRequest"`
} `xml:"value"`
} `xml:"initiatingMessage"`
} `xml:"E2AP-PDU"`
}
type RanFunctionItem struct {
Text string `xml:",chardata"`
RanFunctionID string `xml:"ranFunctionID"`
RanFunctionDefinition string `xml:"ranFunctionDefinition"`
RanFunctionRevision string `xml:"ranFunctionRevision"`
}
type RANfunctionsList struct {
Text string `xml:",chardata"`
ProtocolIESingleContainer []struct {
Text string `xml:",chardata"`
ID string `xml:"id"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
RANfunctionItem RanFunctionItem `xml:"RANfunction-Item"`
} `xml:"value"`
} `xml:"ProtocolIE-SingleContainer"`
}
func (m *E2SetupRequestMessage) ExtractRanFunctionsList() ([]*entities.RanFunction, error) {
setupRequestIes := m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs
if len(setupRequestIes) < 2 {
return nil, nil
}
list := setupRequestIes[1].Value.RANfunctionsList.ProtocolIESingleContainer
funcs := make([]*entities.RanFunction, len(list))
for i := 0; i < len(funcs); i++ {
funcs[i] = &entities.RanFunction{}
id, err := strconv.ParseUint(list[i].Value.RANfunctionItem.RanFunctionID, 10, 32)
if err != nil {
return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.ExtractRanFunctionsList - Failed parse uint RanFunctionID from %s", list[i].Value.RANfunctionItem.RanFunctionID))
}
funcs[i].RanFunctionId = uint32(id)
rev, err := strconv.ParseUint(list[i].Value.RANfunctionItem.RanFunctionRevision, 10, 32)
if err != nil {
return nil, errors.New(fmt.Sprintf("#e2_setup_request_message.ExtractRanFunctionsList - Failed parse uint RanFunctionRevision from %s", list[i].Value.RANfunctionItem.RanFunctionRevision))
}
funcs[i].RanFunctionDefinition = m.trimSpaces(list[i].Value.RANfunctionItem.RanFunctionDefinition)
funcs[i].RanFunctionRevision = uint32(rev)
}
return funcs, nil
}
func (m *E2SetupRequestMessage) getGlobalE2NodeId() GlobalE2NodeId {
return m.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[0].Value.GlobalE2nodeID
}
//func (m *E2SetupRequestMessage) GetNodeType() entities.Node_Type {
// globalE2NodeId := m.getGlobalE2NodeId()
// if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
// return entities.Node_GNB
// }
// if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
// return entities.Node_GNB
// }
// if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
// return entities.Node_ENB
// }
// if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
// return entities.Node_ENB
// }
// return entities.Node_UNKNOWN
//}
func (m *E2SetupRequestMessage) GetPlmnId() string {
globalE2NodeId := m.getGlobalE2NodeId()
if id := globalE2NodeId.GNB.GlobalGNBID.PlmnID; id != "" {
return m.trimSpaces(id)
}
if id := globalE2NodeId.EnGNB.GlobalGNBID.PlmnID; id != "" {
return m.trimSpaces(id)
}
if id := globalE2NodeId.ENB.GlobalENBID.PlmnID; id != "" {
return m.trimSpaces(id)
}
if id := globalE2NodeId.NgENB.GlobalNgENBID.PlmnID; id != "" {
return m.trimSpaces(id)
}
return ""
}
func (m *E2SetupRequestMessage) getInnerEnbId(enbId EnbId) string {
if id := enbId.HomeEnbId; id != "" {
return id
}
if id := enbId.LongMacroEnbId; id != "" {
return id
}
if id := enbId.MacroEnbId; id != "" {
return id
}
if id := enbId.ShortMacroEnbId; id != "" {
return id
}
return ""
}
func (m *E2SetupRequestMessage) getInnerNgEnbId(enbId NgEnbId) string {
if id := enbId.EnbIdLongMacro; id != "" {
return id
}
if id := enbId.EnbIdMacro; id != "" {
return id
}
if id := enbId.EnbIdShortMacro; id != "" {
return id
}
return ""
}
func (m *E2SetupRequestMessage) GetNbId() string {
globalE2NodeId := m.getGlobalE2NodeId()
if id := globalE2NodeId.GNB.GlobalGNBID.GnbID.GnbID; id != "" {
return m.trimSpaces(id)
}
if id := globalE2NodeId.EnGNB.GlobalGNBID.GnbID.GnbID; id != "" {
return m.trimSpaces(id)
}
if id := m.getInnerEnbId(globalE2NodeId.ENB.GlobalENBID.EnbID); id != "" {
return m.trimSpaces(id)
}
if id := m.getInnerNgEnbId(globalE2NodeId.NgENB.GlobalNgENBID.EnbID); id != "" {
return m.trimSpaces(id)
}
return ""
}
func (m *E2SetupRequestMessage) trimSpaces(str string) string {
return strings.NewReplacer(" ", "", "\n", "").Replace(str)
}

View File

@@ -0,0 +1,244 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"encoding/xml"
)
type TimeToWait = int
var TimeToWaitEnum = struct {
V60s TimeToWait
V20s TimeToWait
V10s TimeToWait
V5s TimeToWait
V2s TimeToWait
V1s TimeToWait
}{60, 20, 10, 5, 2, 1}
var timeToWaitMap = map[TimeToWait]interface{}{
TimeToWaitEnum.V60s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V60s string `xml:"v60s"`
}{},
TimeToWaitEnum.V20s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V20s string `xml:"v20s"`
}{},
TimeToWaitEnum.V10s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V10s string `xml:"v10s"`
}{},
TimeToWaitEnum.V5s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V5s string `xml:"v5s"`
}{},
TimeToWaitEnum.V2s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V2s string `xml:"v2s"`
}{},
TimeToWaitEnum.V1s: struct {
XMLName xml.Name `xml:"TimeToWait"`
Text string `xml:",chardata"`
V1s string `xml:"v1s"`
}{},
}
func NewE2SetupSuccessResponseMessage(plmnId string, ricId string, request *E2SetupRequestMessage) E2SetupResponseMessage {
outcome := SuccessfulOutcome{}
outcome.ProcedureCode = "1"
setupRequestIes := request.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs
outcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs = make([]E2setupResponseIEs, len(setupRequestIes))
outcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[0].ID = "4"
outcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[0].Value = GlobalRICID{GlobalRICID: struct {
Text string `xml:",chardata"`
PLMNIdentity string `xml:"pLMN-Identity"`
RicID string `xml:"ric-ID"`
}{PLMNIdentity: plmnId, RicID: ricId}}
if len(setupRequestIes) < 2 {
return E2SetupResponseMessage{E2APPDU: E2APPDU{Outcome: outcome}}
}
functionsIdList := extractRanFunctionsIDList(request)
outcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[1].ID = "9"
outcome.Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs[1].Value = RANfunctionsIDList{RANfunctionsIDList: struct {
Text string `xml:",chardata"`
ProtocolIESingleContainer []ProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
}{ProtocolIESingleContainer: functionsIdList}}
return E2SetupResponseMessage{E2APPDU: E2APPDU{Outcome: outcome}}
}
func NewE2SetupFailureResponseMessage(timeToWait TimeToWait) E2SetupResponseMessage {
outcome := UnsuccessfulOutcome{}
outcome.Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs = make([]E2setupFailureIEs, 2)
outcome.ProcedureCode = "1"
outcome.Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs[0].ID = "1"
outcome.Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs[0].Value.Value = Cause{}
outcome.Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs[1].ID = "31"
outcome.Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs[1].Value.Value = timeToWaitMap[timeToWait]
return E2SetupResponseMessage{E2APPDU: E2APPDU{Outcome: outcome}}
}
type E2SetupResponseMessage struct {
XMLName xml.Name `xml:"E2SetupSuccessResponseMessage"`
Text string `xml:",chardata"`
E2APPDU E2APPDU
}
type E2APPDU struct {
XMLName xml.Name `xml:"E2AP-PDU"`
Text string `xml:",chardata"`
Outcome interface{}
}
type SuccessfulOutcome struct {
XMLName xml.Name `xml:"successfulOutcome"`
Text string `xml:",chardata"`
ProcedureCode string `xml:"procedureCode"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
E2setupResponse struct {
Text string `xml:",chardata"`
ProtocolIEs struct {
Text string `xml:",chardata"`
E2setupResponseIEs []E2setupResponseIEs `xml:"E2setupResponseIEs"`
} `xml:"protocolIEs"`
} `xml:"E2setupResponse"`
} `xml:"value"`
}
type E2setupResponseIEs struct {
Text string `xml:",chardata"`
ID string `xml:"id"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value interface{} `xml:"value"`
}
type GlobalRICID struct {
Text string `xml:",chardata"`
GlobalRICID struct {
Text string `xml:",chardata"`
PLMNIdentity string `xml:"pLMN-Identity"`
RicID string `xml:"ric-ID"`
} `xml:"GlobalRIC-ID"`
}
type RANfunctionsIDList struct {
Text string `xml:",chardata"`
RANfunctionsIDList struct {
Text string `xml:",chardata"`
ProtocolIESingleContainer []ProtocolIESingleContainer `xml:"ProtocolIE-SingleContainer"`
} `xml:"RANfunctionsID-List"`
}
type ProtocolIESingleContainer struct {
Text string `xml:",chardata"`
ID string `xml:"id"`
Criticality struct {
Text string `xml:",chardata"`
Ignore string `xml:"ignore"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
RANfunctionIDItem struct {
Text string `xml:",chardata"`
RanFunctionID string `xml:"ranFunctionID"`
RanFunctionRevision string `xml:"ranFunctionRevision"`
} `xml:"RANfunctionID-Item"`
} `xml:"value"`
}
type UnsuccessfulOutcome struct {
XMLName xml.Name `xml:"unsuccessfulOutcome"`
Text string `xml:",chardata"`
ProcedureCode string `xml:"procedureCode"`
Criticality struct {
Text string `xml:",chardata"`
Reject string `xml:"reject"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
E2setupFailure struct {
Text string `xml:",chardata"`
ProtocolIEs struct {
Text string `xml:",chardata"`
E2setupFailureIEs []E2setupFailureIEs `xml:"E2setupFailureIEs"`
} `xml:"protocolIEs"`
} `xml:"E2setupFailure"`
} `xml:"value"`
}
type E2setupFailureIEs struct {
Text string `xml:",chardata"`
ID string `xml:"id"`
Criticality struct {
Text string `xml:",chardata"`
Ignore string `xml:"ignore"`
} `xml:"criticality"`
Value struct {
Text string `xml:",chardata"`
Value interface{}
} `xml:"value"`
}
type Cause struct {
XMLName xml.Name `xml:"Cause"`
Text string `xml:",chardata"`
Transport struct {
Text string `xml:",chardata"`
TransportResourceUnavailable string `xml:"transport-resource-unavailable"`
} `xml:"transport"`
}
func extractRanFunctionsIDList(request *E2SetupRequestMessage) []ProtocolIESingleContainer {
list := &request.E2APPDU.InitiatingMessage.Value.E2setupRequest.ProtocolIEs.E2setupRequestIEs[1].Value.RANfunctionsList
ids := make([]ProtocolIESingleContainer, len(list.ProtocolIESingleContainer))
for i := 0; i < len(ids); i++ {
ids[i] = convertToRANfunctionID(list, i)
}
return ids
}
func convertToRANfunctionID(list *RANfunctionsList, i int) ProtocolIESingleContainer {
id := ProtocolIESingleContainer{}
id.ID = "6"
id.Value.RANfunctionIDItem.RanFunctionID = list.ProtocolIESingleContainer[i].Value.RANfunctionItem.RanFunctionID
id.Value.RANfunctionIDItem.RanFunctionRevision = list.ProtocolIESingleContainer[i].Value.RANfunctionItem.RanFunctionRevision
return id
}

View File

@@ -0,0 +1,27 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type E2TermInitPayload struct {
Address string `json:"address"`
Fqdn string `json:"fqdn"`
PodName string `json:"pod_name"`
}

View File

@@ -0,0 +1,25 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type E2TKeepAlivePayload struct {
Address string `json:"address"`
}

View File

@@ -0,0 +1,26 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type ErrorResponse struct {
Code int `json:"errorCode"`
Message string `json:"errorMessage"`
}

View File

@@ -0,0 +1,52 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/e2managererrors"
"encoding/json"
)
type E2TInstancesResponse []*E2TInstanceResponseModel
type E2TInstanceResponseModel struct {
E2TAddress string `json:"e2tAddress"`
RanNames []string `json:"ranNames"`
}
func NewE2TInstanceResponseModel(e2tAddress string, ranNames []string) *E2TInstanceResponseModel {
return &E2TInstanceResponseModel{
E2TAddress: e2tAddress,
RanNames: ranNames,
}
}
func (response E2TInstancesResponse) Marshal() ([]byte, error) {
data, err := json.Marshal(response)
if err != nil {
return nil, e2managererrors.NewInternalError()
}
return data, nil
}

View File

@@ -0,0 +1,48 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/e2managererrors"
"e2mgr/utils"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
)
type GetNodebIdListResponse struct {
nodebIdList []*entities.NbIdentity
}
func NewGetNodebIdListResponse(nodebIdList []*entities.NbIdentity) *GetNodebIdListResponse {
return &GetNodebIdListResponse{
nodebIdList: nodebIdList,
}
}
func (response *GetNodebIdListResponse) Marshal() ([]byte, error) {
pmList := utils.ConvertNodebIdListToProtoMessageList(response.nodebIdList)
result, err := utils.MarshalProtoMessageListToJsonArray(pmList)
if err != nil {
return nil, e2managererrors.NewInternalError();
}
return []byte(result), nil
}

View File

@@ -0,0 +1,25 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type GetNodebRequest struct {
RanName string
}

View File

@@ -0,0 +1,49 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/e2managererrors"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"github.com/golang/protobuf/jsonpb"
)
type GetNodebResponse struct {
nodebInfo *entities.NodebInfo
}
func NewGetNodebResponse(nodebInfo *entities.NodebInfo) *GetNodebResponse {
return &GetNodebResponse{
nodebInfo: nodebInfo,
}
}
func (response *GetNodebResponse) Marshal() ([]byte, error) {
m := jsonpb.Marshaler{}
result, err := m.MarshalToString(response.nodebInfo)
if err != nil {
return nil, e2managererrors.NewInternalError()
}
return []byte(result), nil
}

View File

@@ -0,0 +1,25 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type IResponse interface {
Marshal() ([]byte, error)
}

View File

@@ -0,0 +1,50 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"time"
"unsafe"
)
type NotificationRequest struct {
RanName string
Len int
Payload []byte
StartTime time.Time
TransactionId []byte
msgSrc unsafe.Pointer
}
func NewNotificationRequest(ranName string, payload []byte, startTime time.Time, transactionId []byte, msgSrc unsafe.Pointer) *NotificationRequest {
return &NotificationRequest{
ranName,
len(payload),
payload,
startTime,
transactionId,
msgSrc,
}
}
func (r NotificationRequest) GetMsgSrc() unsafe.Pointer{
return r.msgSrc
}

View File

@@ -0,0 +1,48 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/e2managererrors"
"encoding/json"
)
type RedButtonPartialSuccessResponseModel struct {
Message string `json:"message"`
}
func NewRedButtonPartialSuccessResponseModel(message string) *RedButtonPartialSuccessResponseModel {
return &RedButtonPartialSuccessResponseModel{
Message: message,
}
}
func (response RedButtonPartialSuccessResponseModel) Marshal() ([]byte, error) {
data, err := json.Marshal(response)
if err != nil {
return nil, e2managererrors.NewInternalError()
}
return data, nil
}

View File

@@ -0,0 +1,25 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type Request interface {
}

View File

@@ -0,0 +1,26 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type ResetRequest struct {
RanName string
Cause string `json:"cause"`
}

View File

@@ -0,0 +1,38 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/enums"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
)
type ResourceStatusPayload struct {
NodeType entities.Node_Type `json:"nodeType"`
MessageDirection enums.MessageDirection `json:"messageDirection"`
}
func NewResourceStatusPayload(nodeType entities.Node_Type, messageDirection enums.MessageDirection) *ResourceStatusPayload {
return &ResourceStatusPayload{
NodeType: nodeType,
MessageDirection: messageDirection,
}
}

View File

@@ -0,0 +1,45 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import "unsafe"
type RmrMessage struct {
MsgType int
RanName string
Payload []byte
XAction []byte
msgSrc unsafe.Pointer
}
func NewRmrMessage(msgType int, ranName string, payload []byte, xAction []byte, msgSrc unsafe.Pointer) *RmrMessage {
return &RmrMessage{
msgType,
ranName,
payload,
xAction,
msgSrc,
}
}
func (m RmrMessage) GetMsgSrc() unsafe.Pointer{
return m.msgSrc
}

View File

@@ -0,0 +1,34 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type RoutingManagerDeleteRequestModel struct {
E2TAddress string `json:"E2TAddress"`
RanNameListToBeDissociated []string `json:"ranNamelistTobeDissociated,omitempty"`
RanAssocList RoutingManagerE2TDataList `json:"ranAssocList,omitempty"`
}
func NewRoutingManagerDeleteRequestModel(e2tAddress string, ranNameListToBeDissociated []string, ranAssocList RoutingManagerE2TDataList) *RoutingManagerDeleteRequestModel {
return &RoutingManagerDeleteRequestModel{
E2TAddress: e2tAddress,
RanNameListToBeDissociated: ranNameListToBeDissociated,
RanAssocList: ranAssocList,
}
}

View File

@@ -0,0 +1,41 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type RoutingManagerE2TData struct {
E2TAddress string `json:"E2TAddress"`
RanNamelist []string `json:"ranNamelist,omitempty"`
}
func NewRoutingManagerE2TData (e2tAddress string, ranNameList ...string) *RoutingManagerE2TData {
data := &RoutingManagerE2TData{
E2TAddress: e2tAddress,
}
if len(ranNameList) == 0 {
return data
}
for _, ranName := range ranNameList {
data.RanNamelist = append(data.RanNamelist, ranName)
}
return data
}

View File

@@ -0,0 +1,22 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type RoutingManagerE2TDataList []*RoutingManagerE2TData

View File

@@ -0,0 +1,27 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
type SetupRequest struct {
RanIp string `json:"ranIp"`
RanPort uint16 `json:"ranPort"`
RanName string `json:"ranName"`
}

View File

@@ -0,0 +1,27 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
type UpdateGnbRequest struct {
RanName string
*entities.Gnb
}

View File

@@ -0,0 +1,48 @@
//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
package models
import (
"e2mgr/e2managererrors"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"github.com/golang/protobuf/jsonpb"
)
type UpdateGnbResponse struct {
nodebInfo *entities.NodebInfo
}
func NewUpdateGnbResponse(nodebInfo *entities.NodebInfo) *UpdateGnbResponse {
return &UpdateGnbResponse{
nodebInfo: nodebInfo,
}
}
func (response *UpdateGnbResponse) Marshal() ([]byte, error) {
m := jsonpb.Marshaler{}
result, err := m.MarshalToString(response.nodebInfo)
if err != nil {
return nil, e2managererrors.NewInternalError()
}
return []byte(result), nil
}