ua_server.c 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. #include "ua_types.h"
  2. #include "ua_server_internal.h"
  3. #include "ua_securechannel_manager.h"
  4. #include "ua_session_manager.h"
  5. #include "ua_util.h"
  6. #include "ua_services.h"
  7. #include "ua_nodeids.h"
  8. const UA_EXPORT UA_ServerConfig UA_ServerConfig_standard = {
  9. .Login_enableAnonymous = UA_TRUE,
  10. .Login_enableUsernamePassword = UA_TRUE,
  11. .Login_usernames = (char *[]){"user1","user2"},
  12. .Login_passwords = (char *[]){"password","password1"},
  13. .Login_loginsCount = 2,
  14. .Application_applicationURI = "urn:unconfigured:open62541:open62541Server",
  15. .Application_applicationName = "open62541" };
  16. /**********************/
  17. /* Namespace Handling */
  18. /**********************/
  19. static void UA_ExternalNamespace_init(UA_ExternalNamespace *ens) {
  20. ens->index = 0;
  21. UA_String_init(&ens->url);
  22. }
  23. static void UA_ExternalNamespace_deleteMembers(UA_ExternalNamespace *ens) {
  24. UA_String_deleteMembers(&ens->url);
  25. ens->externalNodeStore.destroy(ens->externalNodeStore.ensHandle);
  26. }
  27. /*****************/
  28. /* Configuration */
  29. /*****************/
  30. UA_Logger * UA_Server_getLogger(UA_Server *server) {
  31. return &server->logger;
  32. }
  33. void UA_Server_addNetworkLayer(UA_Server *server, UA_ServerNetworkLayer networkLayer) {
  34. UA_ServerNetworkLayer *newlayers =
  35. UA_realloc(server->networkLayers, sizeof(UA_ServerNetworkLayer)*(server->networkLayersSize+1));
  36. if(!newlayers) {
  37. UA_LOG_ERROR(server->logger, UA_LOGCATEGORY_SERVER, "Networklayer added");
  38. return;
  39. }
  40. server->networkLayers = newlayers;
  41. server->networkLayers[server->networkLayersSize] = networkLayer;
  42. server->networkLayersSize++;
  43. if(networkLayer.discoveryUrl){
  44. if(server->description.discoveryUrlsSize < 0)
  45. server->description.discoveryUrlsSize = 0;
  46. UA_String* newUrls = UA_realloc(server->description.discoveryUrls,
  47. sizeof(UA_String)*(server->description.discoveryUrlsSize+1));
  48. if(!newUrls) {
  49. UA_LOG_ERROR(server->logger, UA_LOGCATEGORY_SERVER, "Adding discoveryUrl");
  50. return;
  51. }
  52. server->description.discoveryUrls = newUrls;
  53. UA_String_copy(networkLayer.discoveryUrl,
  54. &server->description.discoveryUrls[server->description.discoveryUrlsSize]);
  55. server->description.discoveryUrlsSize++;
  56. }
  57. }
  58. void UA_Server_setServerCertificate(UA_Server *server, UA_ByteString certificate) {
  59. for(UA_Int32 i = 0; i < server->endpointDescriptionsSize; i++)
  60. UA_ByteString_copy(&certificate, &server->endpointDescriptions[i].serverCertificate);
  61. }
  62. void UA_Server_setLogger(UA_Server *server, UA_Logger logger) {
  63. server->logger = logger;
  64. }
  65. UA_UInt16 UA_Server_addNamespace(UA_Server *server, const char* name) {
  66. server->namespaces = UA_realloc(server->namespaces, sizeof(UA_String) * (server->namespacesSize+1));
  67. server->namespaces[server->namespacesSize] = UA_STRING_ALLOC(name);
  68. server->namespacesSize++;
  69. return server->namespacesSize-1;
  70. }
  71. /**********/
  72. /* Server */
  73. /**********/
  74. /* The server needs to be stopped before it can be deleted */
  75. void UA_Server_delete(UA_Server *server) {
  76. // Delete the timed work
  77. UA_Server_deleteTimedWork(server);
  78. // Delete all internal data
  79. UA_ApplicationDescription_deleteMembers(&server->description);
  80. UA_SecureChannelManager_deleteMembers(&server->secureChannelManager);
  81. UA_SessionManager_deleteMembers(&server->sessionManager);
  82. UA_NodeStore_delete(server->nodestore);
  83. UA_ByteString_deleteMembers(&server->serverCertificate);
  84. UA_Array_delete(server->namespaces, &UA_TYPES[UA_TYPES_STRING], server->namespacesSize);
  85. UA_Array_delete(server->endpointDescriptions, &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION],
  86. server->endpointDescriptionsSize);
  87. // Delete the network layers
  88. for(size_t i = 0; i < server->networkLayersSize; i++) {
  89. server->networkLayers[i].free(server->networkLayers[i].nlHandle);
  90. }
  91. UA_free(server->networkLayers);
  92. #ifdef UA_MULTITHREADING
  93. pthread_cond_destroy(&server->dispatchQueue_condition); // so the workers don't spin if the queue is empty
  94. rcu_barrier(); // wait for all scheduled call_rcu work to complete
  95. #endif
  96. UA_free(server);
  97. }
  98. /* Recurring cleanup. Removing unused and timed-out channels and sessions */
  99. static void UA_Server_cleanup(UA_Server *server, void *nothing) {
  100. UA_DateTime now = UA_DateTime_now();
  101. UA_SessionManager_cleanupTimedOut(&server->sessionManager, now);
  102. UA_SecureChannelManager_cleanupTimedOut(&server->secureChannelManager, now);
  103. }
  104. #define MANUFACTURER_NAME "open62541"
  105. #define PRODUCT_NAME "open62541 OPC UA Server"
  106. #define STRINGIFY(x) #x //some magic
  107. #define TOSTRING(x) STRINGIFY(x) //some magic
  108. #define SOFTWARE_VERSION TOSTRING(VERSION)
  109. #define BUILD_NUMBER "0"
  110. static void getBulidInfo(const UA_Server* server, UA_BuildInfo *buildInfo){
  111. buildInfo->productUri = UA_STRING_ALLOC(PRODUCT_URI);
  112. buildInfo->manufacturerName = UA_STRING_ALLOC(MANUFACTURER_NAME);
  113. buildInfo->productName = UA_STRING_ALLOC(PRODUCT_NAME);
  114. buildInfo->softwareVersion = UA_STRING_ALLOC(SOFTWARE_VERSION);
  115. buildInfo->buildNumber = UA_STRING_ALLOC(BUILD_NUMBER);
  116. buildInfo->buildDate = server->buildDate;
  117. }
  118. static UA_StatusCode readStatus(void *handle, UA_Boolean sourceTimeStamp, UA_DataValue *value) {
  119. UA_ServerStatusDataType *status = UA_ServerStatusDataType_new();
  120. status->startTime = ((const UA_Server*)handle)->startTime;
  121. status->currentTime = UA_DateTime_now();
  122. status->state = UA_SERVERSTATE_RUNNING;
  123. getBulidInfo(((const UA_Server*)handle), &status->buildInfo);
  124. status->secondsTillShutdown = 0;
  125. value->value.type = &UA_TYPES[UA_TYPES_SERVERSTATUSDATATYPE];
  126. value->value.arrayLength = -1;
  127. value->value.data = status;
  128. value->value.arrayDimensionsSize = -1;
  129. value->value.arrayDimensions = UA_NULL;
  130. value->hasValue = UA_TRUE;
  131. if(sourceTimeStamp) {
  132. value->hasSourceTimestamp = UA_TRUE;
  133. value->sourceTimestamp = UA_DateTime_now();
  134. }
  135. return UA_STATUSCODE_GOOD;
  136. }
  137. static void releaseStatus(void *handle, UA_DataValue *value) {
  138. UA_ServerStatusDataType_delete((UA_ServerStatusDataType*)value->value.data);
  139. value->value.data = UA_NULL;
  140. value->hasValue = UA_FALSE;
  141. UA_DataValue_deleteMembers(value);
  142. }
  143. static UA_StatusCode readNamespaces(void *handle, UA_Boolean sourceTimestamp, UA_DataValue *value) {
  144. UA_Server *server = (UA_Server*)handle;
  145. value->hasValue = UA_TRUE;
  146. value->value.storageType = UA_VARIANT_DATA_NODELETE;
  147. value->value.type = &UA_TYPES[UA_TYPES_STRING];
  148. value->value.arrayLength = server->namespacesSize;
  149. value->value.data = server->namespaces;
  150. if(sourceTimestamp) {
  151. value->hasSourceTimestamp = UA_TRUE;
  152. value->sourceTimestamp = UA_DateTime_now();
  153. }
  154. return UA_STATUSCODE_GOOD;
  155. }
  156. static void releaseNamespaces(void *handle, UA_DataValue *value) {
  157. }
  158. static UA_StatusCode readCurrentTime(void *handle, UA_Boolean sourceTimeStamp, UA_DataValue *value) {
  159. UA_DateTime *currentTime = UA_DateTime_new();
  160. if(!currentTime)
  161. return UA_STATUSCODE_BADOUTOFMEMORY;
  162. *currentTime = UA_DateTime_now();
  163. value->value.type = &UA_TYPES[UA_TYPES_DATETIME];
  164. value->value.data = currentTime;
  165. value->hasValue = UA_TRUE;
  166. if(sourceTimeStamp) {
  167. value->hasSourceTimestamp = UA_TRUE;
  168. value->sourceTimestamp = *currentTime;
  169. }
  170. return UA_STATUSCODE_GOOD;
  171. }
  172. static void releaseCurrentTime(void *handle, UA_DataValue *value) {
  173. UA_DateTime_delete((UA_DateTime*)value->value.data);
  174. }
  175. static void copyNames(UA_Node *node, char *name) {
  176. node->browseName = UA_QUALIFIEDNAME_ALLOC(0, name);
  177. node->displayName = UA_LOCALIZEDTEXT_ALLOC("", name);
  178. node->description = UA_LOCALIZEDTEXT_ALLOC("", name);
  179. }
  180. static void addDataTypeNode(UA_Server *server, char* name, UA_UInt32 datatypeid, UA_Int32 parent) {
  181. UA_DataTypeNode *datatype = UA_DataTypeNode_new();
  182. copyNames((UA_Node*)datatype, name);
  183. datatype->nodeId.identifier.numeric = datatypeid;
  184. UA_Server_addNode(server, (UA_Node*)datatype,
  185. UA_EXPANDEDNODEID_NUMERIC(0, parent),
  186. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  187. }
  188. static void addObjectTypeNode(UA_Server *server, char* name, UA_UInt32 objecttypeid, UA_Int32 parent,
  189. UA_Int32 parentreference) {
  190. UA_ObjectTypeNode *objecttype = UA_ObjectTypeNode_new();
  191. copyNames((UA_Node*)objecttype, name);
  192. objecttype->nodeId.identifier.numeric = objecttypeid;
  193. UA_Server_addNode(server, (UA_Node*)objecttype,
  194. UA_EXPANDEDNODEID_NUMERIC(0, parent),
  195. UA_NODEID_NUMERIC(0, parentreference));
  196. }
  197. static UA_VariableTypeNode*
  198. createVariableTypeNode(UA_Server *server, char* name, UA_UInt32 variabletypeid,
  199. UA_Int32 parent, UA_Boolean abstract) {
  200. UA_VariableTypeNode *variabletype = UA_VariableTypeNode_new();
  201. copyNames((UA_Node*)variabletype, name);
  202. variabletype->nodeId.identifier.numeric = variabletypeid;
  203. variabletype->isAbstract = abstract;
  204. variabletype->value.variant.type = &UA_TYPES[UA_TYPES_VARIANT];
  205. return variabletype;
  206. }
  207. static void addVariableTypeNode_organized(UA_Server *server, char* name, UA_UInt32 variabletypeid,
  208. UA_Int32 parent, UA_Boolean abstract) {
  209. UA_VariableTypeNode *variabletype = createVariableTypeNode(server, name, variabletypeid, parent, abstract);
  210. UA_Server_addNode(server, (UA_Node*)variabletype,
  211. UA_EXPANDEDNODEID_NUMERIC(0, parent),
  212. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  213. }
  214. static void addVariableTypeNode_subtype(UA_Server *server, char* name, UA_UInt32 variabletypeid,
  215. UA_Int32 parent, UA_Boolean abstract) {
  216. UA_VariableTypeNode *variabletype = createVariableTypeNode(server, name, variabletypeid, parent, abstract);
  217. UA_Server_addNode(server, (UA_Node*)variabletype,
  218. UA_EXPANDEDNODEID_NUMERIC(0, parent),
  219. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  220. }
  221. UA_Server * UA_Server_new(UA_ServerConfig config) {
  222. UA_Server *server = UA_malloc(sizeof(UA_Server));
  223. if(!server)
  224. return UA_NULL;
  225. //FIXME: config contains strings, for now its okay, but consider copying them aswell
  226. server->config = config;
  227. LIST_INIT(&server->timedWork);
  228. #ifdef UA_MULTITHREADING
  229. rcu_init();
  230. cds_wfcq_init(&server->dispatchQueue_head, &server->dispatchQueue_tail);
  231. server->delayedWork = UA_NULL;
  232. #endif
  233. // logger
  234. server->logger = UA_NULL;
  235. // random seed
  236. server->random_seed = (UA_UInt32)UA_DateTime_now();
  237. // networklayers
  238. server->networkLayers = UA_NULL;
  239. server->networkLayersSize = 0;
  240. UA_ByteString_init(&server->serverCertificate);
  241. // mockup application description
  242. UA_ApplicationDescription_init(&server->description);
  243. server->description.productUri = UA_STRING_ALLOC(PRODUCT_URI);
  244. server->description.applicationUri = UA_STRING_ALLOC(server->config.Application_applicationURI);
  245. server->description.discoveryUrlsSize = 0;
  246. server->description.applicationName = UA_LOCALIZEDTEXT_ALLOC("", server->config.Application_applicationName);
  247. server->description.applicationType = UA_APPLICATIONTYPE_SERVER;
  248. server->externalNamespacesSize = 0;
  249. server->externalNamespaces = UA_NULL;
  250. /* ns0 and ns1 */
  251. server->namespaces = UA_Array_new(&UA_TYPES[UA_TYPES_STRING], 2);
  252. server->namespaces[0] = UA_STRING_ALLOC("http://opcfoundation.org/UA/");
  253. UA_String_copy(&server->description.applicationUri, &server->namespaces[1]);
  254. server->namespacesSize = 2;
  255. server->endpointDescriptions = UA_NULL;
  256. server->endpointDescriptionsSize = 0;
  257. UA_EndpointDescription *endpoint = UA_EndpointDescription_new(); // todo: check return code
  258. if(endpoint) {
  259. endpoint->securityMode = UA_MESSAGESECURITYMODE_NONE;
  260. endpoint->securityPolicyUri = UA_STRING_ALLOC("http://opcfoundation.org/UA/SecurityPolicy#None");
  261. endpoint->transportProfileUri = UA_STRING_ALLOC("http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary");
  262. int size = 0;
  263. if(server->config.Login_enableAnonymous){
  264. size++;
  265. }
  266. if(server->config.Login_enableUsernamePassword){
  267. size++;
  268. }
  269. endpoint->userIdentityTokensSize = size;
  270. endpoint->userIdentityTokens = UA_Array_new(&UA_TYPES[UA_TYPES_USERTOKENPOLICY], size);
  271. int currentIndex = 0;
  272. if(server->config.Login_enableAnonymous){
  273. UA_UserTokenPolicy_init(&endpoint->userIdentityTokens[currentIndex]);
  274. endpoint->userIdentityTokens[currentIndex].tokenType = UA_USERTOKENTYPE_ANONYMOUS;
  275. endpoint->userIdentityTokens[currentIndex].policyId = UA_STRING_ALLOC(ANONYMOUS_POLICY); // defined per server
  276. currentIndex++;
  277. }
  278. if(server->config.Login_enableUsernamePassword){
  279. UA_UserTokenPolicy_init(&endpoint->userIdentityTokens[currentIndex]);
  280. endpoint->userIdentityTokens[currentIndex].tokenType = UA_USERTOKENTYPE_USERNAME;
  281. endpoint->userIdentityTokens[currentIndex].policyId = UA_STRING_ALLOC(USERNAME_POLICY); // defined per server
  282. currentIndex++;
  283. }
  284. /* UA_String_copy(endpointUrl, &endpoint->endpointUrl); */
  285. /* /\* The standard says "the HostName specified in the Server Certificate is the */
  286. /* same as the HostName contained in the endpointUrl provided in the */
  287. /* EndpointDescription *\/ */
  288. /* UA_String_copy(&server->serverCertificate, &endpoint->serverCertificate); */
  289. UA_ApplicationDescription_copy(&server->description, &endpoint->server);
  290. server->endpointDescriptions = endpoint;
  291. server->endpointDescriptionsSize = 1;
  292. }
  293. #define MAXCHANNELCOUNT 100
  294. #define STARTCHANNELID 1
  295. #define TOKENLIFETIME 600000
  296. #define STARTTOKENID 1
  297. UA_SecureChannelManager_init(&server->secureChannelManager, MAXCHANNELCOUNT,
  298. TOKENLIFETIME, STARTCHANNELID, STARTTOKENID);
  299. #define MAXSESSIONCOUNT 1000
  300. #define MAXSESSIONLIFETIME 10000
  301. #define STARTSESSIONID 1
  302. UA_SessionManager_init(&server->sessionManager, MAXSESSIONCOUNT, MAXSESSIONLIFETIME, STARTSESSIONID);
  303. server->nodestore = UA_NodeStore_new();
  304. UA_WorkItem cleanup = {.type = UA_WORKITEMTYPE_METHODCALL,
  305. .work.methodCall = {.method = UA_Server_cleanup, .data = NULL} };
  306. UA_Server_addRepeatedWorkItem(server, &cleanup, 10000, NULL);
  307. /**********************/
  308. /* Server Information */
  309. /**********************/
  310. server->startTime = UA_DateTime_now();
  311. static struct tm ct;
  312. ct.tm_year = (__DATE__[7] - '0') * 1000 + (__DATE__[8] - '0') * 100 + (__DATE__[9] - '0') * 10 + (__DATE__[10] - '0')- 1900;
  313. if ((__DATE__[0]=='J') && (__DATE__[1]=='a') && (__DATE__[2]=='n')) ct.tm_mon = 1-1;
  314. else if ((__DATE__[0]=='F') && (__DATE__[1]=='e') && (__DATE__[2]=='b')) ct.tm_mon = 2-1;
  315. else if ((__DATE__[0]=='M') && (__DATE__[1]=='a') && (__DATE__[2]=='r')) ct.tm_mon = 3-1;
  316. else if ((__DATE__[0]=='A') && (__DATE__[1]=='p') && (__DATE__[2]=='r')) ct.tm_mon = 4-1;
  317. else if ((__DATE__[0]=='M') && (__DATE__[1]=='a') && (__DATE__[2]=='y')) ct.tm_mon = 5-1;
  318. else if ((__DATE__[0]=='J') && (__DATE__[1]=='u') && (__DATE__[2]=='n')) ct.tm_mon = 6-1;
  319. else if ((__DATE__[0]=='J') && (__DATE__[1]=='u') && (__DATE__[2]=='l')) ct.tm_mon = 7-1;
  320. else if ((__DATE__[0]=='A') && (__DATE__[1]=='u') && (__DATE__[2]=='g')) ct.tm_mon = 8-1;
  321. else if ((__DATE__[0]=='S') && (__DATE__[1]=='e') && (__DATE__[2]=='p')) ct.tm_mon = 9-1;
  322. else if ((__DATE__[0]=='O') && (__DATE__[1]=='c') && (__DATE__[2]=='t')) ct.tm_mon = 10-1;
  323. else if ((__DATE__[0]=='N') && (__DATE__[1]=='o') && (__DATE__[2]=='v')) ct.tm_mon = 11-1;
  324. else if ((__DATE__[0]=='D') && (__DATE__[1]=='e') && (__DATE__[2]=='c')) ct.tm_mon = 12-1;
  325. // special case to handle __DATE__ not inserting leading zero on day of month
  326. // if Day of month is less than 10 - it inserts a blank character
  327. // this results in a negative number for tm_mday
  328. if(__DATE__[4] == ' ')
  329. ct.tm_mday = __DATE__[5]-'0';
  330. else
  331. ct.tm_mday = (__DATE__[4]-'0')*10 + (__DATE__[5]-'0');
  332. ct.tm_hour = ((__TIME__[0] - '0') * 10 + __TIME__[1] - '0');
  333. ct.tm_min = ((__TIME__[3] - '0') * 10 + __TIME__[4] - '0');
  334. ct.tm_sec = ((__TIME__[6] - '0') * 10 + __TIME__[7] - '0');
  335. ct.tm_isdst = -1; // information is not available.
  336. //FIXME: next 3 lines are copy-pasted from ua_types.c
  337. #define UNIX_EPOCH_BIAS_SEC 11644473600LL // Number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC
  338. #define HUNDRED_NANOSEC_PER_USEC 10LL
  339. #define HUNDRED_NANOSEC_PER_SEC (HUNDRED_NANOSEC_PER_USEC * 1000000LL)
  340. server->buildDate = (mktime(&ct) + UNIX_EPOCH_BIAS_SEC) * HUNDRED_NANOSEC_PER_SEC;
  341. /**************/
  342. /* References */
  343. /**************/
  344. /* bootstrap by manually inserting "references" and "hassubtype" */
  345. UA_ReferenceTypeNode *references = UA_ReferenceTypeNode_new();
  346. copyNames((UA_Node*)references, "References");
  347. references->nodeId.identifier.numeric = UA_NS0ID_REFERENCES;
  348. references->isAbstract = UA_TRUE;
  349. references->symmetric = UA_TRUE;
  350. references->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "References");
  351. // this node has no parent??
  352. UA_NodeStore_insert(server->nodestore, (UA_Node*)references, UA_NULL);
  353. UA_ReferenceTypeNode *hassubtype = UA_ReferenceTypeNode_new();
  354. copyNames((UA_Node*)hassubtype, "HasSubtype");
  355. hassubtype->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "HasSupertype");
  356. hassubtype->nodeId.identifier.numeric = UA_NS0ID_HASSUBTYPE;
  357. hassubtype->isAbstract = UA_FALSE;
  358. hassubtype->symmetric = UA_FALSE;
  359. UA_NodeStore_insert(server->nodestore, (UA_Node*)hassubtype, UA_NULL);
  360. /* continue adding reference types with normal "addnode" */
  361. UA_ReferenceTypeNode *hierarchicalreferences = UA_ReferenceTypeNode_new();
  362. copyNames((UA_Node*)hierarchicalreferences, "Hierarchicalreferences");
  363. hierarchicalreferences->nodeId.identifier.numeric = UA_NS0ID_HIERARCHICALREFERENCES;
  364. hierarchicalreferences->isAbstract = UA_TRUE;
  365. hierarchicalreferences->symmetric = UA_FALSE;
  366. UA_Server_addNode(server, (UA_Node*)hierarchicalreferences,
  367. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_REFERENCES),
  368. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  369. UA_ReferenceTypeNode *nonhierarchicalreferences = UA_ReferenceTypeNode_new();
  370. copyNames((UA_Node*)nonhierarchicalreferences, "NonHierarchicalReferences");
  371. nonhierarchicalreferences->nodeId.identifier.numeric = UA_NS0ID_NONHIERARCHICALREFERENCES;
  372. nonhierarchicalreferences->isAbstract = UA_TRUE;
  373. nonhierarchicalreferences->symmetric = UA_FALSE;
  374. UA_Server_addNode(server, (UA_Node*)nonhierarchicalreferences,
  375. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_REFERENCES),
  376. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  377. UA_ReferenceTypeNode *haschild = UA_ReferenceTypeNode_new();
  378. copyNames((UA_Node*)haschild, "HasChild");
  379. haschild->nodeId.identifier.numeric = UA_NS0ID_HASCHILD;
  380. haschild->isAbstract = UA_TRUE;
  381. haschild->symmetric = UA_FALSE;
  382. UA_Server_addNode(server, (UA_Node*)haschild,
  383. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HIERARCHICALREFERENCES),
  384. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  385. UA_ReferenceTypeNode *organizes = UA_ReferenceTypeNode_new();
  386. copyNames((UA_Node*)organizes, "Organizes");
  387. organizes->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "OrganizedBy");
  388. organizes->nodeId.identifier.numeric = UA_NS0ID_ORGANIZES;
  389. organizes->isAbstract = UA_FALSE;
  390. organizes->symmetric = UA_FALSE;
  391. UA_Server_addNode(server, (UA_Node*)organizes,
  392. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HIERARCHICALREFERENCES),
  393. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  394. UA_ReferenceTypeNode *haseventsource = UA_ReferenceTypeNode_new();
  395. copyNames((UA_Node*)haseventsource, "HasEventSource");
  396. haseventsource->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "EventSourceOf");
  397. haseventsource->nodeId.identifier.numeric = UA_NS0ID_HASEVENTSOURCE;
  398. haseventsource->isAbstract = UA_FALSE;
  399. haseventsource->symmetric = UA_FALSE;
  400. UA_Server_addNode(server, (UA_Node*)haseventsource,
  401. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HIERARCHICALREFERENCES),
  402. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  403. UA_ReferenceTypeNode *hasmodellingrule = UA_ReferenceTypeNode_new();
  404. copyNames((UA_Node*)hasmodellingrule, "HasModellingRule");
  405. hasmodellingrule->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "ModellingRuleOf");
  406. hasmodellingrule->nodeId.identifier.numeric = UA_NS0ID_HASMODELLINGRULE;
  407. hasmodellingrule->isAbstract = UA_FALSE;
  408. hasmodellingrule->symmetric = UA_FALSE;
  409. UA_Server_addNode(server, (UA_Node*)hasmodellingrule,
  410. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  411. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  412. UA_ReferenceTypeNode *hasencoding = UA_ReferenceTypeNode_new();
  413. copyNames((UA_Node*)hasencoding, "HasEncoding");
  414. hasencoding->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "EncodingOf");
  415. hasencoding->nodeId.identifier.numeric = UA_NS0ID_HASENCODING;
  416. hasencoding->isAbstract = UA_FALSE;
  417. hasencoding->symmetric = UA_FALSE;
  418. UA_Server_addNode(server, (UA_Node*)hasencoding,
  419. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  420. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  421. UA_ReferenceTypeNode *hasdescription = UA_ReferenceTypeNode_new();
  422. copyNames((UA_Node*)hasdescription, "HasDescription");
  423. hasdescription->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "DescriptionOf");
  424. hasdescription->nodeId.identifier.numeric = UA_NS0ID_HASDESCRIPTION;
  425. hasdescription->isAbstract = UA_FALSE;
  426. hasdescription->symmetric = UA_FALSE;
  427. UA_Server_addNode(server, (UA_Node*)hasdescription,
  428. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  429. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  430. UA_ReferenceTypeNode *hastypedefinition = UA_ReferenceTypeNode_new();
  431. copyNames((UA_Node*)hastypedefinition, "HasTypeDefinition");
  432. hastypedefinition->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "TypeDefinitionOf");
  433. hastypedefinition->nodeId.identifier.numeric = UA_NS0ID_HASTYPEDEFINITION;
  434. hastypedefinition->isAbstract = UA_FALSE;
  435. hastypedefinition->symmetric = UA_FALSE;
  436. UA_Server_addNode(server, (UA_Node*)hastypedefinition,
  437. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  438. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  439. UA_ReferenceTypeNode *generatesevent = UA_ReferenceTypeNode_new();
  440. copyNames((UA_Node*)generatesevent, "GeneratesEvent");
  441. generatesevent->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "GeneratedBy");
  442. generatesevent->nodeId.identifier.numeric = UA_NS0ID_GENERATESEVENT;
  443. generatesevent->isAbstract = UA_FALSE;
  444. generatesevent->symmetric = UA_FALSE;
  445. UA_Server_addNode(server, (UA_Node*)generatesevent,
  446. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  447. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  448. UA_ReferenceTypeNode *aggregates = UA_ReferenceTypeNode_new();
  449. copyNames((UA_Node*)aggregates, "Aggregates");
  450. // Todo: Is there an inverse name?
  451. aggregates->nodeId.identifier.numeric = UA_NS0ID_AGGREGATES;
  452. aggregates->isAbstract = UA_TRUE;
  453. aggregates->symmetric = UA_FALSE;
  454. UA_Server_addNode(server, (UA_Node*)aggregates,
  455. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HASCHILD),
  456. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  457. // complete bootstrap of hassubtype
  458. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_HASCHILD), UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE),
  459. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  460. UA_ReferenceTypeNode *hasproperty = UA_ReferenceTypeNode_new();
  461. copyNames((UA_Node*)hasproperty, "HasProperty");
  462. hasproperty->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "PropertyOf");
  463. hasproperty->nodeId.identifier.numeric = UA_NS0ID_HASPROPERTY;
  464. hasproperty->isAbstract = UA_FALSE;
  465. hasproperty->symmetric = UA_FALSE;
  466. UA_Server_addNode(server, (UA_Node*)hasproperty,
  467. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_AGGREGATES),
  468. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  469. UA_ReferenceTypeNode *hascomponent = UA_ReferenceTypeNode_new();
  470. copyNames((UA_Node*)hascomponent, "HasComponent");
  471. hascomponent->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "ComponentOf");
  472. hascomponent->nodeId.identifier.numeric = UA_NS0ID_HASCOMPONENT;
  473. hascomponent->isAbstract = UA_FALSE;
  474. hascomponent->symmetric = UA_FALSE;
  475. UA_Server_addNode(server, (UA_Node*)hascomponent,
  476. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_AGGREGATES),
  477. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  478. UA_ReferenceTypeNode *hasnotifier = UA_ReferenceTypeNode_new();
  479. copyNames((UA_Node*)hasnotifier, "HasNotifier");
  480. hasnotifier->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "NotifierOf");
  481. hasnotifier->nodeId.identifier.numeric = UA_NS0ID_HASNOTIFIER;
  482. hasnotifier->isAbstract = UA_FALSE;
  483. hasnotifier->symmetric = UA_FALSE;
  484. UA_Server_addNode(server, (UA_Node*)hasnotifier,
  485. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HASEVENTSOURCE),
  486. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  487. UA_ReferenceTypeNode *hasorderedcomponent = UA_ReferenceTypeNode_new();
  488. copyNames((UA_Node*)hasorderedcomponent, "HasOrderedComponent");
  489. hasorderedcomponent->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "OrderedComponentOf");
  490. hasorderedcomponent->nodeId.identifier.numeric = UA_NS0ID_HASORDEREDCOMPONENT;
  491. hasorderedcomponent->isAbstract = UA_FALSE;
  492. hasorderedcomponent->symmetric = UA_FALSE;
  493. UA_Server_addNode(server, (UA_Node*)hasorderedcomponent,
  494. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
  495. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  496. UA_ReferenceTypeNode *hasmodelparent = UA_ReferenceTypeNode_new();
  497. copyNames((UA_Node*)hasmodelparent, "HasModelParent");
  498. hasmodelparent->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "ModelParentOf");
  499. hasmodelparent->nodeId.identifier.numeric = UA_NS0ID_HASMODELPARENT;
  500. hasmodelparent->isAbstract = UA_FALSE;
  501. hasmodelparent->symmetric = UA_FALSE;
  502. UA_Server_addNode(server, (UA_Node*)hasmodelparent,
  503. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  504. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  505. UA_ReferenceTypeNode *fromstate = UA_ReferenceTypeNode_new();
  506. copyNames((UA_Node*)fromstate, "FromState");
  507. fromstate->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "ToTransition");
  508. fromstate->nodeId.identifier.numeric = UA_NS0ID_FROMSTATE;
  509. fromstate->isAbstract = UA_FALSE;
  510. fromstate->symmetric = UA_FALSE;
  511. UA_Server_addNode(server, (UA_Node*)fromstate,
  512. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  513. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  514. UA_ReferenceTypeNode *tostate = UA_ReferenceTypeNode_new();
  515. copyNames((UA_Node*)tostate, "ToState");
  516. tostate->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "FromTransition");
  517. tostate->nodeId.identifier.numeric = UA_NS0ID_TOSTATE;
  518. tostate->isAbstract = UA_FALSE;
  519. tostate->symmetric = UA_FALSE;
  520. UA_Server_addNode(server, (UA_Node*)tostate,
  521. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  522. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  523. UA_ReferenceTypeNode *hascause = UA_ReferenceTypeNode_new();
  524. copyNames((UA_Node*)hascause, "HasCause");
  525. hascause->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "MayBeCausedBy");
  526. hascause->nodeId.identifier.numeric = UA_NS0ID_HASCAUSE;
  527. hascause->isAbstract = UA_FALSE;
  528. hascause->symmetric = UA_FALSE;
  529. UA_Server_addNode(server, (UA_Node*)hascause,
  530. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  531. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  532. UA_ReferenceTypeNode *haseffect = UA_ReferenceTypeNode_new();
  533. copyNames((UA_Node*)haseffect, "HasEffect");
  534. haseffect->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "MayBeEffectedBy");
  535. haseffect->nodeId.identifier.numeric = UA_NS0ID_HASEFFECT;
  536. haseffect->isAbstract = UA_FALSE;
  537. haseffect->symmetric = UA_FALSE;
  538. UA_Server_addNode(server, (UA_Node*)haseffect,
  539. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_NONHIERARCHICALREFERENCES),
  540. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  541. UA_ReferenceTypeNode *hashistoricalconfiguration = UA_ReferenceTypeNode_new();
  542. copyNames((UA_Node*)hashistoricalconfiguration, "HasHistoricalConfiguration");
  543. hashistoricalconfiguration->inverseName = UA_LOCALIZEDTEXT_ALLOC("", "HistoricalConfigurationOf");
  544. hashistoricalconfiguration->nodeId.identifier.numeric = UA_NS0ID_HASHISTORICALCONFIGURATION;
  545. hashistoricalconfiguration->isAbstract = UA_FALSE;
  546. hashistoricalconfiguration->symmetric = UA_FALSE;
  547. UA_Server_addNode(server, (UA_Node*)hashistoricalconfiguration,
  548. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_AGGREGATES),
  549. UA_NODEID_NUMERIC(0, UA_NS0ID_HASSUBTYPE));
  550. /*****************/
  551. /* Basic Folders */
  552. /*****************/
  553. UA_ObjectNode *root = UA_ObjectNode_new();
  554. copyNames((UA_Node*)root, "Root");
  555. root->nodeId.identifier.numeric = UA_NS0ID_ROOTFOLDER;
  556. UA_NodeStore_insert(server->nodestore, (UA_Node*)root, UA_NULL);
  557. UA_ObjectNode *objects = UA_ObjectNode_new();
  558. copyNames((UA_Node*)objects, "Objects");
  559. objects->nodeId.identifier.numeric = UA_NS0ID_OBJECTSFOLDER;
  560. UA_Server_addNode(server, (UA_Node*)objects,
  561. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_ROOTFOLDER),
  562. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  563. UA_ObjectNode *types = UA_ObjectNode_new();
  564. copyNames((UA_Node*)types, "Types");
  565. types->nodeId.identifier.numeric = UA_NS0ID_TYPESFOLDER;
  566. UA_Server_addNode(server, (UA_Node*)types,
  567. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_ROOTFOLDER),
  568. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  569. UA_ObjectNode *views = UA_ObjectNode_new();
  570. copyNames((UA_Node*)views, "Views");
  571. views->nodeId.identifier.numeric = UA_NS0ID_VIEWSFOLDER;
  572. UA_Server_addNode(server, (UA_Node*)views,
  573. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_ROOTFOLDER),
  574. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  575. UA_ObjectNode *referencetypes = UA_ObjectNode_new();
  576. copyNames((UA_Node*)referencetypes, "ReferenceTypes");
  577. referencetypes->nodeId.identifier.numeric = UA_NS0ID_REFERENCETYPESFOLDER;
  578. UA_Server_addNode(server, (UA_Node*)referencetypes,
  579. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_TYPESFOLDER),
  580. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  581. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_REFERENCETYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
  582. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_REFERENCES));
  583. /**********************/
  584. /* Basic Object Types */
  585. /**********************/
  586. UA_ObjectNode *objecttypes = UA_ObjectNode_new();
  587. copyNames((UA_Node*)objecttypes, "ObjectTypes");
  588. objecttypes->nodeId.identifier.numeric = UA_NS0ID_OBJECTTYPESFOLDER;
  589. UA_Server_addNode(server, (UA_Node*)objecttypes,
  590. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_TYPESFOLDER),
  591. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  592. addObjectTypeNode(server, "BaseObjectType", UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_OBJECTTYPESFOLDER, UA_NS0ID_ORGANIZES);
  593. addObjectTypeNode(server, "FolderType", UA_NS0ID_FOLDERTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  594. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTTYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  595. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  596. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_ROOTFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  597. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  598. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  599. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  600. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_TYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  601. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  602. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_VIEWSFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  603. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  604. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_REFERENCETYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  605. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  606. addObjectTypeNode(server, "ServerType", UA_NS0ID_SERVERTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  607. addObjectTypeNode(server, "ServerDiagnosticsType", UA_NS0ID_SERVERDIAGNOSTICSTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  608. addObjectTypeNode(server, "ServerCapatilitiesType", UA_NS0ID_SERVERCAPABILITIESTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  609. addObjectTypeNode(server, "ServerStatusType", UA_NS0ID_SERVERSTATUSTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  610. addObjectTypeNode(server, "BuildInfoType", UA_NS0ID_BUILDINFOTYPE, UA_NS0ID_BASEOBJECTTYPE, UA_NS0ID_HASSUBTYPE);
  611. /**************/
  612. /* Data Types */
  613. /**************/
  614. UA_ObjectNode *datatypes = UA_ObjectNode_new();
  615. copyNames((UA_Node*)datatypes, "DataTypes");
  616. datatypes->nodeId.identifier.numeric = UA_NS0ID_DATATYPESFOLDER;
  617. UA_Server_addNode(server, (UA_Node*)datatypes,
  618. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_TYPESFOLDER),
  619. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  620. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_DATATYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  621. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  622. addDataTypeNode(server, "BaseDataType", UA_NS0ID_BASEDATATYPE, UA_NS0ID_DATATYPESFOLDER);
  623. addDataTypeNode(server, "Boolean", UA_NS0ID_BOOLEAN, UA_NS0ID_BASEDATATYPE);
  624. addDataTypeNode(server, "Number", UA_NS0ID_NUMBER, UA_NS0ID_BASEDATATYPE);
  625. addDataTypeNode(server, "Float", UA_NS0ID_FLOAT, UA_NS0ID_NUMBER);
  626. addDataTypeNode(server, "Double", UA_NS0ID_DOUBLE, UA_NS0ID_NUMBER);
  627. addDataTypeNode(server, "Integer", UA_NS0ID_INTEGER, UA_NS0ID_NUMBER);
  628. addDataTypeNode(server, "SByte", UA_NS0ID_SBYTE, UA_NS0ID_INTEGER);
  629. addDataTypeNode(server, "Int16", UA_NS0ID_INT16, UA_NS0ID_INTEGER);
  630. addDataTypeNode(server, "Int32", UA_NS0ID_INT32, UA_NS0ID_INTEGER);
  631. addDataTypeNode(server, "Int64", UA_NS0ID_INT64, UA_NS0ID_INTEGER);
  632. addDataTypeNode(server, "UInteger", UA_NS0ID_UINTEGER, UA_NS0ID_INTEGER);
  633. addDataTypeNode(server, "Byte", UA_NS0ID_BYTE, UA_NS0ID_UINTEGER);
  634. addDataTypeNode(server, "UInt16", UA_NS0ID_UINT16, UA_NS0ID_UINTEGER);
  635. addDataTypeNode(server, "UInt32", UA_NS0ID_UINT32, UA_NS0ID_UINTEGER);
  636. addDataTypeNode(server, "UInt64", UA_NS0ID_UINT64, UA_NS0ID_UINTEGER);
  637. addDataTypeNode(server, "String", UA_NS0ID_STRING, UA_NS0ID_BASEDATATYPE);
  638. addDataTypeNode(server, "DateTime", UA_NS0ID_DATETIME, UA_NS0ID_BASEDATATYPE);
  639. addDataTypeNode(server, "Guid", UA_NS0ID_GUID, UA_NS0ID_BASEDATATYPE);
  640. addDataTypeNode(server, "ByteString", UA_NS0ID_BYTESTRING, UA_NS0ID_BASEDATATYPE);
  641. addDataTypeNode(server, "XmlElement", UA_NS0ID_XMLELEMENT, UA_NS0ID_BASEDATATYPE);
  642. addDataTypeNode(server, "NodeId", UA_NS0ID_NODEID, UA_NS0ID_BASEDATATYPE);
  643. addDataTypeNode(server, "ExpandedNodeId", UA_NS0ID_EXPANDEDNODEID, UA_NS0ID_BASEDATATYPE);
  644. addDataTypeNode(server, "StatusCode", UA_NS0ID_STATUSCODE, UA_NS0ID_BASEDATATYPE);
  645. addDataTypeNode(server, "QualifiedName", UA_NS0ID_QUALIFIEDNAME, UA_NS0ID_BASEDATATYPE);
  646. addDataTypeNode(server, "LocalizedText", UA_NS0ID_LOCALIZEDTEXT, UA_NS0ID_BASEDATATYPE);
  647. addDataTypeNode(server, "Structure", UA_NS0ID_STRUCTURE, UA_NS0ID_BASEDATATYPE);
  648. addDataTypeNode(server, "ServerStatusDataType", UA_NS0ID_SERVERSTATUSDATATYPE, UA_NS0ID_STRUCTURE);
  649. addDataTypeNode(server, "BuildInfo", UA_NS0ID_BUILDINFO, UA_NS0ID_STRUCTURE);
  650. addDataTypeNode(server, "DataValue", UA_NS0ID_DATAVALUE, UA_NS0ID_BASEDATATYPE);
  651. addDataTypeNode(server, "DiagnosticInfo", UA_NS0ID_DIAGNOSTICINFO, UA_NS0ID_BASEDATATYPE);
  652. addDataTypeNode(server, "Enumeration", UA_NS0ID_ENUMERATION, UA_NS0ID_BASEDATATYPE);
  653. addDataTypeNode(server, "ServerState", UA_NS0ID_SERVERSTATE, UA_NS0ID_ENUMERATION);
  654. UA_ObjectNode *variabletypes = UA_ObjectNode_new();
  655. copyNames((UA_Node*)variabletypes, "VariableTypes");
  656. variabletypes->nodeId.identifier.numeric = UA_NS0ID_VARIABLETYPESFOLDER;
  657. UA_Server_addNode(server, (UA_Node*)variabletypes,
  658. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_TYPESFOLDER),
  659. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  660. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_VARIABLETYPESFOLDER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  661. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_FOLDERTYPE));
  662. addVariableTypeNode_organized(server, "BaseVariableType", UA_NS0ID_BASEVARIABLETYPE, UA_NS0ID_VARIABLETYPESFOLDER, UA_TRUE);
  663. addVariableTypeNode_subtype(server, "BaseDataVariableType", UA_NS0ID_BASEDATAVARIABLETYPE, UA_NS0ID_BASEVARIABLETYPE, UA_FALSE);
  664. addVariableTypeNode_subtype(server, "PropertyType", UA_NS0ID_PROPERTYTYPE, UA_NS0ID_BASEVARIABLETYPE, UA_FALSE);
  665. /*********************/
  666. /* The Server Object */
  667. /*********************/
  668. UA_ObjectNode *servernode = UA_ObjectNode_new();
  669. copyNames((UA_Node*)servernode, "Server");
  670. servernode->nodeId.identifier.numeric = UA_NS0ID_SERVER;
  671. UA_Server_addNode(server, (UA_Node*)servernode,
  672. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
  673. UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
  674. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER),
  675. UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  676. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVERTYPE));
  677. UA_VariableNode *namespaceArray = UA_VariableNode_new();
  678. copyNames((UA_Node*)namespaceArray, "NamespaceArray");
  679. namespaceArray->nodeId.identifier.numeric = UA_NS0ID_SERVER_NAMESPACEARRAY;
  680. namespaceArray->valueSource = UA_VALUESOURCE_DATASOURCE;
  681. namespaceArray->value.dataSource = (UA_DataSource) {.handle = server, .read = readNamespaces,
  682. .release = releaseNamespaces, .write = UA_NULL};
  683. namespaceArray->valueRank = 1;
  684. namespaceArray->minimumSamplingInterval = 1.0;
  685. namespaceArray->historizing = UA_FALSE;
  686. UA_Server_addNode(server, (UA_Node*)namespaceArray,
  687. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER),
  688. UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
  689. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_NAMESPACEARRAY),
  690. UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  691. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
  692. UA_VariableNode *serverArray = UA_VariableNode_new();
  693. copyNames((UA_Node*)serverArray, "ServerArray");
  694. serverArray->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERARRAY;
  695. serverArray->value.variant.data = UA_Array_new(&UA_TYPES[UA_TYPES_STRING], 1);
  696. serverArray->value.variant.arrayLength = 1;
  697. serverArray->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  698. *(UA_String *)serverArray->value.variant.data = UA_STRING_ALLOC(server->config.Application_applicationURI);
  699. serverArray->valueRank = 1;
  700. serverArray->minimumSamplingInterval = 1.0;
  701. serverArray->historizing = UA_FALSE;
  702. UA_Server_addNode(server, (UA_Node*)serverArray,
  703. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER),
  704. UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
  705. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERARRAY),
  706. UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  707. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
  708. UA_ObjectNode *servercapablities = UA_ObjectNode_new();
  709. copyNames((UA_Node*)servercapablities, "ServerCapabilities");
  710. servercapablities->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERCAPABILITIES;
  711. UA_Server_addNode(server, (UA_Node*)servercapablities,
  712. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER),
  713. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  714. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  715. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVERCAPABILITIESTYPE));
  716. UA_VariableNode *localeIdArray = UA_VariableNode_new();
  717. copyNames((UA_Node*)localeIdArray, "LocaleIdArray");
  718. localeIdArray->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERCAPABILITIES_LOCALEIDARRAY;
  719. localeIdArray->value.variant.data = UA_Array_new(&UA_TYPES[UA_TYPES_STRING], 1);
  720. localeIdArray->value.variant.arrayLength = 1;
  721. localeIdArray->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  722. *(UA_String *)localeIdArray->value.variant.data = UA_STRING_ALLOC("en");
  723. localeIdArray->valueRank = 1;
  724. localeIdArray->minimumSamplingInterval = 1.0;
  725. localeIdArray->historizing = UA_FALSE;
  726. UA_Server_addNode(server, (UA_Node*)localeIdArray,
  727. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES),
  728. UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
  729. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES_LOCALEIDARRAY), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  730. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
  731. UA_VariableNode *maxBrowseContinuationPoints = UA_VariableNode_new();
  732. copyNames((UA_Node*)maxBrowseContinuationPoints, "MaxBrowseContinuationPoints");
  733. maxBrowseContinuationPoints->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERCAPABILITIES_MAXBROWSECONTINUATIONPOINTS;
  734. maxBrowseContinuationPoints->value.variant.data = UA_UInt16_new();
  735. *((UA_UInt16*)maxBrowseContinuationPoints->value.variant.data) = MAXCONTINUATIONPOINTS;
  736. maxBrowseContinuationPoints->value.variant.type = &UA_TYPES[UA_TYPES_UINT16];
  737. UA_Server_addNode(server, (UA_Node*)maxBrowseContinuationPoints,
  738. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES),
  739. UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
  740. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERCAPABILITIES_MAXBROWSECONTINUATIONPOINTS),
  741. UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION), UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
  742. UA_ObjectNode *serverdiagnostics = UA_ObjectNode_new();
  743. copyNames((UA_Node*)serverdiagnostics, "ServerDiagnostics");
  744. serverdiagnostics->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERDIAGNOSTICS;
  745. UA_Server_addNode(server, (UA_Node*)serverdiagnostics,
  746. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER),
  747. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  748. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERDIAGNOSTICS), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  749. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVERDIAGNOSTICSTYPE));
  750. UA_VariableNode *enabledFlag = UA_VariableNode_new();
  751. copyNames((UA_Node*)enabledFlag, "EnabledFlag");
  752. enabledFlag->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERDIAGNOSTICS_ENABLEDFLAG;
  753. enabledFlag->value.variant.data = UA_Boolean_new(); //itialized as false
  754. enabledFlag->value.variant.type = &UA_TYPES[UA_TYPES_BOOLEAN];
  755. enabledFlag->valueRank = 1;
  756. enabledFlag->minimumSamplingInterval = 1.0;
  757. enabledFlag->historizing = UA_FALSE;
  758. UA_Server_addNode(server, (UA_Node*)enabledFlag,
  759. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERDIAGNOSTICS),
  760. UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY));
  761. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERDIAGNOSTICS_ENABLEDFLAG), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  762. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_PROPERTYTYPE));
  763. UA_VariableNode *serverstatus = UA_VariableNode_new();
  764. copyNames((UA_Node*)serverstatus, "ServerStatus");
  765. serverstatus->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS);
  766. serverstatus->valueSource = UA_VALUESOURCE_DATASOURCE;
  767. serverstatus->value.dataSource = (UA_DataSource) {.handle = server, .read = readStatus,
  768. .release = releaseStatus, .write = UA_NULL};
  769. UA_Server_addNode(server, (UA_Node*)serverstatus, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER),
  770. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  771. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  772. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVERSTATUSTYPE));
  773. UA_VariableNode *starttime = UA_VariableNode_new();
  774. copyNames((UA_Node*)starttime, "StartTime");
  775. starttime->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_STARTTIME);
  776. starttime->value.variant.storageType = UA_VARIANT_DATA_NODELETE;
  777. starttime->value.variant.data = &server->startTime;
  778. starttime->value.variant.type = &UA_TYPES[UA_TYPES_DATETIME];
  779. UA_Server_addNode(server, (UA_Node*)starttime, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  780. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  781. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_STARTTIME), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  782. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  783. UA_VariableNode *currenttime = UA_VariableNode_new();
  784. copyNames((UA_Node*)currenttime, "CurrentTime");
  785. currenttime->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME);
  786. currenttime->valueSource = UA_VALUESOURCE_DATASOURCE;
  787. currenttime->value.dataSource = (UA_DataSource) {.handle = NULL, .read = readCurrentTime,
  788. .release = releaseCurrentTime, .write = UA_NULL};
  789. UA_Server_addNode(server, (UA_Node*)currenttime, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  790. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  791. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_CURRENTTIME), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  792. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  793. UA_VariableNode *state = UA_VariableNode_new();
  794. UA_ServerState *stateEnum = UA_ServerState_new();
  795. *stateEnum = UA_SERVERSTATE_RUNNING;
  796. copyNames((UA_Node*)state, "State");
  797. state->nodeId.identifier.numeric = UA_NS0ID_SERVER_SERVERSTATUS_STATE;
  798. state->value.variant.type = &UA_TYPES[UA_TYPES_SERVERSTATE];
  799. state->value.variant.arrayLength = -1;
  800. state->value.variant.data = stateEnum; // points into the other object.
  801. UA_Server_addNode(server, (UA_Node*)state, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  802. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  803. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_STATE), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  804. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  805. UA_VariableNode *buildinfo = UA_VariableNode_new();
  806. copyNames((UA_Node*)buildinfo, "BuildInfo");
  807. buildinfo->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO);
  808. buildinfo->value.variant.data = UA_BuildInfo_new();
  809. buildinfo->value.variant.type = &UA_TYPES[UA_TYPES_BUILDINFO];
  810. getBulidInfo(server, (UA_BuildInfo*)buildinfo->value.variant.data);
  811. UA_Server_addNode(server, (UA_Node*)buildinfo, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  812. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  813. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  814. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BUILDINFOTYPE));
  815. UA_VariableNode *producturi = UA_VariableNode_new();
  816. copyNames((UA_Node*)producturi, "ProductUri");
  817. producturi->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_PRODUCTURI);
  818. producturi->value.variant.data = UA_String_new();
  819. *((UA_String*)producturi->value.variant.data) = UA_STRING_ALLOC(PRODUCT_URI);
  820. producturi->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  821. UA_Server_addNode(server, (UA_Node*)producturi, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  822. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  823. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_PRODUCTURI), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  824. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  825. UA_VariableNode *manufacturername = UA_VariableNode_new();
  826. copyNames((UA_Node*)manufacturername, "ManufacturererName");
  827. manufacturername->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_MANUFACTURERNAME);
  828. manufacturername->value.variant.data = UA_String_new();
  829. *((UA_String*)manufacturername->value.variant.data) = UA_STRING_ALLOC(MANUFACTURER_NAME);
  830. manufacturername->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  831. UA_Server_addNode(server, (UA_Node*)manufacturername, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  832. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  833. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_MANUFACTURERNAME), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  834. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  835. UA_VariableNode *productname = UA_VariableNode_new();
  836. copyNames((UA_Node*)productname, "ProductName");
  837. productname->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_PRODUCTNAME);
  838. productname->value.variant.data = UA_String_new();
  839. *((UA_String*)productname->value.variant.data) = UA_STRING_ALLOC(PRODUCT_NAME);
  840. productname->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  841. UA_Server_addNode(server, (UA_Node*)productname, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  842. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  843. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_PRODUCTNAME), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  844. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  845. UA_VariableNode *softwareversion = UA_VariableNode_new();
  846. copyNames((UA_Node*)softwareversion, "SoftwareVersion");
  847. softwareversion->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_SOFTWAREVERSION);
  848. softwareversion->value.variant.data = UA_String_new();
  849. *((UA_String*)softwareversion->value.variant.data) = UA_STRING_ALLOC(SOFTWARE_VERSION);
  850. softwareversion->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  851. UA_Server_addNode(server, (UA_Node*)softwareversion, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  852. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  853. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_SOFTWAREVERSION), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  854. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  855. UA_VariableNode *buildnumber = UA_VariableNode_new();
  856. copyNames((UA_Node*)buildnumber, "BuildNumber");
  857. buildnumber->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_BUILDNUMBER);
  858. buildnumber->value.variant.data = UA_String_new();
  859. *((UA_String*)buildnumber->value.variant.data) = UA_STRING_ALLOC(BUILD_NUMBER);
  860. buildnumber->value.variant.type = &UA_TYPES[UA_TYPES_STRING];
  861. UA_Server_addNode(server, (UA_Node*)buildnumber, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  862. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  863. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_BUILDNUMBER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  864. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  865. UA_VariableNode *builddate = UA_VariableNode_new();
  866. copyNames((UA_Node*)builddate, "BuildDate");
  867. builddate->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_BUILDDATE);
  868. builddate->value.variant.storageType = UA_VARIANT_DATA_NODELETE;
  869. builddate->value.variant.data = &server->buildDate;
  870. builddate->value.variant.type = &UA_TYPES[UA_TYPES_DATETIME];
  871. UA_Server_addNode(server, (UA_Node*)builddate, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO),
  872. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  873. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_BUILDINFO_BUILDNUMBER), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  874. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  875. UA_VariableNode *secondstillshutdown = UA_VariableNode_new();
  876. copyNames((UA_Node*)secondstillshutdown, "SecondsTillShutdown");
  877. secondstillshutdown->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_SECONDSTILLSHUTDOWN);
  878. secondstillshutdown->value.variant.data = UA_UInt32_new();
  879. secondstillshutdown->value.variant.type = &UA_TYPES[UA_TYPES_UINT32];
  880. UA_Server_addNode(server, (UA_Node*)secondstillshutdown, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  881. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  882. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_SECONDSTILLSHUTDOWN), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  883. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  884. UA_VariableNode *shutdownreason = UA_VariableNode_new();
  885. copyNames((UA_Node*)shutdownreason, "ShutdownReason");
  886. shutdownreason->nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_SHUTDOWNREASON);
  887. shutdownreason->value.variant.data = UA_LocalizedText_new();
  888. shutdownreason->value.variant.type = &UA_TYPES[UA_TYPES_LOCALIZEDTEXT];
  889. UA_Server_addNode(server, (UA_Node*)shutdownreason, UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS),
  890. UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT));
  891. ADDREFERENCE(UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_SERVERSTATUS_SHUTDOWNREASON), UA_NODEID_NUMERIC(0, UA_NS0ID_HASTYPEDEFINITION),
  892. UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_BASEDATAVARIABLETYPE));
  893. return server;
  894. }