ua_server_internal.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 UA_ENABLE_SUBSCRIPTIONS
  10. #include "ua_subscription_manager.h"
  11. #endif
  12. #define ANONYMOUS_POLICY "open62541-anonymous-policy"
  13. #define USERNAME_POLICY "open62541-username-policy"
  14. #ifdef UA_ENABLE_EXTERNAL_NAMESPACES
  15. /** Mapping of namespace-id and url to an external nodestore. For namespaces
  16. that have no mapping defined, the internal nodestore is used by default. */
  17. typedef struct UA_ExternalNamespace {
  18. UA_UInt16 index;
  19. UA_String url;
  20. UA_ExternalNodeStore externalNodeStore;
  21. } UA_ExternalNamespace;
  22. #endif
  23. #ifdef UA_ENABLE_MULTITHREADING
  24. typedef struct {
  25. UA_Server *server;
  26. pthread_t thr;
  27. UA_UInt32 counter;
  28. volatile UA_Boolean running;
  29. char padding[64 - sizeof(void*) - sizeof(pthread_t) -
  30. sizeof(UA_UInt32) - sizeof(UA_Boolean)]; // separate cache lines
  31. } UA_Worker;
  32. #endif
  33. struct UA_Server {
  34. /* Meta */
  35. UA_DateTime startTime;
  36. size_t endpointDescriptionsSize;
  37. UA_EndpointDescription *endpointDescriptions;
  38. /* Security */
  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_ENABLE_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_ENABLE_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_Worker *workers; /* there are nThread workers in a running server */
  55. struct cds_lfs_stack mainLoopJobs; /* Work that shall be executed only in the main loop and not
  56. by worker threads */
  57. struct DelayedJobs *delayedJobs;
  58. pthread_cond_t dispatchQueue_condition; /* so the workers don't spin if the queue is empty */
  59. struct cds_wfcq_tail dispatchQueue_tail; /* Dispatch queue tail for the worker threads */
  60. #endif
  61. /* Config is the last element so that MSVC allows the usernamePasswordLogins
  62. field with zero-sized array */
  63. UA_ServerConfig config;
  64. };
  65. /* The node is assumed to be "finished", i.e. no instantiation from inheritance is necessary */
  66. void UA_Server_addExistingNode(UA_Server *server, UA_Session *session, UA_Node *node,
  67. const UA_NodeId *parentNodeId, const UA_NodeId *referenceTypeId,
  68. UA_AddNodesResult *result);
  69. typedef UA_StatusCode (*UA_EditNodeCallback)(UA_Server*, UA_Session*, UA_Node*, const void*);
  70. /* Calls callback on the node. In the multithreaded case, the node is copied before and replaced in
  71. the nodestore. */
  72. UA_StatusCode UA_Server_editNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  73. UA_EditNodeCallback callback, const void *data);
  74. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  75. UA_StatusCode UA_Server_addDelayedJob(UA_Server *server, UA_Job job);
  76. void UA_Server_deleteAllRepeatedJobs(UA_Server *server);
  77. #endif /* UA_SERVER_INTERNAL_H_ */