X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Frmr%2Frmr.go;fp=a1-go%2Fpkg%2Frmr%2Frmr.go;h=78adf46499bf23c889782c115ed9d3382f19beb0;hb=1a41ce75dbf508ae4d85c2dc4a562f36da04bb65;hp=0000000000000000000000000000000000000000;hpb=6242a3ff1b95eb8fc89931b11115ec9c06d08e96;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/rmr/rmr.go b/a1-go/pkg/rmr/rmr.go new file mode 100644 index 0000000..78adf46 --- /dev/null +++ b/a1-go/pkg/rmr/rmr.go @@ -0,0 +1,74 @@ +/* +================================================================================== + Copyright (c) 2022 Samsung + + 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 rmr + +import ( + "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" +) + +const ( + a1PolicyRequest = 20010 + a1SourceName = "service-ricplt-a1mediator-http" +) + +type RmrSender struct { + rmrclient *xapp.RMRClient +} + +type IRmrSender interface { + RmrSendToXapp(httpBodyString string) bool +} + +func NewRMRSender() IRmrSender { + RMRclient := xapp.NewRMRClientWithParams(&xapp.RMRClientParams{ + StatDesc: "", + RmrData: xapp.PortData{ + Name: "", + MaxSize: 65534, + ThreadType: 0, + LowLatency: false, + FastAck: false, + MaxRetryOnFailure: 1, + }, + }) + return &RmrSender{ + rmrclient: RMRclient, + } +} + +func (rmr *RmrSender) RmrSendToXapp(httpBodyString string) bool { + + params := &xapp.RMRParams{} + params.Mtype = a1PolicyRequest + params.SubId = -1 + params.Xid = "" + params.Meid = &xapp.RMRMeid{} + params.Src = a1SourceName + params.PayloadLen = len([]byte(httpBodyString)) + params.Payload = []byte(httpBodyString) + a1.Logger.Debug("MSG to XAPP: %s ", params.String()) + a1.Logger.Debug("len payload %+v", len(params.Payload)) + s := rmr.rmrclient.SendMsg(params) + a1.Logger.Debug("rmrSendToXapp: sending: %+v", s) + return s +}