fix(rtable): Potential memory leak in rte replace
[ric-plt/lib/rmr.git] / src / common / include / rmr.h
index 15c8400..e6c1660 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
 
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
 
-       http://www.apache.org/licenses/LICENSE-2.0
+          http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -47,6 +47,8 @@ extern "C" {
 
 #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
 
+#define RMR_VOID_MSGTYPE       (-1)    // unset/invalid message type and sub id
+#define RMR_VOID_SUBID         (-1)
 
 #define RMR_OK                         0               // state is good
 #define RMR_ERR_BADARG         1               // argument passd to function was unusable
 
 #define RMR_OK                         0               // state is good
 #define RMR_ERR_BADARG         1               // argument passd to function was unusable
@@ -74,14 +76,15 @@ extern "C" {
        into or out of their environment they dup it all, not just what we choose to expose.)
 */
 typedef struct {
        into or out of their environment they dup it all, not just what we choose to expose.)
 */
 typedef struct {
-       int             state;                          // state of processing
+       int     state;                                  // state of processing
        int     mtype;                                  // message type
        int     len;                                    // length of data in the payload (send or received)
        unsigned char* payload;         // transported data
        unsigned char* xaction;         // pointer to fixed length transaction id bytes
        int     mtype;                                  // message type
        int     len;                                    // length of data in the payload (send or received)
        unsigned char* payload;         // transported data
        unsigned char* xaction;         // pointer to fixed length transaction id bytes
+       int sub_id;                                     // subscription id
 
                                                                // these things are off limits to the user application
 
                                                                // these things are off limits to the user application
-       void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)    
+       void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)
        void*   header;                         // internal message header (whole buffer: header+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
        void*   header;                         // internal message header (whole buffer: header+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
@@ -121,6 +124,7 @@ extern void rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char const* src, int l
 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 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 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 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 );
@@ -139,23 +143,23 @@ extern int rmr_send_to( void* vctx, int time );           // DEPRECATED -- replaced with
 #ifdef UTA_COMPAT
 #pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
 
 #ifdef UTA_COMPAT
 #pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
 
-#define UTA_MAX_XID RMR_MAX_XID 
-#define UTA_MAX_SID    RMR_MAX_SID 
-#define UTA_MAX_SRC RMR_MAX_SRC 
-#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES 
+#define UTA_MAX_XID RMR_MAX_XID
+#define UTA_MAX_SID    RMR_MAX_SID
+#define UTA_MAX_SRC RMR_MAX_SRC
+#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES
 
 
-#define UTAFL_NONE             RMRFL_NONE 
-#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC 
+#define UTAFL_NONE             RMRFL_NONE
+#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC
 
 
-#define UTA_DEF_SIZE   RMRFL_AUTO_ALLOC 
+#define UTA_DEF_SIZE   RMRFL_AUTO_ALLOC
 
 
-#define UTA_OK                  RMR_OK 
-#define UTA_ERR_BADARG RMR_ERR_BADARG 
-#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT        
+#define UTA_OK                  RMR_OK
+#define UTA_ERR_BADARG RMR_ERR_BADARG
+#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT
 #define UTA_ERR_EMPTY  RMR_ERR_EMPTY
 #define UTA_ERR_EMPTY  RMR_ERR_EMPTY
-#define UTA_ERR_NOHDR  RMR_ERR_NOHDR 
-#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED 
-#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED 
+#define UTA_ERR_NOHDR  RMR_ERR_NOHDR
+#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED
+#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED
 
 #define uta_mbuf_t rmr_mbuf_t
 
 
 #define uta_mbuf_t rmr_mbuf_t