Browse Source

[FIX] Initialize ServerArray with same ApplicationURI as NamespaceArray

 - At present ServerArray has no value assigned and is NULL
 - Update the ServerArray with same ApplicationURI as NamespaceArray
 - Resolves test case 013.js in Discovery Get Endpoints conformance
   unit of CTT

Change-Id: I564c8adca95737996f4f83dbad1d357cbb4bbbe9
Signed-off-by: Asish Ganesh <asish.g@kalycito.com>
Asish Ganesh 5 years ago
parent
commit
2e14f900ab
3 changed files with 17 additions and 4 deletions
  1. 10 2
      src/server/ua_server.c
  2. 4 0
      src/server/ua_server_internal.h
  3. 3 2
      src/server/ua_server_ns0.c

+ 10 - 2
src/server/ua_server.c

@@ -14,6 +14,7 @@
  *    Copyright 2017 (c) frax2222
  *    Copyright 2017 (c) Mark Giraud, Fraunhofer IOSB
  *    Copyright 2018 (c) Hilscher Gesellschaft für Systemautomation mbH (Author: Martin Lang)
+ *    Copyright 2019 (c) Kalycito Infotech Private Limited
  */
 
 #include "ua_server_internal.h"
@@ -420,10 +421,17 @@ UA_StatusCode
 UA_Server_run_startup(UA_Server *server) {
     /* ensure that the uri for ns1 is set up from the app description */
     setupNs1Uri(server);
-    
+
+    /* write ServerArray with same ApplicationURI value as NamespaceArray */
+    UA_StatusCode retVal = writeNs0VariableArray(server, UA_NS0ID_SERVER_SERVERARRAY,
+                                    &server->config.applicationDescription.applicationUri,
+                                    1, &UA_TYPES[UA_TYPES_STRING]);
+    if(retVal != UA_STATUSCODE_GOOD)
+        return retVal;
+
     if(server->state > UA_SERVERLIFECYCLE_FRESH)
         return UA_STATUSCODE_GOOD;
-    
+
     /* At least one endpoint has to be configured */
     if(server->config.endpointsSize == 0) {
         UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,

+ 4 - 0
src/server/ua_server_internal.h

@@ -9,6 +9,7 @@
  *    Copyright 2015-2016 (c) Oleksiy Vasylyev
  *    Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH
  *    Copyright 2017 (c) Julian Grothoff
+ *    Copyright 2019 (c) Kalycito Infotech Private Limited
  */
 
 #ifndef UA_SERVER_INTERNAL_H_
@@ -277,6 +278,9 @@ AddNode_finish(UA_Server *server, UA_Session *session, const UA_NodeId *nodeId);
 
 UA_StatusCode UA_Server_initNS0(UA_Server *server);
 
+UA_StatusCode writeNs0VariableArray(UA_Server *server, UA_UInt32 id, void *v,
+                      size_t length, const UA_DataType *type);
+
 _UA_END_DECLS
 
 #endif /* UA_SERVER_INTERNAL_H_ */

+ 3 - 2
src/server/ua_server_ns0.c

@@ -1,6 +1,6 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  *    Copyright 2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
@@ -8,6 +8,7 @@
  *    Copyright 2017 (c) Julian Grothoff
  *    Copyright 2017 (c) Henrik Norrman
  *    Copyright 2018 (c) Fabian Arndt, Root-Core
+ *    Copyright 2019 (c) Kalycito Infotech Private Limited
  */
 
 #include "open62541/namespace0_generated.h"
@@ -541,7 +542,7 @@ writeNs0Variable(UA_Server *server, UA_UInt32 id, void *v, const UA_DataType *ty
     return UA_Server_writeValue(server, UA_NODEID_NUMERIC(0, id), var);
 }
 
-static UA_StatusCode
+UA_StatusCode
 writeNs0VariableArray(UA_Server *server, UA_UInt32 id, void *v,
                       size_t length, const UA_DataType *type) {
     UA_Variant var;