ua_server_internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. UA_UInt32 random_seed;
  29. /* Meta */
  30. UA_DateTime startTime;
  31. UA_DateTime buildDate;
  32. UA_ApplicationDescription description;
  33. UA_Int32 endpointDescriptionsSize;
  34. UA_EndpointDescription *endpointDescriptions;
  35. /* Communication */
  36. size_t networkLayersSize;
  37. UA_ServerNetworkLayer **networkLayers;
  38. /* Security */
  39. UA_ByteString serverCertificate;
  40. UA_SecureChannelManager secureChannelManager;
  41. UA_SessionManager sessionManager;
  42. /* Address Space */
  43. UA_NodeStore *nodestore;
  44. size_t namespacesSize;
  45. UA_String *namespaces;
  46. #ifdef UA_EXTERNAL_NAMESPACES
  47. size_t externalNamespacesSize;
  48. UA_ExternalNamespace *externalNamespaces;
  49. #endif
  50. /* Jobs with a repetition interval */
  51. LIST_HEAD(RepeatedJobsList, RepeatedJobs) repeatedJobs;
  52. #ifdef UA_MULTITHREADING
  53. /* Dispatch queue head for the worker threads (the tail should not be in the same cache line) */
  54. struct cds_wfcq_head dispatchQueue_head;
  55. UA_Boolean *running;
  56. UA_UInt16 nThreads;
  57. UA_UInt32 **workerCounters;
  58. pthread_t *thr;
  59. struct cds_lfs_stack mainLoopJobs; /* Work that shall be executed only in the main loop and not
  60. by worker threads */
  61. struct DelayedJobs *delayedJobs;
  62. pthread_cond_t dispatchQueue_condition; /* so the workers don't spin if the queue is empty */
  63. /* Dispatch queue tail for the worker threads */
  64. struct cds_wfcq_tail dispatchQueue_tail;
  65. #endif
  66. };
  67. /* The node is assumed to be "finished", i.e. no instantiation from inheritance is necessary */
  68. void UA_Server_addExistingNode(UA_Server *server, UA_Session *session, UA_Node *node,
  69. const UA_NodeId *parentNodeId, const UA_NodeId *referenceTypeId,
  70. UA_AddNodesResult *result);
  71. typedef UA_StatusCode (*UA_EditNodeCallback)(UA_Server *server, UA_Session*, UA_Node*, const void*);
  72. /* Calls callback on the node. In the multithreaded case, the node is copied before and replaced in
  73. the nodestore. */
  74. UA_StatusCode UA_Server_editNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  75. UA_EditNodeCallback callback, const void *data);
  76. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  77. UA_StatusCode UA_Server_addDelayedJob(UA_Server *server, UA_Job job);
  78. void UA_Server_deleteAllRepeatedJobs(UA_Server *server);
  79. #endif /* UA_SERVER_INTERNAL_H_ */