ua_server_internal.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #define ANONYMOUS_POLICY "open62541-anonymous-policy"
  11. #define USERNAME_POLICY "open62541-username-policy"
  12. #ifdef UA_ENABLE_EXTERNAL_NAMESPACES
  13. /** Mapping of namespace-id and url to an external nodestore. For namespaces
  14. that have no mapping defined, the internal nodestore is used by default. */
  15. typedef struct UA_ExternalNamespace {
  16. UA_UInt16 index;
  17. UA_String url;
  18. UA_ExternalNodeStore externalNodeStore;
  19. } UA_ExternalNamespace;
  20. #endif
  21. #ifdef UA_ENABLE_MULTITHREADING
  22. typedef struct {
  23. UA_Server *server;
  24. pthread_t thr;
  25. UA_UInt32 counter;
  26. volatile UA_Boolean running;
  27. char padding[64 - sizeof(void*) - sizeof(pthread_t) -
  28. sizeof(UA_UInt32) - sizeof(UA_Boolean)]; // separate cache lines
  29. } UA_Worker;
  30. #endif
  31. #if defined(UA_ENABLE_METHODCALLS) && defined(UA_ENABLE_SUBSCRIPTIONS)
  32. /* Internally used context to a session 'context' of the current mehtod call */
  33. extern UA_THREAD_LOCAL UA_Session* methodCallSession;
  34. #endif
  35. struct UA_Server {
  36. /* Meta */
  37. UA_DateTime startTime;
  38. size_t endpointDescriptionsSize;
  39. UA_EndpointDescription *endpointDescriptions;
  40. /* Security */
  41. UA_SecureChannelManager secureChannelManager;
  42. UA_SessionManager sessionManager;
  43. /* Address Space */
  44. UA_NodeStore *nodestore;
  45. size_t namespacesSize;
  46. UA_String *namespaces;
  47. #ifdef UA_ENABLE_EXTERNAL_NAMESPACES
  48. size_t externalNamespacesSize;
  49. UA_ExternalNamespace *externalNamespaces;
  50. #endif
  51. /* Jobs with a repetition interval */
  52. LIST_HEAD(RepeatedJobsList, RepeatedJob) repeatedJobs;
  53. #ifdef UA_ENABLE_MULTITHREADING
  54. /* Dispatch queue head for the worker threads (the tail should not be in the same cache line) */
  55. struct cds_wfcq_head dispatchQueue_head;
  56. UA_Worker *workers; /* there are nThread workers in a running server */
  57. struct cds_lfs_stack mainLoopJobs; /* Work that shall be executed only in the main loop and not
  58. by worker threads */
  59. struct DelayedJobs *delayedJobs;
  60. pthread_cond_t dispatchQueue_condition; /* so the workers don't spin if the queue is empty */
  61. struct cds_wfcq_tail dispatchQueue_tail; /* Dispatch queue tail for the worker threads */
  62. #endif
  63. /* Config is the last element so that MSVC allows the usernamePasswordLogins
  64. field with zero-sized array */
  65. UA_ServerConfig config;
  66. };
  67. typedef UA_StatusCode (*UA_EditNodeCallback)(UA_Server*, UA_Session*, UA_Node*, const void*);
  68. /* Calls callback on the node. In the multithreaded case, the node is copied before and replaced in
  69. the nodestore. */
  70. UA_StatusCode UA_Server_editNode(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId,
  71. UA_EditNodeCallback callback, const void *data);
  72. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  73. UA_StatusCode UA_Server_delayedCallback(UA_Server *server, UA_ServerCallback callback, void *data);
  74. UA_StatusCode UA_Server_delayedFree(UA_Server *server, void *data);
  75. void UA_Server_deleteAllRepeatedJobs(UA_Server *server);
  76. #ifdef UA_BUILD_UNIT_TESTS
  77. UA_StatusCode parse_numericrange(const UA_String *str, UA_NumericRange *range);
  78. #endif
  79. UA_StatusCode
  80. getTypeHierarchy(UA_NodeStore *ns, const UA_NodeId *root, UA_NodeId **reftypes, size_t *reftypes_count);
  81. UA_StatusCode
  82. isNodeInTree(UA_NodeStore *ns, const UA_NodeId *rootNode, const UA_NodeId *nodeToFind,
  83. const UA_NodeId *referenceTypeIds, size_t referenceTypeIdsSize,
  84. size_t maxDepth, UA_Boolean *found);
  85. /* find a datatype from the nodeid */
  86. const UA_DataType * findDataType(const UA_NodeId *typeId);
  87. /* Set the value attribute inside a node */
  88. UA_StatusCode
  89. CopyIntoValueAttribute(UA_Server *server, UA_VariableNode *node,
  90. const UA_DataValue *value, const UA_String *indexRange);
  91. #endif /* UA_SERVER_INTERNAL_H_ */