New API added for debugging rmr rx queue
[ric-plt/lib/rmr.git] / src / rmr / common / include / rmr.h
index a824a2a..aeefa57 100644 (file)
@@ -39,7 +39,10 @@ extern "C" {
 #define RMR_MAX_MEID           32              // spece in header reserved for managed element id
 #define RMR_MAX_SRC                    64              // max length of hostname (which could be IPv6 addr with [...]:port so more than the 39 bytes of a plain addr
 #define RMR_MAX_SID                    32              // misc sender info/data (reserved)
 #define RMR_MAX_MEID           32              // spece in header reserved for managed element id
 #define RMR_MAX_SRC                    64              // max length of hostname (which could be IPv6 addr with [...]:port so more than the 39 bytes of a plain addr
 #define RMR_MAX_SID                    32              // misc sender info/data (reserved)
-#define RMR_MAX_RCV_BYTES      4096    // max bytes we support in a receive message
+
+
+#define RMR_MAX_RCV_BYTES      1024 * 2        // DEPRECATED CONSTANT NAME as underlying transport no longer have a max receive size
+#define RMR_DEF_MSG_SIZE       1024    // default message size that applications might want to use
 
                                                                        // various flags for function calls
 #define RMRFL_NONE                     0x00    // no flags
 
                                                                        // various flags for function calls
 #define RMRFL_NONE                     0x00    // no flags
@@ -47,6 +50,7 @@ extern "C" {
 #define RMRFL_MTCALL           0x02    // set up multi-threaded call support (rmr_init)
 #define RMRFL_AUTO_ALLOC       0x03    // send auto allocates a zerocopy buffer
 #define RMRFL_NAME_ONLY                0x04    // only the hostname:ip is provided as source information for rts() calls
 #define RMRFL_MTCALL           0x02    // set up multi-threaded call support (rmr_init)
 #define RMRFL_AUTO_ALLOC       0x03    // send auto allocates a zerocopy buffer
 #define RMRFL_NAME_ONLY                0x04    // only the hostname:ip is provided as source information for rts() calls
+#define RMRFL_NOLOCK           0x08    // disable receive ring locking (user app ensures single thread or provides collision protection)
 
 #define RMR_DEF_SIZE           0               // pass as size to have msg allocation use the default msg size
 
 
 #define RMR_DEF_SIZE           0               // pass as size to have msg allocation use the default msg size
 
@@ -71,6 +75,11 @@ extern "C" {
 #define RMR_ERR_INITFAILED     15              // initialisation of something (probably message) failed
 #define RMR_ERR_NOTSUPP                16              // the request is not supported, or RMr was not initialised for the request
 
 #define RMR_ERR_INITFAILED     15              // initialisation of something (probably message) failed
 #define RMR_ERR_NOTSUPP                16              // the request is not supported, or RMr was not initialised for the request
 
+#define RMR_NO_CLONE           0               // parm constants for better readability
+#define RMR_CLONE                      1
+#define RMR_NO_COPY                    0
+#define RMR_COPY                       1
+
 #define RMR_WH_CONNECTED(a) (a>=0)     // for now whid is integer; it could be pointer at some future date
 
 /*
 #define RMR_WH_CONNECTED(a) (a>=0)     // for now whid is integer; it could be pointer at some future date
 
 /*
@@ -78,6 +87,14 @@ extern "C" {
 
        (All fields are exposed such that if a wrapper needs to dup the storage as it passes
        into or out of their environment they dup it all, not just what we choose to expose.)
 
        (All fields are exposed such that if a wrapper needs to dup the storage as it passes
        into or out of their environment they dup it all, not just what we choose to expose.)
+
+       NOTE:
+       State is the RMR state of processing on the message. The transport state (tp_state)
+       will be set to mirror the value of errno for wrappers unable to access errno directly,
+       but will only be set if state is not RMR_OK. Even then, the value may be suspect as
+       the underlying transport mechanism may not set errno. It is strongly recommended that
+       user applications use tp_state only for dianostic purposes to convey additional information
+       in a log message.
 */
 typedef struct {
        int     state;                                  // state of processing
 */
 typedef struct {
        int     state;                                  // state of processing
@@ -86,6 +103,7 @@ typedef struct {
        unsigned char* payload;         // transported data
        unsigned char* xaction;         // pointer to fixed length transaction id bytes
        int sub_id;                                     // subscription id
        unsigned char* payload;         // transported data
        unsigned char* xaction;         // pointer to fixed length transaction id bytes
        int sub_id;                                     // subscription id
+       int             tp_state;                       // transport state (errno) valid only if state != RMR_OK, and even then may not be valid
 
                                                                // these things are off limits to the user application
        void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)
 
                                                                // these things are off limits to the user application
        void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)
@@ -93,6 +111,11 @@ typedef struct {
        unsigned char* id;                      // if we need an ID in the message separate from the xaction id
        int             flags;                          // various MFL_ (private) flags as needed
        int             alloc_len;                      // the length of the allocated space (hdr+payload)
        unsigned char* id;                      // if we need an ID in the message separate from the xaction id
        int             flags;                          // various MFL_ (private) flags as needed
        int             alloc_len;                      // the length of the allocated space (hdr+payload)
+
+       void*   ring;                           // ring this buffer should be queued back to
+       int             rts_fd;                         // SI fd for return to sender
+
+       int             cookie;                         // cookie to detect user misuse of free'd msg
 } rmr_mbuf_t;
 
 
 } rmr_mbuf_t;
 
 
@@ -103,6 +126,7 @@ typedef int rmr_whid_t;                     // wormhole identifier returned by rmr_wh_open(), pass
 extern rmr_mbuf_t* rmr_alloc_msg( void* vctx, int size );
 extern rmr_mbuf_t* rmr_call( void* vctx, rmr_mbuf_t* msg );
 extern void rmr_close( void* vctx );
 extern rmr_mbuf_t* rmr_alloc_msg( void* vctx, int size );
 extern rmr_mbuf_t* rmr_call( void* vctx, rmr_mbuf_t* msg );
 extern void rmr_close( void* vctx );
+extern void rmr_set_fack( void* vctx );
 extern void* rmr_init( char* proto_port, int max_msg_size, int flags );
 extern int rmr_init_trace( void* vctx, int size );
 extern int rmr_payload_size( rmr_mbuf_t* msg );
 extern void* rmr_init( char* proto_port, int max_msg_size, int flags );
 extern int rmr_init_trace( void* vctx, int size );
 extern int rmr_payload_size( rmr_mbuf_t* msg );
@@ -115,10 +139,13 @@ extern int rmr_ready( void* vctx );
 extern int rmr_set_rtimeout( void* vctx, int time );
 extern int rmr_set_stimeout( void* vctx, int time );
 extern int rmr_get_rcvfd( void* vctx );                                                                // only supported with nng
 extern int rmr_set_rtimeout( void* vctx, int time );
 extern int rmr_set_stimeout( void* vctx, int time );
 extern int rmr_get_rcvfd( void* vctx );                                                                // only supported with nng
+extern void rmr_set_low_latency( void* vctx );
 extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to );
 extern rmr_mbuf_t*  rmr_tralloc_msg( void* context, int msize, int trsize, unsigned const char* data );
 extern rmr_whid_t rmr_wh_open( void* vctx, char const* target );
 extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to );
 extern rmr_mbuf_t*  rmr_tralloc_msg( void* context, int msize, int trsize, unsigned const char* data );
 extern rmr_whid_t rmr_wh_open( void* vctx, char const* target );
+extern rmr_mbuf_t* rmr_wh_call( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg, int call_id, int max_wait );
 extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg );
 extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg );
