main.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2002-2004 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #define TRUE 1
  35. #define FALSE 0
  36. #include <sys/un.h>
  37. #include "../include/saAis.h"
  38. #include "../include/queue.h"
  39. #include "poll.h"
  40. #include "evs.h"
  41. #include "clm.h"
  42. #include "amf.h"
  43. #include "ckpt.h"
  44. #include "evt.h"
  45. #include "lck.h"
  46. #ifndef AIS_EXEC_H_DEFINED
  47. #define AIS_EXEC_H_DEFINED
  48. /*
  49. * Size of the queue (entries) for I/O's to the API over socket IPC.
  50. */
  51. #define SIZEQUEUE 256
  52. #define SOCKET_SERVICE_INIT 254
  53. struct aisexec_ci {
  54. struct sockaddr_in in_addr; /* address of AF_INET socket, MUST BE FIRST IN STRUCTURE */
  55. SaClmClusterNodeT clusterNode;
  56. SaClmClusterChangesT lastChange;
  57. unsigned char authentication_key[16];
  58. int authenticated;
  59. };
  60. /*
  61. * Connection information for AIS connections
  62. */
  63. struct ais_ci {
  64. struct sockaddr_un un_addr; /* address of AF_UNIX socket, MUST BE FIRST IN STRUCTURE */
  65. union {
  66. struct aisexec_ci aisexec_ci;
  67. struct libevs_ci libevs_ci;
  68. struct libclm_ci libclm_ci;
  69. struct libamf_ci libamf_ci;
  70. struct libckpt_ci libckpt_ci;
  71. struct libevt_ci libevt_ci;
  72. struct liblck_ci liblck_ci;
  73. } u;
  74. };
  75. struct outq_item {
  76. void *msg;
  77. size_t mlen;
  78. };
  79. #define SIZEINB MESSAGE_SIZE_MAX
  80. enum conn_state {
  81. CONN_STATE_ACTIVE,
  82. CONN_STATE_DISCONNECTING,
  83. CONN_STATE_DISCONNECTING_DELAYED
  84. };
  85. struct conn_info {
  86. int fd; /* File descriptor */
  87. enum conn_state state; /* State of this connection */
  88. char *inb; /* Input buffer for non-blocking reads */
  89. int inb_nextheader; /* Next message header starts here */
  90. int inb_start; /* Start location of input buffer */
  91. int inb_inuse; /* Bytes currently stored in input buffer */
  92. struct queue outq; /* Circular queue for outgoing requests */
  93. int byte_start; /* Byte to start sending from in head of queue */
  94. enum service_types service;/* Type of service so dispatch knows how to route message */
  95. struct saAmfComponent *component; /* Component for which this connection relates to TODO shouldn't this be in the ci structure */
  96. int authenticated; /* Is this connection authenticated? */
  97. struct list_head conn_list;
  98. struct ais_ci ais_ci; /* libais connection information */
  99. struct conn_info *conn_info_partner; /* partner connection dispatch<->response */
  100. int should_exit_fn; /* Should call the exit function when closing this ipc */
  101. };
  102. enum nodeexec_message_types {
  103. MESSAGE_REQ_EXEC_SYNC_BARRIER = 0,
  104. MESSAGE_REQ_EXEC_EVS_MCAST = 1,
  105. MESSAGE_REQ_EXEC_CLM_NODEJOIN = 2,
  106. MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER = 3,
  107. MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER = 4,
  108. MESSAGE_REQ_EXEC_AMF_ERRORREPORT = 5,
  109. MESSAGE_REQ_EXEC_AMF_ERRORCANCELALL = 6,
  110. MESSAGE_REQ_EXEC_AMF_READINESSSTATESET = 7,
  111. MESSAGE_REQ_EXEC_AMF_HASTATESET = 8,
  112. MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN = 9,
  113. MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE = 10,
  114. MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK = 11,
  115. MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET = 12,
  116. MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE = 13,
  117. MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE = 14,
  118. MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE = 15,
  119. MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET = 16,
  120. MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE = 17,
  121. MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE = 18,
  122. MESSAGE_REQ_EXEC_CKPT_SECTIONREAD = 19,
  123. MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE = 20,
  124. MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION = 21,
  125. MESSAGE_REQ_EXEC_EVT_EVENTDATA = 22,
  126. MESSAGE_REQ_EXEC_EVT_CHANCMD = 23,
  127. MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA = 24,
  128. MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN = 25,
  129. MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE = 26,
  130. MESSAGE_REQ_EXEC_LCK_RESOURCELOCK = 27,
  131. MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK = 28,
  132. MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN = 29,
  133. MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 30
  134. };
  135. extern struct totem_ip_address *this_ip;
  136. poll_handle aisexec_poll_handle;
  137. extern struct gmi_groupname aisexec_groupname;
  138. extern int libais_send_response (struct conn_info *conn_info, void *msg, int mlen);
  139. extern int message_source_is_local(struct message_source *source);
  140. extern void message_source_set(struct message_source *source, struct conn_info *conn_info);
  141. #endif /* AIS_EXEC_H_DEFINED */