ua_server_internal.h 3.3 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_connection_internal.h"
  7. #include "ua_session_manager.h"
  8. #include "ua_securechannel_manager.h"
  9. #include "ua_nodestore.h"
  10. #ifdef UA_ENABLE_SUBSCRIPTIONS
  11. #include "ua_subscription_manager.h"
  12. #endif
  13. #define ANONYMOUS_POLICY "open62541-anonymous-policy"
  14. #define USERNAME_POLICY "open62541-username-policy"
  15. #ifdef UA_ENABLE_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. #ifdef UA_ENABLE_MULTITHREADING
  25. typedef struct {
  26. UA_Server *server;
  27. pthread_t thr;
  28. UA_UInt32 counter;
  29. volatile UA_Boolean running;
  30. char padding[64 - sizeof(void*) - sizeof(pthread_t) -
  31. sizeof(UA_UInt32) - sizeof(UA_Boolean)]; // separate cache lines
  32. } UA_Worker;
  33. #endif
  34. struct UA_Server {
  35. /* Meta */
  36. UA_DateTime startTime;
  37. size_t endpointDescriptionsSize;
  38. UA_EndpointDescription *endpointDescriptions;
  39. /* Security */
  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_ENABLE_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_ENABLE_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_Worker *workers; /* there are nThread workers in a running server */
  56. struct cds_lfs_stack mainLoopJobs; /* Work that shall be executed only in the main loop and not
  57. by worker threads */
  58. struct DelayedJobs *delayedJobs;
  59. pthread_cond_t dispatchQueue_condition; /* so the workers don't spin if the queue is empty */
  60. struct cds_wfcq_tail dispatchQueue_tail; /* Dispatch queue tail for the worker threads */
  61. #endif
  62. /* Config is the last element so that MSVC allows the usernamePasswordLogins
  63. field with zero-sized array */
  64. UA_ServerConfig config;
  65. };
  66. typedef UA_StatusCode (*UA_EditNodeCallback)(UA_Server*, UA_Session*, UA_Node*, const void*);
  67. /* Calls callback on the node. In the multithreaded case, the node is copied before and replaced in
  68. the nodestore. */
  69. UA_StatusCode UA_Server_editNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  70. UA_EditNodeCallback callback, const void *data);
  71. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  72. UA_StatusCode UA_Server_delayedCallback(UA_Server *server, UA_ServerCallback callback, void *data);
  73. UA_StatusCode UA_Server_delayedFree(UA_Server *server, void *data);
  74. void UA_Server_deleteAllRepeatedJobs(UA_Server *server);
  75. #ifdef UA_BUILD_UNIT_TESTS
  76. UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range);
  77. #endif
  78. #endif /* UA_SERVER_INTERNAL_H_ */