ua_client_internal.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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) Julius Pfrommer, Fraunhofer IOSB
  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 "../../deps/queue.h"
  17. /**************************/
  18. /* Subscriptions Handling */
  19. /**************************/
  20. #ifdef UA_ENABLE_SUBSCRIPTIONS
  21. typedef struct UA_Client_NotificationsAckNumber {
  22. LIST_ENTRY(UA_Client_NotificationsAckNumber) listEntry;
  23. UA_SubscriptionAcknowledgement subAck;
  24. } UA_Client_NotificationsAckNumber;
  25. typedef struct UA_Client_MonitoredItem {
  26. LIST_ENTRY(UA_Client_MonitoredItem) listEntry;
  27. UA_UInt32 monitoredItemId;
  28. UA_UInt32 monitoringMode;
  29. UA_NodeId monitoredNodeId;
  30. UA_UInt32 attributeID;
  31. UA_UInt32 clientHandle;
  32. UA_Double samplingInterval;
  33. UA_UInt32 queueSize;
  34. UA_Boolean discardOldest;
  35. UA_Boolean isEventMonitoredItem; /* Otherwise a DataChange MoniitoredItem */
  36. union {
  37. UA_MonitoredItemHandlingFunction dataChangeHandler;
  38. UA_MonitoredEventHandlingFunction eventHandler;
  39. } handler;
  40. void *handlerContext;
  41. } UA_Client_MonitoredItem;
  42. typedef struct UA_Client_Subscription {
  43. LIST_ENTRY(UA_Client_Subscription) listEntry;
  44. UA_UInt32 lifeTime;
  45. UA_UInt32 keepAliveCount;
  46. UA_Double publishingInterval;
  47. UA_UInt32 subscriptionID;
  48. UA_UInt32 notificationsPerPublish;
  49. UA_UInt32 priority;
  50. LIST_HEAD(UA_ListOfClientMonitoredItems, UA_Client_MonitoredItem) monitoredItems;
  51. } UA_Client_Subscription;
  52. void UA_Client_Subscriptions_forceDelete(UA_Client *client, UA_Client_Subscription *sub);
  53. void UA_Client_Subscriptions_clean(UA_Client *client);
  54. #endif
  55. /**********/
  56. /* Client */
  57. /**********/
  58. typedef struct AsyncServiceCall {
  59. LIST_ENTRY(AsyncServiceCall) pointers;
  60. UA_UInt32 requestId;
  61. UA_ClientAsyncServiceCallback callback;
  62. const UA_DataType *responseType;
  63. void *userdata;
  64. } AsyncServiceCall;
  65. typedef enum {
  66. UA_CLIENTAUTHENTICATION_NONE,
  67. UA_CLIENTAUTHENTICATION_USERNAME
  68. } UA_Client_Authentication;
  69. struct UA_Client {
  70. /* State */
  71. UA_ClientState state;
  72. UA_ClientConfig config;
  73. /* Connection */
  74. UA_Connection connection;
  75. UA_String endpointUrl;
  76. /* SecureChannel */
  77. UA_SecurityPolicy securityPolicy;
  78. UA_SecureChannel channel;
  79. UA_UInt32 requestId;
  80. UA_DateTime nextChannelRenewal;
  81. /* Authentication */
  82. UA_Client_Authentication authenticationMethod;
  83. UA_String username;
  84. UA_String password;
  85. /* Session */
  86. UA_UserTokenPolicy token;
  87. UA_NodeId authenticationToken;
  88. UA_UInt32 requestHandle;
  89. /* Async Service */
  90. LIST_HEAD(ListOfAsyncServiceCall, AsyncServiceCall) asyncServiceCalls;
  91. /* Subscriptions */
  92. #ifdef UA_ENABLE_SUBSCRIPTIONS
  93. UA_UInt32 monitoredItemHandles;
  94. LIST_HEAD(ListOfUnacknowledgedNotifications, UA_Client_NotificationsAckNumber) pendingNotificationsAcks;
  95. LIST_HEAD(ListOfClientSubscriptionItems, UA_Client_Subscription) subscriptions;
  96. #endif
  97. };
  98. void
  99. setClientState(UA_Client *client, UA_ClientState state);
  100. UA_StatusCode
  101. UA_Client_connectInternal(UA_Client *client, const char *endpointUrl,
  102. UA_Boolean endpointsHandshake, UA_Boolean createNewSession);
  103. UA_StatusCode
  104. UA_Client_getEndpointsInternal(UA_Client *client, size_t* endpointDescriptionsSize,
  105. UA_EndpointDescription** endpointDescriptions);
  106. /* Receive and process messages until a synchronous message arrives or the
  107. * timout finishes */
  108. UA_StatusCode
  109. receiveServiceResponse(UA_Client *client, void *response, const UA_DataType *responseType,
  110. UA_DateTime maxDate, UA_UInt32 *synchronousRequestId);
  111. #endif /* UA_CLIENT_INTERNAL_H_ */