ua_server_internal.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef UA_SERVER_INTERNAL_H_
  2. #define UA_SERVER_INTERNAL_H_
  3. #include "ua_config.h"
  4. #ifdef UA_MULTITHREADING
  5. #define _LGPL_SOURCE
  6. #include <urcu.h>
  7. #include <urcu/wfcqueue.h>
  8. #endif
  9. #include "../deps/queue.h"
  10. #include "ua_server.h"
  11. #include "ua_session_manager.h"
  12. #include "ua_securechannel_manager.h"
  13. #include "ua_nodestore.h"
  14. /** Mapping of namespace-id and url to an external nodestore. For namespaces
  15. that have no mapping defined, the internal nodestore is used by default. */
  16. typedef struct UA_ExternalNamespace {
  17. UA_UInt16 index;
  18. UA_String url;
  19. UA_ExternalNodeStore externalNodeStore;
  20. } UA_ExternalNamespace;
  21. // forward declarations
  22. struct UA_TimedWork;
  23. typedef struct UA_TimedWork UA_TimedWork;
  24. struct UA_DelayedWork;
  25. typedef struct UA_DelayedWork UA_DelayedWork;
  26. struct UA_Server {
  27. UA_ApplicationDescription description;
  28. UA_Int32 endpointDescriptionsSize;
  29. UA_EndpointDescription *endpointDescriptions;
  30. UA_ByteString serverCertificate;
  31. UA_SecureChannelManager secureChannelManager;
  32. UA_SessionManager sessionManager;
  33. UA_Logger logger;
  34. UA_NodeStore *nodestore;
  35. UA_Int32 externalNamespacesSize;
  36. UA_ExternalNamespace *externalNamespaces;
  37. UA_Int32 nlsSize;
  38. UA_ServerNetworkLayer *nls;
  39. UA_UInt32 random_seed;
  40. #ifdef UA_MULTITHREADING
  41. UA_Boolean *running;
  42. UA_UInt16 nThreads;
  43. UA_UInt32 **workerCounters;
  44. UA_DelayedWork *delayedWork;
  45. // worker threads wait on the queue
  46. struct cds_wfcq_head dispatchQueue_head;
  47. struct cds_wfcq_tail dispatchQueue_tail;
  48. pthread_cond_t dispatchQueue_condition; // so the workers don't spin if the queue is empty
  49. #endif
  50. LIST_HEAD(UA_TimedWorkList, UA_TimedWork) timedWork;
  51. UA_DateTime startTime;
  52. UA_DateTime buildDate;
  53. };
  54. void UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg);
  55. UA_AddNodesResult UA_Server_addNodeWithSession(UA_Server *server, UA_Session *session, UA_Node *node,
  56. const UA_ExpandedNodeId *parentNodeId,
  57. const UA_NodeId *referenceTypeId);
  58. UA_AddNodesResult UA_Server_addNode(UA_Server *server, UA_Node *node, const UA_ExpandedNodeId *parentNodeId,
  59. const UA_NodeId *referenceTypeId);
  60. UA_StatusCode UA_Server_addReferenceWithSession(UA_Server *server, UA_Session *session, const UA_AddReferencesItem *item);
  61. void UA_Server_deleteTimedWork(UA_Server *server);
  62. /** The (nodes) AttributeIds are defined in part 6, table A1 of the standard */
  63. typedef enum {
  64. UA_ATTRIBUTEID_NODEID = 1,
  65. UA_ATTRIBUTEID_NODECLASS = 2,
  66. UA_ATTRIBUTEID_BROWSENAME = 3,
  67. UA_ATTRIBUTEID_DISPLAYNAME = 4,
  68. UA_ATTRIBUTEID_DESCRIPTION = 5,
  69. UA_ATTRIBUTEID_WRITEMASK = 6,
  70. UA_ATTRIBUTEID_USERWRITEMASK = 7,
  71. UA_ATTRIBUTEID_ISABSTRACT = 8,
  72. UA_ATTRIBUTEID_SYMMETRIC = 9,
  73. UA_ATTRIBUTEID_INVERSENAME = 10,
  74. UA_ATTRIBUTEID_CONTAINSNOLOOPS = 11,
  75. UA_ATTRIBUTEID_EVENTNOTIFIER = 12,
  76. UA_ATTRIBUTEID_VALUE = 13,
  77. UA_ATTRIBUTEID_DATATYPE = 14,
  78. UA_ATTRIBUTEID_VALUERANK = 15,
  79. UA_ATTRIBUTEID_ARRAYDIMENSIONS = 16,
  80. UA_ATTRIBUTEID_ACCESSLEVEL = 17,
  81. UA_ATTRIBUTEID_USERACCESSLEVEL = 18,
  82. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL = 19,
  83. UA_ATTRIBUTEID_HISTORIZING = 20,
  84. UA_ATTRIBUTEID_EXECUTABLE = 21,
  85. UA_ATTRIBUTEID_USEREXECUTABLE = 22
  86. } UA_AttributeId;
  87. #define ADDREFERENCE(NODEID, REFTYPE_NODEID, TARGET_EXPNODEID) do { \
  88. UA_AddReferencesItem item; \
  89. UA_AddReferencesItem_init(&item); \
  90. item.sourceNodeId = NODEID; \
  91. item.referenceTypeId = REFTYPE_NODEID; \
  92. item.isForward = UA_TRUE; \
  93. item.targetNodeId = TARGET_EXPNODEID; \
  94. UA_Server_addReference(server, &item); \
  95. } while(0)
  96. #endif /* UA_SERVER_INTERNAL_H_ */