ua_services.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. #ifndef UA_SERVICES_H_
  5. #define UA_SERVICES_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "ua_server.h"
  10. #include "ua_session.h"
  11. #include "ua_nodes.h"
  12. /**
  13. * .. _services:
  14. *
  15. * Services
  16. * ========
  17. *
  18. * In OPC UA, all communication is based on service calls, each consisting of a
  19. * request and a response message. These messages are defined as data structures
  20. * with a binary encoding and listed in :ref:`generated-types`. Since all
  21. * Services are pre-defined in the standard, they cannot be modified by the
  22. * user. But you can use the :ref:`Call <method-services>` service to invoke
  23. * user-defined methods on the server.
  24. *
  25. * The following service signatures are internal and *not visible to users*.
  26. * Still, we present them here for an overview of the capabilities of OPC UA.
  27. * Please refer to the :ref:`client` and :ref:`server` API where the services
  28. * are exposed to end users. Please see part 4 of the OPC UA standard for the
  29. * authoritative definition of the service and their behaviour. */
  30. /* Most services take as input the server, the current session and pointers to
  31. * the request and response structures. Possible error codes are returned as
  32. * part of the response. */
  33. typedef void (*UA_Service)(UA_Server*, UA_Session*,
  34. const void *request, void *response);
  35. /**
  36. * Discovery Service Set
  37. * ---------------------
  38. * This Service Set defines Services used to discover the Endpoints implemented
  39. * by a Server and to read the security configuration for those Endpoints. */
  40. /* Returns the Servers known to a Server or Discovery Server.
  41. * The Client may reduce the number of results returned by specifying filter criteria */
  42. void Service_FindServers(UA_Server *server, UA_Session *session,
  43. const UA_FindServersRequest *request,
  44. UA_FindServersResponse *response);
  45. /* Returns the Endpoints supported by a Server and all of the configuration
  46. * information required to establish a SecureChannel and a Session. */
  47. void Service_GetEndpoints(UA_Server *server, UA_Session *session,
  48. const UA_GetEndpointsRequest *request,
  49. UA_GetEndpointsResponse *response);
  50. #ifdef UA_ENABLE_DISCOVERY
  51. # ifdef UA_ENABLE_DISCOVERY_MULTICAST
  52. /* Returns the Servers known to a Discovery Server. Unlike FindServer,
  53. * this Service is only implemented by Discovery Servers. It additionally
  54. * Returns servery which may have been detected trough Multicast */
  55. void Service_FindServersOnNetwork(UA_Server *server, UA_Session *session,
  56. const UA_FindServersOnNetworkRequest *request,
  57. UA_FindServersOnNetworkResponse *response);
  58. # endif // UA_ENABLE_DISCOVERY_MULTICAST
  59. /* Registers a remote server in the local discovery service. */
  60. void Service_RegisterServer(UA_Server *server, UA_Session *session,
  61. const UA_RegisterServerRequest *request,
  62. UA_RegisterServerResponse *response);
  63. /* Checks if a registration timed out and removes that registration.
  64. * Should be called periodically in main loop */
  65. void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic);
  66. /* This Service allows a Server to register its DiscoveryUrls and capabilities
  67. * with a Discovery Server. It extends the registration information from
  68. * RegisterServer with information necessary for FindServersOnNetwork. */
  69. void Service_RegisterServer2(UA_Server *server, UA_Session *session,
  70. const UA_RegisterServer2Request *request,
  71. UA_RegisterServer2Response *response);
  72. #endif // UA_ENABLE_DISCOVERY
  73. /**
  74. * SecureChannel Service Set
  75. * -------------------------
  76. * This Service Set defines Services used to open a communication channel that
  77. * ensures the confidentiality and Integrity of all Messages exchanged with the
  78. * Server. */
  79. /* Open or renew a SecureChannel that can be used to ensure Confidentiality and
  80. * Integrity for Message exchange during a Session. */
  81. void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
  82. const UA_OpenSecureChannelRequest *request,
  83. UA_OpenSecureChannelResponse *response);
  84. /* Used to terminate a SecureChannel. */
  85. void Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel);
  86. /**
  87. * Session Service Set
  88. * -------------------
  89. * This Service Set defines Services for an application layer connection
  90. * establishment in the context of a Session. */
  91. /* Used by an OPC UA Client to create a Session and the Server returns two
  92. * values which uniquely identify the Session. The first value is the sessionId
  93. * which is used to identify the Session in the audit logs and in the Server's
  94. * address space. The second is the authenticationToken which is used to
  95. * associate an incoming request with a Session. */
  96. void Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
  97. const UA_CreateSessionRequest *request,
  98. UA_CreateSessionResponse *response);
  99. /* Used by the Client to submit its SoftwareCertificates to the Server for
  100. * validation and to specify the identity of the user associated with the
  101. * Session. This Service request shall be issued by the Client before it issues
  102. * any other Service request after CreateSession. Failure to do so shall cause
  103. * the Server to close the Session. */
  104. void Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
  105. UA_Session *session,
  106. const UA_ActivateSessionRequest *request,
  107. UA_ActivateSessionResponse *response);
  108. /* Used to terminate a Session. */
  109. void Service_CloseSession(UA_Server *server, UA_Session *session,
  110. const UA_CloseSessionRequest *request,
  111. UA_CloseSessionResponse *response);
  112. /* Not Implemented: Service_Cancel */
  113. /**
  114. * NodeManagement Service Set
  115. * --------------------------
  116. * This Service Set defines Services to add and delete AddressSpace Nodes and
  117. * References between them. All added Nodes continue to exist in the
  118. * AddressSpace even if the Client that created them disconnects from the
  119. * Server. */
  120. /* Used to add one or more Nodes into the AddressSpace hierarchy. */
  121. void Service_AddNodes(UA_Server *server, UA_Session *session,
  122. const UA_AddNodesRequest *request,
  123. UA_AddNodesResponse *response);
  124. /* Used to add one or more References to one or more Nodes. */
  125. void Service_AddReferences(UA_Server *server, UA_Session *session,
  126. const UA_AddReferencesRequest *request,
  127. UA_AddReferencesResponse *response);
  128. /* Used to delete one or more Nodes from the AddressSpace. */
  129. void Service_DeleteNodes(UA_Server *server, UA_Session *session,
  130. const UA_DeleteNodesRequest *request,
  131. UA_DeleteNodesResponse *response);
  132. /* Used to delete one or more References of a Node. */
  133. void Service_DeleteReferences(UA_Server *server, UA_Session *session,
  134. const UA_DeleteReferencesRequest *request,
  135. UA_DeleteReferencesResponse *response);
  136. /**
  137. * .. _view-services:
  138. *
  139. * View Service Set
  140. * ----------------
  141. * Clients use the browse Services of the View Service Set to navigate through
  142. * the AddressSpace or through a View which is a subset of the AddressSpace. */
  143. /* Used to discover the References of a specified Node. The browse can be
  144. * further limited by the use of a View. This Browse Service also supports a
  145. * primitive filtering capability. */
  146. void Service_Browse(UA_Server *server, UA_Session *session,
  147. const UA_BrowseRequest *request,
  148. UA_BrowseResponse *response);
  149. /* Used to request the next set of Browse or BrowseNext response information
  150. * that is too large to be sent in a single response. "Too large" in this
  151. * context means that the Server is not able to return a larger response or that
  152. * the number of results to return exceeds the maximum number of results to
  153. * return that was specified by the Client in the original Browse request. */
  154. void Service_BrowseNext(UA_Server *server, UA_Session *session,
  155. const UA_BrowseNextRequest *request,
  156. UA_BrowseNextResponse *response);
  157. /* Used to translate textual node paths to their respective ids. */
  158. void Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *session,
  159. const UA_TranslateBrowsePathsToNodeIdsRequest *request,
  160. UA_TranslateBrowsePathsToNodeIdsResponse *response);
  161. /* Used by Clients to register the Nodes that they know they will access
  162. * repeatedly (e.g. Write, Call). It allows Servers to set up anything needed so
  163. * that the access operations will be more efficient. */
  164. void Service_RegisterNodes(UA_Server *server, UA_Session *session,
  165. const UA_RegisterNodesRequest *request,
  166. UA_RegisterNodesResponse *response);
  167. /* This Service is used to unregister NodeIds that have been obtained via the
  168. * RegisterNodes service. */
  169. void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
  170. const UA_UnregisterNodesRequest *request,
  171. UA_UnregisterNodesResponse *response);
  172. /**
  173. * Query Service Set
  174. * -----------------
  175. * This Service Set is used to issue a Query to a Server. OPC UA Query is
  176. * generic in that it provides an underlying storage mechanism independent Query
  177. * capability that can be used to access a wide variety of OPC UA data stores
  178. * and information management systems. OPC UA Query permits a Client to access
  179. * data maintained by a Server without any knowledge of the logical schema used
  180. * for internal storage of the data. Knowledge of the AddressSpace is
  181. * sufficient. */
  182. /* Not Implemented: Service_QueryFirst */
  183. /* Not Impelemented: Service_QueryNext */
  184. /**
  185. * Attribute Service Set
  186. * ---------------------
  187. * This Service Set provides Services to access Attributes that are part of
  188. * Nodes. */
  189. /* Used to read one or more Attributes of one or more Nodes. For constructed
  190. * Attribute values whose elements are indexed, such as an array, this Service
  191. * allows Clients to read the entire set of indexed values as a composite, to
  192. * read individual elements or to read ranges of elements of the composite. */
  193. void Service_Read(UA_Server *server, UA_Session *session,
  194. const UA_ReadRequest *request,
  195. UA_ReadResponse *response);
  196. /* Used to write one or more Attributes of one or more Nodes. For constructed
  197. * Attribute values whose elements are indexed, such as an array, this Service
  198. * allows Clients to write the entire set of indexed values as a composite, to
  199. * write individual elements or to write ranges of elements of the composite. */
  200. void Service_Write(UA_Server *server, UA_Session *session,
  201. const UA_WriteRequest *request,
  202. UA_WriteResponse *response);
  203. /* Not Implemented: Service_HistoryRead */
  204. /* Not Implemented: Service_HistoryUpdate */
  205. /**
  206. * .. _method-services:
  207. *
  208. * Method Service Set
  209. * ------------------
  210. * The Method Service Set defines the means to invoke methods. A method shall be
  211. * a component of an Object. See the section on :ref:`MethodNodes <methodnode>`
  212. * for more information. */
  213. /* Used to call (invoke) a list of Methods. Each method call is invoked within
  214. * the context of an existing Session. If the Session is terminated, the results
  215. * of the method's execution cannot be returned to the Client and are
  216. * discarded. */
  217. void Service_Call(UA_Server *server, UA_Session *session,
  218. const UA_CallRequest *request,
  219. UA_CallResponse *response);
  220. /**
  221. * MonitoredItem Service Set
  222. * -------------------------
  223. * Clients define MonitoredItems to subscribe to data and Events. Each
  224. * MonitoredItem identifies the item to be monitored and the Subscription to use
  225. * to send Notifications. The item to be monitored may be any Node Attribute. */
  226. /* Used to create and add one or more MonitoredItems to a Subscription. A
  227. * MonitoredItem is deleted automatically by the Server when the Subscription is
  228. * deleted. Deleting a MonitoredItem causes its entire set of triggered item
  229. * links to be deleted, but has no effect on the MonitoredItems referenced by
  230. * the triggered items. */
  231. void Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
  232. const UA_CreateMonitoredItemsRequest *request,
  233. UA_CreateMonitoredItemsResponse *response);
  234. /* Used to remove one or more MonitoredItems of a Subscription. When a
  235. * MonitoredItem is deleted, its triggered item links are also deleted. */
  236. void Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
  237. const UA_DeleteMonitoredItemsRequest *request,
  238. UA_DeleteMonitoredItemsResponse *response);
  239. void Service_ModifyMonitoredItems(UA_Server *server, UA_Session *session,
  240. const UA_ModifyMonitoredItemsRequest *request,
  241. UA_ModifyMonitoredItemsResponse *response);
  242. /* Used to set the monitoring mode for one or more MonitoredItems of a
  243. Subscription. */
  244. void Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
  245. const UA_SetMonitoringModeRequest *request,
  246. UA_SetMonitoringModeResponse *response);
  247. /* Not Implemented: Service_SetTriggering */
  248. /**
  249. * Subscription Service Set
  250. * ------------------------
  251. * Subscriptions are used to report Notifications to the Client. */
  252. /* Used to create a Subscription. Subscriptions monitor a set of MonitoredItems
  253. * for Notifications and return them to the Client in response to Publish
  254. * requests. */
  255. void Service_CreateSubscription(UA_Server *server, UA_Session *session,
  256. const UA_CreateSubscriptionRequest *request,
  257. UA_CreateSubscriptionResponse *response);
  258. /* Used to modify a Subscription. */
  259. void Service_ModifySubscription(UA_Server *server, UA_Session *session,
  260. const UA_ModifySubscriptionRequest *request,
  261. UA_ModifySubscriptionResponse *response);
  262. /* Used to enable sending of Notifications on one or more Subscriptions. */
  263. void Service_SetPublishingMode(UA_Server *server, UA_Session *session,
  264. const UA_SetPublishingModeRequest *request,
  265. UA_SetPublishingModeResponse *response);
  266. /* Used for two purposes. First, it is used to acknowledge the receipt of
  267. * NotificationMessages for one or more Subscriptions. Second, it is used to
  268. * request the Server to return a NotificationMessage or a keep-alive
  269. * Message.
  270. *
  271. * Note that the service signature is an exception and does not contain a
  272. * pointer to a PublishResponse. That is because the service queues up publish
  273. * requests internally and sends responses asynchronously based on timeouts. */
  274. void Service_Publish(UA_Server *server, UA_Session *session,
  275. const UA_PublishRequest *request, UA_UInt32 requestId);
  276. /* Requests the Subscription to republish a NotificationMessage from its
  277. * retransmission queue. */
  278. void Service_Republish(UA_Server *server, UA_Session *session,
  279. const UA_RepublishRequest *request,
  280. UA_RepublishResponse *response);
  281. /* Invoked to delete one or more Subscriptions that belong to the Client's
  282. * Session. */
  283. void Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
  284. const UA_DeleteSubscriptionsRequest *request,
  285. UA_DeleteSubscriptionsResponse *response);
  286. /* Not Implemented: Service_TransferSubscription */
  287. #ifdef __cplusplus
  288. } // extern "C"
  289. #endif
  290. #endif /* UA_SERVICES_H_ */