X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=RSM%2Frmrcgo%2Frmr_c_go_utils.go;h=edf86d5fed11bee1dc851efc428acd8afbb1a7cb;hb=60652d98d51ee23c1eaca2e8bc2bf19c74c57658;hp=777f81a18c848f655de48c90776d8661de636116;hpb=7b80668df78103cebafdfb7caa0070dc92ed3779;p=ric-plt%2Fresource-status-manager.git diff --git a/RSM/rmrcgo/rmr_c_go_utils.go b/RSM/rmrcgo/rmr_c_go_utils.go index 777f81a..edf86d5 100644 --- a/RSM/rmrcgo/rmr_c_go_utils.go +++ b/RSM/rmrcgo/rmr_c_go_utils.go @@ -13,7 +13,10 @@ // 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 rmrcgo @@ -30,23 +33,23 @@ import ( ) func convertToMBuf(m *C.rmr_mbuf_t) *MBuf { - payloadArr := C.GoBytes(unsafe.Pointer(m.payload),C.int(m.len)) - xActionArr := C.GoBytes(unsafe.Pointer(m.xaction),C.int(RMR_MAX_XACTION_LEN)) + payloadArr := C.GoBytes(unsafe.Pointer(m.payload), C.int(m.len)) + xActionArr := C.GoBytes(unsafe.Pointer(m.xaction), C.int(RMR_MAX_XACTION_LEN)) // Trim padding (space and 0) - xActionStr := strings.TrimRight(string(xActionArr),"\040\000") + xActionStr := strings.TrimRight(string(xActionArr), "\040\000") xActionArr = []byte(xActionStr) mbuf := &MBuf{ - MType: int(m.mtype), - Len: int(m.len), + MType: int(m.mtype), + Len: int(m.len), Payload: &payloadArr, XAction: &xActionArr, } meidBuf := make([]byte, RMR_MAX_MEID_LEN) if meidCstr := C.rmr_get_meid(m, (*C.uchar)(unsafe.Pointer(&meidBuf[0]))); meidCstr != nil { - mbuf.Meid = strings.TrimRight(string(meidBuf), "\000") + mbuf.Meid = strings.TrimRight(string(meidBuf), "\000") } return mbuf @@ -54,7 +57,7 @@ func convertToMBuf(m *C.rmr_mbuf_t) *MBuf { func (ctx *Context) getAllocatedCRmrMBuf(logger *logger.Logger, mBuf *MBuf, maxMsgSize int) (cMBuf *C.rmr_mbuf_t) { var xActionBuf [RMR_MAX_XACTION_LEN]byte - var meidBuf[RMR_MAX_MEID_LEN]byte + var meidBuf [RMR_MAX_MEID_LEN]byte cMBuf = C.rmr_alloc_msg(ctx.RmrCtx, C.int(maxMsgSize)) cMBuf.mtype = C.int(mBuf.MType) @@ -65,13 +68,13 @@ func (ctx *Context) getAllocatedCRmrMBuf(logger *logger.Logger, mBuf *MBuf, maxM //Add padding copy(xActionBuf[:], *mBuf.XAction) - for i:= xActionLen; i < RMR_MAX_XACTION_LEN; i++{ + for i := xActionLen; i < RMR_MAX_XACTION_LEN; i++ { xActionBuf[i] = '\040' //space } // Add padding copy(meidBuf[:], mBuf.Meid) - for i:= len(mBuf.Meid); i < RMR_MAX_MEID_LEN; i++{ + for i := len(mBuf.Meid); i < RMR_MAX_MEID_LEN; i++ { meidBuf[i] = 0 } @@ -88,7 +91,7 @@ func (ctx *Context) getAllocatedCRmrMBuf(logger *logger.Logger, mBuf *MBuf, maxM ctx.Logger.Errorf( "#rmrCgoUtils.getAllocatedCRmrMBuf - Failed to read xAction data to allocated RMR message buffer") } - len := C.rmr_bytes2meid(cMBuf, (*C.uchar)(unsafe.Pointer(&meidBuf[0])), C.int(RMR_MAX_MEID_LEN)) + len := C.rmr_bytes2meid(cMBuf, (*C.uchar)(unsafe.Pointer(&meidBuf[0])), C.int(RMR_MAX_MEID_LEN)) if int(len) != RMR_MAX_MEID_LEN { ctx.Logger.Errorf( "#rmrCgoUtils.getAllocatedCRmrMBuf - Failed to copy meid data to allocated RMR message buffer")