coroipcc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 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. coroipcc_service_connect (
  65. const char *socket_name,
  66. enum service_types service,
  67. void **ipc_context);
  68. cs_error_t
  69. coroipcc_service_disconnect (
  70. void *ipc_context);
  71. int
  72. coroipcc_fd_get (
  73. void *ipc_context);
  74. int
  75. coroipcc_dispatch_recv (
  76. void *ipc_context,
  77. void *buf,
  78. size_t buflen,
  79. int timeout);
  80. int
  81. coroipcc_dispatch_flow_control_get (
  82. void *ipc_context);
  83. cs_error_t
  84. coroipcc_msg_send_reply_receive (
  85. void *ipc_context,
  86. const struct iovec *iov,
  87. unsigned int iov_len,
  88. void *res_msg,
  89. size_t res_len);
  90. cs_error_t
  91. coroipcc_msg_send_reply_receive_in_buf (
  92. void *ipc_context,
  93. const struct iovec *iov,
  94. unsigned int iov_len,
  95. void **res_msg);
  96. cs_error_t
  97. saHandleCreate (
  98. struct saHandleDatabase *handleDatabase,
  99. int instanceSize,
  100. uint64_t *handleOut);
  101. cs_error_t
  102. saHandleDestroy (
  103. struct saHandleDatabase *handleDatabase,
  104. uint64_t handle);
  105. cs_error_t
  106. saHandleInstanceGet (
  107. struct saHandleDatabase *handleDatabase,
  108. uint64_t handle,
  109. void **instance);
  110. cs_error_t
  111. saHandleInstancePut (
  112. struct saHandleDatabase *handleDatabase,
  113. uint64_t handle);
  114. #define offset_of(type,member) (int)(&(((type *)0)->member))
  115. #endif /* COROIPC_H_DEFINED */