ua_services.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 2014-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2014-2017 (c) Florian Palm
  7. * Copyright 2015 (c) Sten Grüner
  8. * Copyright 2014 (c) LEvertz
  9. * Copyright 2015 (c) Chris Iatrou
  10. * Copyright 2015 (c) Christian Fimmers
  11. * Copyright 2015-2016 (c) Oleksiy Vasylyev
  12. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  13. */
  14. #ifndef UA_SERVICES_H_
  15. #define UA_SERVICES_H_
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #include "ua_server.h"
  20. #include "ua_session.h"
  21. /**
  22. * .. _services:
  23. *
  24. * Services
  25. * ========
  26. *
  27. * In OPC UA, all communication is based on service calls, each consisting of a
  28. * request and a response message. These messages are defined as data structures
  29. * with a binary encoding and listed in :ref:`generated-types`. Since all
  30. * Services are pre-defined in the standard, they cannot be modified by the
  31. * user. But you can use the :ref:`Call <method-services>` service to invoke
  32. * user-defined methods on the server.
  33. *
  34. * The following service signatures are internal and *not visible to users*.
  35. * Still, we present them here for an overview of the capabilities of OPC UA.
  36. * Please refer to the :ref:`client` and :ref:`server` API where the services
  37. * are exposed to end users. Please see part 4 of the OPC UA standard for the
  38. * authoritative definition of the service and their behaviour.
  39. *
  40. * Most services take as input the server, the current session and pointers to
  41. * the request and response structures. Possible error codes are returned as
  42. * part of the response. */
  43. typedef void (*UA_Service)(UA_Server*, UA_Session*,
  44. const void *request, void *response);
  45. typedef UA_StatusCode (*UA_InSituService)(UA_Server*, UA_Session*, UA_MessageContext *mc,
  46. const void *request, UA_ResponseHeader *rh);
  47. /**
  48. * Discovery Service Set
  49. * ---------------------
  50. * This Service Set defines Services used to discover the Endpoints implemented
  51. * by a Server and to read the security configuration for those Endpoints.
  52. *
  53. * FindServers Service
  54. * ^^^^^^^^^^^^^^^^^^^
  55. * Returns the Servers known to a Server or Discovery Server. The Client may
  56. * reduce the number of results returned by specifying filter criteria */
  57. void Service_FindServers(UA_Server *server, UA_Session *session,
  58. const UA_FindServersRequest *request,
  59. UA_FindServersResponse *response);
  60. /**
  61. * GetEndpoints Service
  62. * ^^^^^^^^^^^^^^^^^^^^
  63. * Returns the Endpoints supported by a Server and all of the configuration
  64. * information required to establish a SecureChannel and a Session. */
  65. void Service_GetEndpoints(UA_Server *server, UA_Session *session,
  66. const UA_GetEndpointsRequest *request,
  67. UA_GetEndpointsResponse *response);
  68. #ifdef UA_ENABLE_DISCOVERY
  69. # ifdef UA_ENABLE_DISCOVERY_MULTICAST
  70. /**
  71. * FindServersOnNetwork Service
  72. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  73. * Returns the Servers known to a Discovery Server. Unlike FindServer,
  74. * this Service is only implemented by Discovery Servers. It additionally
  75. * Returns servery which may have been detected trough Multicast */
  76. void Service_FindServersOnNetwork(UA_Server *server, UA_Session *session,
  77. const UA_FindServersOnNetworkRequest *request,
  78. UA_FindServersOnNetworkResponse *response);
  79. # endif /* UA_ENABLE_DISCOVERY_MULTICAST */
  80. /**
  81. * RegisterServer
  82. * ^^^^^^^^^^^^^^
  83. * Registers a remote server in the local discovery service. */
  84. void Service_RegisterServer(UA_Server *server, UA_Session *session,
  85. const UA_RegisterServerRequest *request,
  86. UA_RegisterServerResponse *response);
  87. /**
  88. * RegisterServer2
  89. * ^^^^^^^^^^^^^^^
  90. * This Service allows a Server to register its DiscoveryUrls and capabilities
  91. * with a Discovery Server. It extends the registration information from
  92. * RegisterServer with information necessary for FindServersOnNetwork. */
  93. void Service_RegisterServer2(UA_Server *server, UA_Session *session,
  94. const UA_RegisterServer2Request *request,
  95. UA_RegisterServer2Response *response);
  96. #endif /* UA_ENABLE_DISCOVERY */
  97. /**
  98. * SecureChannel Service Set
  99. * -------------------------
  100. * This Service Set defines Services used to open a communication channel that
  101. * ensures the confidentiality and Integrity of all Messages exchanged with the
  102. * Server.
  103. *
  104. * OpenSecureChannel Service
  105. * ^^^^^^^^^^^^^^^^^^^^^^^^^
  106. * Open or renew a SecureChannel that can be used to ensure Confidentiality and
  107. * Integrity for Message exchange during a Session. */
  108. void Service_OpenSecureChannel(UA_Server *server, UA_SecureChannel* channel,
  109. const UA_OpenSecureChannelRequest *request,
  110. UA_OpenSecureChannelResponse *response);
  111. /**
  112. * CloseSecureChannel Service
  113. * ^^^^^^^^^^^^^^^^^^^^^^^^^^
  114. * Used to terminate a SecureChannel. */
  115. void Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel);
  116. /**
  117. * Session Service Set
  118. * -------------------
  119. * This Service Set defines Services for an application layer connection
  120. * establishment in the context of a Session.
  121. *
  122. * CreateSession Service
  123. * ^^^^^^^^^^^^^^^^^^^^^
  124. * Used by an OPC UA Client to create a Session and the Server returns two
  125. * values which uniquely identify the Session. The first value is the sessionId
  126. * which is used to identify the Session in the audit logs and in the Server's
  127. * address space. The second is the authenticationToken which is used to
  128. * associate an incoming request with a Session. */
  129. void Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
  130. const UA_CreateSessionRequest *request,
  131. UA_CreateSessionResponse *response);
  132. /**
  133. * ActivateSession
  134. * ^^^^^^^^^^^^^^^
  135. * Used by the Client to submit its SoftwareCertificates to the Server for
  136. * validation and to specify the identity of the user associated with the
  137. * Session. This Service request shall be issued by the Client before it issues
  138. * any other Service request after CreateSession. Failure to do so shall cause
  139. * the Server to close the Session. */
  140. void Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
  141. UA_Session *session,
  142. const UA_ActivateSessionRequest *request,
  143. UA_ActivateSessionResponse *response);
  144. /**
  145. * CloseSession
  146. * ^^^^^^^^^^^^
  147. * Used to terminate a Session. */
  148. void Service_CloseSession(UA_Server *server, UA_Session *session,
  149. const UA_CloseSessionRequest *request,
  150. UA_CloseSessionResponse *response);
  151. /**
  152. * Cancel Service
  153. * ^^^^^^^^^^^^^^
  154. * Used to cancel outstanding Service requests. Successfully cancelled service
  155. * requests shall respond with Bad_RequestCancelledByClient. */
  156. /* Not Implemented */
  157. /**
  158. * NodeManagement Service Set
  159. * --------------------------
  160. * This Service Set defines Services to add and delete AddressSpace Nodes and
  161. * References between them. All added Nodes continue to exist in the
  162. * AddressSpace even if the Client that created them disconnects from the
  163. * Server.
  164. *
  165. * AddNodes Service
  166. * ^^^^^^^^^^^^^^^^
  167. * Used to add one or more Nodes into the AddressSpace hierarchy. */
  168. void Service_AddNodes(UA_Server *server, UA_Session *session,
  169. const UA_AddNodesRequest *request,
  170. UA_AddNodesResponse *response);
  171. /**
  172. * AddReferences Service
  173. * ^^^^^^^^^^^^^^^^^^^^^
  174. * Used to add one or more References to one or more Nodes. */
  175. void Service_AddReferences(UA_Server *server, UA_Session *session,
  176. const UA_AddReferencesRequest *request,
  177. UA_AddReferencesResponse *response);
  178. /**
  179. * DeleteNodes Service
  180. * ^^^^^^^^^^^^^^^^^^^
  181. * Used to delete one or more Nodes from the AddressSpace. */
  182. void Service_DeleteNodes(UA_Server *server, UA_Session *session,
  183. const UA_DeleteNodesRequest *request,
  184. UA_DeleteNodesResponse *response);
  185. /**
  186. * DeleteReferences
  187. * ^^^^^^^^^^^^^^^^
  188. * Used to delete one or more References of a Node. */
  189. void Service_DeleteReferences(UA_Server *server, UA_Session *session,
  190. const UA_DeleteReferencesRequest *request,
  191. UA_DeleteReferencesResponse *response);
  192. /**
  193. * .. _view-services:
  194. *
  195. * View Service Set
  196. * ----------------
  197. * Clients use the browse Services of the View Service Set to navigate through
  198. * the AddressSpace or through a View which is a subset of the AddressSpace.
  199. *
  200. * Browse Service
  201. * ^^^^^^^^^^^^^^
  202. * Used to discover the References of a specified Node. The browse can be
  203. * further limited by the use of a View. This Browse Service also supports a
  204. * primitive filtering capability. */
  205. void Service_Browse(UA_Server *server, UA_Session *session,
  206. const UA_BrowseRequest *request,
  207. UA_BrowseResponse *response);
  208. /**
  209. * BrowseNext Service
  210. * ^^^^^^^^^^^^^^^^^^
  211. * Used to request the next set of Browse or BrowseNext response information
  212. * that is too large to be sent in a single response. "Too large" in this
  213. * context means that the Server is not able to return a larger response or that
  214. * the number of results to return exceeds the maximum number of results to
  215. * return that was specified by the Client in the original Browse request. */
  216. void Service_BrowseNext(UA_Server *server, UA_Session *session,
  217. const UA_BrowseNextRequest *request,
  218. UA_BrowseNextResponse *response);
  219. /**
  220. * TranslateBrowsePathsToNodeIds Service
  221. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  222. * Used to translate textual node paths to their respective ids. */
  223. void Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *session,
  224. const UA_TranslateBrowsePathsToNodeIdsRequest *request,
  225. UA_TranslateBrowsePathsToNodeIdsResponse *response);
  226. /**
  227. * RegisterNodes Service
  228. * ^^^^^^^^^^^^^^^^^^^^^
  229. * Used by Clients to register the Nodes that they know they will access
  230. * repeatedly (e.g. Write, Call). It allows Servers to set up anything needed so
  231. * that the access operations will be more efficient. */
  232. void Service_RegisterNodes(UA_Server *server, UA_Session *session,
  233. const UA_RegisterNodesRequest *request,
  234. UA_RegisterNodesResponse *response);
  235. /**
  236. * UnregisterNodes Service
  237. * ^^^^^^^^^^^^^^^^^^^^^^^
  238. * This Service is used to unregister NodeIds that have been obtained via the
  239. * RegisterNodes service. */
  240. void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
  241. const UA_UnregisterNodesRequest *request,
  242. UA_UnregisterNodesResponse *response);
  243. /**
  244. * Query Service Set
  245. * -----------------
  246. * This Service Set is used to issue a Query to a Server. OPC UA Query is
  247. * generic in that it provides an underlying storage mechanism independent Query
  248. * capability that can be used to access a wide variety of OPC UA data stores
  249. * and information management systems. OPC UA Query permits a Client to access
  250. * data maintained by a Server without any knowledge of the logical schema used
  251. * for internal storage of the data. Knowledge of the AddressSpace is
  252. * sufficient.
  253. *
  254. * QueryFirst Service
  255. * ^^^^^^^^^^^^^^^^^^
  256. * This Service is used to issue a Query request to the Server. */
  257. /* Not Implemented */
  258. /**
  259. * QueryNext Service
  260. * ^^^^^^^^^^^^^^^^^
  261. * This Service is used to request the next set of QueryFirst or QueryNext
  262. * response information that is too large to be sent in a single response. */
  263. /* Not Impelemented */
  264. /**
  265. * Attribute Service Set
  266. * ---------------------
  267. * This Service Set provides Services to access Attributes that are part of
  268. * Nodes.
  269. *
  270. * Read Service
  271. * ^^^^^^^^^^^^
  272. * Used to read attributes of nodes. For constructed attribute values whose
  273. * elements are indexed, such as an array, this Service allows Clients to read
  274. * the entire set of indexed values as a composite, to read individual elements
  275. * or to read ranges of elements of the composite. */
  276. UA_StatusCode Service_Read(UA_Server *server, UA_Session *session, UA_MessageContext *mc,
  277. const UA_ReadRequest *request, UA_ResponseHeader *responseHeader);
  278. /**
  279. * Write Service
  280. * ^^^^^^^^^^^^^
  281. * Used to write attributes of nodes. For constructed attribute values whose
  282. * elements are indexed, such as an array, this Service allows Clients to write
  283. * the entire set of indexed values as a composite, to write individual elements
  284. * or to write ranges of elements of the composite. */
  285. void Service_Write(UA_Server *server, UA_Session *session,
  286. const UA_WriteRequest *request,
  287. UA_WriteResponse *response);
  288. /**
  289. * HistoryRead Service
  290. * ^^^^^^^^^^^^^^^^^^^
  291. * Used to read historical values or Events of one or more Nodes. Servers may
  292. * make historical values available to Clients using this Service, although the
  293. * historical values themselves are not visible in the AddressSpace. */
  294. /* Not Implemented */
  295. /**
  296. * HistoryUpdate Service
  297. * ^^^^^^^^^^^^^^^^^^^^^
  298. * Used to update historical values or Events of one or more Nodes. Several
  299. * request parameters indicate how the Server is to update the historical value
  300. * or Event. Valid actions are Insert, Replace or Delete. */
  301. /* Not Implemented */
  302. /**
  303. * .. _method-services:
  304. *
  305. * Method Service Set
  306. * ------------------
  307. * The Method Service Set defines the means to invoke methods. A method shall be
  308. * a component of an Object. See the section on :ref:`MethodNodes <methodnode>`
  309. * for more information.
  310. *
  311. * Call Service
  312. * ^^^^^^^^^^^^
  313. * Used to call (invoke) a methods. Each method call is invoked within the
  314. * context of an existing Session. If the Session is terminated, the results of
  315. * the method's execution cannot be returned to the Client and are discarded. */
  316. void Service_Call(UA_Server *server, UA_Session *session,
  317. const UA_CallRequest *request,
  318. UA_CallResponse *response);
  319. /**
  320. * MonitoredItem Service Set
  321. * -------------------------
  322. * Clients define MonitoredItems to subscribe to data and Events. Each
  323. * MonitoredItem identifies the item to be monitored and the Subscription to use
  324. * to send Notifications. The item to be monitored may be any Node Attribute.
  325. *
  326. * CreateMonitoredItems Service
  327. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  328. * Used to create and add one or more MonitoredItems to a Subscription. A
  329. * MonitoredItem is deleted automatically by the Server when the Subscription is
  330. * deleted. Deleting a MonitoredItem causes its entire set of triggered item
  331. * links to be deleted, but has no effect on the MonitoredItems referenced by
  332. * the triggered items. */
  333. void Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
  334. const UA_CreateMonitoredItemsRequest *request,
  335. UA_CreateMonitoredItemsResponse *response);
  336. /**
  337. * DeleteMonitoredItems Service
  338. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  339. * Used to remove one or more MonitoredItems of a Subscription. When a
  340. * MonitoredItem is deleted, its triggered item links are also deleted. */
  341. void Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
  342. const UA_DeleteMonitoredItemsRequest *request,
  343. UA_DeleteMonitoredItemsResponse *response);
  344. /**
  345. * ModifyMonitoredItems Service
  346. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  347. * Used to modify MonitoredItems of a Subscription. Changes to the MonitoredItem
  348. * settings shall be applied immediately by the Server. They take effect as soon
  349. * as practical but not later than twice the new revisedSamplingInterval.
  350. *
  351. * Illegal request values for parameters that can be revised do not generate
  352. * errors. Instead the server will choose default values and indicate them in
  353. * the corresponding revised parameter. */
  354. void Service_ModifyMonitoredItems(UA_Server *server, UA_Session *session,
  355. const UA_ModifyMonitoredItemsRequest *request,
  356. UA_ModifyMonitoredItemsResponse *response);
  357. /**
  358. * SetMonitoringMode Service
  359. * ^^^^^^^^^^^^^^^^^^^^^^^^^
  360. * Used to set the monitoring mode for one or more MonitoredItems of a
  361. * Subscription. */
  362. void Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
  363. const UA_SetMonitoringModeRequest *request,
  364. UA_SetMonitoringModeResponse *response);
  365. /**
  366. * SetTriggering Service
  367. * ^^^^^^^^^^^^^^^^^^^^^
  368. * Used to create and delete triggering links for a triggering item. */
  369. /* Not Implemented */
  370. /**
  371. * Subscription Service Set
  372. * ------------------------
  373. * Subscriptions are used to report Notifications to the Client.
  374. *
  375. * CreateSubscription Service
  376. * ^^^^^^^^^^^^^^^^^^^^^^^^^^
  377. * Used to create a Subscription. Subscriptions monitor a set of MonitoredItems
  378. * for Notifications and return them to the Client in response to Publish
  379. * requests. */
  380. void Service_CreateSubscription(UA_Server *server, UA_Session *session,
  381. const UA_CreateSubscriptionRequest *request,
  382. UA_CreateSubscriptionResponse *response);
  383. /**
  384. * ModifySubscription Service
  385. * ^^^^^^^^^^^^^^^^^^^^^^^^^^
  386. * Used to modify a Subscription. */
  387. void Service_ModifySubscription(UA_Server *server, UA_Session *session,
  388. const UA_ModifySubscriptionRequest *request,
  389. UA_ModifySubscriptionResponse *response);
  390. /**
  391. * SetPublishingMode Service
  392. * ^^^^^^^^^^^^^^^^^^^^^^^^^
  393. * Used to enable sending of Notifications on one or more Subscriptions. */
  394. void Service_SetPublishingMode(UA_Server *server, UA_Session *session,
  395. const UA_SetPublishingModeRequest *request,
  396. UA_SetPublishingModeResponse *response);
  397. /**
  398. * Publish Service
  399. * ^^^^^^^^^^^^^^^
  400. * Used for two purposes. First, it is used to acknowledge the receipt of
  401. * NotificationMessages for one or more Subscriptions. Second, it is used to
  402. * request the Server to return a NotificationMessage or a keep-alive
  403. * Message.
  404. *
  405. * Note that the service signature is an exception and does not contain a
  406. * pointer to a PublishResponse. That is because the service queues up publish
  407. * requests internally and sends responses asynchronously based on timeouts. */
  408. void Service_Publish(UA_Server *server, UA_Session *session,
  409. const UA_PublishRequest *request, UA_UInt32 requestId);
  410. /**
  411. * Republish Service
  412. * ^^^^^^^^^^^^^^^^^
  413. * Requests the Subscription to republish a NotificationMessage from its
  414. * retransmission queue. */
  415. void Service_Republish(UA_Server *server, UA_Session *session,
  416. const UA_RepublishRequest *request,
  417. UA_RepublishResponse *response);
  418. /**
  419. * DeleteSubscriptions Service
  420. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  421. * Invoked to delete one or more Subscriptions that belong to the Client's
  422. * Session. */
  423. void Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
  424. const UA_DeleteSubscriptionsRequest *request,
  425. UA_DeleteSubscriptionsResponse *response);
  426. /**
  427. * TransferSubscription Service
  428. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  429. * Used to transfer a Subscription and its MonitoredItems from one Session to
  430. * another. For example, a Client may need to reopen a Session and then transfer
  431. * its Subscriptions to that Session. It may also be used by one Client to take
  432. * over a Subscription from another Client by transferring the Subscription to
  433. * its Session. */
  434. /* Not Implemented */
  435. #ifdef __cplusplus
  436. } // extern "C"
  437. #endif
  438. #endif /* UA_SERVICES_H_ */