ua_services.h 16 KB

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