coroipc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2002-2003 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2007 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 COROIPC_H_DEFINED
  36. #define COROIPC_H_DEFINED
  37. #include <pthread.h>
  38. #include <sys/poll.h>
  39. #include <sys/socket.h>
  40. #include <corosync/corotypes.h>
  41. #include <corosync/ipc_gen.h>
  42. /* Debug macro
  43. */
  44. #ifdef DEBUG
  45. #define DPRINT(s) printf s
  46. #else
  47. #define DPRINT(s)
  48. #endif
  49. #ifdef SO_NOSIGPIPE
  50. #ifndef MSG_NOSIGNAL
  51. #define MSG_NOSIGNAL 0
  52. #endif
  53. void socket_nosigpipe(int s);
  54. #else
  55. #define socket_nosigpipe(s)
  56. #endif
  57. struct saHandleDatabase {
  58. unsigned int handleCount;
  59. struct saHandle *handles;
  60. pthread_mutex_t mutex;
  61. void (*handleInstanceDestructor) (void *);
  62. };
  63. cs_error_t
  64. cslib_service_connect (
  65. enum service_types service,
  66. void **ipc_context);
  67. cs_error_t
  68. cslib_service_disconnect (
  69. void *ipc_context);
  70. int
  71. cslib_fd_get (
  72. void *ipc_context);
  73. int
  74. cslib_dispatch_recv (
  75. void *ipc_context,
  76. void *buf,
  77. int timeout);
  78. int
  79. cslib_dispatch_flow_control_get (
  80. void *ipc_context);
  81. cs_error_t
  82. cslib_msg_send_reply_receive (
  83. void *ipc_context,
  84. struct iovec *iov,
  85. int iov_len,
  86. void *res_msg,
  87. int res_len);
  88. cs_error_t
  89. cslib_msg_send_reply_receive_in_buf (
  90. void *ipc_context,
  91. struct iovec *iov,
  92. int iov_len,
  93. void **res_msg);
  94. cs_error_t
  95. saHandleCreate (
  96. struct saHandleDatabase *handleDatabase,
  97. int instanceSize,
  98. uint64_t *handleOut);
  99. cs_error_t
  100. saHandleDestroy (
  101. struct saHandleDatabase *handleDatabase,
  102. uint64_t handle);
  103. cs_error_t
  104. saHandleInstanceGet (
  105. struct saHandleDatabase *handleDatabase,
  106. uint64_t handle,
  107. void **instance);
  108. cs_error_t
  109. saHandleInstancePut (
  110. struct saHandleDatabase *handleDatabase,
  111. uint64_t handle);
  112. #define offset_of(type,member) (int)(&(((type *)0)->member))
  113. #endif /* COROIPC_H_DEFINED */