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/e2ap/pkg/e2ap"
26 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 type RequestId struct {
38 func (rid *RequestId) String() string {
39 return "reqid(" + rid.RequestId.String() + ")"
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
45 type RmrEndpoint struct {
46 Addr string // xapp addr
47 Port uint16 // xapp port
50 func (endpoint RmrEndpoint) String() string {
51 return endpoint.Addr + ":" + strconv.FormatUint(uint64(endpoint.Port), 10)
54 func (endpoint *RmrEndpoint) Equal(ep *RmrEndpoint) bool {
55 if (endpoint.Addr == ep.Addr) &&
56 (endpoint.Port == ep.Port) {
62 func (endpoint *RmrEndpoint) GetAddr() string {
66 func (endpoint *RmrEndpoint) GetPort() uint16 {
70 func (endpoint *RmrEndpoint) Set(src string) bool {
71 elems := strings.Split(src, ":")
74 srcPort, err := strconv.ParseUint(elems[1], 10, 16)
76 endpoint.Addr = srcAddr
77 endpoint.Port = uint16(srcPort)
84 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
87 type RmrEndpointList struct {
88 Endpoints []RmrEndpoint
91 func (eplist *RmrEndpointList) String() string {
92 tmpList := eplist.Endpoints
93 valuesText := []string{}
94 for i := range tmpList {
95 valuesText = append(valuesText, tmpList[i].String())
97 return strings.Join(valuesText, ",")
100 func (eplist *RmrEndpointList) Size() int {
101 return len(eplist.Endpoints)
104 func (eplist *RmrEndpointList) AddEndpoint(ep *RmrEndpoint) bool {
105 for i := range eplist.Endpoints {
106 if eplist.Endpoints[i].Equal(ep) {
110 eplist.Endpoints = append(eplist.Endpoints, *ep)
114 func (eplist *RmrEndpointList) DelEndpoint(ep *RmrEndpoint) bool {
115 for i := range eplist.Endpoints {
116 if eplist.Endpoints[i].Equal(ep) {
117 eplist.Endpoints[i] = eplist.Endpoints[len(eplist.Endpoints)-1]
118 eplist.Endpoints[len(eplist.Endpoints)-1] = RmrEndpoint{"", 0}
119 eplist.Endpoints = eplist.Endpoints[:len(eplist.Endpoints)-1]
126 func (eplist *RmrEndpointList) DelEndpoints(otheplist *RmrEndpointList) bool {
127 var retval bool = false
128 for i := range otheplist.Endpoints {
129 if eplist.DelEndpoint(&otheplist.Endpoints[i]) {
136 func (eplist *RmrEndpointList) HasEndpoint(ep *RmrEndpoint) bool {
137 for i := range eplist.Endpoints {
138 if eplist.Endpoints[i].Equal(ep) {
145 func NewRmrEndpoint(src string) *RmrEndpoint {
147 if ep.Set(src) == false {
153 //-----------------------------------------------------------------------------
154 // To add own method for rmrparams
155 //-----------------------------------------------------------------------------
156 type RMRParams struct {
160 func (params *RMRParams) String() string {
162 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)