Add wormhole state check function
[ric-plt/lib/rmr.git] / src / rmr / common / include / rmr.h
index a824a2a..cc2c0c8 100644 (file)
@@ -47,6 +47,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_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
 
@@ -78,6 +79,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.)
+
+       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
@@ -86,6 +95,7 @@ typedef struct {
        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)
@@ -93,6 +103,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)
+
+       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;
 
 
@@ -103,6 +118,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 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 );
@@ -115,10 +131,12 @@ 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 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_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 --------------------------------------------------------------------------------
@@ -133,7 +151,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_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_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 );
@@ -147,6 +167,8 @@ 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
 
+// ---- misc user interface stuff ----------------------------------------------------------------------
+extern void rmr_set_vlevel( int new_level );
 
 // --- uta compatability defs if needed user should define UTA_COMPAT  ----------------------------------
 #ifdef UTA_COMPAT