saMsg.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@redhat.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. typedef enum {
  121. SA_MSG_QUEUE_CAPACITY_REACHED = 1,
  122. SA_MSG_QUEUE_CAPACITY_AVAILABLE = 2,
  123. SA_MSG_QUEUE_GROUP_CAPACITY_REACHED = 3,
  124. SA_MSG_QUEUE_GROUP_CAPACITY_AVAILABLE = 4
  125. } SaMsgMessageCapacityStatusT;
  126. typedef struct {
  127. SaSizeT capacityReached[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
  128. SaSizeT capacityAvailable[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
  129. } SaMsgQueueThresholdsT;
  130. typedef enum {
  131. SA_MSG_DEST_CAPACITY_STATUS = 1
  132. } SaMsgStateT;
  133. typedef enum {
  134. SA_MSG_MAX_PRIORITY_AREA_SIZE_ID = 1,
  135. SA_MSG_MAX_QUEUE_SIZE_ID = 2,
  136. SA_MSG_MAX_NUM_QUEUES_ID = 3,
  137. SA_MSG_MAX_NUM_QUEUE_GROUPS_ID = 4,
  138. SA_MSG_MAX_NUM_QUEUES_PER_GROUP_ID = 5,
  139. SA_MSG_MAX_MESSAGE_SIZE_ID = 6,
  140. SA_MSG_MAX_REPLY_SIZE_ID = 7
  141. } SaMsgLimitIdT;
  142. SaAisErrorT
  143. saMsgInitialize (
  144. SaMsgHandleT *msgHandle,
  145. const SaMsgCallbacksT *msgCallbacks,
  146. SaVersionT *version);
  147. SaAisErrorT
  148. saMsgSelectionObjectGet (
  149. SaMsgHandleT msgHandle,
  150. SaSelectionObjectT *selectionObject);
  151. SaAisErrorT
  152. saMsgDispatch (
  153. SaMsgHandleT msgHandle,
  154. SaDispatchFlagsT dispatchFlags);
  155. SaAisErrorT
  156. saMsgFinalize (
  157. SaMsgHandleT msgHandle);
  158. SaAisErrorT
  159. saMsgQueueOpen (
  160. SaMsgHandleT msgHandle,
  161. const SaNameT *queueName,
  162. const SaMsgQueueCreationAttributesT *creationAttributes,
  163. SaMsgQueueOpenFlagsT openFlags,
  164. SaTimeT timeout,
  165. SaMsgQueueHandleT *queueHandle);
  166. SaAisErrorT
  167. saMsgQueueOpenAsync (
  168. SaMsgHandleT msgHandle,
  169. SaInvocationT invocation,
  170. const SaNameT *queueName,
  171. const SaMsgQueueCreationAttributesT *creationAttributes,
  172. SaMsgQueueOpenFlagsT openFlags);
  173. SaAisErrorT
  174. saMsgQueueClose (
  175. SaMsgQueueHandleT msgHandle);
  176. SaAisErrorT
  177. saMsgQueueStatusGet (
  178. SaMsgHandleT msgHandle,
  179. const SaNameT *queueName,
  180. SaMsgQueueStatusT *queueStatus);
  181. SaAisErrorT
  182. saMsgQueueRetentionTimeSet (
  183. SaMsgQueueHandleT queueHandle,
  184. SaTimeT *retentionTime);
  185. SaAisErrorT
  186. saMsgQueueUnlink (
  187. SaMsgQueueHandleT msgHandle,
  188. const SaNameT *queueName);
  189. SaAisErrorT
  190. saMsgQueueGroupCreate (
  191. SaMsgHandleT msgHandle,
  192. const SaNameT *queueGroupName,
  193. SaMsgQueueGroupPolicyT queueGroupPolicy);
  194. SaAisErrorT
  195. saMsgQueueGroupInsert (
  196. SaMsgHandleT msgHandle,
  197. const SaNameT *queueGroupName,
  198. const SaNameT *queueName);
  199. SaAisErrorT
  200. saMsgQueueGroupRemove (
  201. SaMsgHandleT msgHandle,
  202. const SaNameT *queueGroupName,
  203. const SaNameT *queueName);
  204. SaAisErrorT
  205. saMsgQueueGroupDelete (
  206. SaMsgHandleT msgHandle,
  207. const SaNameT *queueGroupName);
  208. SaAisErrorT
  209. saMsgQueueGroupTrack (
  210. SaMsgHandleT msgHandle,
  211. const SaNameT *queueGroupName,
  212. SaUint8T trackFlags,
  213. SaMsgQueueGroupNotificationBufferT *notificationBuffer);
  214. SaAisErrorT
  215. saMsgQueueGroupTrackStop (
  216. SaMsgHandleT msgHandle,
  217. const SaNameT *queueGroupName);
  218. SaAisErrorT
  219. saMsgQueueGroupNotificationFree (
  220. SaMsgHandleT msgHandle,
  221. SaMsgQueueGroupNotificationT *notification);
  222. SaAisErrorT
  223. saMsgMessageSend (
  224. SaMsgHandleT msgHandle,
  225. const SaNameT *destination,
  226. const SaMsgMessageT *message,
  227. SaTimeT timeout);
  228. SaAisErrorT
  229. saMsgMessageSendAsync (
  230. SaMsgHandleT msgHandle,
  231. SaInvocationT invocation,
  232. const SaNameT *destination,
  233. const SaMsgMessageT *message,
  234. SaMsgAckFlagsT ackFlags);
  235. SaAisErrorT
  236. saMsgMessageGet (
  237. SaMsgQueueHandleT queueHandle,
  238. SaMsgMessageT *message,
  239. SaTimeT *sendTIme,
  240. SaMsgSenderIdT *senderId,
  241. SaTimeT timeout);
  242. SaAisErrorT
  243. saMsgMessageDataFree (
  244. SaMsgHandleT msgHandle,
  245. void *data);
  246. SaAisErrorT
  247. saMsgMessageCancel (
  248. SaMsgQueueHandleT queueHandle);
  249. SaAisErrorT
  250. saMsgMessageSendReceive (
  251. SaMsgHandleT msgHandle,
  252. const SaNameT *destination,
  253. const SaMsgMessageT *sendMessage,
  254. SaMsgMessageT *receiveMessage,
  255. SaTimeT *replySendTime,
  256. SaTimeT timeout);
  257. SaAisErrorT
  258. saMsgMessageReply (
  259. SaMsgHandleT msgHandle,
  260. const SaMsgMessageT *replyMessage,
  261. const SaMsgSenderIdT *senderId,
  262. SaTimeT timeout);
  263. SaAisErrorT
  264. saMsgMessageReplyAsync (
  265. SaMsgHandleT msgHandle,
  266. SaInvocationT invocation,
  267. const SaMsgMessageT *replyMessage,
  268. const SaMsgSenderIdT *senderId,
  269. SaMsgAckFlagsT ackFlags);
  270. SaAisErrorT
  271. saMsgQueueCapacityThresholdSet (
  272. SaMsgQueueHandleT queueHandle,
  273. const SaMsgQueueThresholdsT *thresholds);
  274. SaAisErrorT
  275. saMsgQueueCapacityThresholdGet (
  276. SaMsgQueueHandleT queueHandle,
  277. SaMsgQueueThresholdsT *thresholds);
  278. SaAisErrorT
  279. saMsgMetadataSizeGet (
  280. SaMsgHandleT msgHandle,
  281. SaUint32T *metadataSize);
  282. SaAisErrorT
  283. saMsgLimitGet (
  284. SaMsgHandleT msgHandle,
  285. SaMsgLimitIdT limitId,
  286. SaLimitValueT *limitValue);
  287. #endif /* SAMSG_H_DEFINED */