Add rmr_get_xact function
[ric-plt/lib/rmr.git] / src / rmr / common / include / rmr.h
index e6c1660..d43d3ba 100644 (file)
@@ -36,14 +36,17 @@ extern "C" {
 
 
 #define RMR_MAX_XID                    32              // space in header reserved for user xaction id
 
 
 #define RMR_MAX_XID                    32              // space in header reserved for user xaction id
-#define RMR_MAX_SID                    32              // spece in header reserved for sender id
 #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_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
 
                                                                        // various flags for function calls
 #define RMRFL_NONE                     0x00    // no flags
 #define RMR_MAX_RCV_BYTES      4096    // max bytes we support in a receive message
 
                                                                        // various flags for function calls
 #define RMRFL_NONE                     0x00    // no flags
-#define RMRFL_AUTO_ALLOC       0x01    // send auto allocates a zerocopy buffer
+#define RMRFL_NOTHREAD         0x01    // do not start an additional route collector thread
+#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 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
 
@@ -66,6 +69,7 @@ extern "C" {
 #define RMR_ERR_UNSET          13              // the message hasn't been populated with a transport buffer
 #define        RMR_ERR_TRUNC           14              // received message likely truncated
 #define RMR_ERR_INITFAILED     15              // initialisation of something (probably message) failed
 #define RMR_ERR_UNSET          13              // the message hasn't been populated with a transport buffer
 #define        RMR_ERR_TRUNC           14              // received message likely truncated
 #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_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
 
@@ -74,6 +78,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
@@ -82,6 +94,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)
@@ -117,6 +130,9 @@ 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 void rmr_wh_close( void* vctx, int whid );
 
 extern rmr_mbuf_t* rmr_wh_send_msg( void* vctx, rmr_whid_t whid, rmr_mbuf_t* msg );
 extern void rmr_wh_close( void* vctx, int whid );
 
+// ----- mt call support --------------------------------------------------------------------------------
+extern rmr_mbuf_t* rmr_mt_call( void* vctx, rmr_mbuf_t* mbuf, int call_id, int max_wait );
+extern rmr_mbuf_t* rmr_mt_rcv( void* vctx, rmr_mbuf_t* mbuf, int max_wait );
 
 // ----- msg buffer operations (no context needed) ------------------------------------------------------
 extern int rmr_bytes2meid( rmr_mbuf_t* mbuf, unsigned char const* src, int len );
 
 // ----- msg buffer operations (no context needed) ------------------------------------------------------
 extern int rmr_bytes2meid( rmr_mbuf_t* mbuf, unsigned char const* src, int len );
@@ -125,11 +141,14 @@ extern int rmr_bytes2xact( rmr_mbuf_t* mbuf, unsigned char const* src, int len )
 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 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 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_str2xact( rmr_mbuf_t* mbuf, unsigned char const* str );
 extern rmr_mbuf_t* rmr_realloc_msg( rmr_mbuf_t* mbuf, int new_tr_size );
 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_str2xact( rmr_mbuf_t* mbuf, unsigned char const* str );
+extern void* rmr_trace_ref( rmr_mbuf_t* msg, int* sizeptr );
 
 extern int rmr_get_trlen( rmr_mbuf_t* msg );
 extern int rmr_get_trace( rmr_mbuf_t* msg, unsigned char* dest, int size );
 
 extern int rmr_get_trlen( rmr_mbuf_t* msg );
 extern int rmr_get_trace( rmr_mbuf_t* msg, unsigned char* dest, int size );