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) HasEndpoint(ep *RmrEndpoint) bool {
95 for i := range eplist.Endpoints {
96 if (eplist.Endpoints[i].Addr == ep.Addr) && (eplist.Endpoints[i].Port == ep.Port) {
103 func NewRmrEndpoint(src string) *RmrEndpoint {
105 if ep.Set(src) == false {
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
116 func (act Action) String() string {
117 actions := [...]string{
124 if act < CREATE || act > DELETE {
130 //-----------------------------------------------------------------------------
131 // To add own method for rmrparams
132 //-----------------------------------------------------------------------------
133 type RMRParams struct {
137 func (params *RMRParams) String() string {
139 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)