ua_client_config.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 2018 (c) Stefan Profanter, fortiss GmbH
  6. * Copyright 2018 (c) Thomas Stalder, Blue Time Concept SA
  7. */
  8. #ifndef UA_CLIENT_CONFIG_H
  9. #define UA_CLIENT_CONFIG_H
  10. #include "ua_config.h"
  11. #include "ua_plugin_network.h"
  12. _UA_BEGIN_DECLS
  13. struct UA_Client;
  14. typedef struct UA_Client UA_Client;
  15. /**
  16. * .. _client-config:
  17. *
  18. * Client Configuration
  19. * --------------------
  20. *
  21. * The client configuration is used for setting connection parameters and
  22. * additional settings used by the client.
  23. * The configuration should not be modified after it is passed to a client.
  24. * Currently, only one client can use a configuration at a time.
  25. *
  26. * Examples for configurations are provided in the ``/plugins`` folder.
  27. * The usual usage is as follows:
  28. *
  29. * 1. Create a client configuration with default settings as a starting point
  30. * 2. Modifiy the configuration, e.g. modifying the timeout
  31. * 3. Instantiate a client with it
  32. * 4. After shutdown of the client, clean up the configuration (free memory)
  33. *
  34. * The :ref:`tutorials` provide a good starting point for this. */
  35. typedef enum {
  36. UA_CLIENTSTATE_DISCONNECTED, /* The client is disconnected */
  37. UA_CLIENTSTATE_WAITING_FOR_ACK, /* The Client has sent HEL and waiting */
  38. UA_CLIENTSTATE_CONNECTED, /* A TCP connection to the server is open */
  39. UA_CLIENTSTATE_SECURECHANNEL, /* A SecureChannel to the server is open */
  40. UA_CLIENTSTATE_SESSION, /* A session with the server is open */
  41. UA_CLIENTSTATE_SESSION_DISCONNECTED, /* Disconnected vs renewed? */
  42. UA_CLIENTSTATE_SESSION_RENEWED /* A session with the server is open (renewed) */
  43. } UA_ClientState;
  44. typedef struct {
  45. /* Basic client configuration */
  46. void *clientContext; /* User-defined data attached to the client */
  47. UA_Logger logger; /* Logger used by the client */
  48. UA_UInt32 timeout; /* Response timeout in ms */
  49. UA_ApplicationDescription clientDescription;
  50. /* Basic connection configuration */
  51. UA_ExtensionObject userIdentityToken; /* Configured User-Identity Token */
  52. UA_MessageSecurityMode securityMode; /* None, Sign, SignAndEncrypt. The
  53. * default is invalid. This indicates
  54. * the client to select any matching
  55. * endpoint. */
  56. UA_String securityPolicyUri; /* SecurityPolicy for the SecureChannel. An
  57. * empty string indicates the client to select
  58. * any matching SecurityPolicy. */
  59. /* Advanced connection configuration
  60. *
  61. * If either endpoint or userTokenPolicy has been set (at least one non-zero
  62. * byte in either structure), then the selected Endpoint and UserTokenPolicy
  63. * overwrite the settings in the basic connection configuration. The
  64. * userTokenPolicy array in the EndpointDescription is ignored. The selected
  65. * userTokenPolicy is set in the dedicated configuration field.
  66. *
  67. * If the advanced configuration is not set, the client will write to it the
  68. * selected Endpoint and UserTokenPolicy during GetEndpoints.
  69. *
  70. * The information in the advanced configuration is used during reconnect
  71. * when the SecureChannel was broken. */
  72. UA_EndpointDescription endpoint;
  73. UA_UserTokenPolicy userTokenPolicy;
  74. /* Advanced client configuration */
  75. UA_UInt32 secureChannelLifeTime; /* Lifetime in ms (then the channel needs
  76. to be renewed) */
  77. UA_UInt32 requestedSessionTimeout; /* Session timeout in ms */
  78. UA_ConnectionConfig localConnectionConfig;
  79. UA_UInt32 connectivityCheckInterval; /* Connectivity check interval in ms.
  80. * 0 = background task disabled */
  81. const UA_DataTypeArray *customDataTypes; /* Custom DataTypes. Attention!
  82. * Custom datatypes are not cleaned
  83. * up together with the
  84. * configuration. So it is possible
  85. * to allocate them on ROM. */
  86. /* Available SecurityPolicies */
  87. size_t securityPoliciesSize;
  88. UA_SecurityPolicy *securityPolicies;
  89. /* Certificate Verification Plugin */
  90. UA_CertificateVerification certificateVerification;
  91. /* Callbacks for async connection handshakes */
  92. UA_ConnectClientConnection connectionFunc;
  93. UA_ConnectClientConnection initConnectionFunc;
  94. void (*pollConnectionFunc)(UA_Client *client, void *context);
  95. /* Callback for state changes */
  96. void (*stateCallback)(UA_Client *client, UA_ClientState clientState);
  97. /* When connectivityCheckInterval is greater than 0, every
  98. * connectivityCheckInterval (in ms), a async read request is performed on
  99. * the server. inactivityCallback is called when the client receive no
  100. * response for this read request The connection can be closed, this in an
  101. * attempt to recreate a healthy connection. */
  102. void (*inactivityCallback)(UA_Client *client);
  103. #ifdef UA_ENABLE_SUBSCRIPTIONS
  104. /* Number of PublishResponse queued up in the server */
  105. UA_UInt16 outStandingPublishRequests;
  106. /* If the client does not receive a PublishResponse after the defined delay
  107. * of ``(sub->publishingInterval * sub->maxKeepAliveCount) +
  108. * client->config.timeout)``, then subscriptionInactivityCallback is called
  109. * for the subscription.. */
  110. void (*subscriptionInactivityCallback)(UA_Client *client,
  111. UA_UInt32 subscriptionId,
  112. void *subContext);
  113. #endif
  114. } UA_ClientConfig;
  115. _UA_END_DECLS
  116. #endif /* UA_CLIENT_CONFIG_H */