ua_services.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. #ifndef UA_SERVICES_H_
  2. #define UA_SERVICES_H_
  3. #include "ua_util.h"
  4. #include "ua_types.h"
  5. #include "ua_types_generated.h"
  6. #include "ua_server.h"
  7. #include "ua_session.h"
  8. #include "ua_nodes.h"
  9. typedef void (*UA_Service)(UA_Server*, UA_Session*, const void*, void*);
  10. /**
  11. * @ingroup server
  12. * @defgroup services Services
  13. *
  14. * @brief The UA services that can be called from a remote user
  15. *
  16. * @{
  17. */
  18. /**
  19. * @name Discovery Service Set
  20. *
  21. * This Service Set defines Services used to discover the Endpoints implemented
  22. * by a Server and to read the security configuration for those Endpoints.
  23. *
  24. * @{
  25. */
  26. void Service_FindServers(UA_Server *server, UA_Session *session,
  27. const UA_FindServersRequest *request,
  28. UA_FindServersResponse *response);
  29. /**
  30. * Returns the Endpoints supported by a Server and all of the configuration
  31. * information required to establish a SecureChannel and a Session.
  32. */
  33. void Service_GetEndpoints(UA_Server *server, UA_Session *session,
  34. const UA_GetEndpointsRequest *request,
  35. UA_GetEndpointsResponse *response);
  36. // Service_RegisterServer
  37. /** @} */
  38. /**
  39. * @name SecureChannel Service Set
  40. *
  41. * This Service Set defines Services used to open a communication channel that
  42. * ensures the confidentiality and Integrity of all Messages exchanged with the
  43. * Server.
  44. *
  45. * @{
  46. */
  47. /**
  48. * Open or renew a SecureChannel that can be used to ensure Confidentiality and
  49. * Integrity for Message exchange during a Session.
  50. */
  51. void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
  52. const UA_OpenSecureChannelRequest *request,
  53. UA_OpenSecureChannelResponse *response);
  54. /** Used to terminate a SecureChannel. */
  55. void Service_CloseSecureChannel(UA_Server *server, UA_UInt32 channelId);
  56. /** @} */
  57. /**
  58. * @name Session Service Set
  59. *
  60. * This Service Set defines Services for an application layer connection
  61. * establishment in the context of a Session.
  62. *
  63. * @{
  64. */
  65. /**
  66. * Used by an OPC UA Client to create a Session and the Server returns two
  67. * values which uniquely identify the Session. The first value is the sessionId
  68. * which is used to identify the Session in the audit logs and in the Server's
  69. * address space. The second is the authenticationToken which is used to
  70. * associate an incoming request with a Session.
  71. */
  72. void Service_CreateSession(UA_Server *server, UA_Session *session,
  73. const UA_CreateSessionRequest *request,
  74. UA_CreateSessionResponse *response);
  75. /**
  76. * Used by the Client to submit its SoftwareCertificates to the Server for
  77. * validation and to specify the identity of the user associated with the
  78. * Session. This Service request shall be issued by the Client before it issues
  79. * any other Service request after CreateSession. Failure to do so shall cause
  80. * the Server to close the Session.
  81. */
  82. void Service_ActivateSession(UA_Server *server, UA_Session *session,
  83. const UA_ActivateSessionRequest *request,
  84. UA_ActivateSessionResponse *response);
  85. /** Used to terminate a Session. */
  86. void Service_CloseSession(UA_Server *server, UA_Session *session,
  87. const UA_CloseSessionRequest *request,
  88. UA_CloseSessionResponse *response);
  89. // Service_Cancel
  90. /** @} */
  91. /**
  92. * @name NodeManagement Service Set
  93. *
  94. * This Service Set defines Services to add and delete AddressSpace Nodes and References between
  95. * them. All added Nodes continue to exist in the AddressSpace even if the Client that created them
  96. * disconnects from the Server.
  97. *
  98. * @{
  99. */
  100. /** Used to add one or more Nodes into the AddressSpace hierarchy. */
  101. void Service_AddNodes(UA_Server *server, UA_Session *session,
  102. const UA_AddNodesRequest *request,
  103. UA_AddNodesResponse *response);
  104. void Service_AddNodes_single(UA_Server *server, UA_Session *session, const UA_AddNodesItem *item,
  105. UA_AddNodesResult *result, UA_InstantiationCallback *instantiationCallback);
  106. /** Used to add one or more References to one or more Nodes. */
  107. void Service_AddReferences(UA_Server *server, UA_Session *session,
  108. const UA_AddReferencesRequest *request,
  109. UA_AddReferencesResponse *response);
  110. UA_StatusCode Service_AddReferences_single(UA_Server *server, UA_Session *session,
  111. const UA_AddReferencesItem *item);
  112. /** Used to delete one or more Nodes from the AddressSpace. */
  113. void Service_DeleteNodes(UA_Server *server, UA_Session *session,
  114. const UA_DeleteNodesRequest *request,
  115. UA_DeleteNodesResponse *response);
  116. UA_StatusCode Service_DeleteNodes_single(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  117. UA_Boolean deleteReferences);
  118. /** Used to delete one or more References of a Node. */
  119. void Service_DeleteReferences(UA_Server *server, UA_Session *session,
  120. const UA_DeleteReferencesRequest *request,
  121. UA_DeleteReferencesResponse *response);
  122. UA_StatusCode Service_DeleteReferences_single(UA_Server *server, UA_Session *session,
  123. const UA_DeleteReferencesItem *item);
  124. /** @} */
  125. /**
  126. * @name View Service Set
  127. *
  128. * Clients use the browse Services of the View Service Set to navigate through
  129. * the AddressSpace or through a View which is a subset of the AddressSpace.
  130. *
  131. * @{
  132. */
  133. /**
  134. * Used to discover the References of a specified Node. The browse can be
  135. * further limited by the use of a View. This Browse Service also supports a
  136. * primitive filtering capability.
  137. */
  138. void Service_Browse(UA_Server *server, UA_Session *session,
  139. const UA_BrowseRequest *request,
  140. UA_BrowseResponse *response);
  141. void Service_Browse_single(UA_Server *server, UA_Session *session,
  142. struct ContinuationPointEntry *cp, const UA_BrowseDescription *descr,
  143. UA_UInt32 maxrefs, UA_BrowseResult *result);
  144. /**
  145. * Used to request the next set of Browse or BrowseNext response information
  146. * that is too large to be sent in a single response. "Too large" in this
  147. * context means that the Server is not able to return a larger response or that
  148. * the number of results to return exceeds the maximum number of results to
  149. * return that was specified by the Client in the original Browse request.
  150. */
  151. void Service_BrowseNext(UA_Server *server, UA_Session *session,
  152. const UA_BrowseNextRequest *request,
  153. UA_BrowseNextResponse *response);
  154. void UA_Server_browseNext_single(UA_Server *server, UA_Session *session, UA_Boolean releaseContinuationPoint,
  155. const UA_ByteString *continuationPoint, UA_BrowseResult *result);
  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. void Service_TranslateBrowsePathsToNodeIds_single(UA_Server *server, UA_Session *session,
  161. const UA_BrowsePath *path, UA_BrowsePathResult *result);
  162. void Service_RegisterNodes(UA_Server *server, UA_Session *session,
  163. const UA_RegisterNodesRequest *request,
  164. UA_RegisterNodesResponse *response);
  165. void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
  166. const UA_UnregisterNodesRequest *request,
  167. UA_UnregisterNodesResponse *response);
  168. /** @} */
  169. /**
  170. * @name Query Service Set
  171. *
  172. * This Service Set is used to issue a Query to a Server. OPC UA Query is
  173. * generic in that it provides an underlying storage mechanism independent Query
  174. * capability that can be used to access a wide variety of OPC UA data stores
  175. * and information management systems. OPC UA Query permits a Client to access
  176. * data maintained by a Server without any knowledge of the logical schema used
  177. * for internal storage of the data. Knowledge of the AddressSpace is
  178. * sufficient.
  179. *
  180. * @{
  181. */
  182. // Service_QueryFirst
  183. // Service_QueryNext
  184. /** @} */
  185. /**
  186. * @name Attribute Service Set
  187. *
  188. * This Service Set provides Services to access Attributes that are part of
  189. * Nodes.
  190. *
  191. * @{
  192. */
  193. /* Mock-Up of the function signature for Unit Tests */
  194. #ifdef UA_BUILD_UNIT_TESTS
  195. UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range);
  196. #endif
  197. /**
  198. * Used to read one or more Attributes of one or more Nodes. For constructed
  199. * Attribute values whose elements are indexed, such as an array, this Service
  200. * allows Clients to read the entire set of indexed values as a composite, to
  201. * read individual elements or to read ranges of elements of the composite.
  202. */
  203. void
  204. Service_Read(UA_Server *server, UA_Session *session,
  205. const UA_ReadRequest *request,
  206. UA_ReadResponse *response);
  207. void
  208. Service_Read_single(UA_Server *server, UA_Session *session,
  209. UA_TimestampsToReturn timestamps,
  210. const UA_ReadValueId *id, UA_DataValue *v);
  211. // Service_HistoryRead
  212. /**
  213. * Used to write one or more Attributes of one or more Nodes. For constructed
  214. * Attribute values whose elements are indexed, such as an array, this Service
  215. * allows Clients to write the entire set of indexed values as a composite, to
  216. * write individual elements or to write ranges of elements of the composite.
  217. */
  218. void
  219. Service_Write(UA_Server *server, UA_Session *session,
  220. const UA_WriteRequest *request,
  221. UA_WriteResponse *response);
  222. /** Single attribute writes are exposed to the userspace. The wvalue may be destroyed (deleteMembers) */
  223. UA_StatusCode
  224. Service_Write_single(UA_Server *server, UA_Session *session, const UA_WriteValue *wvalue);
  225. // Service_HistoryUpdate
  226. /** @} */
  227. /**
  228. * @name Method Service Set
  229. *
  230. * The Method Service Set defines the means to invoke methods. A method shall be
  231. * a component of an Object.
  232. *
  233. * @{
  234. */
  235. #ifdef UA_ENABLE_METHODCALLS
  236. void
  237. Service_Call(UA_Server *server, UA_Session *session,
  238. const UA_CallRequest *request,
  239. UA_CallResponse *response);
  240. void
  241. Service_Call_single(UA_Server *server, UA_Session *session,
  242. const UA_CallMethodRequest *request,
  243. UA_CallMethodResult *result);
  244. #endif
  245. /** @} */
  246. #ifdef UA_ENABLE_SUBSCRIPTIONS
  247. /**
  248. * @name MonitoredItem Service Set
  249. *
  250. * Clients define MonitoredItems to subscribe to data and Events. Each
  251. * MonitoredItem identifies the item to be monitored and the Subscription to use
  252. * to send Notifications. The item to be monitored may be any Node Attribute.
  253. *
  254. * @{
  255. */
  256. /*
  257. * Used to create and add one or more MonitoredItems to a Subscription. A
  258. * MonitoredItem is deleted automatically by the Server when the Subscription is
  259. * deleted. Deleting a MonitoredItem causes its entire set of triggered item
  260. * links to be deleted, but has no effect on the MonitoredItems referenced by
  261. * the triggered items.
  262. */
  263. void
  264. Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
  265. const UA_CreateMonitoredItemsRequest *request,
  266. UA_CreateMonitoredItemsResponse *response);
  267. // Service_ModifyMonitoredItems
  268. // Service_SetMonitoringMode
  269. // Service_SetTriggering
  270. void
  271. Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
  272. const UA_DeleteMonitoredItemsRequest *request,
  273. UA_DeleteMonitoredItemsResponse *response);
  274. /** @} */
  275. /**
  276. * @name Subscription Service Set
  277. *
  278. * Subscriptions are used to report Notifications to the Client.
  279. *
  280. * @{
  281. */
  282. void
  283. Service_CreateSubscription(UA_Server *server, UA_Session *session,
  284. const UA_CreateSubscriptionRequest *request,
  285. UA_CreateSubscriptionResponse *response);
  286. void
  287. Service_ModifySubscription(UA_Server *server, UA_Session *session,
  288. const UA_ModifySubscriptionRequest *request,
  289. UA_ModifySubscriptionResponse *response);
  290. void
  291. Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
  292. const UA_DeleteSubscriptionsRequest *request,
  293. UA_DeleteSubscriptionsResponse *response);
  294. void
  295. Service_Publish(UA_Server *server, UA_Session *session,
  296. const UA_PublishRequest *request, UA_UInt32 requestId);
  297. void
  298. Service_Republish(UA_Server *server, UA_Session *session,
  299. const UA_RepublishRequest *request,
  300. UA_RepublishResponse *response);
  301. // Service_ModifySubscription
  302. // Service_SetPublishingMode
  303. // UA_Int32 Service_SetPublishingMode(UA_Server *server, UA_Session *session,
  304. // const UA_SetPublishingModeRequest *request,
  305. // UA_SetPublishingModeResponse *response);
  306. // Service_TransferSubscription
  307. // Service_DeleteSubscription
  308. /** @} */
  309. #endif
  310. #endif /* UA_SERVICES_H_ */
  311. /** @} */