X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2FrmrCgo%2FrmrCgoApi.go;h=5ec09b984d1809a3e9b25b9d019871e1eceff073;hb=b3805a9d29e2c7f6f14e3fedfa1ba504f734eea9;hp=d247efb73954ced897d34aef54a5c51bfc97ac77;hpb=a75da9a56d61ca4754650d44a54bbf0b04f610d1;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/rmrCgo/rmrCgoApi.go b/E2Manager/rmrCgo/rmrCgoApi.go index d247efb..5ec09b9 100644 --- a/E2Manager/rmrCgo/rmrCgoApi.go +++ b/E2Manager/rmrCgo/rmrCgoApi.go @@ -87,6 +87,41 @@ func (ctx *Context) SendMsg(msg *MBuf, printLogs bool) (*MBuf, error) { return convertToMBuf(ctx.Logger, currCMBuf), nil } +func (ctx *Context) WhSendMsg(msg *MBuf, printLogs bool) (*MBuf, error) { + ctx.checkContextInitialized() + ctx.Logger.Debugf("#rmrCgoApi.WhSendMsg - Going to wormhole send message. MBuf: %v", *msg) + + whid := C.rmr_wh_open(ctx.RmrCtx, (*C.char)(msg.GetMsgSrc())) // open direct connection, returns wormhole ID + ctx.Logger.Infof("#rmrCgoApi.WhSendMsg - The wormhole id %v has been received", whid) + defer C.rmr_wh_close(ctx.RmrCtx, whid) + + allocatedCMBuf := ctx.getAllocatedCRmrMBuf(ctx.Logger, msg, ctx.MaxMsgSize) + state := allocatedCMBuf.state + if state != RMR_OK { + errorMessage := fmt.Sprintf("#rmrCgoApi.WhSendMsg - Failed to get allocated message. state: %v - %s", state, states[int(state)]) + return nil, errors.New(errorMessage) + } + + if printLogs { + transactionId := string(*msg.XAction) + tmpTid := strings.TrimSpace(transactionId) + ctx.Logger.Infof("[E2 Manager -> RMR] #rmrCgoApi.WhSendMsg - Going to send message %v for transaction id: %s", *msg, tmpTid) + } + + currCMBuf := C.rmr_wh_send_msg(ctx.RmrCtx, whid, allocatedCMBuf) + defer C.rmr_free_msg(currCMBuf) + + state = currCMBuf.state + + if state != RMR_OK { + errorMessage := fmt.Sprintf("#rmrCgoApi.WhSendMsg - Failed to send message. state: %v - %s", state, states[int(state)]) + return nil, errors.New(errorMessage) + } + + return convertToMBuf(ctx.Logger, currCMBuf), nil +} + + func (ctx *Context) RecvMsg() (*MBuf, error) { ctx.checkContextInitialized() ctx.Logger.Debugf("#rmrCgoApi.RecvMsg - Going to receive message")