ua_server_internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef UA_SERVER_INTERNAL_H_
  2. #define UA_SERVER_INTERNAL_H_
  3. #include "ua_util.h"
  4. #include "ua_server.h"
  5. #include "ua_server_external_ns.h"
  6. #include "ua_session_manager.h"
  7. #include "ua_securechannel_manager.h"
  8. #include "ua_nodestore.h"
  9. #ifdef ENABLE_SUBSCRIPTIONS
  10. #include "ua_subscription_manager.h"
  11. #endif
  12. #define PRODUCT_URI "http://open62541.org"
  13. #define ANONYMOUS_POLICY "open62541-anonymous-policy"
  14. #define USERNAME_POLICY "open62541-username-policy"
  15. #ifdef UA_EXTERNAL_NAMESPACES
  16. /** Mapping of namespace-id and url to an external nodestore. For namespaces
  17. that have no mapping defined, the internal nodestore is used by default. */
  18. typedef struct UA_ExternalNamespace {
  19. UA_UInt16 index;
  20. UA_String url;
  21. UA_ExternalNodeStore externalNodeStore;
  22. } UA_ExternalNamespace;
  23. #endif
  24. struct UA_Server {
  25. /* Config */
  26. UA_ServerConfig config;
  27. UA_Logger logger;
  28. /* Meta */
  29. UA_DateTime startTime;
  30. UA_DateTime buildDate;
  31. UA_ApplicationDescription description;
  32. size_t endpointDescriptionsSize;
  33. UA_EndpointDescription *endpointDescriptions;
  34. /* Communication */
  35. size_t networkLayersSize;
  36. UA_ServerNetworkLayer **networkLayers;
  37. /* Security */
  38. UA_ByteString serverCertificate;
  39. UA_SecureChannelManager secureChannelManager;
  40. UA_SessionManager sessionManager;
  41. /* Address Space */
  42. UA_NodeStore *nodestore;
  43. size_t namespacesSize;
  44. UA_String *namespaces;
  45. #ifdef UA_EXTERNAL_NAMESPACES
  46. size_t externalNamespacesSize;
  47. UA_ExternalNamespace *externalNamespaces;
  48. #endif
  49. /* Jobs with a repetition interval */
  50. LIST_HEAD(RepeatedJobsList, RepeatedJobs) repeatedJobs;
  51. #ifdef UA_MULTITHREADING
  52. /* Dispatch queue head for the worker threads (the tail should not be in the same cache line) */
  53. struct cds_wfcq_head dispatchQueue_head;
  54. UA_Boolean *running;
  55. UA_UInt16 nThreads;
  56. UA_UInt32 **workerCounters;
  57. pthread_t *thr;
  58. struct cds_lfs_stack mainLoopJobs; /* Work that shall be executed only in the main loop and not
  59. by worker threads */
  60. struct DelayedJobs *delayedJobs;
  61. pthread_cond_t dispatchQueue_condition; /* so the workers don't spin if the queue is empty */
  62. /* Dispatch queue tail for the worker threads */
  63. struct cds_wfcq_tail dispatchQueue_tail;
  64. #endif
  65. };
  66. /* The node is assumed to be "finished", i.e. no instantiation from inheritance is necessary */
  67. void UA_Server_addExistingNode(UA_Server *server, UA_Session *session, UA_Node *node,
  68. const UA_NodeId *parentNodeId, const UA_NodeId *referenceTypeId,
  69. UA_AddNodesResult *result);
  70. typedef UA_StatusCode (*UA_EditNodeCallback)(UA_Server*, UA_Session*, UA_Node*, const void*);
  71. /* Calls callback on the node. In the multithreaded case, the node is copied before and replaced in
  72. the nodestore. */
  73. UA_StatusCode UA_Server_editNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  74. UA_EditNodeCallback callback, const void *data);
  75. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  76. UA_StatusCode UA_Server_addDelayedJob(UA_Server *server, UA_Job job);
  77. void UA_Server_deleteAllRepeatedJobs(UA_Server *server);
  78. #endif /* UA_SERVER_INTERNAL_H_ */