ua_server.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2014 the contributors as stated in the AUTHORS file
  3. *
  4. * This file is part of open62541. open62541 is free software: you can
  5. * redistribute it and/or modify it under the terms of the GNU Lesser General
  6. * Public License, version 3 (as published by the Free Software Foundation) with
  7. * a static linking exception as stated in the LICENSE file provided with
  8. * open62541.
  9. *
  10. * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. #ifndef UA_SERVER_H_
  16. #define UA_SERVER_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "ua_types.h"
  21. #include "ua_types_generated.h"
  22. #include "ua_connection.h"
  23. #include "ua_log.h"
  24. /** @defgroup server Server */
  25. //identifier numbers are different for XML and binary, so we have to substract an offset for comparison
  26. #define UA_ENCODINGOFFSET_XML 1
  27. #define UA_ENCODINGOFFSET_BINARY 2
  28. struct UA_SecureChannelManager;
  29. typedef struct UA_SecureChannelManager UA_SecureChannelManager;
  30. struct UA_SessionManager;
  31. typedef struct UA_SessionManager UA_SessionManager;
  32. struct UA_NodeStore;
  33. typedef struct UA_NodeStore UA_NodeStore;
  34. struct UA_NodeStoreExample;
  35. typedef struct UA_NodeStoreExample UA_NodeStoreExample;
  36. //struct UA_Namespace;
  37. //typedef struct UA_Namespace UA_Namespace;
  38. typedef struct UA_Namespace
  39. {
  40. UA_UInt16 index;
  41. UA_NodeStore *nodeStore;
  42. }UA_Namespace;
  43. struct UA_NamespaceManager;
  44. typedef struct UA_NamespaceManager UA_NamespaceManager;
  45. typedef UA_Int32 (*UA_NodeStore_addNodes)(UA_AddNodesItem *nodesToAdd,UA_UInt32 *indices,UA_UInt32 indicesSize, UA_AddNodesResult* addNodesResults, UA_DiagnosticInfo *diagnosticInfos);
  46. typedef UA_Int32 (*UA_NodeStore_addReferences)(UA_AddReferencesItem* referencesToAdd,UA_UInt32 *indices,UA_UInt32 indicesSize, UA_StatusCode *addReferencesResults, UA_DiagnosticInfo diagnosticInfos);
  47. typedef UA_Int32 (*UA_NodeStore_deleteNodes)(UA_DeleteNodesItem *nodesToDelete,UA_UInt32 *indices,UA_UInt32 indicesSize, UA_StatusCode *deleteNodesResults, UA_DiagnosticInfo *diagnosticInfos);
  48. typedef UA_Int32 (*UA_NodeStore_deleteReferences)(UA_DeleteReferencesItem referenceToDelete,UA_UInt32 *indices, UA_UInt32 indicesSize,UA_StatusCode deleteReferencesresults, UA_DiagnosticInfo diagnosticInfos);
  49. typedef UA_Int32 (*UA_NodeStore_readNodes)(UA_ReadValueId *readValueIds,UA_UInt32 *indices,UA_UInt32 indicesSize,UA_DataValue *readNodesResults, UA_Boolean timeStampToReturn, UA_DiagnosticInfo *diagnosticInfos);
  50. typedef UA_Int32 (*UA_NodeStore_writeNodes)(UA_WriteValue *writeValues,UA_UInt32 *indices ,UA_UInt32 indicesSize, UA_StatusCode *writeNodesResults, UA_DiagnosticInfo *diagnosticInfo);
  51. typedef UA_Int32 (*UA_NodeStore_browseNodes)(UA_UInt32 requestedMaxReferencesPerNode, UA_BrowseDescription *browseDescriptions,UA_Int32 *indices,UA_UInt32 indicesSize, UA_BrowseResult *browseResults, UA_DiagnosticInfo *diagnosticInfos);
  52. struct UA_NodeStore{
  53. //new, set, get, remove,
  54. UA_NodeStore_addNodes addNodes;
  55. UA_NodeStore_deleteNodes deleteNodes;
  56. UA_NodeStore_writeNodes writeNodes;
  57. UA_NodeStore_readNodes readNodes;
  58. UA_NodeStore_browseNodes browseNodes;
  59. UA_NodeStore_addReferences addReferences;
  60. UA_NodeStore_deleteReferences deleteReferences;
  61. };
  62. typedef struct UA_Server {
  63. UA_ApplicationDescription description;
  64. UA_SecureChannelManager *secureChannelManager;
  65. UA_SessionManager *sessionManager;
  66. UA_NamespaceManager* namespaceManager;
  67. UA_NodeStoreExample *nodestore;
  68. UA_Logger logger;
  69. UA_ByteString serverCertificate;
  70. // todo: move these somewhere sane
  71. UA_ExpandedNodeId objectsNodeId;
  72. UA_NodeId hasComponentReferenceTypeId;
  73. } UA_Server;
  74. void UA_EXPORT UA_Server_init(UA_Server *server, UA_String *endpointUrl);
  75. UA_Int32 UA_EXPORT UA_Server_deleteMembers(UA_Server *server);
  76. UA_Int32 UA_EXPORT UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  77. /* Services for local use */
  78. UA_AddNodesResult UA_EXPORT UA_Server_addScalarVariableNode(UA_Server *server, UA_String *browseName, void *value,
  79. const UA_VTable_Entry *vt, UA_ExpandedNodeId *parentNodeId,
  80. UA_NodeId *referenceTypeId );
  81. UA_AddNodesResult UA_EXPORT UA_Server_addNode(UA_Server *server, UA_Node **node, UA_ExpandedNodeId *parentNodeId,
  82. UA_NodeId *referenceTypeId);
  83. void UA_EXPORT UA_Server_addReferences(UA_Server *server, const UA_AddReferencesRequest *request,
  84. UA_AddReferencesResponse *response);
  85. UA_Int32 UA_EXPORT UA_Server_addNamespace(UA_Server *server, UA_UInt16 namespaceIndex, UA_NodeStore *nodeStore);
  86. UA_Int32 UA_EXPORT UA_Server_removeNamespace(UA_Server *server, UA_UInt16 namespaceIndex);
  87. UA_Int32 UA_EXPORT UA_Server_setNodeStore(UA_Server *server, UA_UInt16 namespaceIndex, UA_NodeStore *nodeStore);
  88. #ifdef __cplusplus
  89. } // extern "C"
  90. #endif
  91. #endif /* UA_SERVER_H_ */