Sfoglia il codice sorgente

add more structure to sources

Julius Pfrommer 10 anni fa
parent
commit
127f7c637c

+ 24 - 20
CMakeLists.txt

@@ -65,6 +65,7 @@ include_directories("${PROJECT_BINARY_DIR}/src_generated")
 configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")
 
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/server")
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/util")
 
 file(GLOB_RECURSE headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
@@ -72,45 +73,45 @@ file(GLOB generated_headers "${PROJECT_BINARY_DIR}/src_generated/*.h")
 
 set(lib_sources src/ua_types.c
                 src/ua_types_encoding_binary.c
-                src/ua_application.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
                 src/ua_transport.c
                 src/ua_transport_binary.c
                 src/ua_transport_binary_secure.c
-                src/ua_services_attribute.c
-                src/ua_services_session.c
-                src/ua_services_discovery.c
-                src/ua_services_securechannel.c
-                src/ua_services_nodemanagement.c
-                src/ua_services_view.c
-                src/ua_services_subscription.c
-                src/ua_services_monitoreditems.c
-                src/ua_stack_channel.c
-                src/ua_stack_channel_manager.c
-                src/ua_stack_session_manager.c
-                src/ua_stack_session.c
+                src/ua_channel.c
+                src/ua_session.c
                 src/ua_transport_connection.c
-                src/ua_transport_connection_manager.c
-				src/ua_server.c
+                src/server/ua_services_attribute.c
+                src/server/ua_services_session.c
+                src/server/ua_services_discovery.c
+                src/server/ua_services_securechannel.c
+                src/server/ua_services_nodemanagement.c
+                src/server/ua_services_view.c
+                src/server/ua_services_subscription.c
+                src/server/ua_services_monitoreditems.c
+                src/server/ua_channel_manager.c
+                src/server/ua_session_manager.c
+                src/server/ua_transport_connection_manager.c
+				src/server/ua_server.c
+                src/server/ua_application.c
                 src/util/ua_util.c
                 src/util/ua_list.c
                 src/util/ua_indexedList.c
                 src/util/ua_base64.c
-                ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
-                ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
 				${headers}
 				${generated_headers})
 
 if(MULTITHREADING)
-    list(APPEND lib_sources src/ua_namespace_concurrent.c)
+    list(APPEND lib_sources src/server/ua_namespace_concurrent.c)
 else()
-    list(APPEND lib_sources src/ua_namespace.c)
+    list(APPEND lib_sources src/server/ua_namespace.c)
 endif(MULTITHREADING)
 
 set(generate_src_options "")
 
 if(UA_ENCODING_XML)
     list(APPEND lib_sources src/ua_types_encoding_xml.c
-                            src/ua_namespace_xml.c
+                            src/server/ua_namespace_xml.c
                             src/ua_xml.c)
     set(generate_src_options "${generate_src_options}--with-xml")
 endif(UA_ENCODING_XML)
@@ -154,6 +155,9 @@ target_link_libraries(exampleServer open62541)
 if(WIN32)
     target_link_libraries(exampleServer ws2_32)
 endif(WIN32)
+if(MULTITHREADING)
+    target_link_libraries(exampleServer urcu-cds urcu)
+endif(MULTITHREADING)
 
 # generate documentation
 option(GENERATE_DOCUMENTATION "Generate doxygen documentation" OFF)

+ 3 - 4
examples/opcuaServer.c

@@ -4,8 +4,7 @@
 #include "networklayer.h"
 #include "ua_application.h"
 
-#ifdef WIN32
-#else
+#ifndef WIN32
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <unistd.h>
@@ -15,8 +14,8 @@
 #include <fcntl.h>
 
 #include <signal.h>
-#include "ua_stack_channel_manager.h"
-#include "ua_stack_session_manager.h"
+#include "ua_channel_manager.h"
+#include "ua_session_manager.h"
 #include "ua_server.h"
 
 UA_Boolean running = UA_TRUE;

src/ua_application.c → src/server/ua_application.c


src/ua_application.h → src/server/ua_application.h


+ 1 - 1
src/ua_stack_channel_manager.c

@@ -1,4 +1,4 @@
-#include "ua_stack_channel_manager.h"
+#include "ua_channel_manager.h"
 
 struct SL_ChannelManager {
 	UA_Int32 maxChannelCount;

+ 4 - 4
src/ua_stack_channel_manager.h

@@ -1,7 +1,7 @@
-#ifndef UA_STACK_CHANNEL_MANAGER_H_
-#define UA_STACK_CHANNEL_MANAGER_H_
+#ifndef UA_CHANNEL_MANAGER_H_
+#define UA_CHANNEL_MANAGER_H_
 
-#include "ua_stack_channel.h"
+#include "ua_channel.h"
 
 struct SL_ChannelManager;
 typedef struct SL_ChannelManager SL_ChannelManager;
@@ -14,4 +14,4 @@ UA_Int32 SL_ChannelManager_getChannelLifeTime(UA_DateTime *lifeTime);
 UA_Int32 SL_ChannelManager_generateToken(SL_Channel *channel, UA_Int32 requestedLifeTime, SecurityTokenRequestType requestType, UA_ChannelSecurityToken* newToken);
 UA_Int32 SL_ChannelManager_generateChannelId(UA_UInt32 *newChannelId);
 
-#endif /* UA_STACK_CHANNEL_MANAGER_H_ */
+#endif /* UA_CHANNEL_MANAGER_H_ */

src/ua_namespace.c → src/server/ua_namespace.c


src/ua_namespace.h → src/server/ua_namespace.h


+ 1 - 1
src/ua_namespace_concurrent.c

@@ -221,7 +221,7 @@ UA_Int32 Namespace_delete(Namespace *ns) {
 }
 
 UA_Int32 Namespace_insert(Namespace *ns, UA_Node **node, UA_Byte flags) {
-	if(ns == UA_NULL || node == UA_NULL || *node == UA_NULL || (*node)->nodeId.namespace != ns->namespaceId)
+	if(ns == UA_NULL || node == UA_NULL || *node == UA_NULL || (*node)->nodeId.ns != ns->namespaceId)
 		return UA_ERROR;
 
 	UA_UInt32 nodesize;

src/ua_namespace_xml.c → src/server/ua_namespace_xml.c


src/ua_namespace_xml.h → src/server/ua_namespace_xml.h


src/ua_server.c → src/server/ua_server.c


src/ua_server.h → src/server/ua_server.h


+ 3 - 2
src/ua_services.h

@@ -11,8 +11,9 @@
 #include "ua_types_generated.h"
 #include "ua_application.h"
 #include "ua_transport_binary_secure.h"
-#include "ua_stack_session_manager.h"
-#include "ua_stack_channel_manager.h"
+#include "ua_session_manager.h"
+#include "ua_channel_manager.h"
+
 /**
  * @defgroup services Services
  *

src/ua_services_attribute.c → src/server/ua_services_attribute.c


src/ua_services_discovery.c → src/server/ua_services_discovery.c


src/ua_services_internal.h → src/server/ua_services_internal.h


src/ua_services_monitoreditems.c → src/server/ua_services_monitoreditems.c


+ 2 - 1
src/ua_services_nodemanagement.c

@@ -2,7 +2,8 @@
 #include "ua_statuscodes.h"
 #include "ua_namespace.h"
 #include "ua_services_internal.h"
-#include "ua_stack_session.h"
+#include "ua_session.h"
+
 #define CHECKED_ACTION(ACTION, CLEAN_UP, GOTO) do {	\
 	status |= ACTION; \
 	if(status != UA_SUCCESS) { \

src/ua_services_securechannel.c → src/server/ua_services_securechannel.c


src/ua_services_session.c → src/server/ua_services_session.c


src/ua_services_subscription.c → src/server/ua_services_subscription.c


src/ua_services_view.c → src/server/ua_services_view.c


+ 1 - 1
src/ua_stack_session_manager.c

@@ -1,4 +1,4 @@
-#include "ua_stack_session_manager.h"
+#include "ua_session_manager.h"
 
 struct UA_SessionManager {
 	UA_list_List sessions;

+ 4 - 4
src/ua_stack_session_manager.h

@@ -1,7 +1,7 @@
-#ifndef UA_STACK_SESSION_MANAGER_H_
-#define UA_STACK_SESSION_MANAGER_H_
+#ifndef UA_SESSION_MANAGER_H_
+#define UA_SESSION_MANAGER_H_
 
-#include "ua_stack_session.h"
+#include "ua_session.h"
 
 struct UA_SessionManager;
 typedef struct UA_SessionManager UA_SessionManager;
@@ -57,4 +57,4 @@ UA_Int32 UA_SessionManager_getSessionTimeout(UA_Int64 *timeout_ms);
 //UA_Int32 UA_SessionManager_generateToken(UA_Session session, UA_Int32 requestedLifeTime, SecurityTokenRequestType requestType, UA_ChannelSecurityToken* newToken);
 UA_Int32 UA_SessionManager_generateSessionId(UA_NodeId *newSessionId);
 
-#endif /* UA_STACK_SESSION_MANAGER_H_ */
+#endif /* UA_SESSION_MANAGER_H_ */

src/ua_transport_connection_manager.c → src/server/ua_transport_connection_manager.c


src/ua_transport_connection_manager.h → src/server/ua_transport_connection_manager.h


+ 1 - 1
src/ua_stack_channel.c

@@ -1,4 +1,4 @@
-#include "ua_stack_channel.h"
+#include "ua_channel.h"
 #include <time.h>
 #include <stdlib.h>
 

+ 3 - 3
src/ua_stack_channel.h

@@ -1,5 +1,5 @@
-#ifndef UA_STACK_CHANNEL_H_
-#define UA_STACK_CHANNEL_H_
+#ifndef UA_CHANNEL_H_
+#define UA_CHANNEL_H_
 
 #include <stdio.h>
 #include <memory.h> // memcpy
@@ -62,4 +62,4 @@ UA_Int32 SL_Channel_getRevisedLifetime(SL_Channel *channel, UA_UInt32 *revisedLi
 //setters
 UA_Int32 SL_Channel_setId(SL_Channel *channel, UA_UInt32 id);
 
-#endif /* UA_STACK_CHANNEL_H_ */
+#endif /* UA_CHANNEL_H_ */

+ 2 - 9
src/ua_stack_session.c

@@ -1,13 +1,8 @@
-/*
- * ua_stack_session.c
- *
- *  Created on: 05.06.2014
- *      Author: root
- */
 #include <time.h>
 #include <stdlib.h>
 
-#include "ua_stack_session.h"
+#include "ua_session.h"
+
 struct UA_Session {
 	UA_NodeId authenticationToken;
 	UA_NodeId sessionId;
@@ -185,5 +180,3 @@ UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, Application* appl
 	session->application = application;
 	return UA_SUCCESS;
 }
-
-

+ 4 - 4
src/ua_stack_session.h

@@ -1,7 +1,7 @@
-#ifndef UA_STACK_SESSION_H_
-#define UA_STACK_SESSION_H_
+#ifndef UA_SESSION_H_
+#define UA_SESSION_H_
 
-#include "ua_stack_channel.h"
+#include "ua_channel.h"
 
 struct UA_Session;
 typedef struct UA_Session UA_Session;
@@ -128,4 +128,4 @@ UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, Application** app
  */
 UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, Application* application);
 
-#endif /* UA_STACK_SESSION_H_ */
+#endif /* UA_SESSION_H_ */

+ 48 - 132
src/ua_transport_binary_secure.c

@@ -6,15 +6,13 @@
 #include "ua_transport.h"
 #include "ua_statuscodes.h"
 #include "ua_services.h"
-#include "ua_stack_session_manager.h"
-#include "ua_stack_session.h"
+#include "ua_session_manager.h"
+#include "ua_session.h"
 
 #define SIZE_SECURECHANNEL_HEADER 12
 #define SIZE_SEQHEADER_HEADER 8
 
-static UA_Int32 SL_Send(SL_Channel *channel,
-		const UA_ByteString * responseMessage, UA_Int32 type)
-{
+static UA_Int32 SL_Send(SL_Channel *channel, const UA_ByteString * responseMessage, UA_Int32 type) {
 	UA_UInt32 pos = 0;
 	UA_Int32 isAsym = (type == UA_OPENSECURECHANNELRESPONSE_NS0); // FIXME: this is a to dumb method to determine asymmetric algorithm setting
 	UA_UInt32 channelId;
@@ -37,9 +35,7 @@ static UA_Int32 SL_Send(SL_Channel *channel,
 						+ UA_AsymmetricAlgorithmSecurityHeader_calcSizeBinary(
 								asymAlgSettings)
 						+ UA_NodeId_calcSizeBinary(&resp_nodeid));
-	}
-	else
-	{
+	} else {
 		UA_ByteString_newMembers((UA_ByteString *) response_gather[0], 8 + 16 + // normal header + 4*32bit secure channel information
 				UA_NodeId_calcSizeBinary(&resp_nodeid));
 	}
@@ -49,14 +45,11 @@ static UA_Int32 SL_Send(SL_Channel *channel,
 	UA_ByteString *header = (UA_ByteString *) response_gather[0];
 
 	/*---encode Secure Conversation Message Header  ---*/
-	if (isAsym)
-	{
+	if (isAsym) {
 		header->data[0] = 'O';
 		header->data[1] = 'P';
 		header->data[2] = 'N';
-	}
-	else
-	{
+	} else {
 		header->data[0] = 'M';
 		header->data[1] = 'S';
 		header->data[2] = 'G';
@@ -74,20 +67,12 @@ static UA_Int32 SL_Send(SL_Channel *channel,
 	UA_UInt32_encodeBinary(&channelId, header,&pos);
 
 	/*---encode Algorithm Security Header ---*/
-	if (isAsym)
-	{
-
-
-		UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(asymAlgSettings,
-				header,&pos);
+	if (isAsym) {
+		UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(asymAlgSettings, header,&pos);
 		UA_free(asymAlgSettings);
-	}
-	else
-	{
-
+	} else {
 		UA_UInt32 tokenId = 0;
 		SL_Channel_getTokenId(channel, &tokenId);
-
 		UA_UInt32_encodeBinary(&tokenId, header,&pos);
 	}
 
@@ -163,9 +148,7 @@ static void init_response_header(UA_RequestHeader const * p, UA_ResponseHeader *
 	UA_##TYPE##Response_deleteMembers(&r); \
 
 
-UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
-		UA_UInt32 *pos)
-{
+UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_UInt32 recvOffset = *pos;
 	UA_UInt32 sendOffset = 0;
@@ -180,62 +163,46 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
 	UA_Int32 serviceid = serviceRequestType.identifier.numeric - 2; // binary encoding has 2 added to the id
 	UA_Int32 responsetype;
 /* stack related services which only need information about the secure Channel */
-	if (serviceid == UA_GETENDPOINTSREQUEST_NS0)
-	{
+	if (serviceid == UA_GETENDPOINTSREQUEST_NS0) {
 		RESPONSE_PREPARE(GetEndpoints);
 		Service_GetEndpoints(channel,&p, &r);
 		RESPONSE_CLEANUP(GetEndpoints);
 		//INVOKE_SERVICE(GetEndpoints);
 		responsetype = UA_GETENDPOINTSRESPONSE_NS0;
-	}
-	else if (serviceid == UA_OPENSECURECHANNELREQUEST_NS0)
-	{
+	} else if (serviceid == UA_OPENSECURECHANNELREQUEST_NS0) {
 		RESPONSE_PREPARE(OpenSecureChannel);
 		Service_OpenSecureChannel(channel,&p, &r);
 		RESPONSE_CLEANUP(OpenSecureChannel);
 		responsetype = UA_OPENSECURECHANNELRESPONSE_NS0;
-	}
-	else if (serviceid == UA_CLOSESECURECHANNELREQUEST_NS0)
-	{
+	} else if (serviceid == UA_CLOSESECURECHANNELREQUEST_NS0) {
 		RESPONSE_PREPARE(CloseSecureChannel);
 		Service_CloseSecureChannel(channel,&p,&r);
 		RESPONSE_CLEANUP(CloseSecureChannel);
 		responsetype = UA_CLOSESECURECHANNELRESPONSE_NS0;
-	}
-
-	else if (serviceid == UA_CREATESESSIONREQUEST_NS0)
-	{
+	} else if (serviceid == UA_CREATESESSIONREQUEST_NS0) {
 		RESPONSE_PREPARE(CreateSession);
 		Service_CreateSession(channel,&p, &r);
 		RESPONSE_CLEANUP(CreateSession);
 		responsetype = UA_CREATESESSIONRESPONSE_NS0;
 	}
 /* services which need a session object */
-	else if (serviceid == UA_ACTIVATESESSIONREQUEST_NS0)
-	{
+	else if (serviceid == UA_ACTIVATESESSIONREQUEST_NS0) {
 		RESPONSE_PREPARE(ActivateSession);
 		UA_Session_updateLifetime(session); //renew session timeout
 		Service_ActivateSession(channel, session,&p, &r);
 		RESPONSE_CLEANUP(ActivateSession);
-
 		responsetype = UA_ACTIVATESESSIONRESPONSE_NS0;
-	}
-	else if (serviceid == UA_CLOSESESSIONREQUEST_NS0)
-	{
+	} else if (serviceid == UA_CLOSESESSIONREQUEST_NS0) {
 		RESPONSE_PREPARE(CloseSession);
 		if (UA_Session_verifyChannel(session,channel)){
 			UA_Session_updateLifetime(session); //renew session timeout
 			Service_CloseSession(session,&p, &r);
 		RESPONSE_CLEANUP(CloseSession);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		responsetype = UA_CLOSESESSIONRESPONSE_NS0;
-	}
-	else if (serviceid == UA_READREQUEST_NS0)
-	{
+	} else if (serviceid == UA_READREQUEST_NS0) {
 
 		RESPONSE_PREPARE(Read);
 		UA_Session_updateLifetime(session); //renew session timeout
@@ -243,137 +210,96 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
 		if (UA_Session_verifyChannel(session,channel)){
 			UA_Session_updateLifetime(session); //renew session timeout
 			Service_Read(session,&p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", Read));
 		RESPONSE_CLEANUP(Read);
 
 		responsetype = UA_READRESPONSE_NS0;
-	}
-	else if (serviceid == UA_WRITEREQUEST_NS0)
-	{
+	} else if (serviceid == UA_WRITEREQUEST_NS0) {
 
 		RESPONSE_PREPARE(Write);
 		DBG_VERBOSE(printf("Finished Service: %s\n", Write));
 		if (UA_Session_verifyChannel(session,channel)){
 			UA_Session_updateLifetime(session); //renew session timeout
 			Service_Write(session,&p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", Write));
 		RESPONSE_CLEANUP(Write);
-
-
 		responsetype = UA_WRITERESPONSE_NS0;
-	}
-	else if (serviceid == UA_BROWSEREQUEST_NS0)
-	{
-
+	} else if (serviceid == UA_BROWSEREQUEST_NS0) {
 		RESPONSE_PREPARE(Browse);
 		DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
 		if (UA_Session_verifyChannel(session,channel)){
 			Service_Browse(session,&p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
 		RESPONSE_CLEANUP(Browse);
-
-
 		responsetype = UA_BROWSERESPONSE_NS0;
-	}
-	else if (serviceid == UA_CREATESUBSCRIPTIONREQUEST_NS0)
-	{
-
+	} else if (serviceid == UA_CREATESUBSCRIPTIONREQUEST_NS0) {
 		RESPONSE_PREPARE(CreateSubscription);
 		DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
 		if (UA_Session_verifyChannel(session,channel)){
 			Service_CreateSubscription(session, &p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
 		RESPONSE_CLEANUP(CreateSubscription);
 		responsetype = UA_CREATESUBSCRIPTIONRESPONSE_NS0;
-	}
-	else if (serviceid == UA_TRANSLATEBROWSEPATHSTONODEIDSREQUEST_NS0)
-	{
-
+	} else if (serviceid == UA_TRANSLATEBROWSEPATHSTONODEIDSREQUEST_NS0) {
 		RESPONSE_PREPARE(TranslateBrowsePathsToNodeIds);
 		DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
 		if (UA_Session_verifyChannel(session,channel)){
 			Service_TranslateBrowsePathsToNodeIds(session, &p, &r);
-		}
-		else
-		{
+		} else {
 				DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
 		RESPONSE_CLEANUP(TranslateBrowsePathsToNodeIds);
 		responsetype = UA_TRANSLATEBROWSEPATHSTONODEIDSRESPONSE_NS0;
-	}
-	else if (serviceid == UA_PUBLISHREQUEST_NS0)
-	{
+	} else if (serviceid == UA_PUBLISHREQUEST_NS0) {
 
 		RESPONSE_PREPARE(Publish);
 		DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
-		if (UA_Session_verifyChannel(session,channel)){
+		if (UA_Session_verifyChannel(session,channel)) {
 			Service_Publish(session, &p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
 		RESPONSE_CLEANUP(Publish);
 		responsetype = UA_PUBLISHRESPONSE_NS0;
-	}
-	else if (serviceid == UA_CREATEMONITOREDITEMSREQUEST_NS0)
-	{
+	} else if (serviceid == UA_CREATEMONITOREDITEMSREQUEST_NS0) {
 		RESPONSE_PREPARE(CreateMonitoredItems);
 		DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
-		if (UA_Session_verifyChannel(session,channel)){
+		if (UA_Session_verifyChannel(session,channel)) {
 			Service_CreateMonitoredItems(session, &p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
 		RESPONSE_CLEANUP(CreateMonitoredItems);
 		responsetype = UA_CREATEMONITOREDITEMSRESPONSE_NS0;
-	}
-	else if (serviceid == UA_SETPUBLISHINGMODEREQUEST_NS0)
-	{
+	} else if (serviceid == UA_SETPUBLISHINGMODEREQUEST_NS0) {
 		RESPONSE_PREPARE(SetPublishingMode);
 		DBG_VERBOSE(printf("Finished Service: %s\n",SetPublishingMode));
-		if (UA_Session_verifyChannel(session,channel)){
+		if (UA_Session_verifyChannel(session,channel)) {
 			Service_SetPublishingMode(session, &p, &r);
-		}
-		else
-		{
+		} else {
 			DBG_VERBOSE(printf("session does not match secure channel"));
 		}
 		DBG_VERBOSE(printf("Finished Service: %s\n", SetPublishingMode));
 		RESPONSE_CLEANUP(SetPublishingMode);
 		responsetype = UA_SETPUBLISHINGMODERESPONSE_NS0;
-	}
-	else
-	{
-		printf(
-				"SL_processMessage - unknown request, namespace=%d, request=%d\n",
-				serviceRequestType.ns,
-				serviceRequestType.identifier.numeric);
+	} else {
+		printf("SL_processMessage - unknown request, namespace=%d, request=%d\n",
+			   serviceRequestType.ns, serviceRequestType.identifier.numeric);
 		retval = UA_ERROR;
 		UA_RequestHeader p;
 		UA_ResponseHeader r;
@@ -387,17 +313,16 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
 		UA_ResponseHeader_encodeBinary(&r, &response_msg,&sendOffset);
 		responsetype = UA_RESPONSEHEADER_NS0;
 	}
-	if(serviceid != UA_CLOSESECURECHANNELREQUEST_NS0){
+
+	if(serviceid != UA_CLOSESECURECHANNELREQUEST_NS0)
 		SL_Send(channel, &response_msg, responsetype);
-	}
+
 	UA_ByteString_deleteMembers(&response_msg);
 	*pos = recvOffset;
 	return retval;
 }
 
-UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg,
-		UA_UInt32 *pos)
-{
+UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_SequenceHeader sequenceHeader;
 	UA_AsymmetricAlgorithmSecurityHeader asymHeader;
@@ -408,23 +333,21 @@ UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg,
 	SL_Channel_setRemoteSecuritySettings(channel,&asymHeader,&sequenceHeader);
 	return SL_handleRequest(channel, msg, pos) | retval;
 }
+
 /* not used anymore */
 //UA_Int32 SL_ProcessCloseChannel(SL_Channel *channel, const UA_ByteString* msg,
 //		UA_UInt32 *pos)
 //{
 //	return SL_handleRequest(channel, msg, pos);
 //}
-UA_Int32 SL_Process(const UA_ByteString* msg,
-		UA_UInt32* pos)
-{
 
+UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos) {
 	DBG_VERBOSE(printf("SL_process - entered \n"));
 	UA_UInt32 secureChannelId;
 	UA_UInt32 foundChannelId;
 	SL_Channel *channel;
 	UA_SequenceHeader sequenceHeader;
 
-
 	UA_UInt32_decodeBinary(msg, pos, &secureChannelId);
 
 	//FIXME: we assume SAS, need to check if AAS or SAS
@@ -433,13 +356,9 @@ UA_Int32 SL_Process(const UA_ByteString* msg,
 	UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos,
 			&symAlgSecHeader);
 
- 	if (SL_ChannelManager_getChannel(secureChannelId,
-			&channel) == UA_SUCCESS)
-	{
-
+ 	if (SL_ChannelManager_getChannel(secureChannelId, &channel) == UA_SUCCESS) {
 		SL_Channel_getChannelId(channel, &foundChannelId);
-		printf("SL_process - received msg, with channel id: %i \n",
-				foundChannelId);
+		printf("SL_process - received msg, with channel id: %i \n", foundChannelId);
 
 		//sequence number processing
 		UA_SequenceHeader_decodeBinary(msg, pos,
@@ -448,11 +367,8 @@ UA_Int32 SL_Process(const UA_ByteString* msg,
 		SL_Channel_checkRequestId(channel,sequenceHeader.requestId);
 		//request id processing
 
-
 		SL_handleRequest(channel, msg, pos);
-	}
-	else
-	{
+	} else {
 		printf("SL_process - ERROR could not find channel with id: %i \n",
 				secureChannelId);
 		//TODO generate ERROR_Bad_SecureChannelUnkown

+ 2 - 2
src/ua_transport_binary_secure.h

@@ -3,8 +3,8 @@
 #include "ua_types.h"
 #include "ua_transport.h"
 #include "ua_transport_binary.h"
-#include "ua_stack_channel.h"
-#include "ua_stack_channel_manager.h"
+#include "ua_channel.h"
+#include "ua_channel_manager.h"
 
 /*inputs for secure Channel which must be provided once
 endPointUrl

+ 5 - 5
src/ua_types_encoding_xml.c

@@ -186,7 +186,7 @@ UA_Int32 UA_NodeId_decodeXmlFromStack(XML_Stack *s, XML_Attr *attr, UA_NodeId *d
 		s->parent[s->depth].len = 0;
 		XML_Stack_addChildHandler(s, "Namespace", strlen(
 		                              "Namespace"), (XML_decoder)UA_Int16_decodeXmlFromStack, UA_INT16,
-		                          &(dst->namespace));
+		                          &(dst->ns));
 		XML_Stack_addChildHandler(s, "Numeric", strlen(
 		                              "Numeric"), (XML_decoder)UA_Int32_decodeXmlFromStack, UA_INT32,
 		                          &(dst->identifier.numeric));
@@ -197,10 +197,10 @@ UA_Int32 UA_NodeId_decodeXmlFromStack(XML_Stack *s, XML_Attr *attr, UA_NodeId *d
 		// set attributes
 		for(i = 0; attr[i]; i += 2) {
 		if(0 == strncmp("Namespace", attr[i], strlen("Namespace")))
-			dst->namespace = atoi(attr[i + 1]);
+			dst->ns = atoi(attr[i + 1]);
 		else if(0 == strncmp("Numeric", attr[i], strlen("Numeric"))) {
 		dst->identifier.numeric = atoi(attr[i + 1]);
-		dst->encodingByte       = UA_NODEIDTYPE_FOURBYTE;
+		dst->nodeIdType = UA_NODEIDTYPE_NUMERIC;
 		} else
 			printf("UA_NodeId_decodeXml - Unknown attribute name=%s, value=%s\n", attr[i], attr[i+1]);
 		}
@@ -230,7 +230,7 @@ UA_Int32 UA_ExpandedNodeId_decodeXmlFromStack(XML_Stack *s, XML_Attr *attr, UA_E
 		                              "NodeId"), (XML_decoder)UA_NodeId_decodeXmlFromStack, UA_NODEID, &(dst->nodeId));
 		XML_Stack_addChildHandler(s, "Namespace", strlen(
 		                              "Namespace"), (XML_decoder)UA_Int16_decodeXmlFromStack, UA_INT16,
-		                          &(dst->nodeId.namespace));
+		                          &(dst->nodeId.ns));
 		XML_Stack_addChildHandler(s, "Numeric", strlen("Numeric"), (XML_decoder)UA_Int32_decodeXmlFromStack, UA_INT32,
 		                          &(dst->nodeId.identifier.numeric));
 		XML_Stack_addChildHandler(s, "Id", strlen("Id"), (XML_decoder)UA_String_decodeXmlFromStack, UA_STRING, UA_NULL);
@@ -239,7 +239,7 @@ UA_Int32 UA_ExpandedNodeId_decodeXmlFromStack(XML_Stack *s, XML_Attr *attr, UA_E
 		// set attributes
 		for(i = 0; attr[i]; i += 2) {
 		if(0 == strncmp("Namespace", attr[i], strlen("Namespace")))
-			UA_UInt16_copycstring((cstring)attr[i + 1], &(dst->nodeId.namespace));
+			UA_UInt16_copycstring((cstring)attr[i + 1], &(dst->nodeId.ns));
 		else if(0 == strncmp("Numeric", attr[i], strlen("Numeric"))) {
 		UA_NodeId_copycstring((cstring)attr[i + 1], &(dst->nodeId), s->aliases);
 		} else if(0 == strncmp("NodeId", attr[i], strlen("NodeId")))

+ 6 - 7
src/ua_xml.c

@@ -85,7 +85,7 @@ UA_Int32 _UA_NodeId_copycstring(cstring src, UA_NodeId* dst, UA_NodeSetAliases*
 		if (src[0] == 'i' && src[1] == '=') { // namespace zero numeric identifier
 			dst->identifier.numeric = atoi(&src[2]);
 		} else if (src[0] == 'n' && src[1] == 's' && src[2] == '=') { // namespace
-			dst->namespace = atoi(&src[3]);
+			dst->ns = atoi(&src[3]);
 			src = strchr(&src[3],';');
 			if (src != UA_NULL)
 				retval = _UA_NodeId_copycstring(src+1,dst,aliases);  // +1 to start beyond ;
@@ -110,8 +110,8 @@ UA_Int32 _UA_NodeId_copycstring(cstring src, UA_NodeId* dst, UA_NodeSetAliases*
 }
 
 UA_Int32 UA_NodeId_copycstring(cstring src, UA_NodeId* dst, UA_NodeSetAliases* aliases) {
-	dst->encodingByte = UA_NODEIDTYPE_FOURBYTE;
-	dst->namespace = 0;
+	dst->nodeIdType = UA_NODEIDTYPE_NUMERIC;
+	dst->ns = 0;
 	dst->identifier.numeric = 0;
 	return _UA_NodeId_copycstring(src,dst,aliases);
 }
@@ -126,8 +126,8 @@ UA_Int32 UA_ReferenceNode_println(cstring label, UA_ReferenceNode *a) {
 }
 
 UA_Int32 UA_ExpandedNodeId_copycstring(cstring src, UA_ExpandedNodeId *dst, UA_NodeSetAliases *aliases) {
-	dst->nodeId.encodingByte       = UA_NODEIDTYPE_FOURBYTE;
-	dst->nodeId.namespace          = 0;
+	dst->nodeId.nodeIdType       = UA_NODEIDTYPE_NUMERIC;
+	dst->nodeId.ns          = 0;
 	dst->nodeId.identifier.numeric = 0;
 	UA_NodeId_copycstring(src, &(dst->nodeId), aliases);
 	DBG_VERBOSE(printf("UA_ExpandedNodeId_copycstring src=%s,id=%d\n", src, dst->nodeId.identifier.numeric));
@@ -593,8 +593,7 @@ UA_Int32 UA_TypedArray_decodeXmlFromStack(XML_Stack* s, XML_Attr* attr, UA_Typed
 /* } */
 
 _Bool UA_NodeId_isBuiltinType(UA_NodeId* nodeid) {
-	return (nodeid->namespace == 0 &&
-			nodeid->identifier.numeric >= UA_BOOLEAN_NS0 &&
+	return (nodeid->ns == 0 && nodeid->identifier.numeric >= UA_BOOLEAN_NS0 &&
 			nodeid->identifier.numeric <= UA_DIAGNOSTICINFO_NS0
 			);
 }

+ 3 - 0
tests/CMakeLists.txt

@@ -5,6 +5,9 @@ set(LIBS open62541 ${CHECK_LIBRARIES} m)
 if(NOT WIN32)
     list(APPEND LIBS rt pthread)
 endif(NOT WIN32)
+if(MULTITHREADING)
+    list(APPEND LIBS urcu-cds urcu)
+endif(MULTITHREADING)
 
 add_executable(check_builtin check_builtin.c)
 target_link_libraries(check_builtin ${LIBS})

+ 2 - 2
tests/check_stack.c

@@ -6,8 +6,8 @@
 #include "ua_transport_binary.h"
 #include "ua_transport_binary_secure.h"
 #include "ua_transport_connection.h"
-#include "ua_stack_channel_manager.h"
-#include "ua_stack_session_manager.h"
+#include "ua_channel_manager.h"
+#include "ua_session_manager.h"
 #include "check.h"
 
 #define MAXMSG 512