ua_client_internal.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2015-2016 (c) Sten Grüner
  6. * Copyright 2015-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  7. * Copyright 2015 (c) Oleksiy Vasylyev
  8. * Copyright 2016-2017 (c) Florian Palm
  9. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  10. * Copyright 2017 (c) Mark Giraud, Fraunhofer IOSB
  11. */
  12. #ifndef UA_CLIENT_INTERNAL_H_
  13. #define UA_CLIENT_INTERNAL_H_
  14. #include "ua_securechannel.h"
  15. #include "ua_client_highlevel.h"
  16. #include "ua_client_subscriptions.h"
  17. #include "../../deps/queue.h"
  18. /**************************/
  19. /* Subscriptions Handling */
  20. /**************************/
  21. #ifdef UA_ENABLE_SUBSCRIPTIONS
  22. typedef struct UA_Client_NotificationsAckNumber {
  23. LIST_ENTRY(UA_Client_NotificationsAckNumber) listEntry;
  24. UA_SubscriptionAcknowledgement subAck;
  25. } UA_Client_NotificationsAckNumber;
  26. typedef struct UA_Client_MonitoredItem {
  27. LIST_ENTRY(UA_Client_MonitoredItem) listEntry;
  28. UA_UInt32 monitoredItemId;
  29. UA_UInt32 clientHandle;
  30. void *context;
  31. UA_Client_DeleteMonitoredItemCallback deleteCallback;
  32. union {
  33. UA_Client_DataChangeNotificationCallback dataChangeCallback;
  34. UA_Client_EventNotificationCallback eventCallback;
  35. } handler;
  36. UA_Boolean isEventMonitoredItem; /* Otherwise a DataChange MoniitoredItem */
  37. } UA_Client_MonitoredItem;
  38. typedef struct UA_Client_Subscription {
  39. LIST_ENTRY(UA_Client_Subscription) listEntry;
  40. UA_UInt32 subscriptionId;
  41. void *context;
  42. UA_Double publishingInterval;
  43. UA_UInt32 maxKeepAliveCount;
  44. UA_Client_StatusChangeNotificationCallback statusChangeCallback;
  45. UA_Client_DeleteSubscriptionCallback deleteCallback;
  46. UA_UInt32 sequenceNumber;
  47. UA_DateTime lastActivity;
  48. LIST_HEAD(UA_ListOfClientMonitoredItems, UA_Client_MonitoredItem) monitoredItems;
  49. } UA_Client_Subscription;
  50. void
  51. UA_Client_Subscriptions_clean(UA_Client *client);
  52. void
  53. UA_Client_MonitoredItem_remove(UA_Client *client, UA_Client_Subscription *sub,
  54. UA_Client_MonitoredItem *mon);
  55. void
  56. UA_Client_Subscriptions_processPublishResponse(UA_Client *client,
  57. UA_PublishRequest *request,
  58. UA_PublishResponse *response);
  59. UA_StatusCode
  60. UA_Client_preparePublishRequest(UA_Client *client, UA_PublishRequest *request);
  61. UA_StatusCode
  62. UA_Client_Subscriptions_backgroundPublish(UA_Client *client);
  63. void
  64. UA_Client_Subscriptions_backgroundPublishInactivityCheck(UA_Client *client);
  65. #endif /* UA_ENABLE_SUBSCRIPTIONS */
  66. /**********/
  67. /* Client */
  68. /**********/
  69. typedef struct AsyncServiceCall {
  70. LIST_ENTRY(AsyncServiceCall) pointers;
  71. UA_UInt32 requestId;
  72. UA_ClientAsyncServiceCallback callback;
  73. const UA_DataType *responseType;
  74. void *userdata;
  75. } AsyncServiceCall;
  76. void UA_Client_AsyncService_cancel(UA_Client *client, AsyncServiceCall *ac,
  77. UA_StatusCode statusCode);
  78. void UA_Client_AsyncService_removeAll(UA_Client *client, UA_StatusCode statusCode);
  79. typedef enum {
  80. UA_CLIENTAUTHENTICATION_NONE,
  81. UA_CLIENTAUTHENTICATION_USERNAME
  82. } UA_Client_Authentication;
  83. struct UA_Client {
  84. /* State */
  85. UA_ClientState state;
  86. UA_ClientConfig config;
  87. /* Connection */
  88. UA_Connection connection;
  89. UA_String endpointUrl;
  90. /* SecureChannel */
  91. UA_SecurityPolicy securityPolicy; /* TODO: Move supported policies to the config */
  92. UA_SecureChannel channel;
  93. UA_UInt32 requestId;
  94. UA_DateTime nextChannelRenewal;
  95. /* Authentication */
  96. UA_Client_Authentication authenticationMethod;
  97. UA_String username;
  98. UA_String password;
  99. /* Session */
  100. UA_UserTokenPolicy token;
  101. UA_NodeId authenticationToken;
  102. UA_UInt32 requestHandle;
  103. /* Async Service */
  104. LIST_HEAD(ListOfAsyncServiceCall, AsyncServiceCall) asyncServiceCalls;
  105. /* Subscriptions */
  106. #ifdef UA_ENABLE_SUBSCRIPTIONS
  107. UA_UInt32 monitoredItemHandles;
  108. LIST_HEAD(ListOfUnacknowledgedNotifications, UA_Client_NotificationsAckNumber) pendingNotificationsAcks;
  109. LIST_HEAD(ListOfClientSubscriptionItems, UA_Client_Subscription) subscriptions;
  110. UA_UInt16 currentlyOutStandingPublishRequests;
  111. #endif
  112. };
  113. void
  114. setClientState(UA_Client *client, UA_ClientState state);
  115. UA_StatusCode
  116. UA_Client_connectInternal(UA_Client *client, const char *endpointUrl,
  117. UA_Boolean endpointsHandshake, UA_Boolean createNewSession);
  118. UA_StatusCode
  119. UA_Client_getEndpointsInternal(UA_Client *client, size_t* endpointDescriptionsSize,
  120. UA_EndpointDescription** endpointDescriptions);
  121. /* Receive and process messages until a synchronous message arrives or the
  122. * timout finishes */
  123. UA_StatusCode
  124. receiveServiceResponse(UA_Client *client, void *response, const UA_DataType *responseType,
  125. UA_DateTime maxDate, UA_UInt32 *synchronousRequestId);
  126. #endif /* UA_CLIENT_INTERNAL_H_ */