Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief ATMI internals
0003  *
0004  * @file atmi_int.h
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012  * See LICENSE file for full text.
0013  * -----------------------------------------------------------------------------
0014  * AGPL license:
0015  *
0016  * This program is free software; you can redistribute it and/or modify it under
0017  * the terms of the GNU Affero General Public License, version 3 as published
0018  * by the Free Software Foundation;
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023  * for more details.
0024  *
0025  * You should have received a copy of the GNU Affero General Public License along 
0026  * with this program; if not, write to the Free Software Foundation, Inc.,
0027  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028  *
0029  * -----------------------------------------------------------------------------
0030  * A commercial use license is available from Mavimax, Ltd
0031  * contact@mavimax.com
0032  * -----------------------------------------------------------------------------
0033  */
0034 
0035 #ifndef ATMI_INT_H
0036 #define ATMI_INT_H
0037 
0038 #ifdef  __cplusplus
0039 extern "C" {
0040 #endif
0041 
0042 /*---------------------------Includes-----------------------------------*/
0043 #include <sys_mqueue.h>
0044 #include <xa.h>
0045 #include <atmi.h>
0046 #include <ndrxdcmn.h>
0047 #include <stdint.h>
0048 #include <nstopwatch.h>
0049 #include <sys/sem.h>
0050 #include <exhash.h>
0051 #include <ndrstandard.h>
0052 #include <userlog.h>
0053 #include <tperror.h>
0054 #include <exparson.h>
0055 #include <tmenv.h>
0056 #include <nstdutil.h>
0057 /*---------------------------Externs------------------------------------*/
0058 /*---------------------------Macros-------------------------------------*/
0059 
0060 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
0061 #define NDRX_API_EXPORT __declspec(dllexport)
0062 #else
0063 #define NDRX_API_EXPORT
0064 #endif
0065 
0066 /*
0067  * List of internal queue errors
0068  */
0069 #define GEN_QUEUE_ERR_NO_DATA   -2
0070 
0071     
0072 /* Special queue logical numbers used by atmi server */
0073 #define ATMI_SRV_ADMIN_Q            0           /**< This is admin queue */
0074 #define ATMI_SRV_REPLY_Q            1           /**< This is reply queue */
0075 #define ATMI_SRV_Q_ADJUST           2           /**< Adjustment for Q nr */
0076 #define ATMI_SRV_SVC                3           /**< Normal service Q    */
0077 
0078 /*
0079  * List of ATMI internal protocol commands
0080  */
0081 #define ATMI_COMMAND_UNKNOWN    0
0082 #define ATMI_COMMAND_TPCALL     1
0083 #define ATMI_COMMAND_TPREPLY    2
0084 #define ATMI_COMMAND_TPFORWARD  3
0085 #define ATMI_COMMAND_CONNECT    4
0086 #define ATMI_COMMAND_CONVDATA   5
0087 #define ATMI_COMMAND_CONNRPLY   6
0088 #define ATMI_COMMAND_DISCONN    7
0089 #define ATMI_COMMAND_CONNUNSOL  8
0090 #define ATMI_COMMAND_CONVACK    9
0091 #define ATMI_COMMAND_SHUTDOWN   10
0092 /* #define ATMI_COMMAND_EVPOST     11 */
0093 #define ATMI_COMMAND_SELF_SD    12      /* Self shutdown                */
0094 #define ATMI_COMMAND_TPNOTIFY   13      /* Notification message         */
0095 #define ATMI_COMMAND_BROADCAST  14      /* Broadcast notification       */
0096 
0097 /* Call states */
0098 #define CALL_NOT_ISSUED         0
0099 #define CALL_WAITING_FOR_ANS    1
0100 #define CALL_CANCELED           2
0101 
0102 
0103 /* Global conversation status */
0104 #define CONV_NO_INITATED          0
0105 #define CONV_IN_CONVERSATION      1
0106 
0107 /* Translate error code */
0108 #define CONV_ERROR_CODE(_ret, _err) \
0109             if (EINTR==_ret)\
0110             {\
0111                 _err=TPGOTSIG;\
0112             }\
0113             else if (ETIMEDOUT==_ret)\
0114             {\
0115                 _err=TPETIME;\
0116             }\
0117             else if (EAGAIN==_ret)\
0118             {\
0119                 _err=TPEBLOCK;\
0120             }\
0121             else\
0122             {\
0123                 _err=TPEOS;\
0124             }
0125 
0126 #define TPEXIT_ENOENT           150             /* No such file or directory */
0127     
0128 #define Q_SEND_GRACE            10              /* Number of messages for q to wait to process */
0129     
0130 /* Even processing */
0131 #define EV_TPEVSUBS         "TPEVSUBS%03hd"
0132 #define EV_TPEVUNSUBS       "TPEVUNSUBS%03hd"
0133 #define EV_TPEVPOST         "TPEVPOST%03hd"
0134 #define EV_TPEVDOPOST       "TPEVDOPOST%03hd"
0135     
0136 /* RECOVERY processing */
0137 #define TPRECOVERSVC        "TPRECOVER"     /* Recovery administrative service */
0138     
0139 /* Special flags for tpcallex */
0140 #define TPCALL_EVPOST               0x0001 /**< Event posting                 */
0141 #define TPCALL_BRCALL               0x0002 /**< Bridge call                   */
0142 #define TPCALL_BROADCAST            0x0004 /**< Broadcast call                */
0143 
0144 /* XA TM reason codes */
0145 /* Lower reason includes XA error code. 
0146  * Note! these reasons are not used in any state driving
0147  */    
0148 #define NDRX_XA_ERSN_BASE           2000
0149 #define NDRX_XA_ERSN_NONE           0      /**< No reason specified for error */
0150 #define NDRX_XA_ERSN_LOGFAIL        2001   /**< Log failed                    */
0151 #define NDRX_XA_ERSN_INVPARAM       2002   /**< Invalid parameters sent to TMS*/
0152 #define NDRX_XA_ERSN_NOTX           2003   /**< Transaction not logged        */
0153 #define NDRX_XA_ERSN_PREPFAIL       2004   /**< One of the nodes failed to prepare */
0154 #define NDRX_XA_ERSN_RMLOGFAIL      2005   /**< New RM logging failed         */
0155 #define NDRX_XA_ERSN_RMCOMMITFAIL   2006   /**< Some resource manager failed to commit */
0156 #define NDRX_XA_ERSN_UBFERR         2007   /**< UBF Error                     */
0157 #define NDRX_XA_ERSN_RMERR          2008   /**< Resource Manager Failed       */
0158 #define NDRX_XA_ERSN_TPENOENT       2009   /**< TMSRV is unavailable          */
0159 #define NDRX_XA_ERSN_INPROGRESS     2010   /**< Action already in progress    */
0160 #define NDRX_XA_ERSN_LOCK           2011   /**< Cannot acquire lock           */
0161 
0162     
0163 #define NDRX_XID_FORMAT_ID  0x6194f7a1L    /**< Enduro/X XID format id        */
0164 #define NDRX_XID_TRID_LEN   sizeof(exuuid_t)
0165 #define NDRX_XID_BQUAL_LEN  sizeof(unsigned char) + sizeof(short) + sizeof(short)
0166 
0167 /* Helpers: */    
0168 #define XA_IS_DYNAMIC_REG       (G_atmi_env.xa_sw->flags & TMREGISTER)
0169 #define NDRX_CONF_MSGSEQ_START  4294967294   /**< Have a high number for wrap test */    
0170     
0171 /* Memory allocation helpers */
0172 
0173 /**
0174  * Allocate buffer, if fail set UBF error, and goto out
0175  */
0176 #define NDRX_SYSBUF_MALLOC_WERR_OUT(__buf, __p_bufsz, __ret)  \
0177 {\
0178     int __buf_size__ = NDRX_MSGSIZEMAX;\
0179     __buf = NDRX_FPMALLOC(__buf_size__, NDRX_FPSYSBUF);\
0180     if (NULL==__buf)\
0181     {\
0182         int err = errno;\
0183         ndrx_TPset_error_fmt(TPEOS, "%s: failed to allocate sysbuf: %s", __func__, strerror(errno));\
0184         NDRX_LOG(log_error, "%s: failed to allocate sysbuf: %s", __func__, strerror(errno));\
0185         userlog("%s: failed to allocate sysbuf: %s", __func__, strerror(errno));\
0186         errno = err;\
0187         EXFAIL_OUT(__ret);\
0188     }\
0189     __p_bufsz = __buf_size__;\
0190 }
0191 
0192 #define NDRX_XA_FLAG_NOJOIN         "NOJOIN"      /**< XA Switch does not support TMJOIN mode  */
0193 #define NDRX_XA_FLAG_NOSTARTXID     "NOSTARTXID"  /**< No XID in start call to RM      */
0194 #define NDRX_XA_FLAG_NOSUSPEND      "NOSUSPEND"   /**< No automatic suspend            */
0195 #define NDRX_XA_FLAG_RECON          "RECON"       /**< Reconnect on tpbegin(), xa_start() if fails */
0196 #define NDRX_XA_FLAG_RECON_TEST     "RECON:"      /**< Test the line                   */
0197 #define NDRX_XA_FLAGS_RECON_RETCODES_BUFSZ  32    /**< List of error codes for retry   */
0198 #define NDRX_XA_FLAG_FSYNC          "FSYNC"       /**< Perform Fsync                   */
0199 #define NDRX_XA_FLAG_FDATASYNC      "FDATASYNC"   /**< Perform Fdatasync               */
0200 #define NDRX_XA_FLAG_DSYNC          "DSYNC"       /**< Perform directory sync          */
0201 #define NDRX_XA_FLAG_BTIGHT         "BTIGHT"      /**< Tight branches                  */
0202 
0203 /**
0204  * Internal system flags
0205  * @defgroup xa_flags_sys
0206  * @{
0207  */
0208 #define NDRX_XA_FLAG_SYS_NOAPISUSP      0x00000001  /**< No tran susp in contexting   */
0209 #define NDRX_XA_FLAG_SYS_NOJOIN         0x00000002  /**< No join supported            */
0210 #define NDRX_XA_FLAG_SYS_NOSTARTXID     0x00000004  /**< No XID given in start        */
0211 #define NDRX_XA_FLAG_SYS_NOSUSPEND      0x00000008  /**< Do not suspend automatically */
0212 #define NDRX_XA_FLAG_SYS_BTIGHT         0x00000010  /**< Tight branching              */
0213 
0214 /** @} */ /* xa_flags_sys */
0215     
0216 /**
0217  * use silent debug for some tools
0218  */
0219 #define NDRX_EMPTY_DEBUG do {\
0220         /* Empty debug */\
0221         if (NULL==getenv("NDRX_DEBUG_CONF"))\
0222         {\
0223             setenv("NDRX_DEBUG_CONF", "", 1);\
0224         }\
0225     }\
0226     while (0)
0227 
0228 /**
0229  * Use silent logging...
0230  */
0231 #define NDRX_BANNER(X)                      \
0232     if (NULL==getenv(CONF_NDRX_SILENT))     \
0233     {\
0234         if (X[0])\
0235         {\
0236             fprintf(stderr, "%s\n\n", X);\
0237         }\
0238         fprintf(stderr, "%s, build %s %s, using %s for %s (%ld bits)\n\n", NDRX_VERSION, \
0239                         __DATE__, __TIME__, ndrx_epoll_mode(), NDRX_BUILD_OS_NAME, sizeof(void *)*8);\
0240         fprintf(stderr, "Enduro/X Middleware Platform for Distributed Transaction Processing\n");\
0241         fprintf(stderr, "Copyright (C) 2009-2016 ATR Baltic Ltd.\n");\
0242         fprintf(stderr, "Copyright (C) 2017-2023 Mavimax Ltd. All Rights Reserved.\n\n");\
0243         fprintf(stderr, "This software is released under one of the following licenses:\n");\
0244         fprintf(stderr, "AGPLv3 (exceptions for Java, Go) or Mavimax license for commercial use.\n\n");\
0245     }
0246 
0247 /** Used by NDRX_SYSFLAGS env variable, Full application start */
0248 #define NDRX_PRC_SYSFLAGS_FULLSTART     0x00000001
0249 
0250 /** xadmin error format */
0251 #define NDRX_XADMIN_ERR_FMT_PFX         "ERROR ! "
0252 
0253 /** EINVAL on queues: */
0254 #define NDRX_QERR_MSG_EINVAL NDRX_XADMIN_ERR_FMT_PFX \
0255     "Invalid queue config, see \"Enduro/X Administration Manual\" (ex_adminman), chapter 2."
0256     
0257 /** ENOSPC on queues: */
0258 #define NDRX_QERR_MSG_ENOSPC NDRX_XADMIN_ERR_FMT_PFX \
0259     "Insufficient space for the creation of a new message queue"
0260     
0261 /** Generic queue error */
0262 #define NDRX_QERR_MSG_SYSERR NDRX_XADMIN_ERR_FMT_PFX \
0263     "Queue error, check logs"
0264     
0265 /** The 31 bit on, indicates that connection is servers accept one */
0266 #define NDRX_CONV_SRVMASK       0x40000000
0267     
0268     
0269 #define NDRX_MBUF_FLAG_NOCALLINFO   0x00000001  /**< Do not serialize callinfo  for mbuf*/
0270 /**
0271  * XATMI IPC internal flags (i.e. value for sysflags fields of the atmi call structs)
0272  * @defgroup sysflags
0273  * @{
0274  */
0275 #define SYS_FLAG_REPLY_ERROR    0x00000001
0276 #define SYS_CONVERSATION        0x00000002 /**< We have or was open conversation      */
0277 /* buffer management flags: */
0278 #define NDRX_SYS_SRV_THREAD     SYS_SRV_THREAD /**< value from xatmi.h                */
0279 #define SYS_SRV_CVT_JSON2UBF    0x00000008 /**< Message is converted from JSON to UBF */
0280 #define SYS_SRV_CVT_UBF2JSON    0x00000010 /**< Message is converted from UBF to JSON */
0281 
0282 #define SYS_SRV_CVT_JSON2VIEW   0x00000020 /**< Message is converted from JSON to VIEW */
0283 #define SYS_SRV_CVT_VIEW2JSON   0x00000040 /**< Message is converted from UBF to JSON (non NULL)*/
0284 #define SYS_FLAG_AUTOTRAN       0x00000100 /**< Auto transaction started               */
0285 /* Test is any flag set */
0286 #define SYS_SRV_CVT_ANY_SET(X) (X & SYS_SRV_CVT_JSON2UBF || X & SYS_SRV_CVT_UBF2JSON ||\
0287         X & SYS_SRV_CVT_JSON2VIEW || X & SYS_SRV_CVT_VIEW2JSON)
0288     
0289 /** @} */ /* sysflags */
0290 
0291     
0292 /** tpcall() abort only check start */
0293 #define NDRX_ABORT_START(IS_ABORT_ONLY) \
0294 /* Do not abort, if TPNOTRAN specified. */ \
0295     /* Feature #299 */ \
0296     if ( !(flags & TPNOTRAN) && !(flags & TPNOABORT) && \
0297     G_atmi_tls->G_atmi_xa_curtx.txinfo && \
0298         /* no abort if already aborted */ \
0299         !(G_atmi_tls->G_atmi_xa_curtx.txinfo->tmtxflags & TMTXFLAGS_IS_ABORT_ONLY) && \
0300     (EXSUCCEED!=ret || IS_ABORT_ONLY)) \
0301     { \
0302         int abort_needed = EXTRUE; \
0303         switch (tperrno) \
0304         { \
0305             case TPENOENT: \
0306             case TPEBADDESC: \
0307             case TPEINVAL: \
0308             case TPEITYPE: \
0309             case TPEBLOCK: \
0310                 NDRX_LOG(log_info, "No abort marking needed"); \
0311                 abort_needed=EXFALSE; \
0312                 break; \
0313         }
0314 
0315 /** tpcall() abort only end block*/
0316 #define NDRX_ABORT_END(IS_ABORT_ONLY) \
0317         if (abort_needed) \
0318         { \
0319             NDRX_LOG(log_warn, "Marking current transaction as abort only!"); \
0320             /* later should be handled by transaction initiator! */ \
0321             G_atmi_tls->G_atmi_xa_curtx.txinfo->tmtxflags |= TMTXFLAGS_IS_ABORT_ONLY; \
0322         } \
0323     }
0324 
0325 #define NDRX_SGCMD_VERIFY           "VERIFY" /**< Verfy the lock i   */
0326 #define NDRX_SGCMD_QUERY            "QUERY"  /**< Query lock status` */
0327 #define NDRX_SGMAX_CMDLEN            16      /**< command code buffer sz */
0328 
0329 /*---------------------------Enums--------------------------------------*/
0330 /*---------------------------Typedefs-----------------------------------*/
0331 /**
0332  * Structure represents typed buffer instance
0333  */
0334 typedef struct buffer_obj buffer_obj_t;
0335 struct buffer_obj
0336 {
0337     int type_id;
0338     /** int sub_type_id; */
0339     char subtype[XATMI_SUBTYPE_LEN+1];
0340     short autoalloc;  /**< Is buffer automatically allocated by tpcall? */
0341     char *buf;        /**< allocated datat block                        */
0342     long size;        /**< Allocated size....                           */
0343     char *callinfobuf;/**< Call info allocated buffer                   */
0344     long callinfobuf_len; /**< buffer len                               */
0345     /* Move to hash by buf */
0346     /* buffer_obj_t *prev, *next; */
0347     EX_hash_handle hh;         /**< makes this structure hashable */
0348 };
0349 
0350 /**
0351  * Typed buffer descriptor table. Type of \ref typed_buffer_descr
0352  */
0353 typedef struct typed_buffer_descr typed_buffer_descr_t;
0354 
0355 /**
0356  * Buffer type descriptor structure
0357  */
0358 struct typed_buffer_descr
0359 {
0360     int type_id;
0361     char *type;
0362     char *alias;
0363     char *subtype;
0364     /*
0365      * Prepare buffer for outgoing call/reply
0366      * idata - buffer data
0367      * ilen - data len (if needed)
0368      * obuf - place where to copy prepared buffer
0369      * olen - the actual lenght of data that should sent
0370      *
0371      * Error detail should be set by this funcion
0372      */
0373     int (*pf_prepare_outgoing) (typed_buffer_descr_t *descr, char *idata, 
0374         long ilen, char *obuf, long *olen, long flags);
0375 
0376     /*
0377      * Prepare received buffer for internal processing.
0378      * May re-allocate the buffer.
0379      * rcv_data - received data buffer
0380      * odata - ptr to handler. Existing buffer may be reused or re-allocated
0381      * olen - output data length
0382      *
0383      * Error detail should be set by this function.
0384      */
0385     int (*pf_prepare_incoming) (typed_buffer_descr_t *descr, char *rcv_data, 
0386         long rcv_len, char **odata, long *olen, long flags);
0387 
0388     /*
0389      * This will allocate buffer memory. Error details should be provided by
0390      * this function by it self.
0391      * On error NULL shall be returned.
0392      */
0393     char *(*pf_alloc) (typed_buffer_descr_t *descr, char *subtype, long *len);
0394 
0395     /*
0396      * Reallocate memory
0397      * cur_ptr - pointer to current buffer
0398      * len - new len that should be set
0399      *
0400      * returns NULL on error.
0401      * Error detail should be set by this function
0402      */
0403     char *(*pf_realloc) (typed_buffer_descr_t *descr, char *cur_ptr, long len);
0404 
0405     /*
0406      * Free up allocate buffer with proper routines!
0407      */
0408     void (*pf_free)(typed_buffer_descr_t *descr, char *buf);
0409 
0410     int (*pf_test)(typed_buffer_descr_t *descr, char *buf, BFLDLEN len, char *expr);
0411 };
0412 
0413 /**
0414  * Structure for keeping calldescriptor states
0415  */
0416 struct call_descriptor_state
0417 {
0418     int cd;
0419     short status;
0420     time_t timestamp;
0421     unsigned callseq;
0422     long flags;         /**< call flags associated..                    */
0423     int tout_eff; /**< effective timeout, used for call           */
0424 };
0425 typedef struct call_descriptor_state call_descriptor_state_t;
0426 
0427 /**
0428  * Structure for holding atmi library configuration and other global
0429  * variables.
0430  * 
0431  * This structure also will hold all environmental configuration for
0432  * EnduroX!
0433  */
0434 struct atmi_lib_conf
0435 {
0436     /** Is this client? */
0437     int is_client;
0438     /** Provide reply q better debug */
0439     char reply_q_str[NDRX_MAX_Q_SIZE+1];
0440     /** Reply queue */
0441     mqd_t reply_q;
0442     /** queue attributes - of replyq*/
0443     struct mq_attr reply_q_attr;
0444     /**
0445      * ID string. For example:
0446      * srv.testsrv-1
0447      * or
0448      * clt.testclt-1265
0449      */
0450     char my_id[NDRX_MAX_ID_SIZE+1];
0451 
0452     /** Queue prefix (from environment) */
0453     char q_prefix[NDRX_MAX_Q_SIZE+1];
0454 
0455     /** Queue name for ndrxd connection */
0456     char ndrxd_q_str[NDRX_MAX_Q_SIZE+1]; /* Queue name for ndrxd connection */
0457     
0458     /** In which context lib is initialized? */
0459     long contextid;
0460     
0461 };
0462 /** typedef for atmi_lib_conf structure */
0463 typedef struct atmi_lib_conf atmi_lib_conf_t;
0464 
0465 /**
0466  * Common atmi lib environmental configuration
0467  */
0468 struct atmi_lib_env
0469 {   
0470     /* Other global settings */
0471     int     max_servers; /**< Max server instance count - CONF_NDRX_SRVMAX  */
0472     int     max_svcs;    /**< Max services per server - CONF_NDRX_SVCMAX    */
0473     int     max_clts;    /**< Max number of CPMSRV clients                  */
0474     char    rnd_key[NDRX_MAX_KEY_SIZE];   /**< random key to be passed to all EnduroX servers in session */
0475     int     msg_max;     /**< maximum number of messages in a posix queue   */
0476     int     msgsize_max; /**< maximum message size for a posix queue        */
0477     key_t   ipckey;      /**< IPC Key                                       */
0478     int     time_out;    /**< Timeout in seconds to be applied for calls    */
0479     int     our_nodeid;  /**< Cluster node id                               */
0480     int     ldbal;       /**< Load balance settings                         */
0481     int     is_clustered;/**< Will we run in cluster mode or not?           */
0482     
0483     int     rtcrtmax; /**< size of routing criterion shared memory size  (one seg)*/
0484     int     rtsvcmax; /**< one segment size of criterion memory        */
0485     
0486     /**
0487      * @defgroup xa_params XA configuration parameters
0488      * @{
0489      */
0490     short xa_rmid;    /**< XA Resource ID 1..255 range */
0491     char xa_open_str[PATH_MAX]; /**< XA Open string           */
0492     char xa_close_str[PATH_MAX];/**< XA Close string          */
0493     char xa_driverlib[PATH_MAX];/**< Enduro RM Library/driver */
0494     char xa_rmlib[PATH_MAX];    /**< RM library               */
0495     int  xa_lazy_init;          /**< Should we  init lately?  */
0496     char xa_flags[PATH_MAX];    /**< Specific flags for XA    */
0497     long xa_flags_sys;          /**< Internal driver specfic flags */
0498     struct xa_switch_t * xa_sw; /**< handler to XA switch     */
0499     
0500     /** return codes for retry of the start */
0501     char xa_recon_retcodes[NDRX_XA_FLAGS_RECON_RETCODES_BUFSZ];
0502     
0503     /** retry does for all other xa_ calls */
0504     char xa_recon_retcodes_other[NDRX_XA_FLAGS_RECON_RETCODES_BUFSZ];
0505     
0506     int xa_recon_times;         /**< Number of times to retry the recon    */
0507     long xa_recon_usleep;       /**< Microseconds to sleep between retries */
0508     
0509     int (*pf_xa_loctxabort)(XID *xid, long flags); /**< Local abort function  */
0510     
0511     void* (*pf_getconn)(void);  /**< Return connection object  */
0512     
0513     /**@}*/
0514     
0515     int     nrsems; /**< number of sempahores for poll() mode of service mem    */
0516     int     maxsvcsrvs; /**< Max servers per service (only for poll() mode)     */
0517     int     max_normwait; /**< Max number of attempts for busy context of ndrxd */
0518     char    qprefix[NDRX_MAX_Q_SIZE+1]; /**< Queue prefix (common, finally!)    */
0519     char    qprefix_match[NDRX_MAX_Q_SIZE+1]; /**< Includes separator at the end*/
0520     int     qprefix_match_len;              /**< Includes number bytes to match */
0521     char    qpath[PATH_MAX+1]; /**< Queue path (common, finally!)               */
0522     char    ndrxd_pidfile[PATH_MAX];    /**< ndrxd pid file                     */
0523     ndrx_env_priv_t integpriv;    /**< integration  private data                */
0524     char    rtgrp[NDRX_DDR_GRP_MAX+1]; /**< routing grup setting                */
0525 
0526     /**
0527      * Special flags needed for QA
0528      * @defgroup qa_handlers
0529      * @{
0530      */
0531     int    test_qdisk_write_fail;   /**< Simulate disk write failure, queue    */
0532     int    test_tmsrv_write_fail;   /**< Simulate disk write failure, tmsrv    */
0533     int    test_tmsrv_commit_crash; /**< Simualte commit crash                 */
0534     void (*test_advertise_crash)(void); /**< XATMI server crash before reaching ndrxd */
0535     
0536     /**@}*/
0537 
0538     int procgrp_no;                 /**< Process group number for the curret bin */
0539 
0540     /** Increment for singleton-group at lock. Used for transaction lifecycle
0541      * management. I.e. txn must be completed (from start to commit/abort decision)
0542      * within this given time. Otherwise tmsrv will reboot, as it does not
0543      * know was there lock/lost/lock gain during the transaction processing.
0544      */
0545     long sglockinc;
0546 
0547     long xa_fsync_flags;            /**< Special tmqueue flags                   */
0548 };
0549 typedef struct  atmi_lib_env atmi_lib_env_t;
0550 
0551 /**
0552  * Generic command handler, tp commands.
0553  */
0554 struct tp_command_generic
0555 {
0556     /* <standard comms header:> */
0557 #if defined(EX_USE_SYSVQ) || defined(EX_USE_SVAPOLL)
0558     long mtype; /* mandatory for System V queues */
0559 #endif
0560     short command_id;
0561     char proto_ver[4];
0562     int proto_magic;
0563     /* </standard comms header> */
0564 };
0565 typedef struct tp_command_generic tp_command_generic_t;
0566 
0567 /**
0568  * Call handler.
0569  * For storing the tppost associated timestamp, we could allow data to be installed
0570  * in the rval/rcode for requests...
0571  * NOTE: If changing something, check with $ pahole ./libatmi.so for alignment, and sort the 
0572  * variable accordingly.
0573  */
0574 struct tp_command_call
0575 {
0576     /* <standard comms header:> */
0577 #if defined(EX_USE_SYSVQ) || defined(EX_USE_SVAPOLL)
0578     long mtype; /* mandatory for System V queues */
0579 #endif
0580     short command_id;
0581     char proto_ver[4];
0582     int proto_magic;
0583     /* </standard comms header> */
0584     char name[XATMI_SERVICE_NAME_LENGTH+1];
0585     char reply_to[NDRX_MAX_Q_SIZE+1];
0586     /** Zero terminated string... (might contain special symbols)*/
0587     char callstack[CONF_NDRX_NODEID_COUNT+1];
0588     char my_id[NDRX_MAX_ID_SIZE+1]; /* ID of caller */
0589     long sysflags; /* internal flags of the call */
0590     int cd;
0591     /* User1 field in request: */
0592     int rval;   /* This also should be present only on reply... */
0593     /* User2 field in request: */
0594     long rcode; /* should be preset on reply only */
0595     int user3;  /* user field 3, request */
0596     unsigned callseq;
0597     long user4; /* user field 4, request */
0598     int clttout; /* client process timeout setting */
0599     /** Extended size for storing cache updates in format
0600      * @CD002/Flgs/SERVICENAMEXXXXXXXXXXXXXXXXXXX
0601      * @CA002//SERVICENAMEXXXXXXXXXXXXXXXXXXX
0602      * where @CA -> Cache Add, @CD -> Cache delete, 002 -> source node id
0603      * Flgs -> max 4 flags ascii letters. And service name
0604      */
0605     char extradata[XATMI_EVENT_MAX+1]; /* Extra char data to be passed over the call */
0606     long flags; /* should be preset on reply only */
0607     time_t timestamp; /* provide time stamp of the call */
0608     /** message sequence for conversational over multithreaded bridges*/
0609     unsigned msgseq;
0610     
0611     /* <XA section begin> */
0612     ATMI_XA_TX_INFO_FIELDS;
0613     /* <XA section end> */
0614     
0615     /** call timer so that we do not operate with timed-out calls. */
0616     ndrx_stopwatch_t timer;
0617     
0618     /* Have a ptr to auto-buffer: */
0619     buffer_obj_t * autobuf;
0620     
0621 #if EX_SIZEOF_LONG == 4
0622     /* we need data to aligned to 8 */
0623     long padding1;
0624 #endif
0625 
0626     /* Payload: */
0627     long data_len;
0628     char data[0];
0629 };
0630 typedef struct tp_command_call tp_command_call_t;
0631 
0632 /*
0633  * Notification message
0634  */
0635 struct tp_notif_call
0636 {
0637     /* <standard comms header:> */
0638 #if defined(EX_USE_SYSVQ) || defined(EX_USE_SVAPOLL)
0639     long mtype; /* mandatory for System V queues */
0640 #endif
0641     short command_id;
0642     char proto_ver[4];
0643     int proto_magic;
0644     /* </standard comms header> */
0645     
0646     /* See clientid_t, same fields */
0647     char destclient[NDRX_MAX_ID_SIZE+1];      /**< Destination client ID */
0648     
0649     /* fields from boradcast */
0650     char nodeid[MAXTIDENT*2];  /**< In case of using regex */
0651     int nodeid_isnull;         /**< Is NULL */
0652     char usrname[MAXTIDENT*2]; /**< In case of using regex */
0653     int usrname_isnull;        /**< Is NULL */
0654     char cltname[MAXTIDENT*2]; /**< In case of using regex */
0655     int cltname_isnull;        /**< Is NULL */
0656     
0657     /** See clientid_t, same fields, end */
0658     char reply_to[NDRX_MAX_Q_SIZE+1];
0659     /** Zero terminated string... (might contain special symbols)*/
0660     char callstack[CONF_NDRX_NODEID_COUNT+1];
0661     char my_id[NDRX_MAX_ID_SIZE+1]; /**< ID of caller */
0662     long sysflags; /**< internal flags of the call */
0663     int cd;
0664     int rval; /**< on request -> userfield1 */
0665     long rcode; /**< should be preset on reply only, on request -> userfield2 */
0666     long flags; 
0667     time_t timestamp; /**< provide time stamp of the call */
0668     unsigned callseq;
0669     /** message sequence for conversational over multithreaded bridges*/
0670     unsigned msgseq;
0671     /** call timer so that we do not operate with timed-out calls. */
0672     ndrx_stopwatch_t timer;    
0673     
0674     buffer_obj_t * autobuf; /**< Have a ptr to auto-buffer: */
0675     
0676     long destnodeid; /**< Dest node to which we are sending the msg */
0677     
0678 #if EX_SIZEOF_LONG == 4
0679     /* we need data to aligned to 8 */
0680     long padding1;
0681 #endif
0682 
0683     long data_len;
0684     char data[0];
0685 };
0686 typedef struct tp_notif_call tp_notif_call_t;
0687 
0688 /**
0689  * Conversational buffer by message sequence number
0690  * Needed to keep the messages in memory to have them in order
0691  * as the muli-threaded bridge can send messages out of the order
0692  */
0693 typedef struct tpconv_buffer tpconv_buffer_t;
0694 struct tpconv_buffer
0695 {
0696     unsigned msgseq;
0697     char *buf;
0698     size_t size;        /**< Allocated size....                 */
0699     
0700     EX_hash_handle hh;  /**< makes this structure hashable      */
0701 };
0702 
0703 
0704 /**
0705  * Structure for holding conversation details
0706  */
0707 struct tp_conversation_control
0708 {
0709     int status;
0710     int cd;
0711     long flags;
0712 
0713     char reply_q_str[NDRX_MAX_Q_SIZE+1]; /* Reply back queue string */
0714     mqd_t reply_q; /* Reply back queue (file descriptor) - should be already open. */
0715     struct mq_attr reply_q_attr; /* Reply queue attributes. */
0716 
0717     char my_listen_q_str[NDRX_MAX_Q_SIZE+1]; /* Reply back queue string */
0718     mqd_t my_listen_q; /* Queue on which we are going to wait for msg */
0719     struct mq_attr my_q_attr; /* My listening queue attributes. */
0720     time_t timestamp;
0721     unsigned callseq; /* Call/conv sequence number */
0722     
0723     /** 
0724      * message sequence number (from our side to their) 
0725      * Basically this is message number we are sending them
0726      * The other side will follow the incremental order of the messages.
0727      */
0728     unsigned msgseqout;  /**< Next number to send */
0729     unsigned msgseqin;  /**< incoming message sequence number, expecting num */
0730     int rval; /* when tpreturn took a place */
0731     long rcode; /* when tpreturn took a place */
0732     long revent; /* Last event occurred at channel */
0733     short handshaked;
0734     
0735     tpconv_buffer_t *out_of_order_msgs; /* hash for out of the order messages */
0736     
0737 };
0738 typedef struct tp_conversation_control tp_conversation_control_t;
0739 
0740 
0741 /* Simple command to get ACK back when we have sent something */
0742 struct tp_conv_ack
0743 {
0744     short command_id;
0745     int cd;
0746 };
0747 typedef struct tp_conv_ack tp_conv_ack_t;
0748 
0749 
0750 /**
0751  * Structure to keep the list of extended FDs.
0752  */
0753 typedef struct pollextension_rec pollextension_rec_t;
0754 struct pollextension_rec
0755 {
0756     int fd; /* FD that is polled. */
0757     void *ptr1; /* Used defined pointer to be holded in extension  */
0758     int (*p_pollevent)(int fd, uint32_t events, void *ptr1); /* Event callback */
0759     uint32_t events; /*  Events subscribed to. */
0760     pollextension_rec_t *prev, *next;
0761 };
0762 
0763 /**
0764  * Type used for service listing LL return.
0765  */
0766 typedef struct atmi_svc_list atmi_svc_list_t;
0767 struct atmi_svc_list
0768 {
0769     /* Service name */
0770     char svcnm[XATMI_SERVICE_NAME_LENGTH+1];
0771     
0772     /* Linked list */
0773     atmi_svc_list_t *next;
0774 };
0775 
0776 /**
0777  * Enduro/X Queue details
0778  * parsed all attributes of the queue in single struct
0779  * Used only those attribs which match the q type.
0780  * Currently holds only those fields which are needed for certain system
0781  * functions, for example client reply Q details for tpbroadcast..
0782  */
0783 struct ndrx_qdet
0784 {
0785     int qtype; /* queue type, see  NDRX_QTYPE_* */
0786     char qprefix[NDRX_MAX_Q_SIZE+1]; 
0787     char binary_name[MAXTIDENT+2];
0788     pid_t pid;
0789     long contextid;
0790 };
0791 
0792 typedef struct ndrx_qdet ndrx_qdet_t;
0793 
0794 /**
0795  * tpcall() cache control structure - additional data to tpacall for providing
0796  * results back if cache lookup is done (i.e. service is present and 
0797  * result is found. Needed for cases to detect actual service existence
0798  * if service does not exists, then cache will not provide any results back.
0799  * because cache is transparent and shall not interfere with logic if service
0800  * does not exists.
0801  */
0802 struct ndrx_tpcall_cache_ctl
0803 {
0804     int should_cache;           /**< should we cache response?              */
0805     int cached_rsp;             /**< data is in cache, respond with them    */
0806     int saved_tperrno;
0807     long saved_tpurcode;
0808     long *olen;
0809     char **odata;
0810 };
0811 typedef struct ndrx_tpcall_cache_ctl ndrx_tpcall_cache_ctl_t;
0812 
0813 
0814 /* This may have some issues with alignment and this make
0815  * actual size smaller than 1 char */
0816 #define MAX_CALL_DATA_SIZE (NDRX_MSGSIZEMAX-sizeof(tp_command_call_t))
0817 
0818 
0819 /* Indicators for  tpexportex() and tpimportex() */
0820 struct ndrx_expbufctl
0821 {
0822     char buftype[XATMI_TYPE_LEN+1];
0823     short buftype_ind;
0824 
0825     char subtype[XATMI_SUBTYPE_LEN+1];
0826     short subtype_ind;
0827 
0828     double version;
0829     short version_ind;
0830 
0831     char svcnm[XATMI_SERVICE_NAME_LENGTH+1];
0832     short svcnm_ind;
0833 
0834     int rval;
0835     short rval_ind;
0836 
0837     long rcode;
0838     short rcode_ind;
0839 
0840     int tperror;
0841     short tperror_ind;
0842 
0843     char tpstrerror[MAX_TP_ERROR_LEN+1];
0844     short tpstrerror_ind;
0845 };
0846 
0847 typedef struct ndrx_expbufctl ndrx_expbufctl_t;
0848 
0849 /**
0850  * Server thread struct. Used for internal multi-threading
0851  */
0852 struct ndrx_thread_server
0853 {
0854     char *context_data; /* malloced by enduro/x */
0855     int cd;
0856     char *buffer; /* buffer data, managed by enduro/x */
0857 };
0858 typedef struct ndrx_thread_server ndrx_thread_server_t;
0859 
0860 /*---------------------------Globals------------------------------------*/
0861 extern NDRX_API atmi_lib_env_t G_atmi_env; /* global access to env configuration */
0862 extern NDRX_API int G_srv_id;
0863 extern NDRX_API pollextension_rec_t * ndrx_G_pollext;
0864 /*---------------------------Statics------------------------------------*/
0865 /*---------------------------Prototypes---------------------------------*/
0866 
0867 /* Utilities */
0868 extern NDRX_API int ndrx_load_common_env(void);
0869 extern NDRX_API long ndrx_ctxid_op(int make_free, long ctxid);
0870 extern NDRX_API int ndrx_load_new_env(char *file);
0871 extern NDRX_API int ndrx_generic_q_send(char *queue, char *data, long len, long flags, int msg_prio);
0872 extern NDRX_API int ndrx_generic_q_send_2(char *queue, char *data, long len, long flags, long tout, int msg_prio);
0873 extern NDRX_API int ndrx_generic_qfd_send(mqd_t q_descr, char *data, long len, long flags);
0874 extern NDRX_API ssize_t ndrx_generic_q_receive(mqd_t q_descr, char *q_str, 
0875         struct mq_attr *reply_q_attr,
0876         char *buf, long buf_max, 
0877         unsigned *prio, long flags);
0878     
0879 extern NDRX_API int ndrx_get_q_attr(char *q, struct mq_attr *p_att);
0880 extern NDRX_API int ndrx_setup_queue_attrs(struct mq_attr *p_q_attr,
0881                                 mqd_t listen_q,
0882                                 char *listen_q_str, 
0883                                 long flags);
0884 extern NDRX_API mqd_t ndrx_mq_open_at(char *name, int oflag, mode_t mode, struct mq_attr *attr);
0885 extern NDRX_API mqd_t ndrx_mq_open_at_wrp(char *name, int oflag);
0886 extern NDRX_API void ndrx_tptoutset(int tout);
0887 extern NDRX_API int ndrx_tptoutget();
0888 extern NDRX_API int ndrx_tptoutget_eff(void);
0889 extern NDRX_API void ndrx_mq_fix_mass_send(int *cntr);
0890 extern NDRX_API int ndrx_q_setblock(mqd_t q_descr, int blocked);
0891 
0892 extern NDRX_API void br_dump_nodestack(char *stack, char *msg);
0893 extern NDRX_API int fill_reply_queue(char *nodestack, 
0894             char *org_reply_to, char *reply_to);
0895 
0896 extern NDRX_API int ndrx_cvnq_parse_client(char *qname, TPMYID *p_myid);
0897 extern NDRX_API int ndrx_cvnq_parse_server(char *qname, TPMYID *p_myid_first,  
0898         TPMYID *p_myid_second);
0899 extern NDRX_API int ndrx_myid_parse(char *my_id, TPMYID *out, int iscnv_initator);
0900 extern NDRX_API int ndrx_myid_parse_clt(char *my_id, TPMYID *out, int iscnv_initator);
0901 extern NDRX_API int ndrx_myid_parse_srv(char *my_id, TPMYID *out, int iscnv_initator);
0902 extern NDRX_API int ndrx_myid_is_alive(TPMYID *p_myid);
0903 extern NDRX_API void ndrx_myid_dump(int lev, TPMYID *p_myid, char *msg);
0904 extern NDRX_API int ndrx_myid_convert_to_q(TPMYID *p_myid, char *rply_q, int rply_q_buflen);
0905 
0906 extern NDRX_API int ndrx_myid_convert_from_qdet(TPMYID *p_myid, ndrx_qdet_t *qdet, long nodeid);
0907 extern NDRX_API void ndrx_myid_to_my_id_str(TPMYID *p_myid, char *my_id);
0908 extern NDRX_API int ndrx_qdet_parse_cltqstr(ndrx_qdet_t *qdet, char *qstr);
0909 extern NDRX_API void ndrx_qdet_dump(int lev, ndrx_qdet_t *qdet, char *msg);
0910 extern NDRX_API int ndrx_q_type_get(char *q);
0911 
0912 extern NDRX_API int ndrx_atmiutil_init(void);
0913 
0914 /* ATMI calls */
0915 extern NDRX_API int ndrx_tpacall (char *svc, char *data,
0916                long len, long flags, char *extradata, int dest_node, int ex_flags,
0917                TPTRANID *p_tran, int user1, long user2, int user3, long user4,
0918                ndrx_tpcall_cache_ctl_t *p_cachectl);
0919 extern NDRX_API int ndrx_tpnotify(CLIENTID *clientid, TPMYID *p_clientid_myid, 
0920         char *cltq, /* client q already built by broadcast */
0921         char *data, long len, long flags, 
0922         int dest_node, char *nodeid, char *usrname,  char *cltname,
0923         int ex_flags);
0924 extern NDRX_API int ndrx_tpchkunsol(long flags);
0925 extern NDRX_API int ndrx_add_to_memq(char **pbuf, size_t pbuf_len, ssize_t rply_len);
0926 extern NDRX_API int ndrx_tpbroadcast_local(char *nodeid, char *usrname, char *cltname,
0927         char *data,  long len, long flags, int dispatch_local);
0928 extern NDRX_API void ndrx_process_notif(char *buf, ssize_t len);
0929 extern NDRX_API char * ndrx_tprealloc (char *buf, long len);
0930 extern NDRX_API long    ndrx_tptypes (char *ptr, char *type, char *subtype);
0931 extern NDRX_API char * ndrx_tpalloc (typed_buffer_descr_t *known_type,
0932                     char *type, char *subtype, long len);
0933 extern NDRX_API void free_auto_buffers(void);
0934 extern NDRX_API int tp_internal_init(atmi_lib_conf_t *init_data);
0935 extern NDRX_API void ndrx_libatmi_deinit(void);
0936 extern NDRX_API int tp_internal_init_upd_replyq(mqd_t reply_q, char *reply_q_str);
0937 extern NDRX_API void tp_thread_shutdown(void *ptr, int *p_finish_off);
0938 extern NDRX_API void ndrx_dump_call_struct(int lev, tp_command_call_t *call);
0939 extern NDRX_API int ndrx_tpcall_init_once(void);
0940 extern NDRX_API unsigned ndrx_get_next_callseq_shared(void);
0941 
0942 extern NDRX_API int ndrx_tpsend (int cd, char *data, long len, long flags, long *revent,
0943                             short command_id);
0944 extern NDRX_API void ndrx_tpfree (char *buf, buffer_obj_t *known_buffer);
0945 extern NDRX_API int ndrx_tpisautobuf (char *buf);
0946 extern NDRX_API void cancel_if_expected(tp_command_call_t *call);
0947 /* Functions for conversation */
0948 extern NDRX_API int accept_connection(void);
0949 extern NDRX_API int ndrx_reject_connection(int err);
0950 extern NDRX_API int svc_fail_to_start(void);
0951 extern NDRX_API int normal_connection_shutdown(tp_conversation_control_t *conv, 
0952         int killq, char *dbgmsg);
0953 extern NDRX_API int close_open_client_connections(void);
0954 extern NDRX_API int have_open_connection(void);
0955 extern NDRX_API int ndrx_get_ack(tp_conversation_control_t *conv, long flags);
0956 
0957 /* Extended version of tpcall, accepts extradata (31+1) symbols */
0958 extern NDRX_API int tpcallex (char *svc, char *idata, long ilen,
0959                 char * *odata, long *olen, long flags,
0960                 char *extradata, int dest_node, int ex_flags,
0961                 int user1, long user2, int user3, long user4);
0962 
0963 extern NDRX_API int tpacallex (char *svc, char *data, 
0964         long len, long flags, char *extradata, int dest_node, int is_evpost,
0965         int user1, long user2, int user3, long user4);
0966 /* event API implementation */
0967 extern NDRX_API long ndrx_tpunsubscribe(long subscription, long flags);
0968 extern NDRX_API long ndrx_tpsubscribe(char *eventexpr, char *filter, TPEVCTL *ctl, long flags);
0969 extern NDRX_API int ndrx_tppost(char *eventname, char *data, long len, long flags,
0970         int user1, long user2, int user3, long user4);
0971 
0972 extern NDRX_API void    tpext_configbrige 
0973     (int nodeid, int flags, int (*p_qmsg)(char **buf, int len, char msg_type));
0974 extern NDRX_API void tpext_configprocgrp_lp(int singlegrp);
0975 
0976 extern NDRX_API int ndrx_tpjsontoubf(UBFH *p_ub, char *buffer, EXJSON_Object *data_object);
0977 extern NDRX_API int ndrx_tpubftojson(UBFH *p_ub, char *buffer, int bufsize, EXJSON_Object *data_object);
0978 extern NDRX_API int ndrx_tpcall (char *svc, char *idata, long ilen,
0979                 char * *odata, long *olen, long flags,
0980                 char *extradata, int dest_node, int ex_flags,
0981                 int user1, long user2, int user3, long user4);
0982 extern NDRX_API int ndrx_tpgetrply (int *cd,
0983                        int cd_exp,
0984                        char * *data ,
0985                        long *len, long flags,
0986                        TPTRANID *p_tranid);
0987 extern NDRX_API int ndrx_tpcancel (int cd);
0988 extern NDRX_API int ndrx_tpterm (void);
0989 extern NDRX_API int ndrx_tpconnect (char *svc, char *data, long len, long flags);
0990 extern NDRX_API int ndrx_tprecv (int cd, char * *data, 
0991                         long *len, long flags, long *revent,
0992                         short *command_id, int ign_blkerr);
0993 extern NDRX_API int ndrx_tpdiscon (int cd);
0994 extern NDRX_API int ndrx_tpenqueue (char *qspace, short nodeid, short srvid, char *qname, TPQCTL *ctl, 
0995         char *data, long len, long flags);
0996 extern NDRX_API int ndrx_tpdequeue (char *qspace, short nodeid, short srvid, char *qname, TPQCTL *ctl, 
0997         char **data, long *len, long flags);
0998 
0999 extern NDRX_API void ndrx_tpfreectxt(TPCONTEXT_T context);
1000 extern NDRX_API int ndrx_tpconvert(char *str, char *bin, long flags);
1001 
1002 /* debug logging */
1003 extern NDRX_API int ndrx_tplogsetreqfile(char **data, char *filename, char *filesvc);
1004 extern NDRX_API int ndrx_tploggetbufreqfile(char *data, char *filename, int bufsize);
1005 extern NDRX_API int ndrx_tplogdelbufreqfile(char *data);
1006 extern NDRX_API void ndrx_tplogprintubf(int lev, char *title, UBFH *p_ub);
1007 
1008 /* ATMI level process management: */
1009 extern NDRX_API int ndrx_chk_server(char *procname, short srvid);
1010 extern NDRX_API int ndrx_chk_ndrxd(void);
1011 extern NDRX_API pid_t ndrx_ndrxd_pid_get(void);
1012 extern NDRX_API int ndrx_down_sys(char *qprefix, char *qpath, int is_force, int user_res);
1013 extern NDRX_API void ndrx_down_userres(void);
1014 extern NDRX_API int ndrx_killall(char *mask);
1015 extern NDRX_API int ndrx_q_exists(char *qpath);
1016 extern NDRX_API int ndrx_get_cached_svc_q(char *q);
1017 extern NDRX_API int ndrx_ndrxd_ping(int *p_seq, long *p_time_msec,
1018                     mqd_t listen_q, char * listen_q_str);
1019 
1020 /* Access to symbols: */
1021 
1022 extern NDRX_API tp_command_call_t *ndrx_get_G_last_call(void);
1023 extern NDRX_API atmi_lib_conf_t *ndrx_get_G_atmi_conf(void);
1024 extern NDRX_API atmi_lib_env_t *ndrx_get_G_atmi_env(void);
1025 extern NDRX_API tp_conversation_control_t *ndrx_get_G_accepted_connection(void);
1026 
1027 /* tpimport() functions */
1028 extern NDRX_API int tpimportex(ndrx_expbufctl_t *bufctl, char *istr, long ilen, char **obuf, long *olen, long flags);
1029 extern NDRX_API int ndrx_tpimportex(ndrx_expbufctl_t *bufctl, char *istr, long ilen, char **obuf, long *olen, long flags, EXJSON_Object *parent_root_object);
1030 
1031 /* tpexport() functions */
1032 extern NDRX_API int tpexportex(ndrx_expbufctl_t *bufctl, char *ibuf, long ilen, char *ostr, long *olen, long flags);
1033 extern NDRX_API int ndrx_tpexportex(ndrx_expbufctl_t *bufctl, char *ibuf, long ilen, char *ostr, long *olen, long flags, EXJSON_Object *parent_root_object);
1034 
1035 /* export the symbol */
1036 extern NDRX_API struct xa_switch_t * ndrx_xa_builtin_get(void);
1037 
1038 extern NDRX_API int ndrx_tpgetcallinfo(const char *msg, UBFH **obuf, long flags);
1039 extern NDRX_API int ndrx_tpsetcallinfo(const char *msg, UBFH *obuf, long flags);
1040 
1041 /* tp encryption functions */
1042 extern NDRX_API int tpencrypt_int(char *input, long ilen, char *output, long *olen, long flags);
1043 extern NDRX_API int tpdecrypt_int(char *input, long ilen, char *output, long *olen, long flags);
1044 
1045 extern NDRX_API void ndrx_mbuf_tlv_debug (char *rcv_data, long rcv_len);
1046 extern NDRX_API int ndrx_mbuf_prepare_outgoing (char *idata, long ilen, char *obuf, long *olen, 
1047         long flags, long mflags);
1048 extern NDRX_API int ndrx_mbuf_prepare_incoming (char *rcv_data, long rcv_len, char **odata, 
1049         long *olen, long flags, long mflags);
1050 
1051 extern NDRX_API void ndrx_mbuf_Bnext_ptr_first(UBFH *p_ub, Bnext_state_t *state);
1052 extern NDRX_API long ndrx_tpsgislocked(int grpno, long flags, long *grp_flags);
1053 
1054 
1055 #ifdef  __cplusplus
1056 }
1057 #endif
1058 
1059 #endif  /* ATMI_INT_H */
1060 
1061 /* vim: set ts=4 sw=4 et smartindent: */