X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2FrmrCgo%2FrmrCgoUtils.go;h=c9d11471de030b5b2ffb05568156fe4059dd6db9;hb=HEAD;hp=fe9c99df97e192672279ac26af560af9a45c6c9b;hpb=19bf35ea1556e746bbcbcaa8090033bd38fe71b7;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/rmrCgo/rmrCgoUtils.go b/E2Manager/rmrCgo/rmrCgoUtils.go index fe9c99d..c9d1147 100644 --- a/E2Manager/rmrCgo/rmrCgoUtils.go +++ b/E2Manager/rmrCgo/rmrCgoUtils.go @@ -13,11 +13,14 @@ // 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 -// #cgo LDFLAGS: -L/usr/local/lib -lrmr_nng -lnng +// #cgo LDFLAGS: -L/usr/local/lib -lrmr_si // #include // #include import "C" @@ -42,8 +45,11 @@ func convertToMBuf(logger *logger.Logger, m *C.rmr_mbuf_t) *MBuf { Len: int(m.len), Payload: &payloadArr, XAction: &xActionArr, + msgSrc: C.CBytes(make([]byte, RMR_MAX_SRC_LEN)), } + C.rmr_get_src(m, (*C.uchar)(mbuf.msgSrc)) // Capture message source + 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") @@ -57,6 +63,9 @@ func (ctx *Context) getAllocatedCRmrMBuf(logger *logger.Logger, mBuf *MBuf, maxM var meidBuf[RMR_MAX_MEID_LEN]byte cMBuf = C.rmr_alloc_msg(ctx.RmrCtx, C.int(maxMsgSize)) + if cMBuf == nil { + return nil + } cMBuf.mtype = C.int(mBuf.MType) cMBuf.len = C.int(mBuf.Len) @@ -99,9 +108,9 @@ func (ctx *Context) getAllocatedCRmrMBuf(logger *logger.Logger, mBuf *MBuf, maxM //TODO: change to assert or return error func (ctx *Context) checkContextInitialized() { if ctx.RmrCtx == nil { - if ctx.Logger != nil { + /*if ctx.Logger != nil { ctx.Logger.DPanicf("#rmrCgoUtils.checkContextInitialized - The RMR router has not been initialized") - } + }*/ panic("#rmrCgoUtils.checkContextInitialized - The RMR router has not been initialized. To initialize router please call Init() method") } }