Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Shared memory API for Enduro/X ATMI
0003  *
0004  * @file atmi_shm.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_SHM_H
0036 #define ATMI_SHM_H
0037 
0038 #ifdef  __cplusplus
0039 extern "C" {
0040 #endif
0041 
0042 /*---------------------------Includes-----------------------------------*/
0043 #include <ndrxdcmn.h>
0044 #include <sys/sem.h>
0045 #include <nstd_shm.h>
0046 /*---------------------------Externs------------------------------------*/
0047 /*---------------------------Macros-------------------------------------*/
0048 
0049 /* ATMI SHM Level */
0050 #define NDRX_SHM_LEV_SVC               0x01    /**< Service array */
0051 #define NDRX_SHM_LEV_SRV               0x02    /**< Server array */
0052 #define NDRX_SHM_LEV_BR                0x04    /**< Bridge array */
0053 
0054 #define NDRX_SHM_BR_CONNECTED          0x01    /**< Bridge is connected */
0055 /*---------------------------Enums--------------------------------------*/
0056 /*---------------------------Typedefs-----------------------------------*/
0057 /*---------------------------Globals------------------------------------*/
0058 extern NDRX_API int G_max_svcs;
0059 extern NDRX_API ndrx_shm_t G_svcinfo;
0060 extern NDRX_API int G_max_servers;
0061 extern NDRX_API ndrx_shm_t G_srvinfo;
0062 
0063 extern NDRX_API ndrx_shm_t ndrx_G_routcrit;    /**< Routing criterions */
0064 extern NDRX_API ndrx_shm_t ndrx_G_routsvc;     /**< Routing services   */
0065 
0066 /*---------------------------Statics------------------------------------*/
0067 /*---------------------------Prototypes---------------------------------*/
0068 extern NDRX_API int ndrx_shm_init(char *q_prefix, int max_servers, int max_svcs,
0069             int rtcrtmax, int rtsvcmax);
0070 extern NDRX_API int ndrxd_shm_close_all(void);
0071 extern NDRX_API void ndrxd_shm_srv_fork_status(int srvid, unsigned execerr);
0072 extern NDRX_API int ndrxd_shm_delete(void);
0073 extern NDRX_API int ndrx_shm_open_all(int lev, int create);
0074 extern NDRX_API int ndrx_shm_get_svc(char *svc, char *send_q, int *is_bridge,
0075                         int *have_shm);
0076 extern NDRX_API int ndrx_shm_get_srvs(char *svc, ndrx_shm_resid_t **srvlist, int *len); /* poll() only */
0077 extern NDRX_API int _ndrx_shm_get_svc(char *svc, int *pos, int doing_install, 
0078                       int *p_install_cmd);
0079 extern NDRX_API int ndrx_shm_get_svc_count(void);
0080 extern NDRX_API int ndrx_shm_install_svc(char *svc, int flags, int resid);
0081 extern NDRX_API int ndrx_shm_install_svc_br(char *svc, int flags, 
0082                 int is_bridge, int nodeid, int count, char mode, int resid);
0083 extern NDRX_API void ndrxd_shm_uninstall_svc(char *svc, int *last, int resid);
0084 extern NDRX_API shm_srvinfo_t* ndrxd_shm_getsrv(int srvid);
0085 extern NDRX_API void ndrxd_shm_resetsrv(int srvid);
0086 
0087 extern NDRX_API int ndrx_shm_birdge_set_flags(int nodeid, int flags, int op_end);
0088 extern NDRX_API int ndrx_shm_bridge_disco(int nodeid);
0089 extern NDRX_API int ndrx_shm_bridge_connected(int nodeid);
0090 extern NDRX_API int ndrx_shm_bridge_is_connected(int nodeid);
0091 extern NDRX_API int ndrx_shm_birdge_getnodesconnected(char *outputbuf);
0092 
0093 /* Semaphore driving: */
0094 extern NDRX_API int ndrxd_sem_init(char *q_prefix);
0095 extern NDRX_API int ndrx_sem_attach(ndrx_sem_t *sem);
0096 extern NDRX_API int ndrx_sem_open_all(int create);
0097 extern NDRX_API int ndrxd_sem_close_all(void);
0098 extern NDRX_API int ndrxd_sem_delete(void);
0099 extern NDRX_API void ndrxd_sem_delete_with_init(char *q_prefix);
0100 extern NDRX_API int ndrx_sem_attach_all(void);
0101 extern NDRX_API int ndrx_lock_svc_op(const char *msg);
0102 extern NDRX_API int ndrx_unlock_svc_op(const char *msg);
0103 
0104 extern NDRX_API int ndrx_lock_svc_nm(char *svcnm, const char *msg, int typ);
0105 extern NDRX_API int ndrx_unlock_svc_nm(char *svcnm, const char *msg, int typ);
0106 
0107 #ifdef  __cplusplus
0108 }
0109 #endif
0110 
0111 #endif  /* ATMI_SHM_H */
0112 
0113 /* vim: set ts=4 sw=4 et smartindent: */