2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
25 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 type RmrDatagram struct {
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 type RmrEndpoint struct {
43 Addr string // xapp addr
44 Port uint16 // xapp port
47 func (endpoint RmrEndpoint) String() string {
51 func (endpoint *RmrEndpoint) GetAddr() string {
55 func (endpoint *RmrEndpoint) GetPort() uint16 {
59 func (endpoint *RmrEndpoint) Get() string {
60 return endpoint.Addr + ":" + strconv.FormatUint(uint64(endpoint.Port), 10)
63 func (endpoint *RmrEndpoint) Set(src string) bool {
64 elems := strings.Split(src, ":")
67 srcPort, err := strconv.ParseUint(elems[1], 10, 16)
69 endpoint.Addr = srcAddr
70 endpoint.Port = uint16(srcPort)
77 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
80 type RmrEndpointList struct {
81 Endpoints []RmrEndpoint
84 func (eplist *RmrEndpointList) String() string {
85 valuesText := []string{}
86 for i := range eplist.Endpoints {
87 ep := eplist.Endpoints[i]
89 valuesText = append(valuesText, text)
91 return strings.Join(valuesText, ",")
94 func (eplist *RmrEndpointList) Size() int {
95 return len(eplist.Endpoints)
98 func (eplist *RmrEndpointList) AddEndpoint(ep *RmrEndpoint) bool {
99 for i := range eplist.Endpoints {
100 if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) {
104 eplist.Endpoints = append(eplist.Endpoints, *ep)
108 func (eplist *RmrEndpointList) DelEndpoint(ep *RmrEndpoint) bool {
109 for i := range eplist.Endpoints {
110 if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) {
111 eplist.Endpoints[i] = eplist.Endpoints[len(eplist.Endpoints)-1]
112 eplist.Endpoints[len(eplist.Endpoints)-1] = RmrEndpoint{"", 0}
113 eplist.Endpoints = eplist.Endpoints[:len(eplist.Endpoints)-1]
120 func (eplist *RmrEndpointList) DelEndpoints(otheplist *RmrEndpointList) bool {
121 var retval bool = false
122 for i := range otheplist.Endpoints {
123 if eplist.DelEndpoint(&eplist.Endpoints[i]) {
130 func (eplist *RmrEndpointList) HasEndpoint(ep *RmrEndpoint) bool {
131 for i := range eplist.Endpoints {
132 if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) {
139 func NewRmrEndpoint(src string) *RmrEndpoint {
141 if ep.Set(src) == false {
147 //-----------------------------------------------------------------------------
149 //-----------------------------------------------------------------------------
152 func (act Action) String() string {
153 actions := [...]string{
160 if act < CREATE || act > DELETE {
166 //-----------------------------------------------------------------------------
167 // To add own method for rmrparams
168 //-----------------------------------------------------------------------------
169 type RMRParams struct {
173 func (params *RMRParams) String() string {
175 fmt.Fprintf(&b, "params(Src=%s Mtype=%s(%d) SubId=%v Xid=%s Meid=%s)", params.Src, xapp.RicMessageTypeToName[params.Mtype], params.Mtype, params.SubId, params.Xid, params.Meid.RanName)