ua_services.h 16 KB

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