saMsg.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Copyright (c) 2005 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. #ifndef SAMSG_H_DEFINED
  35. #define SAMSG_H_DEFINED
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. typedef SaUint64T SaMsgHandleT;
  40. typedef SaUint64T SaMsgQueueHandleT;
  41. typedef SaUint64T SaMsgSenderIdT;
  42. #define SA_MSG_MESSAGE_DELIVERED_ACK 0x1
  43. typedef SaUint32T SaMsgAckFlagsT;
  44. #define SA_MSG_QUEUE_PERSISTENT 0x1
  45. typedef SaUint32T SaMsgQueueCreationFlagsT;
  46. #define SA_MSG_MESSAGE_HIGHEST_PRIORITY 0
  47. #define SA_MSG_MESSAGE_LOWEST_PRIORITY 3
  48. typedef struct {
  49. SaMsgQueueCreationFlagsT creationFlags;
  50. SaSizeT size[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
  51. SaTimeT retentionTime;
  52. } SaMsgQueueCreationAttributesT;
  53. typedef enum {
  54. SA_MSG_QUEUE_GROUP_ROUND_ROBIN = 1,
  55. SA_MSG_QUEUE_GROUP_LOCAL_ROUND_ROBIN = 2,
  56. SA_MSG_QUEUE_GROUP_LOCAL_BEST_QUEUE = 3,
  57. SA_MSG_QUEUE_GROUP_BROADCAST = 4
  58. } SaMsgQueueGroupPolicyT;
  59. #define SA_MSG_QUEUE_CREATE 0x1
  60. #define SA_MSG_QUEUE_RECEIVE_CALLBACK 0x2
  61. #define SA_MSG_QUEUE_EMPTY 0x4
  62. typedef SaUint32T SaMsgQueueOpenFlagsT;
  63. typedef struct {
  64. SaSizeT queueSize;
  65. SaSizeT queueUsed;
  66. SaUint32T numberOfMessages;
  67. } SaMsgQueueUsageT;
  68. typedef struct {
  69. SaMsgQueueCreationFlagsT creationFlags;
  70. SaTimeT retentionTime;
  71. SaTimeT closeTime;
  72. SaMsgQueueUsageT saMsgQueueUsage[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
  73. } SaMsgQueueStatusT;
  74. typedef enum {
  75. SA_MSG_QUEUE_GROUP_NO_CHANGE = 1,
  76. SA_MSG_QUEUE_GROUP_ADDED = 2,
  77. SA_MSG_QUEUE_GROUP_REMOVED = 3,
  78. SA_MSG_QUEUE_GROUP_STATE_CHANGED = 4
  79. } SaMsgQueueGroupChangesT;
  80. typedef struct {
  81. SaNameT queueName;
  82. } SaMsgQueueGroupMemberT;
  83. typedef struct {
  84. SaMsgQueueGroupMemberT member;
  85. SaMsgQueueGroupChangesT change;
  86. } SaMsgQueueGroupNotificationT;
  87. typedef struct {
  88. SaUint32T numberOfItems;
  89. SaMsgQueueGroupNotificationT *notification;
  90. SaMsgQueueGroupPolicyT queueGroupPolicy;
  91. } SaMsgQueueGroupNotificationBufferT;
  92. typedef struct {
  93. SaUint32T type;
  94. SaUint32T version;
  95. SaSizeT size;
  96. SaNameT *senderName;
  97. void *data;
  98. SaUint8T priority;
  99. } SaMsgMessageT;
  100. typedef void (*SaMsgQueueOpenCallbackT) (
  101. SaInvocationT invocation,
  102. SaMsgQueueHandleT queueHandle,
  103. SaAisErrorT error);
  104. typedef void (*SaMsgQueueGroupTrackCallbackT) (
  105. const SaNameT *queueGroupName,
  106. const SaMsgQueueGroupNotificationBufferT *notificationBuffer,
  107. SaUint32T numberOfMembers,
  108. SaAisErrorT error);
  109. typedef void (*SaMsgMessageDeliveredCallbackT) (
  110. SaInvocationT invocation,
  111. SaAisErrorT error);
  112. typedef void (*SaMsgMessageReceivedCallbackT) (
  113. SaMsgQueueHandleT queueHandle);
  114. typedef struct {
  115. SaMsgQueueOpenCallbackT saMsgQueueOpenCallback;
  116. SaMsgQueueGroupTrackCallbackT saMsgQueueGroupTrackCallback;
  117. SaMsgMessageDeliveredCallbackT saMsgMessageDeliveredCallback;
  118. SaMsgMessageReceivedCallbackT saMsgMessageReceivedCallback;
  119. } SaMsgCallbacksT;
  120. SaAisErrorT
  121. saMsgInitialize (
  122. SaMsgHandleT *msgHandle,
  123. const SaMsgCallbacksT *msgCallbacks,
  124. SaVersionT *version);
  125. SaAisErrorT saMsgSelectionObjectGet (
  126. SaMsgHandleT msgHandle,
  127. SaSelectionObjectT *selectionObject);
  128. SaAisErrorT
  129. saMsgDispatch (
  130. SaMsgHandleT msgHandle,
  131. SaDispatchFlagsT dispatchFlags);
  132. SaAisErrorT
  133. saMsgFinalize (
  134. SaMsgHandleT msgHandle);
  135. SaAisErrorT
  136. saMsgQueueOpen (
  137. SaMsgHandleT msgHandle,
  138. const SaNameT *queueName,
  139. const SaMsgQueueCreationAttributesT *creationAttributes,
  140. SaMsgQueueOpenFlagsT openFlags,
  141. SaTimeT timeout,
  142. SaMsgQueueHandleT *queueHandle);
  143. SaAisErrorT
  144. saMsgQueueOpenAsync (
  145. SaMsgHandleT msgHandle,
  146. SaInvocationT invocation,
  147. const SaNameT *queueName,
  148. const SaMsgQueueCreationAttributesT *creationAttributes,
  149. SaMsgQueueOpenFlagsT openFlags);
  150. SaAisErrorT
  151. saMsgQueueClose (
  152. SaMsgQueueHandleT msgHandle);
  153. SaAisErrorT
  154. saMsgQueueStatusGet (
  155. SaMsgQueueHandleT msgHandle,
  156. const SaNameT *queueName,
  157. SaMsgQueueStatusT *queueStatus);
  158. SaAisErrorT
  159. saMsgQueueUnlink (
  160. SaMsgQueueHandleT msgHandle,
  161. const SaNameT *queueName);
  162. SaAisErrorT
  163. saMsgQueueGroupCreate (
  164. SaMsgHandleT msgHandle,
  165. const SaNameT *queueGroupName,
  166. SaMsgQueueGroupPolicyT queueGroupPolicy);
  167. SaAisErrorT
  168. saMsgQueueGroupInsert (
  169. SaMsgHandleT msgHandle,
  170. const SaNameT *queueGroupName,
  171. const SaNameT *queueName);
  172. SaAisErrorT
  173. saMsgQueueGroupRemove (
  174. SaMsgHandleT msgHandle,
  175. const SaNameT *queueGroupName,
  176. const SaNameT *queueName);
  177. SaAisErrorT
  178. saMsgQueueGroupDelete (
  179. SaMsgHandleT msgHandle,
  180. const SaNameT *queueGroupName);
  181. SaAisErrorT
  182. saMsgQueueGroupTrack (
  183. SaMsgHandleT msgHandle,
  184. const SaNameT *queueGroupName,
  185. SaUint8T trackFlags,
  186. SaMsgQueueGroupNotificationBufferT *notificationBuffer);
  187. SaAisErrorT
  188. saMsgQueueGroupTrackStop (
  189. SaMsgHandleT msgHandle,
  190. const SaNameT *queueGroupName);
  191. SaAisErrorT
  192. saMsgMessageSend (
  193. SaMsgHandleT msgHandle,
  194. const SaNameT *destination,
  195. const SaMsgMessageT *message,
  196. SaTimeT timeout);
  197. SaAisErrorT
  198. saMsgMessageSendAsync (
  199. SaMsgHandleT msgHandle,
  200. SaInvocationT invocation,
  201. const SaNameT *destination,
  202. const SaMsgMessageT *message,
  203. SaMsgAckFlagsT ackFlags);
  204. SaAisErrorT
  205. saMsgMessageGet (
  206. SaMsgQueueHandleT queueHandle,
  207. SaMsgMessageT *message,
  208. SaTimeT *sendTIme,
  209. SaMsgSenderIdT *senderId,
  210. SaTimeT timeout);
  211. SaAisErrorT
  212. saMsgMessageCancel (
  213. SaMsgQueueHandleT queueHandle);
  214. SaAisErrorT
  215. saMsgMessageSendReceive (
  216. SaMsgHandleT msgHandle,
  217. const SaNameT *destination,
  218. const SaMsgMessageT *sendMessage,
  219. SaMsgMessageT *receiveMessage,
  220. SaTimeT *replySendTime,
  221. SaTimeT timeout);
  222. SaAisErrorT
  223. saMsgMessageReply (
  224. SaMsgHandleT msgHandle,
  225. const SaMsgMessageT *replyMessage,
  226. const SaMsgSenderIdT *senderId,
  227. SaTimeT timeout);
  228. SaAisErrorT saMsgMessageREplyAsync (
  229. SaMsgHandleT msgHandle,
  230. SaInvocationT invocation,
  231. const SaMsgMessageT *replyMessage,
  232. const SaMsgSenderIdT *senderId,
  233. SaMsgAckFlagsT ackFlags);
  234. #endif /* SALCK_H_DEFINED */