ua_services.h 16 KB

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