coroipcc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2002-2003 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2007, 2009 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef COROIPCC_H_DEFINED
  36. #define COROIPCC_H_DEFINED
  37. #include <config.h>
  38. #include <pthread.h>
  39. #include <sys/poll.h>
  40. #include <sys/socket.h>
  41. #include <corosync/corotypes.h>
  42. extern cs_error_t
  43. coroipcc_service_connect (
  44. const char *socket_name,
  45. unsigned int service,
  46. size_t request_size,
  47. size_t respnse__size,
  48. size_t dispatch_size,
  49. void **ipc_context);
  50. extern cs_error_t
  51. coroipcc_service_disconnect (
  52. void *ipc_context);
  53. extern int
  54. coroipcc_fd_get (
  55. void *ipc_context);
  56. extern int
  57. coroipcc_dispatch_get (
  58. void *ipc_context,
  59. void **buf,
  60. int timeout);
  61. extern int
  62. coroipcc_dispatch_put (
  63. void *ipc_context);
  64. extern int
  65. coroipcc_dispatch_flow_control_get (
  66. void *ipc_context);
  67. extern cs_error_t
  68. coroipcc_msg_send_reply_receive (
  69. void *ipc_context,
  70. const struct iovec *iov,
  71. unsigned int iov_len,
  72. void *res_msg,
  73. size_t res_len);
  74. extern cs_error_t
  75. coroipcc_msg_send_reply_receive_in_buf (
  76. void *ipc_context,
  77. const struct iovec *iov,
  78. unsigned int iov_len,
  79. void **res_msg);
  80. extern cs_error_t
  81. coroipcc_zcb_alloc (
  82. void *ipc_context,
  83. void **buffer,
  84. size_t size,
  85. size_t header_size);
  86. extern cs_error_t
  87. coroipcc_zcb_free (
  88. void *ipc_context,
  89. void *buffer);
  90. extern cs_error_t
  91. coroipcc_zcb_msg_send_reply_receive (
  92. void *ipc_context,
  93. void *msg,
  94. void *res_msg,
  95. size_t res_len);
  96. /*
  97. * TODO This needs to be removed
  98. */
  99. struct saHandleDatabase {
  100. unsigned int handleCount;
  101. struct saHandle *handles;
  102. #if defined(HAVE_PTHREAD_SPIN_LOCK)
  103. pthread_spinlock_t lock;
  104. #else
  105. pthread_mutex_t lock;
  106. #endif
  107. void (*handleInstanceDestructor) (void *);
  108. };
  109. extern void saHandleDatabaseLock_init (struct saHandleDatabase *hdb);
  110. #define DECLARE_SAHDB_DATABASE(database_name,destructor) \
  111. static struct saHandleDatabase (database_name) = { \
  112. .handleInstanceDestructor = destructor, \
  113. .handleCount = 0, \
  114. .handles = NULL, \
  115. }; \
  116. static void database_name##_init(void)__attribute__((constructor)); \
  117. static void database_name##_init(void) \
  118. { \
  119. saHandleDatabaseLock_init (&(database_name)); \
  120. }
  121. extern cs_error_t
  122. saHandleCreate (
  123. struct saHandleDatabase *handleDatabase,
  124. int instanceSize,
  125. uint64_t *handleOut);
  126. extern cs_error_t
  127. saHandleDestroy (
  128. struct saHandleDatabase *handleDatabase,
  129. uint64_t handle);
  130. extern cs_error_t
  131. saHandleInstanceGet (
  132. struct saHandleDatabase *handleDatabase,
  133. uint64_t handle,
  134. void **instance);
  135. extern cs_error_t
  136. saHandleInstancePut (
  137. struct saHandleDatabase *handleDatabase,
  138. uint64_t handle);
  139. #endif /* COROIPCC_H_DEFINED */