totemiba.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Copyright (c) 2009 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@redhat.com)
  7. * This software licensed under BSD license, the text of which follows:
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * - Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  31. * THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <config.h>
  34. #include <assert.h>
  35. #include <pthread.h>
  36. #include <sys/mman.h>
  37. #include <sys/types.h>
  38. #include <sys/stat.h>
  39. #include <sys/socket.h>
  40. #include <netdb.h>
  41. #include <sys/un.h>
  42. #include <sys/ioctl.h>
  43. #include <sys/param.h>
  44. #include <netinet/in.h>
  45. #include <arpa/inet.h>
  46. #include <unistd.h>
  47. #include <fcntl.h>
  48. #include <stdlib.h>
  49. #include <stdio.h>
  50. #include <errno.h>
  51. #include <sched.h>
  52. #include <time.h>
  53. #include <sys/time.h>
  54. #include <sys/poll.h>
  55. #include <limits.h>
  56. #include <corosync/sq.h>
  57. #include <corosync/list.h>
  58. #include <corosync/hdb.h>
  59. #include <corosync/swab.h>
  60. #include <corosync/totem/coropoll.h>
  61. #define LOGSYS_UTILS_ONLY 1
  62. #include <corosync/engine/logsys.h>
  63. #include "totemiba.h"
  64. #include "wthread.h"
  65. #include "crypto.h"
  66. struct totemiba_instance {
  67. int dummy;
  68. };
  69. static void totemiba_instance_initialize (struct totemiba_instance *instance)
  70. {
  71. memset (instance, 0, sizeof (struct totemiba_instance));
  72. }
  73. #define log_printf(level, format, args...) \
  74. do { \
  75. instance->totemiba_log_printf ( \
  76. LOGSYS_ENCODE_RECID(level, \
  77. instance->totemiba_subsys_id, \
  78. LOGSYS_RECID_LOG), \
  79. __FUNCTION__, __FILE__, __LINE__, \
  80. (const char *)format, ##args); \
  81. } while (0);
  82. int totemiba_crypto_set (void *iba_context,
  83. unsigned int type)
  84. {
  85. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  86. int res = 0;
  87. instance = NULL;
  88. return (res);
  89. }
  90. int totemiba_finalize (
  91. void *iba_context)
  92. {
  93. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  94. int res = 0;
  95. instance = NULL;
  96. return (res);
  97. }
  98. /*
  99. * Create an instance
  100. */
  101. int totemiba_initialize (
  102. hdb_handle_t poll_handle,
  103. void **iba_context,
  104. struct totem_config *totem_config,
  105. int interface_no,
  106. void *context,
  107. void (*deliver_fn) (
  108. void *context,
  109. const void *msg,
  110. unsigned int msg_len),
  111. void (*iface_change_fn) (
  112. void *context,
  113. const struct totem_ip_address *iface_address))
  114. {
  115. struct totemiba_instance *instance;
  116. int res = 0;
  117. instance = malloc (sizeof (struct totemiba_instance));
  118. if (instance == NULL) {
  119. return (-1);
  120. }
  121. totemiba_instance_initialize (instance);
  122. return (res);
  123. }
  124. int totemiba_processor_count_set (
  125. void *iba_context,
  126. int processor_count)
  127. {
  128. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  129. int res = 0;
  130. instance = NULL;
  131. return (res);
  132. }
  133. int totemiba_recv_flush (void *iba_context)
  134. {
  135. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  136. int res = 0;
  137. instance = NULL;
  138. return (res);
  139. }
  140. int totemiba_send_flush (void *iba_context)
  141. {
  142. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  143. int res = 0;
  144. instance = NULL;
  145. return (res);
  146. }
  147. int totemiba_token_send (
  148. void *iba_context,
  149. const void *msg,
  150. unsigned int msg_len)
  151. {
  152. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  153. int res = 0;
  154. instance = NULL;
  155. return (res);
  156. }
  157. int totemiba_mcast_flush_send (
  158. void *iba_context,
  159. const void *msg,
  160. unsigned int msg_len)
  161. {
  162. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  163. int res = 0;
  164. instance = NULL;
  165. return (res);
  166. }
  167. int totemiba_mcast_noflush_send (
  168. void *iba_context,
  169. const void *msg,
  170. unsigned int msg_len)
  171. {
  172. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  173. int res = 0;
  174. instance = NULL;
  175. return (res);
  176. }
  177. extern int totemiba_iface_check (void *iba_context)
  178. {
  179. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  180. int res = 0;
  181. instance = NULL;
  182. return (res);
  183. }
  184. extern void totemiba_net_mtu_adjust (void *iba_context, struct totem_config *totem_config)
  185. {
  186. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  187. instance = NULL;
  188. }
  189. const char *totemiba_iface_print (void *iba_context) {
  190. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  191. instance = NULL;
  192. return (NULL);
  193. }
  194. int totemiba_iface_get (
  195. void *iba_context,
  196. struct totem_ip_address *addr)
  197. {
  198. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  199. int res = 0;
  200. instance = NULL;
  201. return (res);
  202. }
  203. int totemiba_token_target_set (
  204. void *iba_context,
  205. const struct totem_ip_address *token_target)
  206. {
  207. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  208. int res = 0;
  209. instance = NULL;
  210. return (res);
  211. }
  212. extern int totemiba_recv_mcast_empty (
  213. void *iba_context)
  214. {
  215. struct totemiba_instance *instance = (struct totemiba_instance *)iba_context;
  216. int res = 0;
  217. instance = NULL;
  218. return (res);
  219. }