+extern int rmr_wh_state( void* vctx, rmr_whid_t whid );
 extern void rmr_wh_close( void* vctx, int whid );
 
 // ----- mt call support --------------------------------------------------------------------------------
 extern void rmr_wh_close( void* vctx, int whid );
 
 // ----- mt call support --------------------------------------------------------------------------------
@@ -133,7 +160,9 @@ extern void rmr_free_msg( rmr_mbuf_t* mbuf );
 extern unsigned char*  rmr_get_meid( rmr_mbuf_t* mbuf, unsigned char* dest );
 extern unsigned char*  rmr_get_src( rmr_mbuf_t* mbuf, unsigned char* dest );
 extern unsigned char* rmr_get_srcip( rmr_mbuf_t* msg, unsigned char* dest );
 extern unsigned char*  rmr_get_meid( rmr_mbuf_t* mbuf, unsigned char* dest );
 extern unsigned char*  rmr_get_src( rmr_mbuf_t* mbuf, unsigned char* dest );
 extern unsigned char* rmr_get_srcip( rmr_mbuf_t* msg, unsigned char* dest );
+extern unsigned char*  rmr_get_xact( rmr_mbuf_t* mbuf, unsigned char* dest );
 extern rmr_mbuf_t* rmr_realloc_msg( rmr_mbuf_t* mbuf, int new_tr_size );
 extern rmr_mbuf_t* rmr_realloc_msg( rmr_mbuf_t* mbuf, int new_tr_size );
+extern rmr_mbuf_t* rmr_realloc_payload( rmr_mbuf_t* old_msg, int new_len, int copy, int clone );
 extern int rmr_str2meid( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern int rmr_str2meid( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str );
@@ -147,6 +176,18 @@ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size )
 extern int rmr_rcv_to( void* vctx, int time );         // DEPRECATED -- replaced with set_rtimeout
 extern int rmr_send_to( void* vctx, int time );                // DEPRECATED -- replaced with set_stimeout
 
 extern int rmr_rcv_to( void* vctx, int time );         // DEPRECATED -- replaced with set_rtimeout
 extern int rmr_send_to( void* vctx, int time );                // DEPRECATED -- replaced with set_stimeout
 
+// ---- misc user interface stuff ----------------------------------------------------------------------
+extern void rmr_set_vlevel( int new_level );
+
+// ---- rmr status debug structures --------------------------------------------------------------------
+typedef struct {
+  uint64_t drop;    // accumulated number of dropped msg
+  uint64_t enqueue; // accumulated number of enqueued msg
+} rmr_rx_debug_t;
+
+// ---- rmr status debug api ---------------------------------------------------------------------------
+extern int rmr_reset_rx_debug_count(void *vctx);
+extern int rmr_get_rx_debug_info(void *vctx, rmr_rx_debug_t *rx_rst);
 
 // --- uta compatability defs if needed user should define UTA_COMPAT  ----------------------------------
 #ifdef UTA_COMPAT
 
 // --- uta compatability defs if needed user should define UTA_COMPAT  ----------------------------------
 #ifdef UTA_COMPAT