Quellcode durchsuchen

deleted unused files

FlorianPalm vor 11 Jahren
Ursprung
Commit
5443b18b0e
48 geänderte Dateien mit 883 neuen und 5187 gelöschten Zeilen
  1. 4 0
      open62541Stack/.cproject
  2. 7 2
      open62541Stack/INSTALL
  3. 1 0
      open62541Stack/Makefile.am
  4. 0 1
      open62541Stack/README
  5. 13 1
      open62541Stack/configure.ac
  6. 79 95
      open62541Stack/examples/src/opcuaServer.c
  7. BIN
      open62541Stack/opcuaserver-1.0.tar.gz
  8. 0 1
      open62541Stack/opcuaserver-1.0/AUTHORS
  9. 0 1
      open62541Stack/opcuaserver-1.0/COPYING
  10. 0 0
      open62541Stack/opcuaserver-1.0/ChangeLog
  11. 0 370
      open62541Stack/opcuaserver-1.0/INSTALL
  12. 0 7
      open62541Stack/opcuaserver-1.0/Makefile.am
  13. 0 1
      open62541Stack/opcuaserver-1.0/NEWS
  14. 0 1
      open62541Stack/opcuaserver-1.0/README
  15. 0 29
      open62541Stack/opcuaserver-1.0/configure.ac
  16. 0 5
      open62541Stack/opcuaserver-1.0/examples/src/Makefile.am
  17. 0 153
      open62541Stack/opcuaserver-1.0/examples/src/opcuaServer.c
  18. 0 43
      open62541Stack/opcuaserver-1.0/src/Makefile.am
  19. 0 973
      open62541Stack/opcuaserver-1.0/src/opcua_advancedDatatypes.h
  20. 0 188
      open62541Stack/opcuaserver-1.0/src/opcua_binaryEncDec.c
  21. 0 125
      open62541Stack/opcuaserver-1.0/src/opcua_binaryEncDec.h
  22. 0 11
      open62541Stack/opcuaserver-1.0/src/opcua_builtInDatatypes.c
  23. 0 493
      open62541Stack/opcuaserver-1.0/src/opcua_builtInDatatypes.h
  24. 0 79
      open62541Stack/opcuaserver-1.0/src/opcua_connectionHelper.h
  25. 0 89
      open62541Stack/opcuaserver-1.0/src/opcua_encodingLayer.c
  26. 0 58
      open62541Stack/opcuaserver-1.0/src/opcua_encodingLayer.h
  27. 0 205
      open62541Stack/opcuaserver-1.0/src/opcua_secureChannelLayer.c
  28. 0 78
      open62541Stack/opcuaserver-1.0/src/opcua_secureChannelLayer.h
  29. 0 314
      open62541Stack/opcuaserver-1.0/src/opcua_transportLayer.c
  30. 0 89
      open62541Stack/opcuaserver-1.0/src/opcua_transportLayer.h
  31. 0 1047
      open62541Stack/opcuaserver-1.0/src/opcua_types.h
  32. 0 16
      open62541Stack/opcuaserver-1.0/src/tcp_layer.h
  33. 0 8
      open62541Stack/opcuaserver-1.0/tests/Makefile.am
  34. 0 208
      open62541Stack/opcuaserver-1.0/tests/check_stack.c
  35. 9 0
      open62541Stack/src/Makefile.am
  36. 29 25
      open62541Stack/src/opcua_binaryEncDec.c
  37. 5 5
      open62541Stack/src/opcua_binaryEncDec.h
  38. 29 0
      open62541Stack/src/opcua_builtInDatatypes.c
  39. 102 90
      open62541Stack/src/opcua_builtInDatatypes.h
  40. 17 10
      open62541Stack/src/opcua_connectionHelper.h
  41. 1 0
      open62541Stack/src/opcua_memory.c
  42. 189 31
      open62541Stack/src/opcua_secureChannelLayer.c
  43. 20 3
      open62541Stack/src/opcua_secureChannelLayer.h
  44. 185 147
      open62541Stack/src/opcua_transportLayer.c
  45. 15 14
      open62541Stack/src/opcua_transportLayer.h
  46. 157 161
      open62541Stack/src/opcua_types.h
  47. 10 1
      open62541Stack/src/tcp_layer.h
  48. 11 9
      open62541Stack/tests/check_stack.c

+ 4 - 0
open62541Stack/.cproject

@@ -33,6 +33,9 @@
 							</tool>
 							</tool>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.1364199788" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.1364199788" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1680098499" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1680098499" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
+								<option id="gnu.c.compiler.option.include.paths.1561944092" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+									<listOptionValue builtIn="false" value="/usr/include/i386-linux-gnu"/>
+								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.386414608" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.386414608" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 							</tool>
 							</tool>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.381891143" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp"/>
 							<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.381891143" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp"/>
@@ -499,6 +502,7 @@
 			</target>
 			</target>
 			<target name="Server" path="src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 			<target name="Server" path="src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 				<buildCommand>make</buildCommand>
 				<buildCommand>make</buildCommand>
+				<buildArguments/>
 				<buildTarget>Server</buildTarget>
 				<buildTarget>Server</buildTarget>
 				<stopOnError>true</stopOnError>
 				<stopOnError>true</stopOnError>
 				<useDefaultCommand>true</useDefaultCommand>
 				<useDefaultCommand>true</useDefaultCommand>

+ 7 - 2
open62541Stack/INSTALL

@@ -1,8 +1,8 @@
 Installation Instructions
 Installation Instructions
 *************************
 *************************
 
 
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+Inc.
 
 
    Copying and distribution of this file, with or without modification,
    Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
 are permitted in any medium without royalty provided the copyright
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
 
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
 
+   HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved.  Use GNU `make'
+instead.
+
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
 parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
 parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
 a workaround.  If GNU CC is not installed, it is therefore recommended
 a workaround.  If GNU CC is not installed, it is therefore recommended

+ 1 - 0
open62541Stack/Makefile.am

@@ -5,3 +5,4 @@ else
 endif
 endif
 
 
 SUBDIRS = $(SUBS) examples/src	
 SUBDIRS = $(SUBS) examples/src	
+

+ 0 - 1
open62541Stack/README

@@ -1 +0,0 @@
-Sample readme file for OPCUAServer project.

+ 13 - 1
open62541Stack/configure.ac

@@ -25,7 +25,19 @@ AM_COND_IF([TARGET_WIN],
 
 
 AM_COND_IF([TARGET_LINUX],
 AM_COND_IF([TARGET_LINUX],
     AC_DEFINE([LINUX]))
     AC_DEFINE([LINUX]))
-    
+   
+AC_ARG_ENABLE(debug,
+AS_HELP_STRING([--enable-debug],
+               [enable debugging, default: no]),
+[case "${enableval}" in
+             yes) debug=true ;;
+             no)  debug=false ;;
+             *)   AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
+esac],
+[debug=false])
+
+AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
+   
 AC_LIBTOOL_WIN32_DLL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 AC_PROG_LIBTOOL
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_MACRO_DIR([m4])

+ 79 - 95
open62541Stack/examples/src/opcuaServer.c

@@ -20,14 +20,17 @@
 
 
 #ifdef LINUX
 #ifdef LINUX
 
 
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
+#include <sys/socketvar.h>
 
 
 void server_init();
 void server_init();
 void server_run();
 void server_run();
 
 
 #endif
 #endif
-
+#define PORT    16664
+     #define MAXMSG  512
 int main(void)
 int main(void)
 {
 {
 
 
@@ -50,120 +53,101 @@ void server_init()
 }
 }
 void server_run()
 void server_run()
 {
 {
-	int server_state = 0;
+	UA_connection connection;
-	int recv_data = 0;
+	UA_ByteString slMessage;
-	int send_data = 1;
+	TL_initConnectionObject(&connection);
-	int new_client = 2;
+	char optval;
-	int new_request = 3;
+	int sockfd, newsockfd, portno, clilen;
-	char buf[8192];
+	char buffer[8192];
-	struct sockaddr_in self;
+	struct sockaddr_in serv_addr, cli_addr;
-	int sockfd;
+	int  n;
-	int clientfd;
+
-
+	/* First call to socket() function */
-	struct sockaddr_in client_addr;
+	sockfd = socket(AF_INET, SOCK_STREAM, 0);
-	int addrlen=sizeof(client_addr);
+	if (sockfd < 0)
-
-
-	Int32 valreal = 0;
-	Int32 valcalc = 0;
-	UA_DiagnosticInfo diagnosticInfo;
-	diagnosticInfo.EncodingMask |= 0x01 | 0x02 | 0x04 | 0x04 | 0x08 | 0x10 | 0x10;
-	diagnosticInfo.SymbolicId = 30;
-	diagnosticInfo.NamespaceUri = 25;
-	diagnosticInfo.LocalizedText = 22;
-	diagnosticInfo.AdditionalInfo.Data = "OPCUA";
-	diagnosticInfo.AdditionalInfo.Length = 5;
-
-	if (diagnosticInfo_calcSize(&diagnosticInfo) > 10)
-	{
-
-
-	//---Create streaming socket---
-	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
 	{
 	{
-		puts("socket error");
+		perror("ERROR opening socket");
+		exit(1);
 	}
 	}
-	}
-	bzero(&self, sizeof(self));
-	self.sin_family = AF_INET;
-	self.sin_port = htons(4840);
-	self.sin_addr.s_addr = htonl(INADDR_ANY);
 
 
-	if( bind(sockfd,(struct sockaddr *)&self , sizeof(self)) < 0)
+	/* Initialize socket structure */
+	bzero((char *) &serv_addr, sizeof(serv_addr));
+	portno = 16664;
+	serv_addr.sin_family = AF_INET;
+	serv_addr.sin_addr.s_addr = INADDR_ANY;
+	serv_addr.sin_port = htons(portno);
+	optval = 1;
+
+	if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&optval,sizeof(int)) == -1) {
+	    perror("setsockopt");
+	    exit(1);
+	}
+	/* Now bind the host address using bind() call.*/
+	if (bind(sockfd, (struct sockaddr *) &serv_addr,
+						  sizeof(serv_addr)) < 0)
 	{
 	{
+		 perror("ERROR on binding");
+		 exit(1);
+	}
 
 
+	/* Now start listening for the clients, here process will
+	* go in sleep mode and will wait for the incoming connection
+	*/
+	listen(sockfd,5);
+	clilen = sizeof(cli_addr);
 
 
-	   //Fehler bei bind()
+	/* Accept actual connection from the client */
-	 }
+	newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
-
+								&clilen);
-	//---Make it a "listening socket"---
+	if (newsockfd < 0)
-	if ( listen(sockfd, 1) != 0 )
 	{
 	{
-		puts("listen error");
+		perror("ERROR on accept");
+		exit(1);
 	}
 	}
-	clientfd = accept(sockfd, (struct sockaddr*)&client_addr, &addrlen);
+	printf("One connection accepted");
-	server_state = 0;
 	while(1)
 	while(1)
 	{
 	{
-		//call recv (nonblocking)
+		/* If connection is established then start communicating */
+		bzero(buffer,8192);
 
 
-		//call TL_getPacketType
+		n = read( newsockfd,buffer,8192);
 
 
-		//if newData
+		if (n > 0)
-		//
-		UA_connection connection;
-		AD_RawMessage *rawMessage;
-		rawMessage->message = buf;
-		rawMessage->length = 0;
-		switch(server_state)
 		{
 		{
+			printf("received: %s\n",buffer);
+			connection.readData.Data = buffer;
+			connection.readData.Length = n;
+			connection.newDataToRead = 1;
 
 
-			recv_data :
+			//TL_receive(&connection, &slMessage);
-			{
+			SL_receive(&connection, &slMessage);
-
+		}
-				//call receive function
+		else if (n < 0)
-				rawMessage->length = recv(sockfd,buf,8192,0);
+		{
-				if(rawMessage->length > 0)
+			perror("ERROR reading from socket1");
-				{
+			exit(1);
-					server_state = new_client;
+		}
-				}
-				break;
-			}
-			send_data :
-			{
-				//call send function
-				break;
-			}
-			new_client :
-			{
-				if(connection.transportLayer.connectionState != connectionState_ESTABLISHED)
-				{
-					TL_open(connection,rawMessage);
-				}
-//			else
-//				{
-//					SL_open(connection,rawMessage);
-//
-//				}
-
-			}
-			new_request :
-			{
-
-
-				break;
-			}
 
 
+		if(connection.newDataToWrite)
+		{
+			printf("data will be sent \n");
+			n = write(newsockfd,connection.writeData.Data,connection.writeData.Length);
+			printf("sent data \n");
+			connection.newDataToWrite = 0;
+			opcua_free(connection.writeData.Data);
+			connection.writeData.Data = NULL;
+			connection.writeData.Length = 0;
 		}
 		}
-		//if newClient
+
+		connection.readData.Data = NULL;
+		connection.readData.Length = 0;
+		connection.newDataToRead = 0;
 
 
 
 
-		//TL_processHELMessage(&connection,);
 
 
-		//--------
-		//call listen
 	}
 	}
+  }
+
 
 
-}
 
 
 #endif
 #endif

BIN
open62541Stack/opcuaserver-1.0.tar.gz


+ 0 - 1
open62541Stack/opcuaserver-1.0/AUTHORS

@@ -1 +0,0 @@
-

+ 0 - 1
open62541Stack/opcuaserver-1.0/COPYING

@@ -1 +0,0 @@
-<Place your desired license here.>

+ 0 - 0
open62541Stack/opcuaserver-1.0/ChangeLog


+ 0 - 370
open62541Stack/opcuaserver-1.0/INSTALL

@@ -1,370 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
-Inc.
-
-   Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved.  This file is offered as-is,
-without warranty of any kind.
-
-Basic Installation
-==================
-
-   Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.  Some packages provide this
-`INSTALL' file but do not implement all of the features documented
-below.  The lack of an optional feature in a given package is not
-necessarily a bug.  More recommendations for GNU packages can be found
-in *note Makefile Conventions: (standards)Makefile Conventions.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-   The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
-
-     Running `configure' might take a while.  While running, it prints
-     some messages telling which features it is checking for.
-
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package, generally using the just-built uninstalled binaries.
-
-  4. Type `make install' to install the programs and any data files and
-     documentation.  When installing into a prefix owned by root, it is
-     recommended that the package be configured and built as a regular
-     user, and only the `make install' phase executed with root
-     privileges.
-
-  5. Optionally, type `make installcheck' to repeat any self-tests, but
-     this time using the binaries in their final installed location.
-     This target does not install anything.  Running this target as a
-     regular user, particularly if the prior `make install' required
-     root privileges, verifies that the installation completed
-     correctly.
-
-  6. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
-
-  7. Often, you can also type `make uninstall' to remove the installed
-     files again.  In practice, not all packages have tested that
-     uninstallation works correctly, even though it is required by the
-     GNU Coding Standards.
-
-  8. Some packages, particularly those that use Automake, provide `make
-     distcheck', which can by used by developers to test that all other
-     targets like `make install' and `make uninstall' work correctly.
-     This target is generally not run by end users.
-
-Compilers and Options
-=====================
-
-   Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
-for details on some of the pertinent environment variables.
-
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-   You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.  This
-is known as a "VPATH" build.
-
-   With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-   On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor.  Like
-this:
-
-     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CPP="gcc -E" CXXCPP="g++ -E"
-
-   This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
-
-Installation Names
-==================
-
-   By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX', where PREFIX must be an
-absolute file name.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
-   In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.  In general, the
-default for these options is expressed in terms of `${prefix}', so that
-specifying just `--prefix' will affect all of the other directory
-specifications that were not explicitly provided.
-
-   The most portable way to affect installation locations is to pass the
-correct locations to `configure'; however, many packages provide one or
-both of the following shortcuts of passing variable assignments to the
-`make install' command line to change installation locations without
-having to reconfigure or recompile.
-
-   The first method involves providing an override variable for each
-affected directory.  For example, `make install
-prefix=/alternate/directory' will choose an alternate location for all
-directory configuration variables that were expressed in terms of
-`${prefix}'.  Any directories that were specified during `configure',
-but not in terms of `${prefix}', must each be overridden at install
-time for the entire installation to be relocated.  The approach of
-makefile variable overrides for each directory variable is required by
-the GNU Coding Standards, and ideally causes no recompilation.
-However, some platforms have known limitations with the semantics of
-shared libraries that end up requiring recompilation when using this
-method, particularly noticeable in packages that use GNU Libtool.
-
-   The second method involves providing the `DESTDIR' variable.  For
-example, `make install DESTDIR=/alternate/directory' will prepend
-`/alternate/directory' before all installation names.  The approach of
-`DESTDIR' overrides is not required by the GNU Coding Standards, and
-does not work on platforms that have drive letters.  On the other hand,
-it does better at avoiding recompilation issues, and works well even
-when some directory options were not specified in terms of `${prefix}'
-at `configure' time.
-
-Optional Features
-=================
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-   Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-   Some packages offer the ability to configure how verbose the
-execution of `make' will be.  For these packages, running `./configure
---enable-silent-rules' sets the default to minimal output, which can be
-overridden with `make V=1'; while running `./configure
---disable-silent-rules' sets the default to verbose, which can be
-overridden with `make V=0'.
-
-Particular systems
-==================
-
-   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
-CC is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
-     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
-   HP-UX `make' updates targets which have the same time stamps as
-their prerequisites, which makes it generally unusable when shipped
-generated files such as `configure' are involved.  Use GNU `make'
-instead.
-
-   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
-a workaround.  If GNU CC is not installed, it is therefore recommended
-to try
-
-     ./configure CC="cc"
-
-and if that doesn't work, try
-
-     ./configure CC="cc -nodtk"
-
-   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
-directory contains several dysfunctional programs; working variants of
-these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
-in your `PATH', put it _after_ `/usr/bin'.
-
-   On Haiku, software installed for all users goes in `/boot/common',
-not `/usr/local'.  It is recommended to use the following options:
-
-     ./configure --prefix=/boot/common
-
-Specifying the System Type
-==========================
-
-   There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
-     CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
-     OS
-     KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-   Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
-
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
-   `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
-     Print a summary of all of the options to `configure', and exit.
-
-`--help=short'
-`--help=recursive'
-     Print a summary of the options unique to this package's
-     `configure', and exit.  The `short' variant lists options used
-     only in the top level, while the `recursive' variant lists options
-     also present in any nested packages.
-
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
-     Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
-     messages will still be shown).
-
-`--srcdir=DIR'
-     Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
-
-`--prefix=DIR'
-     Use DIR as the installation prefix.  *note Installation Names::
-     for more details, including other options available for fine-tuning
-     the installation locations.
-
-`--no-create'
-`-n'
-     Run the configure checks, but stop before creating any output
-     files.
-
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
-

+ 0 - 7
open62541Stack/opcuaserver-1.0/Makefile.am

@@ -1,7 +0,0 @@
-if HAVE_CHECK
-    SUBS=src . tests .
-else 
-    SUBS=src .
-endif
-
-SUBDIRS = $(SUBS) examples/src	

+ 0 - 1
open62541Stack/opcuaserver-1.0/NEWS

@@ -1 +0,0 @@
-Sample NEWS file for OPCUAServer project.

+ 0 - 1
open62541Stack/opcuaserver-1.0/README

@@ -1 +0,0 @@
-Sample readme file for OPCUAServer project.

+ 0 - 29
open62541Stack/opcuaserver-1.0/configure.ac

@@ -1,29 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.59)
-AC_INIT(OPCUAServer, 1.0)
-
-
-AC_CANONICAL_SYSTEM
-AM_INIT_AUTOMAKE()
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CHECK_LIB([m],[exp],,AC_MSG_ERROR([Libm missing]))
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],[have_check="yes"],AC_MSG_WARN([Check not found; cannot run unit tests!])
-[have_check="no"])
-AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = "xyes"])
-AM_CONDITIONAL([TARGET_WIN],[test "${host_os}" = "mingw32"])
-AM_CONDITIONAL([TARGET_LINUX],[test "${host_os}" = "linux-gnu" || test "${host_os}" = "linux"]) 
-#adding platform-dependent information to compile flags
-AM_COND_IF([TARGET_WIN],
-    AC_DEFINE([WINDOWS])) #define WINDOWS is accessible from pre-processor
-
-AM_COND_IF([TARGET_LINUX],
-    AC_DEFINE([LINUX]))
-    
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
-AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile examples/src/Makefile)
-AC_OUTPUT
-

+ 0 - 5
open62541Stack/opcuaserver-1.0/examples/src/Makefile.am

@@ -1,5 +0,0 @@
-
-bin_PROGRAMS= $(top_builddir)/bin/exampleServer.out
-__top_builddir__bin_exampleServer_out_LDFLAGS = -all-static
-__top_builddir__bin_exampleServer_out_SOURCES = opcuaServer.c
-__top_builddir__bin_exampleServer_out_LDADD= ../../src/.libs/libopen62541.la

+ 0 - 153
open62541Stack/opcuaserver-1.0/examples/src/opcuaServer.c

@@ -1,153 +0,0 @@
-/*
- ============================================================================
- Name        : opcuaServer.c
- Author      :
- Version     :
- Copyright   : Your copyright notice
- Description :
- ============================================================================
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-
-#include "../../src/opcua_binaryEncDec.h"
-#include "../../src/opcua_builtInDatatypes.h"
-#include "../../src/opcua_transportLayer.h"
-#include "../../src/opcua_types.h"
-
-#ifdef LINUX
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-void server_init();
-void server_run();
-
-#endif
-
-int main(void)
-{
-
-#ifdef LINUX
-	server_init();
-	server_run();
-#endif
-
-	return EXIT_SUCCESS;
-
-}
-
-#ifdef LINUX
-
-void server_init()
-{
-	puts("starting demo Server");
-	//call listen
-
-}
-void server_run()
-{
-	int server_state = 0;
-	int recv_data = 0;
-	int send_data = 1;
-	int new_client = 2;
-	int new_request = 3;
-	char buf[8192];
-	struct sockaddr_in self;
-	int sockfd;
-	int clientfd;
-
-	struct sockaddr_in client_addr;
-	int addrlen=sizeof(client_addr);
-
-	//---Create streaming socket---
-    if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
-	{
-    	puts("socket error");
-	}
-	bzero(&self, sizeof(self));
-	self.sin_family = AF_INET;
-	self.sin_port = htons(4840);
-	self.sin_addr.s_addr = htonl(INADDR_ANY);
-
-	if( bind(sockfd,(struct sockaddr *)&self , sizeof(self)) < 0)
-	{
-
-
-	   //Fehler bei bind()
-	 }
-
-	//---Make it a "listening socket"---
-	if ( listen(sockfd, 1) != 0 )
-	{
-		puts("listen error");
-	}
-	clientfd = accept(sockfd, (struct sockaddr*)&client_addr, &addrlen);
-	server_state = 0;
-	while(1)
-	{
-		//call recv (nonblocking)
-
-		//call TL_getPacketType
-
-		//if newData
-		//
-		UA_connection connection;
-		AD_RawMessage *rawMessage;
-		rawMessage->message = buf;
-		rawMessage->length = 0;
-		switch(server_state)
-		{
-
-			recv_data :
-			{
-
-				//call receive function
-				rawMessage->length = recv(sockfd,buf,8192,0);
-				if(rawMessage->length > 0)
-				{
-					server_state = new_client;
-				}
-				break;
-			}
-			send_data :
-			{
-				//call send function
-				break;
-			}
-			new_client :
-			{
-				if(connection.transportLayer.connectionState != connectionState_ESTABLISHED)
-				{
-					TL_open(connection,rawMessage);
-				}
-//			else
-//				{
-//					SL_open(connection,rawMessage);
-//
-//				}
-
-			}
-			new_request :
-			{
-
-
-				break;
-			}
-
-		}
-		//if newClient
-
-
-		//TL_processHELMessage(&connection,);
-
-		//--------
-		//call listen
-	}
-
-}
-
-#endif

+ 0 - 43
open62541Stack/opcuaserver-1.0/src/Makefile.am

@@ -1,43 +0,0 @@
-
-
-
-
-
-#__top_builddir__bin_stackTest_out_SOURCES =	opcuaServer.c\
-#											opcua_builtInDatatypes.c\
-#											opcua_binaryEncDec.c\
-#											opcua_transportLayer.c\
-#											opcua_builtInDatatypes.h\
-#											opcua_binaryEncDec.h\
-#											opcua_transportLayer.h\
-#											opcua_advancedDatatypes.h\
-#											opcua_types.h\
-#											opcua_connectionHelper.h\
-#											tcp_layer.h
-
-#lib_LTLIBRARIES = libstack.la
-#libstack_la_SOURCES = opcua_transportLayer.c\
-#					  opcua_transportLayer.h\
-#					  opcua_advancedDatatypes.h\
-#					  opcua_connectionHelper.h	
-lib_LTLIBRARIES =libopen62541.la
-libopen62541_la_LDFLAGS = -avoid-version -no-undefined
-libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
-						opcua_binaryEncDec.c\
-						opcua_transportLayer.c\
-						opcua_encodingLayer.c\
-						opcua_secureChannelLayer.c\
-						opcua_builtInDatatypes.h\
-						opcua_binaryEncDec.h\
-						opcua_transportLayer.h\
-						opcua_advancedDatatypes.h\
-						opcua_types.h\
-						opcua_connectionHelper.h\
-						opcua_encodingLayer.h\
-						opcua_secureChannelLayer.h\
-						tcp_layer.h
-
-#bin_PROGRAMS= $(top_builddir)/bin/open62541.out
-#__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
-#libOpen62541_la_LIBADD = ../lib/libOpen62541.la		  										
-

+ 0 - 973
open62541Stack/opcuaserver-1.0/src/opcua_advancedDatatypes.h

@@ -1,973 +0,0 @@
-/*
- * opcua_advancedDatatypes.h
- *
- *  Created on: Jan 13, 2014
- *      Author: opcua
- */
-
-#ifndef OPCUA_ADVANCEDDATATYPES_H_
-#define OPCUA_ADVANCEDDATATYPES_H_
-
-
-typedef struct AD_RawMessage_t AD_RawMessage;
-
-struct AD_RawMessage_t
-{
-	char *message;
-	UInt32 length;
-};
-
-enum BED_ApplicationType {SERVER_0, CLIENT_1, CLIENTANDSERVER_2, DISCOVERYSERVER_3};
-
-
-/**
-* ApplicationDescription
-* Part: 4
-* Chapter: 7.1
-* Page: 103
-*/
-struct BED_ApplicationDescription
-{
-	UA_String applicationUri;
-	UA_String productUri;
-	UA_LocalizedText applicationName;
-	enum BED_ApplicationType applicationType;
-	UA_String gatewayServerUri;
-	UA_String discoveryProfileUri;
-	UA_String discoverUrls[];
-};
-
-
-/**
-* ApplicationInstanceCertificate
-* Part: 4
-* Chapter: 7.2
-* Page: 104
-*/
-struct BED_ApplicationInstanceCertificate
-{
-	UA_String version;
-	UA_ByteString serialNumber;
-	UA_String signatureAlgorithm;
-	UA_ByteString signature;
-//ToDo	struct issuer				//????????????? S. 108 table 104
-	UA_DateTime validFrom;
-	UA_DateTime valdiTo;
-//ToDo	struct subject;				//????????????? S. 108 table 104
-	UA_String applicationUri;
-	UA_String *hostnames;
-	UA_ByteString pubicKey;
-	UA_String keyUsage[];
-
-};
-
-
-/**
-* BrowseResult
-* Part: 4
-* Chapter: 7.3
-* Page: 104
-*/
-struct BED_BrowseResult
-{
-	UA_StatusCode statusCode;
-//	struct BED_ContinuationPoint continuationPoint;
-//	struct BED_ReferenceDescription references[];
-};
-
-
-/**
-* ContentFilter 						//ToDo
-* Part: 4
-* Chapter: 7.4.1
-* Page: 104
-*/
-struct BED_ContentFilter
-{
-//ToDo	struct BED_ContentFilterElement elements[];		//ToDo
-//ToDo	enum BED_FilterOperand filterOperator;			//ToDo table 110
-//ToDo	struct BED_ExtensibleParamterFilterOperand filterOperands[]; //ToDo 7.4.4
-};
-
-
-/**
-* Counter
-* Part: 4
-* Chapter: 7.5
-* Page: 113
-*/
-typedef UInt32 BED_Counter;
-
-
-/**
-* ContinuationPoint 				//ToDo
-* Part: 4
-* Chapter: 7.6
-* Page: 114
-*/
-struct BED_ContinuationPoint
-{
-};
-
-/**
-* DataValue
-* Part: 4
-* Chapter: 7.7.1
-* Page: 114
-*/
-struct BED_DataValue
-{
-	UA_Variant value;	// BaseDataType are mapped to a UA_Variant -> part: 6 chapter: 5.1.5 page: 14
-	UA_StatusCode statusCode;
-	UA_DateTime sourceTimestamp;
-//ToDo	UInt					//toBeDiscussed: Resolution of PicoSeconds
-	UA_DateTime serverTimestamp;
-//ToDo	UInt					//toBeDiscussed: Resolution of PicoSeconds
-};
-
-
-/**
-* DiagnosticInfo
-* Part: 4
-* Chapter: 7.9*/
-struct BED_DiagnosticInfo
-{
-//ToDo	struct ???? identifier;				//ToDo: what kind of strcuture?
-	Int32 namespaceUri;
-	Int32 symbolicId;
-	Int32 locale;
-	Int32 localizesText;
-	UA_String additionalInfo;
-	UA_StatusCode innerStatusCode;
-//	struct BED_DiagnosticInfo innerDiagnosticInfo;
-};
-
-
-/**
-* EndpointDescription
-* Part: 4
-* Chapter: 7.9
-* Page: 116
-*/
-struct BED_EndpointDescription
-{
-	UA_String endpointUrl;
-	struct BED_ApplicationDescription server;
-	struct BED_ApplicationInstanceCertificate serverCertificate;
-//	enum BED_MessageSecurityMode securityMode;
-	UA_String securityPolicyUri;
-//	struct BED_UserTokenPolicy useridentyTokens[];
-	UA_String transportProfileUri;
-	Byte securtiyLevel;
-};
-
-/**
-* ExpandedNodeId
-* Part: 4
-* Chapter: 7.10
-* Page: 117
-*/
-struct BED_ExpandedNodeId
-{
-//	BED_Index serverIndex;
-	UA_String namespaceUri;
-//	BED_Index namespaveIndex;
-//ToDo	enum BED_IdentifierType identiferType;		//ToDo: Is the enumeration correct?
-//ToDo	UA_NodeIdentifier identifier;		//ToDo -> Part 3: Address Space Model
-};
-
-
-/**
-* ExtensibleParameter
-* Part: 4
-* Chapter: 7.11
-* Page: 117
-*/
-struct BED_ExtensibleParameter
-{
-//	struct UA_NodeId parameterTypeId;
-//ToDo	-- parameterData;			//toBeDiscussed
-};
-
-
-/**
-* Index
-* Part: 4
-* Chapter: 7.12
-* Page: 118
-*/
-typedef UInt32 BED_Index;
-
-
-/**
-* IntegerId
-* Part: 4
-* Chapter: 7.13
-* Page: 118
-*/
-typedef UInt32 BED_IntegerId;
-
-
-/**
-* MessageSecurityMode
-* Part: 4
-* Chapter: 7.14
-* Page: 118
-*/
-enum BED_MessageSecurityMode
-{
-	INVALID_0 = 0,
-	SIGN_1 = 1,
-	SIGNANDENCRYPT_2 = 2
-};
-
-
-/**
-* MonitoringParameters
-* Part: 4
-* Chapter: 7.15
-* Page: 118
-*/
-struct BED_MonitoringParameters
-{
-	BED_IntegerId clientHandle;
-//ToDo	Duration???? samplingInterval;						//ToDo
-//ToDo	struct BED_ExtensibleParameterMonitoringFilter filter			//ToDo
-	BED_Counter queueSize;
-	Boolean discardOldest;
-};
-
-//->ExtensibleParameter ->Part:4 Chapter:7.11 Page:117
-struct BED_ExtensibleParameterMonitoringFilter		//ToDo: Ist die Umsetzung des ExtensibleParameter korrekt?
-{
-//	enum BED_MonitoringFilter parameterTypeId;
-//	struct BED_DataChangeFilter dataChangeFilter;
-//	struct BED_EventFilter eventFilter;
-//	struct BED_AggregateFilter aggregateFilter;
-};
-
-/**
-* MonitoringFilter parameterTypeIds
-* Part: 4
-* Chapter: 7.16.1
-* Page: 119
-*/
-enum BED_MonitoringFilter
-{
-	DATA_CHANGE_FILTER = 1,
-	EVENT_FILTER = 2,
-	AGGREGATE_FILTER = 3
-};
-
-
-/**
-* DataChangeFilter
-* Part: 4
-* Chapter: 7.16.2
-* Page: 119
-*/
-struct BED_DataChangeFilter
-{
-//ToDo	enum BED_MonitoringFilter trigger = BED_MonitoringFilter.DATA_CHANGE_FILTER;
-	UInt32 deadbandType;
-	Double deadbandValue;
-};
-
-
-/**
-* EventFilter
-* Part: 4
-* Chapter: 7.16.3
-* Page: 120
-*/
-struct BED_EventFilter
-{
-//ToDo	SimpleAttributeOperantd selectClauses[]; 		//ToDo
-//ToDo	ContenFilter whereClause;				//ToDo
-};
-
-struct BED_EventFilterResult
-{
-	UA_StatusCode selectClauseResults[3];
-//	struct UA_DiagnosticInfo selectClauseDiagnosticInfos[3];
-//	struct BED_ContentFilterResult whereClauseResult;
-};
-
-
-/**
-* AggregateFilter
-* Part: 4
-* Chapter: 7.16.4
-* Page: 122
-*/
-struct BED_AggregateFilter
-{
-	UA_DateTime startTime;
-//	struct UA_NodeId aggregateType;
-	UA_Duration processingInterval;
-//ToDo	AggregateConfiguration aggregateConfiguration;		//ToDo
-	Boolean useServerCapabilitiesDafaults;
-	Boolean treatUncertainAsBad;
-	Byte percentDataBad;
-	Byte percentDataGood;
-	Boolean steppedSlopedExtrapolation;
-};
-
-struct BED_AggregateFilterResult
-{
-	UA_DateTime revisedStartTime;
-	UA_Duration revisedProcessingInterval;
-};
-
-
-/**
-* MonitoringMode
-* Part: 4
-* Chapter: 7.17
-* Page: 123
-*/
-enum BED_MonitoringModeValues
-{
-	DISABLED_0 = 0,	//The item being monitored is not sampled or evaluated, and Notifications are not generated or queued. Notification reporting is disabled.
-	SAMPLING_1 = 1,	//The item being monitored is sampled and evaluated, and Notifications are generated and queued. Notification reporting is disabled.
-	REPORTING_2 = 2	//The item being monitored is sampled and evaluated, and Notifications are generated and queued. Notification reporting is enabled.
-};
-
-
-/**
-* NodeAttributes parameters
-* Part: 4
-* Chapter: 7.18.1
-* Page: 124
-*/
-enum BED_NodeAttributesParamterTypeIds
-{
-	ObjectAttributes,	//Defines the Attributes for the Object NodeClass.
-	VariableAttributes,	//Defines the Attributes for the Variable NodeClass.
-	MethodAttributes,	//Defines the Attributes for the Method NodeClass.
-	ObjectTypeAttributes,	//Defines the Attributes for the ObjectType NodeClass.
-	VariableTypeAttributes,	//Defines the Attributes for the VariableType NodeClass.
-	ReferenceTypeAttributes,//Defines the Attributes for the ReferenceType NodeClass.
-	DataTypeAttributes,	//Defines the Attributes for the DataType NodeClass.
-	ViewAttributes		//Defines the Attributes for the View NodeClass.
-};
-
-enum BED_NodeAttributesBitMask
-{
-	AccessLevel = 1, 	//Bit: 0 Indicates if the AccessLevel Attribute is set.
-	ArrayDimensions = 2,	//Bit: 1 Indicates if the ArrayDimensions Attribute is set.
-	//Reserved = 4, 	//Bit: 2 Reserved to be consistent with WriteMask defined in IEC 62541-3.
-	ContainsNoLoops = 8,	//Bit: 3 Indicates if the ContainsNoLoops Attribute is set.
-	DataType = 16,		//Bit: 4 Indicates if the DataType Attribute is set.
-	Description = 32,	//Bit: 5 Indicates if the Description Attribute is set.
-	DisplayName = 64,	//Bit: 6 Indicates if the DisplayName Attribute is set.
-	EventNotifier = 128,	//Bit: 7 Indicates if the EventNotifier Attribute is set.
-	Executable = 256,	//Bit: 8 Indicates if the Executable Attribute is set.
-	Historizing = 512,	//Bit: 9 Indicates if the Historizing Attribute is set.
-	InverseName = 1024,	//Bit:10 Indicates if the InverseName Attribute is set.
-	IsAbstract = 2048,	//Bit:11 Indicates if the IsAbstract Attribute is set.
-	MinimumSamplingInterval = 4096, //Bit:12 Indicates if the MinimumSamplingInterval Attribute is set.
-	//Reserved = 8192,	//Bit:13 Reserved to be consistent with WriteMask defined in IEC 62541-3.
-	//Reserved = 16384,	//Bit:14 Reserved to be consistent with WriteMask defined in IEC 62541-3.
-	Symmetric = 32768,	//Bit:15 Indicates if the Symmetric Attribute is set.
-	UserAccessLevel = 65536,//Bit:16 Indicates if the UserAccessLevel Attribute is set.
-	UserExecutable = 131072,//Bit:17 Indicates if the UserExecutable Attribute is set.
-	UserWriteMask = 262144, //Bit:18 Indicates if the UserWriteMask Attribute is set.
-	ValueRank = 524288,	//Bit:19 Indicates if the ValueRank Attribute is set.
-	WriteMask = 1048576,	//Bit:20 Indicates if the WriteMask Attribute is set.
-	Value = 2097152		//Bit:21 Indicates if the Value Attribute is set.
-	//Reserved		//Bit:22:32 Reserved for future use. Shall always be zero.
-};
-
-
-/**
-* ObjectAttributes parameters
-* Part: 4
-* Chapter: 7.18.2
-* Page: 125
-*/
-struct BED_ObjectAttributes
-{
-	UInt32 specifiedAttribute;	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Byte eventNotifier;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* VariableAttributes parameters
-* Part: 4
-* Chapter: 7.18.3
-* Page: 125
-*/
-struct BED_VariableAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-//ToDo	DefinedByTheDataTypeAttribte??? value				//ToDo
-//	struct UA_NodeId dataType;
-	Int32 valueRank;
-//	UInt32 arrayDimensions[];
-	Byte accessLevel;
-	Byte userAccesLevel;
-//ToDo	Duration???? minimumSamplingInterval;			//ToDo
-	Boolean historizing;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* MethodAttributes parameters
-* Part: 4
-* Chapter: 7.18.4
-* Page: 125
-*/
-struct BED_MethodAttributes
-{
-	UInt32 specifiedAttributes;	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean executable;
-	Boolean userExecutable;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* ObjectTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.5
-* Page: 125
-*/
-struct BED_ObjectTypeAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	UInt32 wirteMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* VariableTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.6
-* Page: 126
-*/
-struct BED_VariableTypeAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-//ToDo	DefinedByTheDataTypeAttribte??? value			//ToDo
-//	struct UA_NodeId dataType;
-	Int32 valueRank;
-//	UInt32 arrayDimesions[];
-	Boolean isAbstract;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* ReferenceTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.7
-* Page: 126
-*/
-struct BED_ReferenceTypeAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	Boolean symmetric;
-//	struct UA_LocalizedText inverseName;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-
-/**
-* DataTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.8
-* Page: 126
-*/
-struct BED_DataTypeAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-
-/**
-* ViewAttributes parameters
-* Part: 4
-* Chapter: 7.18.9
-* Page: 127
-*/
-struct BED_ViewAttributes
-{
-	UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean containsNoLoops;
-	Byte eventNotifier;
-	UInt32 writeMask;
-	UInt32 userWriteMask;
-};
-
-
-/**
-* NotificationData parameters
-* Part: 4
-* Chapter: 7.19
-* Page: 127
-*/
-enum BED_NotificationDataParameterTypeIds
-{
-	DATA_CHANGE = 1,
-	EVENT = 2,
-	STATUS_CHANGE = 3
-};
-
-
-/**
-* DataChangeNotification parameter
-* Part: 4
-* Chapter: 7.19.2
-* Page: 127
-*/
-struct BED_DataChangeNotification
-{
-//ToDo	struct BED_MonitoredItemNotification monitoredItems[];		//ToDo
-	BED_IntegerId clientHandle;
-//	struct UA_DataValue value;
-	UA_DiagnosticInfo diagnositcInfos[];
-};
-
-
-/**
-* EventNotificationList parameter
-* Part: 4
-* Chapter: 7.19.3
-* Page: 128
-*/
-struct BED_EventNotificationList
-{
-//ToDo	struct EventFieldList events[];			//ToDo
-	BED_IntegerId clientHandle;
-	UA_Variant eventFields[];	// BaseDataType are mapped to a UA_Variant -> part: 6 chapter: 5.1.5 page: 14
-};
-
-
-/**
-* StatusChangeNotification parameter
-* Part: 4
-* Chapter: 7.19.4
-* Page: 128
-*/
-struct BED_StatusChangeNotification
-{
-	UA_StatusCode status;
-//	struct UA_DiagnosticInfo diagnosticInfo;
-};
-
-
-/**
-* NotificationMessage
-* Part: 4
-* Chapter: 7.20
-* Page: 129
-*/
-struct BED_NotificationMessage
-{
-	BED_Counter sequenceNumber;
-//	struct UA_DateTime publishTime;
-//	struct ExtensibleParameterNotificationData notificationData[];
-};
-
-//->ExtensibleParameter ->Part:4 Chapter:7.11 Page:117
-struct ExtensibleParameterNotificationData 		//ToDo: Ist die Umsetzung des ExtensibleParameter korrekt?
-{
-	enum BED_NotificationDataParameterTypeIds parameterTypeId;
-	struct BED_DataChangeNotification dataChange;
-	struct BED_EventNotificationList event;
-	struct BED_StatusChangeNotification statusChange;
-};
-
-
-/**
-* NumericRange
-* Part: 4
-* Chapter: 7.21
-* Page: 129
-*/
-typedef UA_String NumericRange;
-
-
-/**
-* QueryDataSet
-* Part: 4
-* Chapter: 7.22
-* Page: 130
-*/
-/*
-struct BED_QueryDataSet
-{
-//	struct UA_ExpandedNodeId nodeId;
-//	struct UA_ExpandedNodeId typeDefinitionNode;
-//	struct UA_Variant values[];	// BaseDataType are mapped to a UA_Variant -> part: 6 chapter: 5.1.5 page: 14
-};
-*/
-
-/**
-* ReadValueId
-* Part: 4
-* Chapter: 7.23
-* Page: 130
-*/
-struct BED_QueryDataSet
-{
-//	struct UA_NodeId nodeId;
-	BED_IntegerId attributeId;
-//	struct BED_NumericRange indexRange;
-//	struct UA_QualifiedName dataEncoding;
-};
-
-
-/**
-* ReferenceDescription
-* Part: 4
-* Chapter: 7.24
-* Page: 131
-*/
-struct BED_ReferenceDescription
-{
-//	struct UA_NodeId referenceTypeId;
-	Boolean isForward;
-//	struct UA_ExpandedNodeId nodeId;
-//	struct UA_QualifiedName browseName;
-//	struct UA_LocalizedText displayName;
-//ToDo	struct BED_NodeClass nodeClass;			//ToDo
-//	struct UA_ExpandedNodeId typeDefinition;
-};
-
-
-/**
-* RelativePath
-* Part: 4
-* Chapter: 7.25
-* Page: 131
-*/
-struct BED_RelativePath
-{
-//ToDo	struct BED_RelativePathElement elements[];		//ToDo
-//	struct UA_NodeId referenceTypeId;
-	Boolean isInverse;
-	Boolean includeSubtypes;
-//	struct UA_QualifiedName targetName;
-};
-
-
-/**
-* RequestHeader
-* Part: 4
-* Chapter: 7.26
-* Page: 132
-*/
-struct BED_RequestHeader
-{
-	UA_NodeId authenticationToken;		//ToDo
-	UA_DateTime timestamp;
-	BED_IntegerId requestHandle;
-	UInt32 returnDiagnostics;
-	UA_String auditEntryId;
-	UInt32 timeoutHint;
-	UA_ExtensionObject additionalHeader;
-};
-
-
-enum BED_RequestReturnDiagnositcs
-{
-	SERVICE_LEVEL_SYMBOLIC_ID = 1,				//Hex 0x01
-	SERVICE_LEVEL_LOCALIZED_TEXT= 2,			//Hex 0x02
-	SERVICE_LEVEL_ADDITIONAL_INFO = 4,			//Hex 0x04
-	SERVICE_LEVEL_INNER_STATUS_CODE = 8,		//Hex 0x08
-	SERVICE_LEVEL_INNER_DIAGNOSTICS = 16,		//Hex 0x10
-	OPERATION_LEVEL_SYMBOLIC_ID = 32,			//Hex 0x20
-	OPERATION_LEVEL_LOCALIZED_TEXT= 64,			//Hex 0x40
-	OPERATION_LEVEL_ADDITIONAL_INFO = 128,		//Hex 0x80
-	OPERATION_LEVEL_INNER_STATUS_CODE = 256,	//Hex 0x100
-	OPERATION_LEVEL_INNER_DIAGNOSTICS = 512		//Hex 0x200
-};
-
-
-/**
-* ResponseHeader
-* Part: 4
-* Chapter: 7.27
-* Page: 133
-*/
-struct BED_ResponseHeader
-{
-	UA_DateTime timestamp;
-	BED_IntegerId requestHandle;
-	UA_StatusCode serviceResult;
-	UA_DiagnosticInfo serviceDiagnostics;
-	UA_String stringTable[];
-//ToDo	struct BED_ExtensibleParameterAdditionalHeader additionalHeader;		//ToDo
-};
-
-
-/**
-* ServiceFault
-* Part: 4
-* Chapter: 7.28
-* Page: 133
-*/
-struct BED_ServiceFault
-{
-	struct BED_ResponseHeader responseHeader;
-};
-
-
-//ToDo: Own DataType with typeDef?
-/**
-* SessionAuthenticationToken
-* Part: 4
-* Chapter: 7.29
-* Page: 133
-*/
-
-
-
-/**
-* SignatureData
-* Part: 4
-* Chapter: 7.30
-* Page: 135
-*/
-struct BED_SignatureData
-{
-	UA_ByteString signature;
-	UA_String agorithm;
-};
-
-
-/**
-* SignedSoftwareCertificate
-* Part: 4
-* Chapter: 7.31
-* Page: 135
-*/
-struct BED_SignedSoftwareCertificate
-{
-	UA_String version;
-	UA_ByteString serialNumber;
-	UA_String signatureAlgorithm;
-	UA_ByteString signature;
-//ToDo	struct issuer 					//ToDo: ??? struct?
-	UA_DateTime validFrom;
-	UA_DateTime validTo;
-//ToDo	struct subject;					//ToDo: ??? struct?
-//ToDo	struct subjectAltName[];			//ToDo: ??? struct?
-	UA_ByteString publicKey;
-//	UA_String keyUsage[];
-	UA_ByteString softwareCertificate;
-};
-
-
-/**
-* SoftwareCertificate
-* Part: 4
-* Chapter: 7.32
-* Page: 135
-*/
-struct BED_SoftwareCertificate
-{
-	UA_String productName;
-	UA_String productUri;
-	UA_String vendorName;
-	UA_ByteString vendorProductCertificate;
-	UA_String softwareVersion;
-	UA_String buildNumber;
-	UA_DateTime buildDate;
-	UA_String issuedBy;
-	UA_DateTime issueDate;
-//	UA_ByteString vendorProductCertificate;
-//	struct BED_SupportedProfiles supportedProfiles;
-};
-
-struct BED_SupportedProfiles
-{
-	UA_String oranizationUri;
-	UA_String profileId;
-	UA_String complianceTool;
-	UA_DateTime complianceDate;
-//	enum BED_ComplianceLevel complianceLevel;
-	UA_String unsupportedUnitIds[];
-};
-
-enum BED_ComplianceLevel
-{
-	UNTESTED_0 = 0,		//the profiled capability has not been tested successfully.
-	PARTIAL_1 = 1,		//the profiled capability has been partially tested and has
-				//passed critical tests, as defined by the certifying authority.
-	SELFTESTED_2 = 2,	//the profiled capability has been successfully tested using a
-				//self-test system authorized by the certifying authority.
-	CERTIFIED_3 = 3		//the profiled capability has been successfully tested by a
-				//testing organisation authorized by the certifying authority.
-};
-
-
-/**
-* StatusCode					//ToDo: Do we need them? How do we implement them (enum)?
-* Part: 4
-* Chapter: 7.33
-* Page: 136
-*/
-
-
-/**
-* TimestampsToReturn
-* Part: 4
-* Chapter: 7.34
-* Page: 140
-*/
-enum BED_TimestampsToReturn
-{
-	SOURCE_0 = 1,	//Return the source timestamp.
-			//If used in HistoryRead the source timestamp is used to determine which historical data values are returned.
-	SERVER_1 = 1,	//Return the Server timestamp.
-			//If used in HistoryRead the Server timestamp is used to determine which historical data values are returned.
-	BOTH_2 = 2,	//Return both the source and Server timestamps.
-			//If used in HistoryRead the source timestamp is used to determine which historical data values are returned.
-	NEITHER_3 = 3	//Return neither timestamp.
-			//This is the default value for MonitoredItems if a Variable value is not being accessed.
-			//For HistoryRead this is not a valid setting.
-};
-
-
-/**
-* UserIdentityToken Encrypted Token Format
-* Part: 4
-* Chapter: 7.35.1
-* Page: 140
-*/
-struct BED_UserIdentityTokenEncryptedTokenFormat
-{
-	Byte length[4];
-//	Byte tokenData[];
-//	Byte serverNonce[];
-};
-
-
-/**
-* AnonymousIdentityToken
-* Part: 4
-* Chapter: 7.35.2
-* Page: 141
-*/
-struct BED_AnonymousIdentityToken
-{
-	UA_String policyId;
-};
-
-
-/**
-* UserNameIdentityToken
-* Part: 4
-* Chapter: 7.35.3
-* Page: 141
-*/
-struct BED_UserNameIdentityToken
-{
-	UA_String policyId;
-	UA_String userName;
-	UA_ByteString password;
-	UA_String encryptionAlogrithm;
-};
-
-
-/**
-* X509IdentityTokens
-* Part: 4
-* Chapter: 7.35.4
-* Page: 141
-*/
-struct BED_X509IdentityTokens
-{
-	UA_String policyId;
-	UA_ByteString certificateData;
-};
-
-
-/**
-* IssuedIdentityToken
-* Part: 4
-* Chapter: 7.35.5
-* Page: 142
-*/
-struct BED_IssuedIdentityToken
-{
-	UA_String policyId;
-	UA_ByteString tokenData;
-	UA_String encryptionAlgorithm;
-};
-
-
-
-enum BED_UserIdentityTokenType
-{
-	ANONYMOUS_0 = 0,
-	USERNAME_1 = 1,
-	CERTIFICATE_2 = 2,
-	ISSUEDTOKEN_3 = 3
-};
-
-/**
-* UserTokenPolicy
-* Part: 4
-* Chapter: 7.36
-* Page: 142
-*/
-struct BED_UserTokenPolicy
-{
-	UA_String policyId;
-	enum BED_UserIdentityTokenType tokenType;
-	UA_String issuedTokenType;
-	UA_String issuerEndpointUrl;
-	UA_String securityPolicyUri;
-};
-
-/**
-* ViewDescription
-* Part: 4
-* Chapter: 7.37
-* Page: 143
-*/
-struct BED_ViewDescription
-{
-//	struct UA_NodeId viewId;
-	UA_DateTime timestamp;
-	UInt32 viewVersion;
-};
-
-
-#endif /* OPCUA_ADVANCEDDATATYPES_H_ */

+ 0 - 188
open62541Stack/opcuaserver-1.0/src/opcua_binaryEncDec.c

@@ -1,188 +0,0 @@
-/*
- * opcua_binaryEncDec.c
- *
- *  Created on: Dec 18, 2013
- *      Author: opcua
- */
-
-#include "opcua_binaryEncDec.h"
-#include "opcua_types.h"
-
-
-Byte decodeByte(const char *buf, Int32 *pos)
-{
-	*pos = (*pos) + 1;
-	return (Byte) buf[(*pos)-1];
-
-}
-void encodeByte(Byte encodeByte, Int32 *pos, AD_RawMessage *dstBuf)
-{
-	dstBuf->message[*pos] = encodeByte;
-	*pos = (*pos) + 1;
-
-}
-
-UInt16 decodeUInt16(const char* buf, Int32 *pos)
-{
-
-	Byte t1 = buf[*pos];
-	UInt16 t2 = (UInt16) (buf[*pos + 1] << 8);
-	*pos += 2;
-	return t1 + t2;
-}
-
-void encodeUInt16(UInt16 value, Int32 *pos, AD_RawMessage *dstBuf)
-{
-	memcpy(dstBuf->message, &value, sizeof(UInt16));
-	*pos = (*pos) + sizeof(UInt16);
-
-}
-
-Int16 decodeInt16(const char* buf, Int32 *pos)
-{
-
-	Byte t1 = buf[*pos];
-	Int32 t2 = (Int16) (buf[*pos + 1] << 8);
-	*pos += 2;
-	return t1 + t2;
-}
-Int32 decodeInt32(const char* buf, Int32 *pos)
-{
-
-	SByte t1 = buf[*pos];
-	Int32 t2 = (UInt32) (buf[*pos + 1] << 8);
-	Int32 t3 = (UInt32) (buf[*pos + 2] << 16);
-	Int32 t4 = (UInt32) (buf[*pos + 3] << 24);
-	*pos += 4;
-	return t1 + t2 + t3 + t4;
-}
-
-
-UInt32 decodeUInt32(const char* buf, Int32 *pos)
-{
-	Byte t1 = buf[*pos];
-	UInt32 t2 = (UInt32) (buf[*pos + 1] << 8);
-	UInt32 t3 = (UInt32) (buf[*pos + 2] << 16);
-	UInt32 t4 = (UInt32) (buf[*pos + 3] << 24);
-	*pos += 4;
-	return t1 + t2 + t3 + t4;
-}
-
-void encodeUInt32(UInt32 value, char *dstBuf, Int32 *pos)
-{
-	memcpy(&(dstBuf[*pos]), &value, sizeof(value));
-	pos += 4;
-
-}
-
-
-Int64 decodeInt64(const char* buf, Int32 *pos)
-{
-
-	SByte t1 = buf[*pos];
-	UInt64 t2 = (UInt64) (buf[*pos + 1] << 8);
-	UInt64 t3 = (UInt64) (buf[*pos + 2] << 16);
-	UInt64 t4 = (UInt64) (buf[*pos + 3] << 24);
-	UInt64 t5 = (UInt64) (buf[*pos + 4] << 32);
-	UInt64 t6 = (UInt64) (buf[*pos + 5] << 40);
-	UInt64 t7 = (UInt64) (buf[*pos + 6] << 48);
-	UInt64 t8 = (UInt64) (buf[*pos + 7] << 56);
-	pos += 8;
-	return t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
-}
-
-Int32 decodeUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
-{
-
-	dstUAString->Length = decodeInt32(buf, pos);
-	if (dstUAString->Length > 0)
-	{
-		dstUAString->Data = &(buf[*pos]);
-	}
-	else
-	{
-		dstUAString->Length = 0;
-		dstUAString->Data = NULL;
-	}
-	*pos += dstUAString->Length;
-	return 0;
-}
-
-Int32 decodeUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID)
-{
-	dstGUID->Data1 = decodeUInt32(buf, pos);
-	dstGUID->Data2 = decodeUInt16(buf, pos);
-	dstGUID->Data3 = decodeUInt16(buf, pos);
-	decodeUAByteString(buf, pos, &(dstGUID->Data4));
-	return 0;
-}
-
-void decodeUAByteString(const char *buf, Int32* pos, UA_ByteString *dstBytestring)
-{
-
-	decodeUAString(buf,pos,dstBytestring->Data);
-}
-
-UA_DateTime decodeUADateTime(const char *buf, Int32 *pos)
-{
-	return decodeInt64(buf, pos);
-}
-
-UA_StatusCode decodeUAStatusCode(const char* buf, Int32 *pos)
-{
-	return decodeUInt32(buf, pos);
-}
-
-Int32 decodeUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId)
-{
-
-	dstNodeId->EncodingByte = decodeInt32(buf, pos);
-
-
-	switch (dstNodeId->EncodingByte)
-	{
-	case NIEVT_TWO_BYTE:
-	{
-
-		dstNodeId->Identifier.Numeric = decodeByte(buf, pos);
-		break;
-	}
-	case NIEVT_FOUR_BYTE:
-	{
-		dstNodeId->Identifier.Numeric = decodeInt16(buf, pos);
-		break;
-	}
-	case NIEVT_NUMERIC:
-	{
-
-		dstNodeId->Identifier.Numeric = decodeInt32(buf, pos);
-		break;
-	}
-	case NIEVT_STRING:
-	{
-		decodeUAString(buf, pos, &dstNodeId->Identifier.String);
-		break;
-	}
-	case NIEVT_GUID:
-	{
-		decodeUAGuid(buf, pos, &(dstNodeId->Identifier.Guid));
-		break;
-	}
-	case NIEVT_BYTESTRING:
-	{
-
-		decodeUAByteString(buf, pos,&(dstNodeId->Identifier.OPAQUE));
-		break;
-	}
-	case NIEVT_NAMESPACE_URI_FLAG:
-	{
-		//TODO implement
-		break;
-	}
-	default:
-
-		break;
-	}
-	return 0;
-}
-

+ 0 - 125
open62541Stack/opcuaserver-1.0/src/opcua_binaryEncDec.h

@@ -1,125 +0,0 @@
-/*
- * opcua_BinaryEncDec.h
- *
- *  Created on: Dec 18, 2013
- *      Author: opcua
- */
-
-#ifndef OPCUA_BINARYENCDEC_NEU_H_
-#define OPCUA_BINARYENCDEC_NEU_H_
-
-#include "opcua_builtInDatatypes.h"
-
-#include "opcua_advancedDatatypes.h"
-
-
-
-//functions
-/**
- *
- * @param buf  			binary encoded message
- * @param pos  			position at which the data is located in/out, parser position after the conversion
- * @return
- */
-Byte decodeByte(const char* buf, Int32 *pos);
-
-/**
- *
- * @param encodeByte 	byte that should be encoded
- * @param pos 			position at which the data is located in/out, parser position after the conversion
- * @param dstBuf		rawMessage where the Byte is encoded in
- */
-void encodeByte(Byte encodeByte, Int32 *pos, AD_RawMessage *dstBuf);
-
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-Int16 decodeInt16(const char* buf, Int32 *pos);
-
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeUInt16(UInt16 value, Int32 *pos, AD_RawMessage *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UInt16 decodeUInt16(const char* buf, Int32 *pos);
-/**
- *
- * @param buf  			binary encoded message
- * @param pos  			position at which the data is located in/out, parser position after the conversion
- * @return
- */
-Int32 decodeInt32(const char* buf, Int32 *pos);
-
-/**
- *
- * @param buf  			binary encoded message
- * @param pos  			position at which the data is located in/out, parser position after the conversion
- * @return				encoded data
- */
-UInt32 decodeUInt32(const char* buf, Int32 *pos);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-Int64 decodeInt64(const char* buf, Int32 *pos);
-/**
- *
- * @param buf  			binary encoded message
- * @param pos  			position at which the data is located in/out, parser position after the conversion
- * @param dstNodeId		receiver of the nodeid structure
- * @param return		success = 0
- */
-Int32 decodeUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
-/**
- *
- * @param buf
- * @param pos
- * @param dstGUID
- * @return
- */
-Int32 decodeUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
-
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UA_StatusCode decodeUAStatusCode(const char* buf, Int32 *pos);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UA_DateTime decodeUADateTime(const char *buf, Int32 *pos);
-/**
- *
- * @param buf
- * @param pos
- * @param dstUAString
- * @return
- */
-Int32 decodeUAString(const char* buf, Int32 *pos, UA_String *dstUAString);
-/**
- *
- * @param value
- * @param dstBuf
- * @param pos
- */
-void encodeUInt32(UInt32 value, char *dstBuf, Int32 *pos);
-
-#endif /* OPCUA_BINARYENCDEC_NEU_H_ */

+ 0 - 11
open62541Stack/opcuaserver-1.0/src/opcua_builtInDatatypes.c

@@ -1,11 +0,0 @@
-/*
- * opcua_BuiltInDatatypes.c
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-
-
-#include "opcua_builtInDatatypes.h"
-
-

+ 0 - 493
open62541Stack/opcuaserver-1.0/src/opcua_builtInDatatypes.h

@@ -1,493 +0,0 @@
-/*
- * OPCUA_builtInDatatypes.h
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-#include <stdint.h>
-#include <string.h>
-#ifndef OPCUA_BUILTINDATATYPES_H_
-#define OPCUA_BUILTINDATATYPES_H_
-
-/**
-* Enumerations:
-*	All Enumerations should be encoded as Int32 values
-*
-*
-*/
-
-typedef enum _UA_BuiltInDataTypes
-{
-	BOOLEAN = 	1,
-	SBYTE = 	2,
-	BYTE = 		3,
-	INT16 = 	4,
-	UINT16 = 	5,
-	INT32 = 	6,
-	UINT32 = 	7,
-	INT64 = 	8,
-	UINT64 = 	9,
-	FLOAT = 	10,
-	DOUBLE = 	11,
-	STRING = 	12,
-	DATE_TIME = 13,
-	GUID = 		14,
-	BYTE_STRING = 		15,
-	XML_ELEMENT = 		16,
-	NODE_ID = 			17,
-	EXPANDED_NODE_ID = 	18,
-	STATUS_CODE = 		19,
-	QUALIFIED_NAME = 	20,
-	LOCALIZED_TEXT = 	21,
-	EXTENSION_OBJECT = 	22,
-	DATA_VALUE = 		23,
-	VARIAN = 			24,
-	DIAGNOSTIC_INFO = 	25
-}
-UA_BuiltInDataTypes;
-
-
-/**
-* BasicBuiltInDatatypes
-* Part: 6
-* Chapter: 5.2.2.1 - 5.2.2.3
-* Page: 15
-*/
-typedef _Bool Boolean;
-
-typedef int8_t SByte;
-
-typedef uint8_t Byte;
-
-typedef int16_t Int16;
-
-typedef uint16_t UInt16;
-
-typedef int32_t Int32;
-
-typedef uint32_t UInt32;
-
-typedef int64_t Int64;
-
-typedef uint64_t UInt64;
-
-typedef float Float;
-
-typedef double Double;
-
-
-/**
-* String
-* Part: 6
-* Chapter: 5.2.2.4
-* Page: 16
-*/
-typedef struct _UA_String
-{
-	int Length;
-	char *Data;
-}
-UA_String;
-
-/**
-* DateTime
-* Part: 6
-* Chapter: 5.2.2.5
-* Page: 16
-*/
-typedef Int64 UA_DateTime; //100 nanosecond resolution
-			      //start Date: 1601-01-01 12:00 AM
-
-
-
-
-
-
-/*
-* ByteString
-* Part: 6
-* Chapter: 5.2.2.7
-* Page: 17
-*/
-typedef struct _UA_ByteString
-{
-	Int32 Length;
-	Byte *Data;
-}
-UA_ByteString;
-
-/* GuidType
-* Part: 6
-* Chapter: 5.2.2.6
-* Page: 17
-*/
-typedef struct _UA_Guid
-{
-	UInt32 Data1;
-	UInt16 Data2;
-	UInt16 Data3;
-	UA_ByteString Data4;
-}
-UA_Guid;
-/**
-* XmlElement
-* Part: 6
-* Chapter: 5.2.2.8
-* Page: 17
-*/
-//Überlegung ob man es direkt als ByteString speichert oder als String
-typedef struct _UA_XmlElement
-{
-	UA_String Data;
-}
-UA_XmlElement;
-
-
-typedef struct _UA_XmlElementEncoded
-{
-	UInt32 Length;
-	Byte StartTag[3];
-	Byte *Message;
-	UInt32 EndTag[4];
-}
-UA_XmlElementEncoded;
-
-
-/**
- * NodeIds
-* Part: 6
-* Chapter: 5.2.2.9
-* Page: 17
-*/
-typedef enum _UA_IdentifierType
-{
-	// Some Values are called the same as previouse Enumerations so we need
-	//names that are unique
-	IT_NUMERIC = 0,
-	IT_STRING = 1,
-	IT_GUID = 2,
-	IT_OPAQUE = 3
-}
-UA_IdentifierType;
-
-typedef enum _UA_NodeIdEncodingValuesType
-{
-	// Some Values are called the same as previous Enumerations so we need
-	// names that are unique
-	NIEVT_TWO_BYTE = 	0x00,
-	NIEVT_FOUR_BYTE = 	0x01,
-	NIEVT_NUMERIC = 	0x02,
-	NIEVT_STRING = 		0x03,
-	NIEVT_GUID = 		0x04,
-	NIEVT_BYTESTRING = 	0x05,
-	NIEVT_NAMESPACE_URI_FLAG = 	0x80, 	//Is only for ExpandedNodeId required
-	NIEVT_SERVERINDEX_FLAG = 	0x40 	//Is only for ExpandedNodeId required
-}
-UA_NodeIdEncodingValuesType;
-
-/**
-* NodeId
-*/
-typedef struct _UA_NodeId
-{
-	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
-	UInt16 Namespace;
-
-    union
-    {
-        UInt32 Numeric;
-        UA_String String;
-        UA_Guid Guid;
-        UA_ByteString OPAQUE;
-    }
-    Identifier;
-
-}
-UA_NodeId;
-
-
-/**
-* ExpandedNodeId
-* Part: 6
-* Chapter: 5.2.2.10
-* Page: 19
-*/
-typedef struct _UA_ExpandedNodeId
-{
-	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
-	UInt16 Namespace;
-	UInt32 ServerIndex;
-
-    union
-    {
-        UInt32 Numeric;
-        UA_String String;
-        UA_Guid Guid;
-        UA_ByteString ByteString;
-    }
-    Identifier;
-}
-UA_ExpandedNodeId;
-
-
-/**
-* StatusCodeBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.11
-* Page: 20
-*/
-typedef UInt32 UA_StatusCode;
-
-
-/**
-* DiagnoticInfoBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.12
-* Page: 20
-*/
-typedef struct _UA_DiagnosticInfo
-{
-	Byte EncodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
-	Int32 SymbolicId;
-	Int32 NamespaceUri;
-	Int32 LocalizedText;
-	Int32 Locale;
-	UA_String AdditionalInfo;
-	UA_StatusCode InnerStatusCode;
-	struct _UA_DiagnosticInfo* InnerDiagnosticInfo;
-}
-UA_DiagnosticInfo;
-
-typedef enum _UA_DiagnosticInfoEncodingMaskType
-{
-	// Some Values are called the same as previouse Enumerations so we need
-	//names that are unique
-	DIEMT_SYMBOLIC_ID = 			0x01,
-	DIEMT_NAMESPACE = 				0x02,
-	DIEMT_LOCALIZED_TEXT = 			0x04,
-	DIEMT_LOCATE = 					0x08,
-	DIEMT_ADDITIONAL_INFO = 		0x10,
-	DIEMT_INNER_STATUS_CODE = 		0x20,
-	DIEMT_INNER_DIAGNOSTIC_INFO = 	0x40
-}
-UA_DiagnosticInfoEncodingMaskType;
-
-
-/**
-* QualifiedNameBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.13
-* Page: 20
-*/
-typedef struct _UA_QualifiedName
-{
-	UInt16 NamespaceIndex;
-	UInt16 Reserved;
-	UA_String Name;
-}
-UA_QualifiedName;
-
-
-/**
-* LocalizedTextBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.14
-* Page: 21
-*/
-typedef struct _UA_LocalizedText
-{
-	Byte EncodingMask;
-	UA_String Locale;
-	UA_String Test;
-}
-UA_LocalizedText;
-
-typedef enum _UA_LocalizedTextEncodingMaskType
-{
-	LTEMT_SYMBOLIC_ID = 0x01,
-	LTEMT_NAMESPACE = 	0x02
-}
-UA_LocalizedTextEncodingMaskType;
-
-
-/**
-* ExtensionObjectBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.15
-* Page: 21
-*/
-typedef struct _UA_ExtensionObject
-{
-	UA_NodeId TypeId;
-	Byte Encoding; //Type of the Enum UA_ExtensionObjectEncodingMaskType
-	Int32 Length;
-	Byte *Body;
-}
-UA_ExtensionObject;
-
-typedef enum _UA_ExtensionObjectEncodingMaskType
-{
-	NO_BODY_IS_ENCODED = 	0x00,
-	BODY_IS_BYTE_STRING = 	0x01,
-	BODY_IS_XML_ELEMENT = 	0x02
-}
-UA_ExtensionObjectEncodingMaskType;
-
-
-/**
-* VariantBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.16
-* Page: 22
-*/
-struct _UA_DataValue;
-struct _UA_Variant;
-typedef union _UA_VariantArrayUnion
-{
-    void*              Array;
-    Boolean*           BooleanArray;
-    SByte*             SByteArray;
-    Byte*              ByteArray;
-    Int16*             Int16Array;
-    UInt16*            UInt16Array;
-    Int32*             Int32Array;
-    UInt32*            UInt32Array;
-    Int64*             Int64Array;
-    UInt64*            UInt64Array;
-    Float*             FloatArray;
-    Double*            DoubleArray;
-    UA_String*            StringArray;
-    UA_DateTime*          DateTimeArray;
-    UA_Guid*              GuidArray;
-    UA_ByteString*        ByteStringArray;
-    UA_ByteString*        XmlElementArray;
-    UA_NodeId*            NodeIdArray;
-    UA_ExpandedNodeId*    ExpandedNodeIdArray;
-    UA_StatusCode*        StatusCodeArray;
-    UA_QualifiedName*     QualifiedNameArray;
-    UA_LocalizedText*     LocalizedTextArray;
-    UA_ExtensionObject*   ExtensionObjectArray;
-    struct _UA_DataValue* DataValueArray;
-    struct _UA_Variant*   VariantArray;
-}
-UA_VariantArrayUnion;
-
-typedef struct _UA_VariantArrayValue
-{
-    Int32  Length;
-    UA_VariantArrayUnion Value;
-}
-UA_VariantArrayValue;
-
-typedef struct _UA_VariantMatrixValue
-{
-    Int32 NoOfDimensions;
-    Int32* Dimensions;
-    UA_VariantArrayUnion Value;
-}
-UA_VariantMatrixValue;
-
-typedef union _UA_VariantUnion
-{
-    Boolean Boolean;
-    SByte SByte;
-    Byte Byte;
-    Int16 Int16;
-    UInt16 UInt16;
-    Int32 Int32;
-    UInt32 UInt32;
-    Int64 Int64;
-    UInt64 UInt64;
-    Float Float;
-    Double Double;
-    UA_DateTime DateTime;
-    UA_String String;
-    UA_Guid* Guid;
-    UA_ByteString ByteString;
-    UA_XmlElement XmlElement;
-    UA_NodeId* NodeId;
-    UA_ExpandedNodeId* ExpandedNodeId;
-    UA_StatusCode StatusCode;
-    UA_QualifiedName* QualifiedName;
-    UA_LocalizedText* LocalizedText;
-    UA_ExtensionObject* ExtensionObject;
-    struct _UA_DataValue* DataValue;
-    UA_VariantArrayValue  Array;
-    UA_VariantMatrixValue Matrix;
-}
-UA_VariantUnion;
-
-typedef struct _UA_Variant
-{
-	Byte EncodingMask; //Type of Enum UA_VariantTypeEncodingMaskType
-	Int32 ArrayLength;
-	UA_VariantUnion *Value;
-}
-UA_Variant;
-
-typedef enum _UA_VariantTypeEncodingMaskType
-{
-	//Bytes 0:5	HEX 0x00 - 0x20
-	VTEMT_BOOLEAN = 			1,
-	VTEMT_SBYTE = 				2,
-	VTEMT_BYTE = 				3,
-	VTEMT_INT16 = 				4,
-	VTEMT_UINT16 = 				5,
-	VTEMT_INT32 = 				6,
-	VTEMT_UINT32 = 				7,
-	VTEMT_INT64 = 				8,
-	VTEMT_UINT64 = 				9,
-	VTEMT_FLOAT = 				10,
-	VTEMT_DOUBLE = 				11,
-	VTEMT_STRING = 				12,
-	VTEMT_DATE_TIME = 			13,
-	VTEMT_GUID = 				14,
-	VTEMT_BYTE_STRING = 		15,
-	VTEMT_XML_ELEMENT = 		16,
-	VTEMT_NODE_ID = 			17,
-	VTEMT_EXPANDED_NODE_ID = 	18,
-	VTEMT_STATUS_CODE = 		19,
-	VTEMT_QUALIFIED_NAME = 		20,
-	VTEMT_LOCALIZED_TEXT = 		21,
-	VTEMT_EXTENSION_OBJECT = 	22,
-	VTEMT_DATA_VALUE = 			23,
-	VTEMT_VARIANT = 			24,
-	VTEMT_DIAGNOSTIC_INFO = 	25,
-	//Byte 6
-	VTEMT_ARRAY_DIMENSIONS_ENCODED = 	0x40,
-	//Byte 7
-	VTEMT_ARRAY_VALUE_ENCODED = 		0x80,
-}
-UA_VariantTypeEncodingMaskType;
-
-
-/**
-* DataValueBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.17
-* Page: 23
-*/
-typedef struct _UA_DataValue
-{
-	Byte EncodingMask;
-	UA_Variant Value;
-	UA_StatusCode Status;
-	UA_DateTime SourceTimestamp;
-	Int16 SourcePicoseconds;
-	UA_DateTime ServerTimestamp;
-	Int16 ServerPicoseconds;
-}
-UA_DataValue;
-
-typedef UInt32 IntegerId;
-
-
-/**
-* Duration
-* Part: 3
-* Chapter: 8.13
-* Page: 74
-*/
-typedef double UA_Duration;
-
-#endif /* OPCUA_BUILTINDATATYPES_H_ */

+ 0 - 79
open62541Stack/opcuaserver-1.0/src/opcua_connectionHelper.h

@@ -1,79 +0,0 @@
-/*
- * opcua_connectionHelper.h
- *
- *  Created on: Jan 13, 2014
- *      Author: opcua
- */
-
-#ifndef OPCUA_CONNECTIONHELPER_H_
-#define OPCUA_CONNECTIONHELPER_H_
-#include "opcua_builtInDatatypes.h"
-#include "opcua_types.h"
-
-enum packetType
-{
-	packetType_HEL,
-	packetType_ACK,
-	packetType_ERR,
-	packetType_OPN,
-	packetType_MSG,
-	packetType_CLO
-};
-enum connectionState
-{
-	connectionState_CLOSED,
-	connectionState_OPENING,
-	connectionState_ESTABLISHED,
-
-};
-typedef struct
-{
-	UInt32 recvBufferSize;
-	UInt32 sendBufferSize;
-
-	UInt32 protocolVersion;
-	UInt32 maxMessageSize;
-	UInt32 maxChunkCount;
-}TL_buffer;
-
-struct TL_connection
-{
-	Int32 socket;
-	UInt32 connectionState;
-	TL_buffer remoteConf;
-	TL_buffer localConf;
-	UA_String endpointURL;
-};
-
-
-struct SL_connection
-{
-
-	T_ApplicationInstanceCertificate clientCertificate;
-	UInt32 requestType;
-	UA_String secureChannelId;
-	UInt32 UInt32_secureChannelId;
-	UInt32 securityMode;
-	UA_String clientNonce;
-	UA_Duration requestedLifetime; /// life time of the secure channel
-	UA_DateTime requestedAt; /// Point in time in which the secure channel was requested
-	UInt32 connectionState;
-	UInt32 tokenId;
-	UInt32 revisedLifetime;
-};
-
-struct SS_connection
-{
-
-};
-
-typedef struct
-{
-	struct TL_connection transportLayer;
-	struct SL_connection secureLayer;
-	struct SS_connection serviceLayer;
-}UA_connection;
-
-
-
-#endif /* OPCUA_CONNECTIONHELPER_H_ */

+ 0 - 89
open62541Stack/opcuaserver-1.0/src/opcua_encodingLayer.c

@@ -1,89 +0,0 @@
-/*
- * opcua_encodingLayer.c
- *
- *  Created on: Jan 14, 2014
- *      Author: opcua
- */
-#include "opcua_encodingLayer.h"
-#include "opcua_binaryEncDec.h"
-#include "opcua_types.h"
-#include "opcua_builtInDatatypes.h"
-
-/**
- * IntegerId
- * Part: 4
- * Chapter: 7.13
- * Page: 118
- */
-T_IntegerId decodeIntegerId(char* buf, Int32 *pos)
-{
-	return decodeUInt32(buf, pos);
-}
-
-/**
- * DiagnosticInfo
- * Part: 4
- * Chapter: 7.9
- * Page: 116
- */
-Int32 decodeToDiagnosticInfo(char* buf, Int32 *pos, T_DiagnosticInfo* dstDiagnosticInfo)
-{
-
-	dstDiagnosticInfo->namespaceUri = decodeInt32(buf,pos);
-	dstDiagnosticInfo->symbolicId = decodeInt32(buf, pos);
-	dstDiagnosticInfo->locale = decodeInt32(buf, pos);
-	dstDiagnosticInfo->localizesText = decodeInt32(buf, pos);
-
-	decodeUAByteString(buf, pos, dstDiagnosticInfo->additionalInfo);
-	dstDiagnosticInfo->innerStatusCode = decodeUAStatusCode(buf, pos);
-
-	//If the Flag InnerDiagnosticInfo is set, then the DiagnosticInfo will be encoded
-	if ((dstDiagnosticInfo->innerStatusCode & DIEMT_INNER_DIAGNOSTIC_INFO) == 1)
-	{
-		dstDiagnosticInfo->innerDiagnosticInfo = decodeTDiagnosticInfo(buf,
-				pos);
-	}
-
-	return 0;
-}
-
-/**
- * RequestHeader
- * Part: 4
- * Chapter: 7.26
- * Page: 132
- */
-
-/** \copydoc decodeRequestHeader */
-Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
-		T_RequestHeader *dstRequestHeader)
-{
-
-	decodeUANodeId(srcRaw->message, pos,&(dstRequestHeader->authenticationToken));
-	dstRequestHeader->timestamp = decodeUADateTime(srcRaw->message, pos);
-	dstRequestHeader->requestHandle = decodeIntegerId(srcRaw->message, pos);
-	dstRequestHeader->returnDiagnostics = decodeUInt32(srcRaw->message, pos);
-	decodeUAString(srcRaw->message, pos, &dstRequestHeader->auditEntryId);
-	dstRequestHeader->timeoutHint = decodeUInt32(srcRaw->message, pos);
-
-
-	// AdditionalHeader will stay empty, need to be changed if there is relevant information
-
-	return 0;
-}
-
-/**
- * ResponseHeader
- * Part: 4
- * Chapter: 7.27
- * Page: 133
- */
-/** \copydoc encodeResponseHeader */
-Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf)
-{
-
-	return 0;
-}
-
-
-

+ 0 - 58
open62541Stack/opcuaserver-1.0/src/opcua_encodingLayer.h

@@ -1,58 +0,0 @@
-/*
- * opcua_encodingLayer.h
- *
- *  Created on: Jan 14, 2014
- *      Author: opcua
- */
-
-#ifndef OPCUA_ENCODINGLAYER_H_
-#define OPCUA_ENCODINGLAYER_H_
-
-#include "opcua_builtInDatatypes.h"
-#include "opcua_advancedDatatypes.h"
-#include "opcua_types.h"
-/**
- * \brief
- * \param srcRaw             pointer to raw data which holds the encoded data
- * \param pos
- * \param dstRequestHeader   pointer to a structure which hold the encoded header
- * \return                   0 = success
- */
-Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, T_RequestHeader *dstRequestHeader);
-
-
-
-/**
- *
- * @param srcHeader
- * @param pos
- * @param dstRaw
- * @return
- */
-Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,Int32 *pos,AD_RawMessage *dstRaw);
-
-
-
-/**
- *
- * @param srcRaw
- * @param pos
- * @param dstResponseHeader
- * @return
- */
-Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, Int32 *pos, T_ResponseHeader *dstResponseHeader);
-
-/**
- *  @brief function to encode a secureChannelRequestHeader
- *
- * @param header   a open secure channel header structure which should be encoded to binary format
- * @param dstBuf   pointer to a structure which hold the encoded header
- * @return
- */
-Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf);
-
-
-
-
-
-#endif /* OPCUA_ENCODINGLAYER_H_ */

+ 0 - 205
open62541Stack/opcuaserver-1.0/src/opcua_secureChannelLayer.c

@@ -1,205 +0,0 @@
-/*
- * opcua_secureChannelLayer.c
- *
- *  Created on: Jan 13, 2014
- *      Author: opcua
- */
-#include "opcua_secureChannelLayer.h"
-
-
-Int32 SL_openSecureChannelRequest_check(const UA_connection *connection, secureChannelMessage)
-{
-	return 0;
-}
-
-
-
-/*
- * respond the securechannel_open request
- */
-Int32 SL_secureChannel_ResponseHeader_form(UA_connection *connection, T_ResponseHeader *responseHeader)
-{
-	responseHeader->timestamp = 0;//TODO getCurrentTime();
-	responseHeader->requestHandle = 0;
-	responseHeader->serviceResult = 0; // TODO insert service result code
-
-	responseHeader->serviceDiagnostics.EncodingMask = 0;
-	responseHeader->noOfStringTable = 0;
-
-	responseHeader->additionalHeader.Body = 0;
-	responseHeader->additionalHeader.Encoding = 0;
-	responseHeader->additionalHeader.Length = 0;
-
-	responseHeader->additionalHeader.TypeId.Namespace = 0;
-	responseHeader->additionalHeader.TypeId.Identifier = 0;
-
-
-	responseHeader->requestHandle = 0;
-	return 0;
-}
-/*
- *
- */
-Int32 SL_secureChannel_Response_form(UA_connection *connection, SL_Response *response)
-{
-	response->ServerProtocolVersion = connection->transportLayer//TODO must be set
-	response->SecurityToken.ChannelId = connection->secureLayer.UInt32_secureChannelId;
-	response->SecurityToken.CreatedAt = connection->secureLayer.requestedAt;
-	response->SecurityToken.TokenId = connection->secureLayer.tokenId; //TODO  must be generated;
-	response->SecurityToken.RevisedLifeTime = connection->secureLayer.revisedLifetime;
-	response->ServerNonce.Length = 0; // TODO
-	return 0;
-}
-/*
- * opens a secureChannel (server side)
- */
-Int32 SL_secureChannel_open(const UA_connection *connection,
-		const AD_RawMessage *secureChannelMessage,
-		const SL_SecureConversationMessageHeader *SCM_Header,
-		const SL_AsymmetricAlgorithmSecurityHeader *AAS_Header)
-{
-	SL_Response response;
-
-
-
-
-	TL_send();
-	//client protocol Version
-
-return 0;
-
-}
-/*
- void SL_secureChannel_Request_get(AD_RawMessage        *secureChannelMessage,
- secureChannelRequest *SC_request)
- {
-
- }
-
-/*
- * closes a secureChannel (server side)
- */
-void SL_secureChannel_formResponse()
-{
-
-}
-void SL_secureChannel_close(UA_connection *connection)
-{
-
-}
-
-/*
- * receive and process data from underlying layer
- */
-void SL_receive(UA_connection *connection, AD_RawMessage *serviceMessage)
-{
-	AD_RawMessage* secureChannelMessage;
-	SL_SecureConversationMessageHeader SCM_Header;
-	SL_AsymmetricAlgorithmSecurityHeader AAS_Header;
-	SL_SequenceHeader SequenceHeader;
-
-	//TODO Error Handling, length checking
-	//get data from transport layer
-	TL_receive(UA_connection, secureChannelMessage);
-	Int32 readPosition = 0;
-
-	//get the Secure Channel Message Header
-	SL_secureChannel_SCMHeader_get(connection,secureChannelMessage,
-			&readPosition, &SCM_Header);
-
-	//get the Secure Channel Asymmetric Algorithm Security Header
-	SL_secureChannel_AASHeader_get(connection, secureChannelMessage,
-			&readPosition, &AAS_Header);
-	//get the Sequence Header
-	SL_secureChannel_SequenceHeader_get(connection,secureChannelMessage,
-			readPosition,&SequenceHeader);
-	//get Secure Channel Message
-	SL_secureChannel_Message_get(connection, secureChannelMessage,
-			readPosition,serviceMessage);
-
-	if (secureChannelMessage.length > 0)
-	{
-		switch (SCM_Header.MessageType)
-		{
-		case packetType_MSG:
-			if (connection->secureLayer.connectionState
-					== connectionState_ESTABLISHED)
-			{
-
-			}
-			else //receiving message, without secure channel
-			{
-				//TODO send back Error Message
-			}
-			break;
-		case packetType_OPN:
-			//Server Handling
-			if (openSecureChannelHeader_check(connection, secureChannelMessage))
-			{
-				//check if the request is valid
-				SL_openSecureChannelRequest_check(connection, secureChannelMessage);
-			}
-			SL_secureChannel_open(connection, serviceMessage);
-		}
-		else
-		{
-			//TODO send back Error Message
-		}
-
-		//Client Handling
-
-		//TODO free memory for secureChannelMessage
-
-		break;
-		case packetType_CLO:
-			SL_secureChannel_close(connection, secureChannelMessage);
-
-		//TODO free memory for secureChannelMessage
-		break;
-	}
-
-}
-/*
- * get the secure channel message header
- */
-Int32 SL_secureChannel_SCMHeader_get(UA_connection *connection,
-	AD_RawMessage *rawMessage,Int32 *pos, SL_SecureConversationMessageHeader* SC_Header)
-{
-	SC_Header->MessageType = TL_getPacketType(rawMessage);
-	pos += TL_MESSAGE_TYPE_LEN;
-	SC_Header->IsFinal = rawMessage[*pos];
-	SC_Header->MessageSize = decodeUInt32(rawMessage, *pos);
-	SC_Header->SecureChannelId = decodeUInt32(rawMessage, *pos);
-	return 0;
-
-}
-Int32 SL_secureChannel_SequenceHeader_get(UA_connection *connection,
-		AD_RawMessage *rawMessage, Int32 *pos,
-		SL_SequenceHeader *SequenceHeader)
-{
-	SequenceHeader->RequestId = decodeUInt32(rawMessage->message, pos);
-	SequenceHeader->SequenceNumber = decodeUInt32(rawMessage->message, pos);
-	return 0;
-}
-/*
- * get the asymmetric algorithm security header
- */
-Int32 SL_secureChannel_AASHeader_get(UA_connection *connection,
-	AD_RawMessage *rawMessage, Int32 *pos,
-	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header)
-{
-	Int32 err = 0;
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->SecurityPolicyUri);
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->SenderCertificate);
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->ReceiverThumbprint);
-	return err;
-}
-void SL_secureChannel_Footer_get()
-{
-
-}
-void SL_secureChannel_Message_get(UA_connection *connection,
-	AD_RawMessage *rawMessage, Int32 *pos, AD_RawMessage *message)
-{
-
-}

+ 0 - 78
open62541Stack/opcuaserver-1.0/src/opcua_secureChannelLayer.h

@@ -1,78 +0,0 @@
-/*
- * opcua_secureChannelLayer.h
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-
-#ifndef OPCUA_SECURECHANNELLAYER_H_
-#define OPCUA_SECURECHANNELLAYER_H_
-
-#include "opcua_advancedDatatypes.h"
-#include "opcua_encodingLayer.h"
-static const Int32 SL_HEADER_LENGTH = 0;
-typedef struct _SL_ChannelSecurityToken
-{
-	UInt32 ChannelId;
-	UInt32 TokenId;
-	UA_DateTime CreatedAt;
-	Int32 RevisedLifeTime;
-}SL_ChannelSecurityToken;
-
-
-typedef struct _SL_OpenSecureChannelResponse
-{
-	UInt32 ServerProtocolVersion;
-	SL_ChannelSecurityToken SecurityToken;
-	UA_String ServerNonce;
-}SL_Response;
-
-
-typedef struct _SL_SecureConversationMessageHeader
-{
-	UInt32 MessageType;
-	Byte   IsFinal;
-	UInt32 MessageSize;
-	UInt32 SecureChannelId;
-}SL_SecureConversationMessageHeader;
-
-
-typedef struct _SL_AsymmetricAlgorithmSecurityHeader
-{
-	UA_String SecurityPolicyUri;
-	UA_String SenderCertificate;
-	UA_String ReceiverThumbprint;
-}SL_AsymmetricAlgorithmSecurityHeader;
-
-typedef struct _SL_SequenceHeader
-{
-	UInt32 SequenceNumber;
-	UInt32 RequestId;
-}SL_SequenceHeader;
-
-/*
- * optional, only if there is encryption present
- */
-typedef struct _SL_AsymmetricAlgorithmSecurityFooter
-{
-	Byte PaddingSize;
-	Byte *Padding;
-
-	UInt32 SignatureSize;
-	Byte *Signature;
-}SL_AsymmetricAlgorithmSecurityFooter;
-
-/*
-typedef struct _SL_ResponseHeader
-{
-	UA_DateTime timestamp;
-    IntegerId requestHandle;
-    UA_StatusCode serviceResult;
-    UA_DiagnosticInfo serviceDiagnostics;
-    UA_String *stringTable;
-    UInt32 stringTableLength;
-    UA_ExtensionObject additionalHeader;
-}SL_ResponseHeader;
-*/
-
-#endif /* OPCUA_SECURECHANNELLAYER_H_ */

+ 0 - 314
open62541Stack/opcuaserver-1.0/src/opcua_transportLayer.c

@@ -1,314 +0,0 @@
-/*
- * opcua_transportLayer.c
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-#include "opcua_transportLayer.h"
-
-/*
- * send acknowledge to the client
- */
-void TL_sendACK(UA_connection *connection)
-{
-	//get memory for message
-	//
-	//build message
-	//connection->transportLayer.localConf.maxChunkCount;
-
-	//call send function
-
-}
-/*
- * server answer to open message
- */
-void TL_open(UA_connection *connection, AD_RawMessage *rawMessage)
-{
-	UA_connection tmpConnection;
-	switch(connection->transportLayer.connectionState)
-	{
-		connectionState_CLOSED :
-		{
-			//process the connection values received by the client
-			TL_processHELMessage(&tmpConnection,rawMessage);
-			connection->transportLayer.localConf.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
-
-			connection->transportLayer.localConf.recvBufferSize =
-					tmpConnection.transportLayer.localConf.recvBufferSize;
-
-			connection->transportLayer.localConf.sendBufferSize =
-					tmpConnection.transportLayer.localConf.sendBufferSize;
-
-			connection->transportLayer.localConf.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
-			connection->transportLayer.localConf.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
-
-		    TL_sendACK(connection);
-			connection->transportLayer.connectionState = connectionState_ESTABLISHED;
-			break;
-		}
-		connectionState_OPENING :
-		{
-		//	TL_sendACK(connection);
-		//	connection->transportLayer.connectionState = connectionState_ESTABLISHED;
-			break;
-		}
-		connectionState_ESTABLISHED :
-		{
-
-			break;
-		}
-	}
-}
-Int32 TL_checkMessage(UA_connection *connection, AD_RawMessage *TL_messsage)
-{
-	Int32 position = 4;
-	TL_getPacketType(TL_messsage);
-
-	Int32 messageLen = decodeUInt32(TL_messsage->message, &position);
-	if (messageLen == TL_messsage->length &&
-		messageLen < (connection->transportLayer.localConf.maxMessageSize))
-	{
-		return 1;
-	}
-	return 0;
-}
-void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
-{
-	UInt32 bufferSize = connection->transportLayer.localConf.recvBufferSize = 8192;
-	UInt32 length = 0;
-
-	AD_RawMessage tmpRawMessage;
-	struct TL_header tmpHeader;
-	//allocate memory for the message
-//TODO filter double Hello Messages -> generate error message as response
-//TODO build a file which handles the memory allocation
-	tmpRawMessage.message = (char *)malloc(bufferSize);
-
-	if (tmpRawMessage.message != NULL)
-	{
-		//length = tcp_recv(connection, tmpRawMessage.message, bufferSize);
-	}
-
-
-
-	tmpRawMessage.length = length;
-	if(tmpRawMessage.length > 0)
-	{
-		switch(TL_getPacketType(&tmpRawMessage))
-		{
-		packetType_MSG:
-		packetType_OPN:
-		packetType_CLO:
-			//CHECK MESSAGE SIZE
-			if (TL_checkMessage(connection,TL_message))
-			{
-				TL_message->length = tmpRawMessage.length;
-				TL_message->message = tmpRawMessage.message;
-			}
-			else
-			{
-				// SEND BACK ERROR MESSAGE
-			}
-			break;
-		packetType_HEL:
-			TL_message->length = 0;
-			TL_message->message = NULL;
-			TL_open(connection, &tmpRawMessage);
-			break;
-		packetType_ACK:
-			TL_message->length = 0;
-			TL_message->message = NULL;
-			break;
-		packetType_ERR:
-			TL_message->length = 0;
-			TL_message->message = NULL;
-			//TODO ERROR HANDLING
-			break;
-			//TODO ERROR HANDLING
-		}
-		//check in which state the connection is
-
-	}
-
-}
-
-
-/*
- * get the message header
- */
-void TL_getMessageHeader(struct TL_header *header, AD_RawMessage *rawMessage)
-{
-	int pos = 0;
-
-	if(rawMessage->message[0] == 'H' &&
-	   rawMessage->message[1] == 'E' &&
-	   rawMessage->message[2] == 'L')
-	{
-		header->MessageType = TL_HEL;
-	}
-	else if(rawMessage->message[0] == 'A' &&
-	        rawMessage->message[1] == 'C' &&
-	        rawMessage->message[2] == 'K')
-	{
-		header->MessageType = TL_ACK;
-	}
-	else if(rawMessage->message[0] == 'E' &&
-			rawMessage->message[1] == 'R' &&
-			rawMessage->message[2] == 'R')
-	{
-		header->MessageType = TL_ERR;
-	}
-	else if(rawMessage->message[0] == 'O' &&
-	        rawMessage->message[1] == 'P' &&
-	        rawMessage->message[2] == 'N')
-	{
-		header->MessageType = TL_OPN;
-	}
-	else if(rawMessage->message[0] == 'C' &&
-	        rawMessage->message[1] == 'L' &&
-	        rawMessage->message[2] == 'O')
-	{
-		header->MessageType = TL_CLO;
-	}
-	else if(rawMessage->message[0] == 'M' &&
-			rawMessage->message[1] == 'S' &&
-			rawMessage->message[2] == 'G')
-	{
-		header->MessageType = TL_MSG;
-	}
-	else
-	{
-		//TODO ERROR no valid message received
-	}
-
-	pos = pos + TL_MESSAGE_TYPE_LEN;
-
-	header->Reserved = decodeByte(rawMessage->message,&pos);
-	pos = pos + TL_RESERVED_LEN;
-	header->MessageSize = decodeUInt32(rawMessage->message,&pos);
-
-}
-Int32 TL_getPacketType(AD_RawMessage *rawMessage)
-{
-	if(rawMessage->message[0] == 'H' &&
-	   rawMessage->message[1] == 'E' &&
-	   rawMessage->message[2] == 'L')
-	{
-		return packetType_HEL;
-	}
-	else if(rawMessage->message[0] == 'A' &&
-	        rawMessage->message[1] == 'C' &&
-	        rawMessage->message[2] == 'K')
-	{
-		return packetType_ACK;
-	}
-	else if(rawMessage->message[0] == 'E' &&
-			rawMessage->message[1] == 'R' &&
-			rawMessage->message[2] == 'R')
-	{
-		return packetType_ERR;
-	}
-	else if(rawMessage->message[0] == 'O' &&
-	        rawMessage->message[1] == 'P' &&
-	        rawMessage->message[2] == 'N')
-	{
-		return packetType_OPN;
-	}
-	else if(rawMessage->message[0] == 'C' &&
-	        rawMessage->message[1] == 'L' &&
-	        rawMessage->message[2] == 'O')
-	{
-		return packetType_CLO;
-	}
-	else if(rawMessage->message[0] == 'M' &&
-			rawMessage->message[1] == 'S' &&
-			rawMessage->message[2] == 'G')
-	{
-		return packetType_MSG;
-	}
-	else
-	{
-		return -1;//TODO ERROR no valid message received
-	}
-}
-void TL_processHELMessage_test()
-{
-	Byte data[] = {0x48,0x45,0x4c,0x46,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x88,0x13,0x00,0x00,0x36,0x00,0x00,0x00,0x6f,0x70,0x63,0x2e,0x74,0x63,0x70,0x3a,0x2f,0x2f,0x43,0x61,0x6e,0x6f,0x70,0x75,0x73,0x2e,0x70,0x6c,0x74,0x2e,0x72,0x77,0x74,0x68,0x2d,0x61,0x61,0x63,0x68,0x65,0x6e,0x2e,0x64,0x65,0x3a,0x31,0x36,0x36,0x36,0x34,0x2f,0x34,0x43,0x45,0x55,0x41,0x53,0x65,0x72,0x76,0x65,0x72};
-	UA_connection con;
-	AD_RawMessage rawMessage;
-	rawMessage.message = data;
-	rawMessage.length = 86;
-
-
-	struct TL_messageBodyHEL HELmessage;
-
-	struct TL_header header;
-
-	printf("TL_getHELMessage_test");
-
-	header.MessageSize = 86;
-	header.MessageType = TL_HEL; // HEL message
-	header.Reserved = 0x46; // F
-
-	TL_processHELMessage(&con, &rawMessage);
-
-	if(con.transportLayer.remoteConf.protocolVersion == 0 &&
-	   con.transportLayer.remoteConf.recvBufferSize == 65536 &&
-	   con.transportLayer.remoteConf.sendBufferSize == 65536 &&
-	   con.transportLayer.remoteConf.maxMessageSize == 16777216 &&
-	   con.transportLayer.remoteConf.maxChunkCount == 5000)
-	{
-		printf(" - passed \n");
-	}
-	else
-	{
-		printf(" - failed \n");
-	}
-
-
-
-
-}
-/*
- * gets the TL_messageBody
- */
-void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage)
-{
-	UInt32 pos = TL_HEADER_LENGTH;
-	struct TL_header tmpHeader;
-
-	connection->transportLayer.remoteConf.protocolVersion =
-			decodeUInt32(rawMessage->message,&pos);
-	pos = pos + sizeof(UInt32);
-
-	connection->transportLayer.remoteConf.recvBufferSize =
-			decodeUInt32(rawMessage->message,&pos);
-	pos = pos +  sizeof(UInt32);
-
-	connection->transportLayer.remoteConf.sendBufferSize =
-			decodeUInt32(rawMessage->message,&pos);
-	pos = pos +  sizeof(UInt32);
-	connection->transportLayer.remoteConf.maxMessageSize =
-			decodeUInt32(rawMessage->message,&pos);
-	pos = pos +  sizeof(UInt32);
-
-	connection->transportLayer.remoteConf.maxChunkCount =
-			decodeUInt32(rawMessage->message,&pos);
-	pos = pos +  sizeof(UInt32);
-
-	connection->transportLayer.endpointURL.Data = &(rawMessage->message[pos]);
-	connection->transportLayer.endpointURL.Length = tmpHeader.MessageSize - pos;
-}
-/*
- * respond to client request
- */
-
-
-TL_send(AD_RawMessage *rawMessage)
-{
-	//call tcp function or callback
-}
-
-
-
-

+ 0 - 89
open62541Stack/opcuaserver-1.0/src/opcua_transportLayer.h

@@ -1,89 +0,0 @@
-/*
- * opcua_transportLayer.h
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-
-#ifndef OPCUA_TRANSPORTLAYER_H_
-#define OPCUA_TRANSPORTLAYER_H_
-#include <stdio.h>
-
-#include "opcua_binaryEncDec.h"
-#include "opcua_advancedDatatypes.h"
-#include "opcua_connectionHelper.h"
-
-
-//TODO : Implement this interface
-#include "tcp_layer.h"
-
-//constants
-static const UInt32 TL_HEADER_LENGTH = 8;
-static const UInt32 TL_MESSAGE_TYPE_LEN = 3;
-static const UInt32 TL_RESERVED_LEN = 1;
-
-//variables which belong to layer
-static const TL_SERVER_PROTOCOL_VERSION = 0;
-static const TL_SERVER_MAX_CHUNK_COUNT = 1;
-static const TL_SERVER_MAX_MESSAGE_SIZE = 8192;
-
-enum TL_messageType_td
-{
-	TL_HEL,
-	TL_ACK,
-	TL_ERR,
-	TL_OPN,
-	TL_CLO,
-	TL_MSG
-}TL_messageType;
-
-struct TL_header
-{
-	UInt32 MessageType;
-	Byte Reserved;
-	UInt32 MessageSize;
-};
-struct TL_message
-{
-	struct TL_header Header;
-	char *message;
-};
-
-struct TL_messageBodyHEL
-{
-	UInt32 ProtocolVersion;
-	UInt32 ReceiveBufferSize;
-	UInt32 SendBufferSize;
-	UInt32 MaxMessageSize;
-	UInt32 MaxChunkCount;
-	UA_String EndpointUrl;
-};
-
-struct TL_messageBodyACK
-{
-	UInt32 ProtocolVersion;
-	UInt32 ReceiveBufferSize;
-	UInt32 SendBufferSize;
-	UInt32 MaxMessageSize;
-	UInt32 MaxChunkCount;
-	UA_String EndpointUrl;
-};
-
-struct TL_messageBodyERR
-{
-	UInt32 Error;
-	UA_String Reason;
-
-};
-//functions
-void TL_receive(UA_connection *connection, AD_RawMessage *TL_message);
-//Test
-void TL_getMessageHeader_test();
-Int32 TL_getPacketType(AD_RawMessage *rawMessage);
-void TL_getMessageHeader(struct TL_header *messageHeader,AD_RawMessage *rawMessage);
-
-//Test
-void TL_processHELMessage_test();
-
-void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage);
-#endif /* OPCUA_TRANSPORTLAYER_H_ */

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 1047
open62541Stack/opcuaserver-1.0/src/opcua_types.h


+ 0 - 16
open62541Stack/opcuaserver-1.0/src/tcp_layer.h

@@ -1,16 +0,0 @@
-/*
- * tcp_layer.h
- *
- *  Created on: Jan 10, 2014
- *      Author: opcua
- */
-
-#ifndef TCP_LAYER_H_
-#define TCP_LAYER_H_
-#include "opcua_connectionHelper.h"
-/*
- * returns the length of read bytes
- */
-UInt32 receive(UA_connection *connection, AD_RawMessage *message,UInt32 bufferLength);
-
-#endif /* TCP_LAYER_H_ */

+ 0 - 8
open62541Stack/opcuaserver-1.0/tests/Makefile.am

@@ -1,8 +0,0 @@
-TESTS = check_stack
-check_PROGRAMS = check_stack
-check_stack_SOURCES = check_stack.c $(top_builddir)/src/opcua_transportLayer.h\
-						$(top_builddir)/src/opcua_advancedDatatypes.h\
-						$(top_builddir)/src/opcua_connectionHelper.h
-
-check_stack_CFLAGS = @CHECK_CFLAGS@
-check_stack_LDADD = $(top_builddir)/bin/libOpen62541.la @CHECK_LIBS@

+ 0 - 208
open62541Stack/opcuaserver-1.0/tests/check_stack.c

@@ -1,208 +0,0 @@
-/*
- ============================================================================
- Name        : opcuaServer.c
- Author      :
- Version     :
- Copyright   : Your copyright notice
- Description :
- ============================================================================
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../src/opcua_transportLayer.h"
-#include "../src/opcua_binaryEncDec.h"
-#include "../src/opcua_encodingLayer.h"
-#include "../src/opcua_advancedDatatypes.h"
-#include "check.h"
-
-START_TEST(test_getPacketType_validParameter)
-{
-
-	char buf[] = {'C','L','O'};
-	AD_RawMessage rawMessage;
-	rawMessage.message = buf;
-	rawMessage.length = 3;
-
-	ck_assert_int_eq(TL_getPacketType(&rawMessage),packetType_CLO);
-
-}
-END_TEST
-
-/*
-START_TEST(decodeRequestHeader_test_validParameter)
-{
-		char testMessage = {0x00,0x00,0x72,0xf1,0xdc,0xc9,0x87,0x0b,
-
-							0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
-							0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,
-							0x00,0x00,0x00,0x00,0x00};
-		AD_RawMessage rawMessage;
-		rawMessage.message = &testMessage;
-		rawMessage.length = 29;
-		Int32 position = 0;
-		T_RequestHeader requestHeader;
-		decodeRequestHeader(rawMessage,&position,&requestHeader);
-
-		ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
-
-		ck_assert_int_eq(requestHeader.returnDiagnostics,0);
-
-		ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
-
-}
-END_TEST
-*/
-
-START_TEST(encodeByte_test)
-{
-	AD_RawMessage rawMessage;
-	Int32 position = 0;
-	//EncodeByte
-		char *mem = malloc(sizeof(Byte));
-		rawMessage.message = mem;
-		Byte testByte = 0x08;
-		rawMessage.length = 1;
-		position = 0;
-
-		encodeByte(testByte, &position, &rawMessage);
-
-		ck_assert_int_eq(rawMessage.message[0], 0x08);
-		ck_assert_int_eq(rawMessage.length, 1);
-		ck_assert_int_eq(position, 1);
-		free(mem);
-}
-END_TEST
-
-START_TEST(decodeUInt16_test)
-{
-
-	AD_RawMessage rawMessage;
-	Int32 position = 0;
-	//EncodeUInt16
-	char mem[2] = {0x01,0x00};
-
-	rawMessage.message = mem;
-
-	rawMessage.length = 2;
-
-	//encodeUInt16(testUInt16, &position, &rawMessage);
-
-	Int32 p = 0;
-	UInt16 val = decodeUInt16(rawMessage.message,&p);
-	ck_assert_int_eq(val,1);
-	//ck_assert_int_eq(p, 2);
-	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
-
-}
-END_TEST
-START_TEST(encodeUInt16_test)
-{
-
-	AD_RawMessage rawMessage;
-	Int32 position = 0;
-	//EncodeUInt16
-	char *mem = malloc(sizeof(UInt16));
-	rawMessage.message = mem;
-	UInt16 testUInt16 = 1;
-	rawMessage.length = 2;
-	position = 0;
-
-	encodeUInt16(testUInt16, &position, &rawMessage);
-	//encodeUInt16(testUInt16, &position, &rawMessage);
-
-	ck_assert_int_eq(position, 2);
-	Int32 p = 0;
-	Int16 val = decodeUInt16(rawMessage.message,&p);
-	ck_assert_int_eq(val,testUInt16);
-	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
-
-}
-END_TEST
-
-
-Suite* TL_testSuite_getPacketType(void)
-{
-	Suite *s = suite_create("getPacketType");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core,test_getPacketType_validParameter);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-Suite* TL_testSuite_decodeUInt16(void)
-{
-	Suite *s = suite_create("decodeUInt16_test");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core, decodeUInt16_test);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-Suite* TL_testSuite_encodeUInt16(void)
-{
-	Suite *s = suite_create("encodeUInt16_test");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core, encodeUInt16_test);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-
-Suite* TL_testSuite_encodeByte(void)
-{
-	Suite *s = suite_create("encodeByte_test");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core, encodeByte_test);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-
-/*
-Suite* TL_<TESTSUITENAME>(void)
-{
-	Suite *s = suite_create("<TESTSUITENAME>");
-	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core,<TEST_NAME>);
-	suite_add_tcase(s,tc_core);
-	return s;
-}
-*/
-
-int main (void)
-{
-	int number_failed = 0;
-
-	Suite *s = TL_testSuite_getPacketType();
-	SRunner *sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed = srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	s = TL_testSuite_decodeUInt16();
-	sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed += srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	s = TL_testSuite_encodeUInt16();
-	sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed += srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	s = TL_testSuite_encodeByte();
-	sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed += srunner_ntests_failed(sr);
-	srunner_free(sr);
-
-	/* <TESTSUITE_TEMPLATE>
-	s =  <TESTSUITENAME>;
-	sr = srunner_create(s);
-	srunner_run_all(sr,CK_NORMAL);
-	number_failed += srunner_ntests_failed(sr);
-	srunner_free(sr);
-	*/
-	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-
-}
-
-

+ 9 - 0
open62541Stack/src/Makefile.am

@@ -25,6 +25,7 @@ libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
 						opcua_secureChannelLayer.c\
 						opcua_secureChannelLayer.c\
 						opcua_memory.c\
 						opcua_memory.c\
 						opcua_time.c\
 						opcua_time.c\
+						tcp_layer.c\
 						opcua_builtInDatatypes.h\
 						opcua_builtInDatatypes.h\
 						opcua_binaryEncDec.h\
 						opcua_binaryEncDec.h\
 						opcua_transportLayer.h\
 						opcua_transportLayer.h\
@@ -41,6 +42,14 @@ libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
 #__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
 #__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
 #libOpen62541_la_LIBADD = ../lib/libOpen62541.la		  										
 #libOpen62541_la_LIBADD = ../lib/libOpen62541.la		  										
 
 
+if DEBUG
+AM_CFLAGS = -g -O0
+AM_CXXFLAGS = -g -O0
+else
+AM_CFLAGS = -O2
+AM_CXXFLAGS = -O2
+endif
+
 .PHONY: convenience-link clean-convenience-link
 .PHONY: convenience-link clean-convenience-link
 
 
 convenience-link: $(lib_LTLIBRARIES)
 convenience-link: $(lib_LTLIBRARIES)

+ 29 - 25
open62541Stack/src/opcua_binaryEncDec.c

@@ -37,7 +37,7 @@ Int32 encoder_encodeBuiltInDatatype(void *data, Int32 type, Int32 *pos,
 		encodeInt32((*(Int32*) data), pos, dstBuf);
 		encodeInt32((*(Int32*) data), pos, dstBuf);
 		break;
 		break;
 	case UINT32:
 	case UINT32:
-		encodeUInt32((*(UInt32*) data), pos, dstBuf);
+		encodeUInt32(*(UInt32*)(data), pos, dstBuf);
 		break;
 		break;
 	case INT64:
 	case INT64:
 		encodeInt64((*(Int64*) data), pos, dstBuf);
 		encodeInt64((*(Int64*) data), pos, dstBuf);
@@ -619,8 +619,8 @@ Int32 decodeUInt32(char * const buf, Int32 *pos, UInt32 *dst)
 }
 }
 void encodeUInt32(UInt32 value, Int32 *pos, char *dstBuf)
 void encodeUInt32(UInt32 value, Int32 *pos, char *dstBuf)
 {
 {
-	memcpy(&(dstBuf[*pos]), &value, sizeof(value));
+	memcpy(&(dstBuf[*pos]), &value, sizeof(UInt32));
-	pos += 4;
+	*pos += 4;
 
 
 }
 }
 
 
@@ -635,7 +635,7 @@ Int32 decodeInt64(char * const buf, Int32 *pos, Int64 *dst)
 	Int64 t6 = (Int64) buf[*pos + 5] << 40;
 	Int64 t6 = (Int64) buf[*pos + 5] << 40;
 	Int64 t7 = (Int64) buf[*pos + 6] << 48;
 	Int64 t7 = (Int64) buf[*pos + 6] << 48;
 	Int64 t8 = (Int64) buf[*pos + 7] << 56;
 	Int64 t8 = (Int64) buf[*pos + 7] << 56;
-	pos += 8;
+	*pos += 8;
 	*dst = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 	*dst = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
@@ -656,7 +656,7 @@ Int32 decodeUInt64(char * const buf, Int32 *pos, UInt64 *dst)
 	UInt64 t6 = (UInt64) buf[*pos + 5] << 40;
 	UInt64 t6 = (UInt64) buf[*pos + 5] << 40;
 	UInt64 t7 = (UInt64) buf[*pos + 6] << 48;
 	UInt64 t7 = (UInt64) buf[*pos + 6] << 48;
 	UInt64 t8 = (UInt64) buf[*pos + 7] << 56;
 	UInt64 t8 = (UInt64) buf[*pos + 7] << 56;
-	pos += 8;
+	*pos += 8;
 	*dst = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 	*dst = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
@@ -764,6 +764,7 @@ Int32 decodeUAGuid(char * const buf, Int32 *pos, UA_Guid *dstGUID)
 	decodeUAByteString(buf, pos, &(dstGUID->Data4));
 	decodeUAByteString(buf, pos, &(dstGUID->Data4));
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
+
 Int32 encodeUAGuid(UA_Guid *srcGuid, Int32 *pos, char *buf)
 Int32 encodeUAGuid(UA_Guid *srcGuid, Int32 *pos, char *buf)
 {
 {
 	encodeUInt32(srcGuid->Data1, pos, buf);
 	encodeUInt32(srcGuid->Data1, pos, buf);
@@ -914,7 +915,7 @@ Int32 decodeIntegerId(char* buf, Int32 *pos, Int32 *dst)
 	decoder_decodeBuiltInDatatype(buf, INT32, pos, dst);
 	decoder_decodeBuiltInDatatype(buf, INT32, pos, dst);
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
-void encodeIntegerId(T_IntegerId integerId, Int32 *pos, char *buf)
+void encodeIntegerId(UA_AD_IntegerId integerId, Int32 *pos, char *buf)
 {
 {
 	encodeInt32(integerId, pos, buf);
 	encodeInt32(integerId, pos, buf);
 }
 }
@@ -1245,52 +1246,54 @@ Int32 encodeDataValue(UA_DataValue *dataValue, Int32 *pos, char *dstBuf)
  * Chapter: 7.9
  * Chapter: 7.9
  * Page: 116
  * Page: 116
  */
  */
-Int32 decodeDiagnosticInfo(char* buf, Int32 *pos,
+Int32 decodeDiagnosticInfo(char *buf, Int32 *pos,
-		T_DiagnosticInfo* dstDiagnosticInfo)
+		UA_DiagnosticInfo *dstDiagnosticInfo)
 {
 {
+
 	Byte encodingByte = (buf[*pos]);
 	Byte encodingByte = (buf[*pos]);
 	Byte mask;
 	Byte mask;
 	for (mask = 1; mask <= 0x40; mask << 2)
 	for (mask = 1; mask <= 0x40; mask << 2)
 	{
 	{
+
 		switch (mask & encodingByte)
 		switch (mask & encodingByte)
 		{
 		{
 		case DIEMT_SYMBOLIC_ID:
 		case DIEMT_SYMBOLIC_ID:
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
-					&(dstDiagnosticInfo->symbolicId));
+					&(dstDiagnosticInfo->SymbolicId));
 			//dstDiagnosticInfo->symbolicId = decodeInt32(buf, pos);
 			//dstDiagnosticInfo->symbolicId = decodeInt32(buf, pos);
 			break;
 			break;
 		case DIEMT_NAMESPACE:
 		case DIEMT_NAMESPACE:
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
-					&(dstDiagnosticInfo->namespaceUri));
+					&(dstDiagnosticInfo->NamespaceUri));
 			//dstDiagnosticInfo->namespaceUri = decodeInt32(buf, pos);
 			//dstDiagnosticInfo->namespaceUri = decodeInt32(buf, pos);
 			break;
 			break;
 		case DIEMT_LOCALIZED_TEXT:
 		case DIEMT_LOCALIZED_TEXT:
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
-					&(dstDiagnosticInfo->localizesText));
+					&(dstDiagnosticInfo->LocalizedText));
 			//dstDiagnosticInfo->localizesText = decodeInt32(buf, pos);
 			//dstDiagnosticInfo->localizesText = decodeInt32(buf, pos);
 			break;
 			break;
 		case DIEMT_LOCALE:
 		case DIEMT_LOCALE:
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
 			decoder_decodeBuiltInDatatype(buf, INT32, pos,
-					&(dstDiagnosticInfo->locale));
+					&(dstDiagnosticInfo->Locale));
 			//dstDiagnosticInfo->locale = decodeInt32(buf, pos);
 			//dstDiagnosticInfo->locale = decodeInt32(buf, pos);
 			break;
 			break;
 		case DIEMT_ADDITIONAL_INFO:
 		case DIEMT_ADDITIONAL_INFO:
 			decoder_decodeBuiltInDatatype(buf, STRING, pos,
 			decoder_decodeBuiltInDatatype(buf, STRING, pos,
-					&(dstDiagnosticInfo->additionalInfo));
+					&(dstDiagnosticInfo->AdditionalInfo));
-			decodeUAString(buf, pos, &dstDiagnosticInfo->additionalInfo);
+			decodeUAString(buf, pos, &dstDiagnosticInfo->AdditionalInfo);
 			break;
 			break;
 		case DIEMT_INNER_STATUS_CODE:
 		case DIEMT_INNER_STATUS_CODE:
 			decoder_decodeBuiltInDatatype(buf, STATUS_CODE, pos,
 			decoder_decodeBuiltInDatatype(buf, STATUS_CODE, pos,
-					&(dstDiagnosticInfo->innerStatusCode));
+					&(dstDiagnosticInfo->InnerStatusCode));
 			//dstDiagnosticInfo->innerStatusCode = decodeUAStatusCode(buf, pos);
 			//dstDiagnosticInfo->innerStatusCode = decodeUAStatusCode(buf, pos);
 			break;
 			break;
 		case DIEMT_INNER_DIAGNOSTIC_INFO:
 		case DIEMT_INNER_DIAGNOSTIC_INFO:
 			//TODO memory management should be checked (getting memory within a function)
 			//TODO memory management should be checked (getting memory within a function)
 
 
-			dstDiagnosticInfo->innerDiagnosticInfo =
+			dstDiagnosticInfo->InnerDiagnosticInfo =
-					(T_DiagnosticInfo*) opcua_malloc(sizeof(T_DiagnosticInfo));
+					(UA_DiagnosticInfo*) opcua_malloc(sizeof(UA_DiagnosticInfo));
 			decoder_decodeBuiltInDatatype(buf, DIAGNOSTIC_INFO, pos,
 			decoder_decodeBuiltInDatatype(buf, DIAGNOSTIC_INFO, pos,
-					&(dstDiagnosticInfo->innerDiagnosticInfo));
+					&(dstDiagnosticInfo->InnerDiagnosticInfo));
 
 
 			break;
 			break;
 		}
 		}
@@ -1308,6 +1311,7 @@ Int32 encodeDiagnosticInfo(UA_DiagnosticInfo *diagnosticInfo, Int32 *pos,
 			BYTE, pos, dstbuf);
 			BYTE, pos, dstbuf);
 	for (mask = 1; mask <= 0x40; mask = mask << 2)
 	for (mask = 1; mask <= 0x40; mask = mask << 2)
 	{
 	{
+
 		switch (mask & (diagnosticInfo->EncodingMask))
 		switch (mask & (diagnosticInfo->EncodingMask))
 		{
 		{
 		case DIEMT_SYMBOLIC_ID:
 		case DIEMT_SYMBOLIC_ID:
@@ -1400,7 +1404,7 @@ Int32 diagnosticInfo_calcSize(UA_DiagnosticInfo *diagnosticInfo)
  */
  */
 /** \copydoc decodeRequestHeader */
 /** \copydoc decodeRequestHeader */
 Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
 Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
-		T_RequestHeader *dstRequestHeader)
+		UA_AD_RequestHeader *dstRequestHeader)
 {
 {
 
 
 	decoder_decodeBuiltInDatatype(srcRaw->message, NODE_ID, pos,
 	decoder_decodeBuiltInDatatype(srcRaw->message, NODE_ID, pos,
@@ -1437,12 +1441,12 @@ Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
  * Page: 133
  * Page: 133
  */
  */
 /** \copydoc encodeResponseHeader */
 /** \copydoc encodeResponseHeader */
-Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos,
+Int32 encodeResponseHeader(const UA_AD_ResponseHeader *responseHeader, Int32 *pos,
-		AD_RawMessage *dstBuf)
+		UA_ByteString *dstBuf)
 {
 {
-	encodeUADateTime(responseHeader->timestamp, pos, dstBuf->message);
+	encodeUADateTime(responseHeader->timestamp, pos, dstBuf->Data);
-	encodeIntegerId(responseHeader->requestHandle, pos, dstBuf->message);
+	encodeIntegerId(responseHeader->requestHandle, pos, dstBuf->Data);
-	encodeUInt32(responseHeader->serviceResult, pos, dstBuf->message);
+	encodeUInt32(responseHeader->serviceResult, pos, dstBuf->Data);
 	//Kodieren von String Datentypen
 	//Kodieren von String Datentypen
 
 
 	return 0;
 	return 0;
@@ -1462,7 +1466,7 @@ Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject)
 	return length;
 	return length;
 }
 }
 
 
-Int32 responseHeader_calcSize(T_ResponseHeader *responseHeader)
+Int32 responseHeader_calcSize(UA_AD_ResponseHeader *responseHeader)
 {
 {
 	Int32 minimumLength = 20; // summation of all simple types
 	Int32 minimumLength = 20; // summation of all simple types
 	Int32 i, length;
 	Int32 i, length;

+ 5 - 5
open62541Stack/src/opcua_binaryEncDec.h

@@ -304,7 +304,7 @@ Int32 decodeIntegerId(char* buf, Int32 *pos, Int32* dst);
  * @param buf
  * @param buf
 
 
  */
  */
-void encodeIntegerId(T_IntegerId integerId, Int32 *pos, char *buf);
+void encodeIntegerId(UA_AD_IntegerId integerId, Int32 *pos, char *buf);
 /**
 /**
  * \brief
  * \brief
  * \param srcRaw             pointer to raw data which holds the encoded data
  * \param srcRaw             pointer to raw data which holds the encoded data
@@ -312,7 +312,7 @@ void encodeIntegerId(T_IntegerId integerId, Int32 *pos, char *buf);
  * \param dstRequestHeader   pointer to a structure which hold the encoded header
  * \param dstRequestHeader   pointer to a structure which hold the encoded header
  * \return                   0 = success
  * \return                   0 = success
  */
  */
-Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, T_RequestHeader *dstRequestHeader);
+Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, UA_AD_RequestHeader *dstRequestHeader);
 /**
 /**
  *
  *
  * @param srcHeader
  * @param srcHeader
@@ -320,7 +320,7 @@ Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, T_RequestHeade
  * @param dstRaw
  * @param dstRaw
  * @return
  * @return
  */
  */
-Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,Int32 *pos,AD_RawMessage *dstRaw);
+Int32 encodeRequestHeader(const UA_AD_RequestHeader *srcHeader,Int32 *pos,UA_ByteString *dstRaw);
 /**
 /**
  *
  *
  * @param srcRaw
  * @param srcRaw
@@ -328,7 +328,7 @@ Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,Int32 *pos,AD_RawMess
  * @param dstResponseHeader
  * @param dstResponseHeader
  * @return
  * @return
  */
  */
-Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, Int32 *pos, T_ResponseHeader *dstResponseHeader);
+Int32 decodeResponseHeader(const UA_ByteString *srcRaw, Int32 *pos, UA_AD_ResponseHeader *dstResponseHeader);
 /**
 /**
  *  @brief function to encode a secureChannelRequestHeader
  *  @brief function to encode a secureChannelRequestHeader
  *
  *
@@ -336,7 +336,7 @@ Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, Int32 *pos, T_ResponseHe
  * @param dstBuf   pointer to a structure which hold the encoded header
  * @param dstBuf   pointer to a structure which hold the encoded header
  * @return
  * @return
  */
  */
-Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf);
+Int32 encodeResponseHeader(const UA_AD_ResponseHeader *responseHeader, Int32 *pos, UA_ByteString *dstBuf);
 /**
 /**
  *
  *
  * @param diagnosticInfo
  * @param diagnosticInfo

+ 29 - 0
open62541Stack/src/opcua_builtInDatatypes.c

@@ -9,3 +9,32 @@
 #include "opcua_builtInDatatypes.h"
 #include "opcua_builtInDatatypes.h"
 
 
 
 
+Int32 UA_String_compare(UA_String *string1,UA_String *string2)
+{
+	Int32 i;
+	Boolean equal;
+
+	if(string1->Length == string2->Length &&
+	   string1->Length > 0 &&
+	   string1->Data != NULL && string2->Data != NULL)
+	{
+		for(i = 0; i < string1->Length; i++)
+		{
+			if(string1->Data[i] != string2->Data[i])
+			{
+				return UA_NOT_EQUAL;
+			}
+
+		}
+	}
+	else
+	{
+		return UA_NOT_EQUAL;
+	}
+	return UA_EQUAL;
+}
+
+Int32 UA_ByteString_compare(UA_ByteString *string1,UA_ByteString *string2)
+{
+	return UA_String_compare((UA_String*)string1,(UA_String*)string2);
+}

+ 102 - 90
open62541Stack/src/opcua_builtInDatatypes.h

@@ -15,6 +15,11 @@
 *
 *
 *
 *
 */
 */
+#define UA_NOT_EQUAL 0
+#define UA_EQUAL 1
+
+#define UA_NO_ERROR 0
+#define UA_ERROR 1
 
 
 typedef enum
 typedef enum
 {
 {
@@ -146,7 +151,7 @@ typedef double Double;
 * Chapter: 5.2.2.4
 * Chapter: 5.2.2.4
 * Page: 16
 * Page: 16
 */
 */
-typedef struct _UA_String
+typedef struct UA_String
 {
 {
 	Int32 Length;
 	Int32 Length;
 	char *Data;
 	char *Data;
@@ -162,18 +167,13 @@ UA_String;
 typedef Int64 UA_DateTime; //100 nanosecond resolution
 typedef Int64 UA_DateTime; //100 nanosecond resolution
 			      //start Date: 1601-01-01 12:00 AM
 			      //start Date: 1601-01-01 12:00 AM
 
 
-
-
-
-
-
 /*
 /*
 * ByteString
 * ByteString
 * Part: 6
 * Part: 6
 * Chapter: 5.2.2.7
 * Chapter: 5.2.2.7
 * Page: 17
 * Page: 17
 */
 */
-typedef struct _UA_ByteString
+typedef struct UA_ByteString
 {
 {
 	Int32 Length;
 	Int32 Length;
 	Byte *Data;
 	Byte *Data;
@@ -186,7 +186,7 @@ UA_ByteString;
 * Chapter: 5.2.2.6
 * Chapter: 5.2.2.6
 * Page: 17
 * Page: 17
 */
 */
-typedef struct _UA_Guid
+typedef struct UA_Guid
 {
 {
 	UInt32 Data1;
 	UInt32 Data1;
 	UInt16 Data2;
 	UInt16 Data2;
@@ -202,14 +202,14 @@ UA_Guid;
 * Page: 17
 * Page: 17
 */
 */
 //Überlegung ob man es direkt als ByteString speichert oder als String
 //Überlegung ob man es direkt als ByteString speichert oder als String
-typedef struct _UA_XmlElement
+typedef struct UA_XmlElement
 {
 {
 	UA_ByteString Data;
 	UA_ByteString Data;
 }
 }
 UA_XmlElement;
 UA_XmlElement;
 
 
 
 
-typedef struct _UA_XmlElementEncoded
+typedef struct UA_XmlElementEncoded
 {
 {
 	UInt32 Length;
 	UInt32 Length;
 	Byte StartTag[3];
 	Byte StartTag[3];
@@ -225,7 +225,7 @@ UA_XmlElementEncoded;
 * Chapter: 5.2.2.9
 * Chapter: 5.2.2.9
 * Page: 17
 * Page: 17
 */
 */
-typedef enum _UA_IdentifierType
+typedef enum UA_IdentifierType
 {
 {
 	// Some Values are called the same as previouse Enumerations so we need
 	// Some Values are called the same as previouse Enumerations so we need
 	//names that are unique
 	//names that are unique
@@ -236,7 +236,7 @@ typedef enum _UA_IdentifierType
 }
 }
 UA_IdentifierType;
 UA_IdentifierType;
 
 
-typedef enum _UA_NodeIdEncodingValuesType
+typedef enum UA_NodeIdEncodingValuesType
 {
 {
 	// Some Values are called the same as previous Enumerations so we need
 	// Some Values are called the same as previous Enumerations so we need
 	// names that are unique
 	// names that are unique
@@ -254,7 +254,7 @@ UA_NodeIdEncodingValuesType;
 /**
 /**
 * NodeId
 * NodeId
 */
 */
-typedef struct _UA_NodeId
+typedef struct UA_NodeId
 {
 {
 	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
 	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
 	UInt16 Namespace;
 	UInt16 Namespace;
@@ -278,7 +278,7 @@ UA_NodeId;
 * Chapter: 5.2.2.10
 * Chapter: 5.2.2.10
 * Page: 19
 * Page: 19
 */
 */
-typedef struct _UA_ExpandedNodeId
+typedef struct UA_ExpandedNodeId
 {
 {
 	UA_NodeId NodeId;
 	UA_NodeId NodeId;
 	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
 	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
@@ -303,7 +303,7 @@ typedef UInt32 UA_StatusCode;
 * Chapter: 5.2.2.12
 * Chapter: 5.2.2.12
 * Page: 20
 * Page: 20
 */
 */
-typedef struct _UA_DiagnosticInfo
+typedef struct UA_DiagnosticInfo
 {
 {
 	Byte EncodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
 	Byte EncodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
 	Int32 SymbolicId;
 	Int32 SymbolicId;
@@ -316,9 +316,9 @@ typedef struct _UA_DiagnosticInfo
 }
 }
 UA_DiagnosticInfo;
 UA_DiagnosticInfo;
 
 
-typedef enum _UA_DiagnosticInfoEncodingMaskType
+typedef enum UA_DiagnosticInfoEncodingMaskType
 {
 {
-	// Some Values are called the same as previouse Enumerations so we need
+	// Some Values are called the same as previous Enumerations so we need
 	//names that are unique
 	//names that are unique
 	DIEMT_SYMBOLIC_ID = 			0x01,
 	DIEMT_SYMBOLIC_ID = 			0x01,
 	DIEMT_NAMESPACE = 				0x02,
 	DIEMT_NAMESPACE = 				0x02,
@@ -330,14 +330,13 @@ typedef enum _UA_DiagnosticInfoEncodingMaskType
 }
 }
 UA_DiagnosticInfoEncodingMaskType;
 UA_DiagnosticInfoEncodingMaskType;
 
 
-
 /**
 /**
 * QualifiedNameBinaryEncoding
 * QualifiedNameBinaryEncoding
 * Part: 6
 * Part: 6
 * Chapter: 5.2.2.13
 * Chapter: 5.2.2.13
 * Page: 20
 * Page: 20
 */
 */
-typedef struct _UA_QualifiedName
+typedef struct UA_QualifiedName
 {
 {
 	UInt16 NamespaceIndex;
 	UInt16 NamespaceIndex;
 	UInt16 Reserved;
 	UInt16 Reserved;
@@ -352,7 +351,7 @@ UA_QualifiedName;
 * Chapter: 5.2.2.14
 * Chapter: 5.2.2.14
 * Page: 21
 * Page: 21
 */
 */
-typedef struct _UA_LocalizedText
+typedef struct UA_LocalizedText
 {
 {
 	Byte EncodingMask;
 	Byte EncodingMask;
 	UA_String Locale;
 	UA_String Locale;
@@ -360,21 +359,20 @@ typedef struct _UA_LocalizedText
 }
 }
 UA_LocalizedText;
 UA_LocalizedText;
 
 
-typedef enum _UA_LocalizedTextEncodingMaskType
+typedef enum UA_LocalizedTextEncodingMaskType
 {
 {
 	LTEMT_SYMBOLIC_ID = 0x01,
 	LTEMT_SYMBOLIC_ID = 0x01,
 	LTEMT_NAMESPACE = 	0x02
 	LTEMT_NAMESPACE = 	0x02
 }
 }
 UA_LocalizedTextEncodingMaskType;
 UA_LocalizedTextEncodingMaskType;
 
 
-
 /**
 /**
 * ExtensionObjectBinaryEncoding
 * ExtensionObjectBinaryEncoding
 * Part: 6
 * Part: 6
 * Chapter: 5.2.2.15
 * Chapter: 5.2.2.15
 * Page: 21
 * Page: 21
 */
 */
-typedef struct _UA_ExtensionObject
+typedef struct UA_ExtensionObject
 {
 {
 	UA_NodeId TypeId;
 	UA_NodeId TypeId;
 	Byte Encoding; //Type of the Enum UA_ExtensionObjectEncodingMaskType
 	Byte Encoding; //Type of the Enum UA_ExtensionObjectEncodingMaskType
@@ -383,7 +381,7 @@ typedef struct _UA_ExtensionObject
 }
 }
 UA_ExtensionObject;
 UA_ExtensionObject;
 
 
-typedef enum _UA_ExtensionObjectEncodingMaskType
+typedef enum UA_ExtensionObjectEncodingMaskType
 {
 {
 	NO_BODY_IS_ENCODED = 	0x00,
 	NO_BODY_IS_ENCODED = 	0x00,
 	BODY_IS_BYTE_STRING = 	0x01,
 	BODY_IS_BYTE_STRING = 	0x01,
@@ -391,24 +389,46 @@ typedef enum _UA_ExtensionObjectEncodingMaskType
 }
 }
 UA_ExtensionObjectEncodingMaskType;
 UA_ExtensionObjectEncodingMaskType;
 
 
-
+typedef UA_VariantUnion;
 /**
 /**
 * VariantBinaryEncoding
 * VariantBinaryEncoding
 * Part: 6
 * Part: 6
 * Chapter: 5.2.2.16
 * Chapter: 5.2.2.16
 * Page: 22
 * Page: 22
 */
 */
-struct _UA_DataValue;
+typedef struct UA_Variant
-struct _UA_Variant;
+{
+	Byte EncodingMask; //Type of Enum UA_VariantTypeEncodingMaskType
+	Int32 ArrayLength;
+	UA_VariantUnion *Value;
+}
+UA_Variant;
 
 
+/**
+* DataValueBinaryEncoding
+* Part: 6
+* Chapter: 5.2.2.17
+* Page: 23
+*/
+typedef struct UA_DataValue
+{
+	Byte EncodingMask;
+	UA_Variant Value;
+	UA_StatusCode Status;
+	UA_DateTime SourceTimestamp;
+	Int16 SourcePicoseconds;
+	UA_DateTime ServerTimestamp;
+	Int16 ServerPicoseconds;
+}
+UA_DataValue;
 
 
-typedef struct
+typedef struct IntegerString
 {
 {
 	Int32 *data;
 	Int32 *data;
 	Int32 length;
 	Int32 length;
 }IntegerString;
 }IntegerString;
 
 
-typedef struct
+typedef struct Int32_Array
 {
 {
 	Int32 *data;
 	Int32 *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -417,14 +437,14 @@ typedef struct
 
 
 
 
 // Array types of builtInDatatypes
 // Array types of builtInDatatypes
-typedef struct
+typedef struct SBYte_Array
 {
 {
 	SByte *data;
 	SByte *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString dimensions;
 	IntegerString dimensions;
 }SBYte_Array;
 }SBYte_Array;
 
 
-typedef struct
+typedef struct Boolean_Array
 {
 {
 	Boolean *data;
 	Boolean *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -438,21 +458,21 @@ typedef struct
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }SByte_Array;
 }SByte_Array;
 
 
-typedef struct
+typedef struct Byte_Array
 {
 {
 	Byte *data;
 	Byte *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Byte_Array;
 }Byte_Array;
 
 
-typedef struct
+typedef struct Int16_Array
 {
 {
 	Int16 *data;
 	Int16 *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Int16_Array;
 }Int16_Array;
 
 
-typedef struct
+typedef struct UInt16_Array
 {
 {
 	UInt16 *data;
 	UInt16 *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -460,7 +480,7 @@ typedef struct
 }UInt16_Array;
 }UInt16_Array;
 
 
 
 
-typedef struct
+typedef struct UInt32_Array
 {
 {
 	UInt32 *data;
 	UInt32 *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -474,69 +494,70 @@ typedef struct
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Int64_Array;
 }Int64_Array;
 
 
-typedef struct
+typedef struct UInt64_Array
 {
 {
 	UInt64 *data;
 	UInt64 *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }UInt64_Array;
 }UInt64_Array;
-typedef struct
+
+typedef struct Float_Array
 {
 {
 	Float *data;
 	Float *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Float_Array;
 }Float_Array;
 
 
-typedef struct
+typedef struct Double_Array
 {
 {
 	Double *data;
 	Double *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Double_Array;
 }Double_Array;
 
 
-typedef struct
+typedef struct String_Array
 {
 {
 	UA_String *data;
 	UA_String *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }String_Array;
 }String_Array;
 
 
-typedef struct
+typedef struct DateTime_Array
 {
 {
 	UA_DateTime *data;
 	UA_DateTime *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }DateTime_Array;
 }DateTime_Array;
 
 
-typedef struct
+typedef struct Guid_Array
 {
 {
 	UA_Guid *data;
 	UA_Guid *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Guid_Array;
 }Guid_Array;
 
 
-typedef struct
+typedef struct ByteString_Array
 {
 {
 	UA_ByteString *data;
 	UA_ByteString *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }ByteString_Array;
 }ByteString_Array;
 
 
-typedef struct
+typedef struct XmlElement_Array
 {
 {
 	UA_XmlElement *data;
 	UA_XmlElement *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }XmlElement_Array;
 }XmlElement_Array;
 
 
-typedef struct
+typedef struct NodeId_Array
 {
 {
 	UA_NodeId *data;
 	UA_NodeId *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }NodeId_Array;
 }NodeId_Array;
 
 
-typedef struct
+typedef struct ExpandedNodeId_Array
 {
 {
 	UA_ExpandedNodeId *data;
 	UA_ExpandedNodeId *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -544,28 +565,28 @@ typedef struct
 }ExpandedNodeId_Array;
 }ExpandedNodeId_Array;
 
 
 
 
-typedef struct
+typedef struct StatusCode_Array
 {
 {
 	UA_StatusCode *data;
 	UA_StatusCode *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }StatusCode_Array;
 }StatusCode_Array;
 
 
-typedef struct
+typedef struct QualifiedName_Array
 {
 {
 	UA_QualifiedName *data;
 	UA_QualifiedName *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }QualifiedName_Array;
 }QualifiedName_Array;
 
 
-typedef struct
+typedef struct LocalizedText_Array
 {
 {
 	UA_LocalizedText *data;
 	UA_LocalizedText *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }LocalizedText_Array;
 }LocalizedText_Array;
 
 
-typedef struct
+typedef struct ExtensionObject_Array
 {
 {
 	UA_ExtensionObject *data;
 	UA_ExtensionObject *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -579,14 +600,14 @@ typedef struct
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }DataValue_Array;
 }DataValue_Array;
 
 
-typedef struct
+typedef struct Variant_Array
 {
 {
 	struct UA_Variant *data;
 	struct UA_Variant *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
 	IntegerString  dimensions;
 	IntegerString  dimensions;
 }Variant_Array;
 }Variant_Array;
 
 
-typedef struct
+typedef struct DiagnosticInfo_Array
 {
 {
 	UA_DiagnosticInfo *data;
 	UA_DiagnosticInfo *data;
 	Int32 arrayLength;
 	Int32 arrayLength;
@@ -594,7 +615,7 @@ typedef struct
 }DiagnosticInfo_Array;
 }DiagnosticInfo_Array;
 
 
 
 
-typedef union _UA_VariantArrayUnion
+typedef union UA_VariantArrayUnion
 {
 {
     void*         Array;
     void*         Array;
     Boolean_Array BooleanArray;
     Boolean_Array BooleanArray;
@@ -624,7 +645,8 @@ typedef union _UA_VariantArrayUnion
 }
 }
 UA_VariantArrayUnion;
 UA_VariantArrayUnion;
 
 
-typedef struct _UA_VariantArrayValue
+
+typedef struct UA_VariantArrayValue
 {
 {
 	//Byte TypeEncoding;
 	//Byte TypeEncoding;
     Int32  Length;
     Int32  Length;
@@ -632,7 +654,7 @@ typedef struct _UA_VariantArrayValue
 }
 }
 UA_VariantArrayValue;
 UA_VariantArrayValue;
 
 
-typedef struct _UA_VariantMatrixValue
+typedef struct
 {
 {
     Int32 NoOfDimensions;
     Int32 NoOfDimensions;
     Int32* Dimensions;
     Int32* Dimensions;
@@ -640,7 +662,7 @@ typedef struct _UA_VariantMatrixValue
 }
 }
 UA_VariantMatrixValue;
 UA_VariantMatrixValue;
 
 
-typedef union _UA_VariantUnion
+union UA_VariantUnion
 {
 {
     Boolean Boolean;
     Boolean Boolean;
     SByte SByte;
     SByte SByte;
@@ -655,30 +677,23 @@ typedef union _UA_VariantUnion
     Double Double;
     Double Double;
     UA_DateTime DateTime;
     UA_DateTime DateTime;
     UA_String String;
     UA_String String;
-    UA_Guid* Guid;
+    UA_Guid *Guid;
     UA_ByteString ByteString;
     UA_ByteString ByteString;
     UA_XmlElement XmlElement;
     UA_XmlElement XmlElement;
-    UA_NodeId* NodeId;
+    UA_NodeId *NodeId;
-    UA_ExpandedNodeId* ExpandedNodeId;
+    UA_ExpandedNodeId *ExpandedNodeId;
     UA_StatusCode StatusCode;
     UA_StatusCode StatusCode;
-    UA_QualifiedName* QualifiedName;
+    UA_QualifiedName *QualifiedName;
-    UA_LocalizedText* LocalizedText;
+    UA_LocalizedText *LocalizedText;
-    UA_ExtensionObject* ExtensionObject;
+    UA_ExtensionObject *ExtensionObject;
-    struct _UA_DataValue* DataValue;
+    UA_DataValue *DataValue;
     UA_VariantArrayValue  Array;
     UA_VariantArrayValue  Array;
     UA_VariantMatrixValue Matrix;
     UA_VariantMatrixValue Matrix;
-}
+};
-UA_VariantUnion;
 
 
-typedef struct _UA_Variant
-{
-	Byte EncodingMask; //Type of Enum UA_VariantTypeEncodingMaskType
-	Int32 ArrayLength;
-	UA_VariantUnion *Value;
-}
-UA_Variant;
 
 
-typedef enum _UA_VariantTypeEncodingMaskType
+
+typedef enum UA_VariantTypeEncodingMaskType
 {
 {
 	//Bytes 0:5	HEX 0x00 - 0x20
 	//Bytes 0:5	HEX 0x00 - 0x20
 	VTEMT_BOOLEAN = 			1,
 	VTEMT_BOOLEAN = 			1,
@@ -714,23 +729,7 @@ typedef enum _UA_VariantTypeEncodingMaskType
 UA_VariantTypeEncodingMaskType;
 UA_VariantTypeEncodingMaskType;
 
 
 
 
-/**
+
-* DataValueBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.17
-* Page: 23
-*/
-typedef struct _UA_DataValue
-{
-	Byte EncodingMask;
-	UA_Variant Value;
-	UA_StatusCode Status;
-	UA_DateTime SourceTimestamp;
-	Int16 SourcePicoseconds;
-	UA_DateTime ServerTimestamp;
-	Int16 ServerPicoseconds;
-}
-UA_DataValue;
 
 
 typedef UInt32 IntegerId;
 typedef UInt32 IntegerId;
 
 
@@ -743,6 +742,19 @@ typedef UInt32 IntegerId;
 */
 */
 typedef double UA_Duration;
 typedef double UA_Duration;
 
 
-
+/**
+ *
+ * @param string1
+ * @param string2
+ * @return
+ */
+Int32 UA_String_compare(UA_String *string1, UA_String *string2);
+/**
+ *
+ * @param string1
+ * @param string2
+ * @return
+ */
+Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2);
 
 
 #endif /* OPCUA_BUILTINDATATYPES_H_ */
 #endif /* OPCUA_BUILTINDATATYPES_H_ */

+ 17 - 10
open62541Stack/src/opcua_connectionHelper.h

@@ -12,12 +12,12 @@
 
 
 enum packetType
 enum packetType
 {
 {
-	packetType_HEL,
+	packetType_HEL = 1,
-	packetType_ACK,
+	packetType_ACK = 2,
-	packetType_ERR,
+	packetType_ERR = 3,
-	packetType_OPN,
+	packetType_OPN = 4,
-	packetType_MSG,
+	packetType_MSG = 5,
-	packetType_CLO
+	packetType_CLO = 6
 };
 };
 enum connectionState
 enum connectionState
 {
 {
@@ -37,10 +37,9 @@ typedef struct
 
 
 typedef struct
 typedef struct
 {
 {
-	UInt32 recvBufferSize;
-	UInt32 sendBufferSize;
-
 	UInt32 protocolVersion;
 	UInt32 protocolVersion;
+	UInt32 sendBufferSize;
+	UInt32 recvBufferSize;
 	UInt32 maxMessageSize;
 	UInt32 maxMessageSize;
 	UInt32 maxChunkCount;
 	UInt32 maxChunkCount;
 }TL_buffer;
 }TL_buffer;
@@ -58,7 +57,10 @@ struct TL_connection
 struct SL_connection
 struct SL_connection
 {
 {
 
 
-	T_ApplicationInstanceCertificate clientCertificate;
+	UA_ByteString SecurityPolicyUri;
+	UA_ByteString SenderCertificate;
+	UA_ByteString ReceiverCertificateThumbprint;
+	UInt32 sequenceNumber;
 	UInt32 requestType;
 	UInt32 requestType;
 	UA_String secureChannelId;
 	UA_String secureChannelId;
 	UInt32 UInt32_secureChannelId;
 	UInt32 UInt32_secureChannelId;
@@ -79,6 +81,11 @@ typedef struct
 	struct TL_connection transportLayer;
 	struct TL_connection transportLayer;
 	struct SL_connection secureLayer;
 	struct SL_connection secureLayer;
 	struct SS_connection serviceLayer;
 	struct SS_connection serviceLayer;
+
+	Boolean newDataToRead;
+	UA_ByteString readData;
+	Boolean newDataToWrite;
+	UA_ByteString writeData;
 }UA_connection;
 }UA_connection;
 
 
 
 

+ 1 - 0
open62541Stack/src/opcua_memory.c

@@ -8,6 +8,7 @@
 #include "opcua_memory.h"
 #include "opcua_memory.h"
 void *opcua_malloc(size_t size)
 void *opcua_malloc(size_t size)
 {
 {
+
 	return malloc(size);
 	return malloc(size);
 }
 }
 
 

+ 189 - 31
open62541Stack/src/opcua_secureChannelLayer.c

@@ -5,7 +5,7 @@
  *      Author: opcua
  *      Author: opcua
  */
  */
 #include "opcua_secureChannelLayer.h"
 #include "opcua_secureChannelLayer.h"
-
+#include <stdio.h>
 
 
 
 
 
 
@@ -13,13 +13,13 @@
  * opens a secureChannel (server side)
  * opens a secureChannel (server side)
  */
  */
 Int32 SL_secureChannel_open(const UA_connection *connection,
 Int32 SL_secureChannel_open(const UA_connection *connection,
-		const AD_RawMessage *secureChannelMessage,
+		const AD_RawMessage *secureChannelPacket,
 		const SL_SecureConversationMessageHeader *SCMHeader,
 		const SL_SecureConversationMessageHeader *SCMHeader,
 		const SL_AsymmetricAlgorithmSecurityHeader *AASHeader,
 		const SL_AsymmetricAlgorithmSecurityHeader *AASHeader,
 		const SL_SequenceHeader *SequenceHeader)
 		const SL_SequenceHeader *SequenceHeader)
 {
 {
 
 
-	T_ResponseHeader responseHeader;
+	UA_AD_ResponseHeader responseHeader;
 	AD_RawMessage rawMessage;
 	AD_RawMessage rawMessage;
 	Int32 position = 0;
 	Int32 position = 0;
 	//SL_secureChannel_ResponseHeader_get(connection,&responseHeader);
 	//SL_secureChannel_ResponseHeader_get(connection,&responseHeader);
@@ -37,7 +37,7 @@ Int32 SL_openSecureChannel_responseMessage_get(UA_connection *connection,SL_Resp
 {
 {
 
 
 	response->ServerNonce.Length =0; // TODO set a valid value for the Server Nonce
 	response->ServerNonce.Length =0; // TODO set a valid value for the Server Nonce
-	response->ServerProtocolVersion = UA_PROTOCOL_VERSION; //
+	response->ServerProtocolVersion = 0; //
 	response->SecurityToken.createdAt = opcua_getTime(); //
 	response->SecurityToken.createdAt = opcua_getTime(); //
 	response->SecurityToken.revisedLifetime = 300000; //TODO set Lifetime of Security Token
 	response->SecurityToken.revisedLifetime = 300000; //TODO set Lifetime of Security Token
 	response->SecurityToken.secureChannelId = connection->secureLayer.UInt32_secureChannelId; //TODO set a valid value for secureChannel id
 	response->SecurityToken.secureChannelId = connection->secureLayer.UInt32_secureChannelId; //TODO set a valid value for secureChannel id
@@ -60,41 +60,202 @@ void SL_secureChannel_close(UA_connection *connection)
 {
 {
 
 
 }
 }
+Int32 SL_check(UA_connection *connection,UA_ByteString secureChannelPacket)
+{
+	return UA_NO_ERROR;
+}
+Int32 SL_createSecurityToken(UA_connection *connection, Int32 lifeTime)
+{
+	return UA_NO_ERROR;
+}
+
+
 
 
+Int32 SL_processMessage(UA_connection *connection, UA_ByteString message)
+{
+	Int32 pos = 0;
+	UA_AD_RequestHeader requestHeader;
+	UInt32 clientProtocolVersion;
+	UA_NodeId ServiceRequestType;
+	Int32 requestType;
+	Int32 securityMode;
+	Int32 requestedLifetime;
+	decoder_decodeBuiltInDatatype(message,NODE_ID,&pos,ServiceRequestType);
+
+	if(ServiceRequestType.EncodingByte == NIEVT_FOUR_BYTE)
+	{
+		if(ServiceRequestType.Identifier.Numeric == 446) // OpensecureChannelRequest
+		{
+			decodeRequestHeader(message, &pos, requestHeader);
+			decoder_decodeBuiltInDatatype(message.Data,UINT32, &pos, &clientProtocolVersion);
+
+			if(clientProtocolVersion != connection->transportLayer.remoteConf.protocolVersion)
+			{
+				printf("SL_processMessage - error protocol version \n");
+				//TODO error protocol version
+				//TODO ERROR_Bad_ProtocolVersionUnsupported
+
+			}
+			//securityTokenRequestType
+			decoder_decodeBuiltInDatatype(message,INT32,&pos,requestType);
+			switch(requestType)
+			{
+			case securityToken_ISSUE:
+				if(connection->secureLayer.connectionState == connectionState_ESTABLISHED)
+				{
+					printf("SL_processMessage - multiply security token request");
+					//TODO return ERROR
+					return UA_ERROR;
+				}
+			//	SL_createNewToken(connection);
+				break;
+			case securityToken_RENEW:
+				if(connection->secureLayer.connectionState == connectionState_CLOSED)
+				{
+					printf("SL_processMessage - renew token request received, but no secureChannel was established before");
+					//TODO return ERROR
+					return UA_ERROR;
+				}
+				break;
+			}
+			//securityMode
+			decoder_decodeBuiltInDatatype(message,INT32,&pos,&securityMode);
+			switch(securityMode)
+			{
+			case securityMode_INVALID:
+				connection->secureLayer.clientNonce.Data = NULL;
+				connection->secureLayer.clientNonce.Length = 0;
+				printf("SL_processMessage - client demands no security \n");
+				break;
+			case securityMode_SIGN:
+				//TODO check if senderCertificate and ReceiverCertificateThumbprint are present
+				break;
+
+			case securityMode_SIGNANDENCRYPT:
+				//TODO check if senderCertificate and ReceiverCertificateThumbprint are present
+				break;
+			}
+			decoder_decodeBuiltInDatatype(message,INT32,&pos,&requestedLifetime);
+			//TODO process requestedLifetime
+		}
+		else
+		{
+			printf("SL_processMessage - unknown service request");
+			//TODO change error code
+			return UA_ERROR;
+
+		}
+	}
+	return UA_NO_ERROR;
+}
 /*
 /*
  * receive and process data from underlying layer
  * receive and process data from underlying layer
  */
  */
-void SL_receive(UA_connection *connection, AD_RawMessage *serviceMessage)
+void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage)
 {
 {
-	AD_RawMessage* secureChannelMessage;
+	UA_ByteString secureChannelPacket;
+	UA_ByteString message;
 	SL_SecureConversationMessageHeader SCM_Header;
 	SL_SecureConversationMessageHeader SCM_Header;
 	SL_AsymmetricAlgorithmSecurityHeader AAS_Header;
 	SL_AsymmetricAlgorithmSecurityHeader AAS_Header;
 	SL_SequenceHeader SequenceHeader;
 	SL_SequenceHeader SequenceHeader;
-
+	Int32 packetType = 0;
+	Int32 pos = 0;
+	Int32 iTmp;
 	//TODO Error Handling, length checking
 	//TODO Error Handling, length checking
 	//get data from transport layer
 	//get data from transport layer
+	printf("SL_receive - entered \n");
+
+	TL_receive(connection, &secureChannelPacket);
+
+	if(secureChannelPacket.Length > 0 && secureChannelPacket.Data != NULL)
+	{
+
+
+		printf("SL_receive - data received \n");
+		packetType = TL_getPacketType(&secureChannelPacket, &pos);
 
 
-	TL_receive(connection, secureChannelMessage);
+		decodeSCMHeader(&secureChannelPacket,&pos,&SCM_Header);
 
 
+		switch(SCM_Header.MessageType)
+		{
+
+		case packetType_OPN : /* openSecureChannel Message received */
+
+				decodeAASHeader(&secureChannelPacket,&pos,&AAS_Header);
+				if(SCM_Header.SecureChannelId != 0)
+				{
+
+					iTmp = UA_ByteString_compare(&(connection->secureLayer.SenderCertificate), &(AAS_Header.SenderCertificate));
+					if(iTmp != UA_EQUAL)
+					{
+						printf("SL_receive - UA_ERROR_BadSecureChannelUnknown \n");
+						//TODO return UA_ERROR_BadSecureChannelUnknown
+					}
+
+				}
+
+				decodeSequenceHeader(&secureChannelPacket,&pos,&SequenceHeader);
+				//TODO check that the sequence number is smaller than MaxUInt32 - 1024
+				connection->secureLayer.sequenceNumber = SequenceHeader.SequenceNumber;
+
+				//SL_decrypt(&secureChannelPacket);
+
+				message.Data = secureChannelPacket.Data[pos];
+				message.Length = secureChannelPacket.Length - pos;
+
+				SL_processMessage(connection, message);
+
+			break;
+		case packetType_MSG : /* secure Channel Message received */
+			if(connection->secureLayer.connectionState == connectionState_ESTABLISHED)
+			{
+
+				if(SCM_Header.SecureChannelId == connection->secureLayer.UInt32_secureChannelId)
+				{
+
+				}
+				else
+				{
+					//TODO generate ERROR_Bad_SecureChannelUnkown
+				}
+			}
+
+			break;
+		case packetType_CLO : /* closeSecureChannel Message received */
+			if(SL_check(connection,secureChannelPacket) == UA_NO_ERROR)
+			{
+
+			}
+			break;
+		}
+
+
+
+	}
+	else
+	{
+		printf("SL_receive - no data received \n");
+	}
+	/*
 	Int32 readPosition = 0;
 	Int32 readPosition = 0;
 
 
 	//get the Secure Channel Message Header
 	//get the Secure Channel Message Header
-	decodeSCMHeader(secureChannelMessage,
+	decodeSCMHeader(secureChannelPacket,
 			&readPosition, &SCM_Header);
 			&readPosition, &SCM_Header);
 
 
 	//get the Secure Channel Asymmetric Algorithm Security Header
 	//get the Secure Channel Asymmetric Algorithm Security Header
-	decodeAASHeader(secureChannelMessage,
+	decodeAASHeader(secureChannelPacket,
 			&readPosition, &AAS_Header);
 			&readPosition, &AAS_Header);
 
 
 	//get the Sequence Header
 	//get the Sequence Header
-	decodeSequenceHeader(secureChannelMessage,
+	decodeSequenceHeader(secureChannelPacket,
 			&readPosition, &SequenceHeader);
 			&readPosition, &SequenceHeader);
 
 
 	//get Secure Channel Message
 	//get Secure Channel Message
-	//SL_secureChannel_Message_get(connection, secureChannelMessage,
+	//SL_secureChannel_Message_get(connection, secureChannelPacket,
 //			&readPosition,serviceMessage);
 //			&readPosition,serviceMessage);
 
 
-	if (secureChannelMessage->length > 0)
+	if (secureChannelPacket->length > 0)
 	{
 	{
 		switch (SCM_Header.MessageType)
 		switch (SCM_Header.MessageType)
 		{
 		{
@@ -111,10 +272,10 @@ void SL_receive(UA_connection *connection, AD_RawMessage *serviceMessage)
 			break;
 			break;
 		case packetType_OPN:
 		case packetType_OPN:
 			//Server Handling
 			//Server Handling
-	//		if (openSecureChannelHeader_check(connection, secureChannelMessage))
+	//		if (openSecureChannelHeader_check(connection, secureChannelPacket))
 	//		{
 	//		{
 				//check if the request is valid
 				//check if the request is valid
-			//	SL_openSecureChannelRequest_check(connection, secureChannelMessage);
+			//	SL_openSecureChannelRequest_check(connection, secureChannelPacket);
 	//		}
 	//		}
 	//		else
 	//		else
 	//		{
 	//		{
@@ -122,28 +283,29 @@ void SL_receive(UA_connection *connection, AD_RawMessage *serviceMessage)
 	//		}
 	//		}
 		//Client Handling
 		//Client Handling
 
 
-		//TODO free memory for secureChannelMessage
+		//TODO free memory for secureChannelPacket
 
 
 		break;
 		break;
 		case packetType_CLO:
 		case packetType_CLO:
 
 
 
 
-		//TODO free memory for secureChannelMessage
+		//TODO free memory for secureChannelPacket
 		break;
 		break;
 		}
 		}
 
 
 	}
 	}
-
+*/
 }
 }
 /*
 /*
  * get the secure channel message header
  * get the secure channel message header
  */
  */
-Int32 decodeSCMHeader(AD_RawMessage *rawMessage,Int32 *pos,
+Int32 decodeSCMHeader(UA_ByteString *rawMessage,Int32 *pos,
 		SL_SecureConversationMessageHeader* SC_Header)
 		SL_SecureConversationMessageHeader* SC_Header)
 {
 {
+	printf("decodeSCMHeader - entered \n");
 	SC_Header->MessageType = TL_getPacketType(rawMessage);
 	SC_Header->MessageType = TL_getPacketType(rawMessage);
 	*pos += 3;//TL_MESSAGE_TYPE_LEN;
 	*pos += 3;//TL_MESSAGE_TYPE_LEN;
-	SC_Header->IsFinal = rawMessage->message[*pos];
+	SC_Header->IsFinal = rawMessage->Data[*pos];
 	SC_Header->MessageSize = decodeUInt32(rawMessage, *pos);
 	SC_Header->MessageSize = decodeUInt32(rawMessage, *pos);
 	SC_Header->SecureChannelId = decodeUInt32(rawMessage, *pos);
 	SC_Header->SecureChannelId = decodeUInt32(rawMessage, *pos);
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
@@ -181,11 +343,11 @@ Int32 encodeSCMHeader(SL_SecureConversationMessageHeader *SC_Header,
 
 
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
-Int32 decodeSequenceHeader(AD_RawMessage *rawMessage, Int32 *pos,
+Int32 decodeSequenceHeader(UA_ByteString *rawMessage, Int32 *pos,
 		SL_SequenceHeader *SequenceHeader)
 		SL_SequenceHeader *SequenceHeader)
 {
 {
-	SequenceHeader->RequestId = decodeUInt32(rawMessage->message, pos);
+	SequenceHeader->RequestId = decodeUInt32(rawMessage->Data, pos);
-	SequenceHeader->SequenceNumber = decodeUInt32(rawMessage->message, pos);
+	SequenceHeader->SequenceNumber = decodeUInt32(rawMessage->Data, pos);
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
 Int32 encodeSequenceHeader(SL_SequenceHeader *sequenceHeader,Int32 *pos,
 Int32 encodeSequenceHeader(SL_SequenceHeader *sequenceHeader,Int32 *pos,
@@ -197,13 +359,13 @@ Int32 encodeSequenceHeader(SL_SequenceHeader *sequenceHeader,Int32 *pos,
 /*
 /*
  * get the asymmetric algorithm security header
  * get the asymmetric algorithm security header
  */
  */
-Int32 decodeAASHeader(AD_RawMessage *rawMessage, Int32 *pos,
+Int32 decodeAASHeader(UA_ByteString *rawMessage, Int32 *pos,
 	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header)
 	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header)
 {
 {
 	Int32 err = 0;
 	Int32 err = 0;
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->SecurityPolicyUri);
+	err += decodeUAByteString(rawMessage->Data,pos,AAS_Header->SecurityPolicyUri);
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->SenderCertificate);
+	err += decodeUAByteString(rawMessage->Data,pos,AAS_Header->SenderCertificate);
-	err += decodeUAByteString(rawMessage->message,pos,AAS_Header->ReceiverThumbprint);
+	err += decodeUAByteString(rawMessage->Data,pos,AAS_Header->ReceiverThumbprint);
 	return err;
 	return err;
 }
 }
 Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
 Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
@@ -215,7 +377,3 @@ Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
 
 
-void SL_secureChannel_Footer_get()
-{
-
-}

+ 20 - 3
open62541Stack/src/opcua_secureChannelLayer.h

@@ -14,8 +14,19 @@
 
 
 static const Int32 SL_HEADER_LENGTH = 0;
 static const Int32 SL_HEADER_LENGTH = 0;
 
 
+typedef enum
+{
+	securityToken_ISSUE = 0,
+	securityToken_RENEW = 1
+}SecurityTokenRequestType;
 
 
+typedef enum
+{
+	securityMode_INVALID = 0,
+	securityMode_SIGN = 1,
+	securityMode_SIGNANDENCRYPT = 2
 
 
+}securityMode;
 typedef struct
 typedef struct
 {
 {
 	UInt32 ServerProtocolVersion;
 	UInt32 ServerProtocolVersion;
@@ -81,7 +92,7 @@ Int32 SL_openSecureChannel_responseMessage_get(UA_connection *connection,
  * @param SC_Header
  * @param SC_Header
  * @return
  * @return
  */
  */
-Int32 decodeSCMHeader(AD_RawMessage *rawMessage,Int32 *pos,
+Int32 decodeSCMHeader(UA_ByteString *rawMessage,Int32 *pos,
 		SL_SecureConversationMessageHeader* SC_Header);
 		SL_SecureConversationMessageHeader* SC_Header);
 
 
 /**
 /**
@@ -101,7 +112,7 @@ Int32 encodeSCMHeader(SL_SecureConversationMessageHeader *SC_Header,
  * @param SequenceHeader
  * @param SequenceHeader
  * @return
  * @return
  */
  */
-Int32 decodeSequenceHeader(AD_RawMessage *rawMessage, Int32 *pos,
+Int32 decodeSequenceHeader(UA_ByteString *rawMessage, Int32 *pos,
 		SL_SequenceHeader *sequenceHeader);
 		SL_SequenceHeader *sequenceHeader);
 /**
 /**
  *
  *
@@ -119,7 +130,7 @@ Int32 encodeSequenceHeader(SL_SequenceHeader *sequenceHeader,Int32 *pos,
  * @param AAS_Header
  * @param AAS_Header
  * @return
  * @return
  */
  */
-Int32 decodeAASHeader(AD_RawMessage *rawMessage, Int32 *pos,
+Int32 decodeAASHeader(UA_ByteString *rawMessage, Int32 *pos,
 	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header);
 	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header);
 
 
 /**
 /**
@@ -132,5 +143,11 @@ Int32 decodeAASHeader(AD_RawMessage *rawMessage, Int32 *pos,
 Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
 Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
 		Int32 *pos, AD_RawMessage* dstRawMessage);
 		Int32 *pos, AD_RawMessage* dstRawMessage);
 
 
+/**
+ *
+ * @param connection
+ * @param serviceMessage
+ */
+void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage);
 
 
 #endif /* OPCUA_SECURECHANNELLAYER_H_ */
 #endif /* OPCUA_SECURECHANNELLAYER_H_ */

+ 185 - 147
open62541Stack/src/opcua_transportLayer.c

@@ -8,100 +8,102 @@
 #include "opcua_transportLayer.h"
 #include "opcua_transportLayer.h"
 
 
 
 
-
+Int32 TL_initConnectionObject(UA_connection *connection)
-/*
- * server answer to open message
- */
-void TL_open(UA_connection *connection, AD_RawMessage *rawMessage)
 {
 {
-	UA_connection tmpConnection;
-	switch(connection->transportLayer.connectionState)
-	{
-		connectionState_CLOSED :
-		{
-			//process the connection values received by the client
-			TL_processHELMessage(&tmpConnection,rawMessage);
-			connection->transportLayer.localConf.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
-
-			connection->transportLayer.localConf.recvBufferSize =
-					tmpConnection.transportLayer.localConf.recvBufferSize;
-
-			connection->transportLayer.localConf.sendBufferSize =
-					tmpConnection.transportLayer.localConf.sendBufferSize;
-
-			connection->transportLayer.localConf.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
-			connection->transportLayer.localConf.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
-
-		    TL_sendACK(connection);
-			connection->transportLayer.connectionState = connectionState_ESTABLISHED;
-			break;
-		}
-		connectionState_OPENING :
-		{
-		//	TL_sendACK(connection);
-		//	connection->transportLayer.connectionState = connectionState_ESTABLISHED;
-			break;
-		}
-		connectionState_ESTABLISHED :
-		{
 
 
-			break;
+	connection->newDataToRead = 0;
-		}
+	connection->readData.Data = NULL;
-	}
+	connection->readData.Length = 0;
+	connection->transportLayer.connectionState = connectionState_CLOSED;
+	connection->transportLayer.localConf.maxChunkCount = 1;
+	connection->transportLayer.localConf.maxMessageSize = 16384;
+	connection->transportLayer.localConf.sendBufferSize = 8192;
+	connection->transportLayer.localConf.recvBufferSize = 8192;
+	return UA_NO_ERROR;
 }
 }
 
 
-Int32 TL_check(UA_connection *connection, AD_RawMessage *TL_messsage)
+Int32 TL_check(UA_connection *connection)
 {
 {
 	Int32 position = 4;
 	Int32 position = 4;
 	UInt32 messageLength = 0;
 	UInt32 messageLength = 0;
-	Int32 pos = 0;
-	TL_getPacketType(&pos,TL_messsage);
-	decoder_decodeBuiltInDatatype(TL_messsage->message,UINT32,&position,&messageLength);
 
 
-	if (messageLength == TL_messsage->length &&
+
+	printf("TL_check - entered \n");
+
+
+	decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,&position,&messageLength);
+
+	printf("TL_check - messageLength = %d \n",messageLength);
+
+	if (messageLength == connection->readData.Length &&
 			messageLength < (connection->transportLayer.localConf.maxMessageSize))
 			messageLength < (connection->transportLayer.localConf.maxMessageSize))
 	{
 	{
-		return UA_ERROR;
+		printf("TL_check - no error \n");
+		return UA_NO_ERROR;
 	}
 	}
-	return UA_NO_ERROR;
+
+	printf("TL_check - length error \n");
+
+	return UA_ERROR;
 }
 }
 
 
 
 
-Int32 TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
+Int32 TL_receive(UA_connection *connection, UA_ByteString *packet)
 {
 {
-	UInt32 bufferSize = connection->transportLayer.localConf.recvBufferSize = 8192;
 	UInt32 length = 0;
 	UInt32 length = 0;
 	Int32 pos = 0;
 	Int32 pos = 0;
 
 
 	AD_RawMessage tmpRawMessage;
 	AD_RawMessage tmpRawMessage;
 	struct TL_header tmpHeader;
 	struct TL_header tmpHeader;
-	//TODO call socket receive function
+	printf("TL_receive - entered \n");
-	tmpRawMessage.message = (char *)opcua_malloc(bufferSize);
+
-	tmpRawMessage.length = bufferSize;
+	packet->Data = NULL;
+	packet->Length = 0;
 
 
-	if(TL_check(connection,TL_message) == UA_NO_ERROR)
+	if(TL_check(connection) == UA_NO_ERROR)
 	{
 	{
-		Int32 packetType = TL_getPacketType(&pos,TL_message);
+
+		printf("TL_receive - no error \n");
+		printf("TL_receive - connection->readData.Length %d \n",connection->readData.Length);
+		Int32 packetType = TL_getPacketType(&(connection->readData),&pos);
+
+		//is final chunk or not
+		//TODO process chunks
+		pos += sizeof(Byte);
+		//save the message size if needed
+		pos += sizeof(UInt32);
+
+		printf("TL_receive - packetType = %d \n",packetType);
 		switch(packetType)
 		switch(packetType)
 		{
 		{
-		packetType_MSG:
+		case packetType_MSG:
-		packetType_OPN:
+		case packetType_OPN:
-		packetType_CLO:
+		case packetType_CLO:
+		{
+			packet->Data = connection->readData.Data;
+			packet->Length = connection->readData.Length;
 
 
+			printf("TL_receive - received MSG or OPN or CLO message\n");
 			break;
 			break;
-		packetType_HEL:
+		}
-		packetType_ACK:
+		case packetType_HEL:
-			TL_process(connection,TL_message,packetType);
+		case packetType_ACK:
+		{
+			printf("TL_receive - received HEL or ACK message\n");
+			TL_process(connection, packetType, &pos);
 			break;
 			break;
-		packetType_ERR:
+		}
-			TL_message->length = 0;
+		case packetType_ERR:
-			TL_message->message = NULL;
+		{
+			printf("TL_receive - received ERR message\n");
 
 
 			//TODO ERROR HANDLING
 			//TODO ERROR HANDLING
 
 
 			return UA_ERROR_RCV_ERROR;
 			return UA_ERROR_RCV_ERROR;
 			break;
 			break;
 		}
 		}
+
+		}
 	}
 	}
 	else
 	else
 	{
 	{
@@ -112,138 +114,161 @@ Int32 TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 }
 }
 
 
 
 
-/*
+Int32 TL_getPacketType(UA_ByteString *packet, Int32 *pos)
- * get the message header
- */
-void TL_getMessageHeader(struct TL_header *header, AD_RawMessage *rawMessage)
 {
 {
-	int pos = 0;
+	printf("TL_getPacketType - entered \n");
+	printf("TL_getPacketType - pos = %d \n",*pos);
+	//printf(packet->Data[*pos]);
 
 
-	if(rawMessage->message[0] == 'H' &&
+	if(packet->Data[*pos] == 'H' &&
-	   rawMessage->message[1] == 'E' &&
+	   packet->Data[*pos+1] == 'E' &&
-	   rawMessage->message[2] == 'L')
+	   packet->Data[*pos+2] == 'L')
-	{
-		header->MessageType = TL_HEL;
-	}
-	else if(rawMessage->message[0] == 'A' &&
-	        rawMessage->message[1] == 'C' &&
-	        rawMessage->message[2] == 'K')
-	{
-		header->MessageType = TL_ACK;
-	}
-	else if(rawMessage->message[0] == 'E' &&
-			rawMessage->message[1] == 'R' &&
-			rawMessage->message[2] == 'R')
-	{
-		header->MessageType = TL_ERR;
-	}
-	else if(rawMessage->message[0] == 'O' &&
-	        rawMessage->message[1] == 'P' &&
-	        rawMessage->message[2] == 'N')
-	{
-		header->MessageType = TL_OPN;
-	}
-	else if(rawMessage->message[0] == 'C' &&
-	        rawMessage->message[1] == 'L' &&
-	        rawMessage->message[2] == 'O')
-	{
-		header->MessageType = TL_CLO;
-	}
-	else if(rawMessage->message[0] == 'M' &&
-			rawMessage->message[1] == 'S' &&
-			rawMessage->message[2] == 'G')
-	{
-		header->MessageType = TL_MSG;
-	}
-	else
-	{
-		//TODO ERROR no valid message received
-	}
-
-	pos = pos + TL_MESSAGE_TYPE_LEN;
-
-	decoder_decodeBuiltInDatatype(rawMessage->message,BYTE,&pos,&(header->Reserved));
-	decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,&(header->MessageSize));
-}
-Int32 TL_getPacketType(Int32 *pos,AD_RawMessage *rawMessage)
-{
-
-	if(rawMessage->message[*pos] == 'H' &&
-	   rawMessage->message[*pos+1] == 'E' &&
-	   rawMessage->message[*pos+2] == 'L')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_HEL;
 		return packetType_HEL;
 	}
 	}
-	else if(rawMessage->message[*pos] == 'A' &&
+	else if(packet->Data[*pos] == 'A' &&
-	        rawMessage->message[*pos+1] == 'C' &&
+	        packet->Data[*pos+1] == 'C' &&
-	        rawMessage->message[*pos+2] == 'K')
+	        packet->Data[*pos+2] == 'K')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_ACK;
 		return packetType_ACK;
 	}
 	}
-	else if(rawMessage->message[*pos] == 'E' &&
+	else if(packet->Data[*pos] == 'E' &&
-			rawMessage->message[*pos+1] == 'R' &&
+			packet->Data[*pos+1] == 'R' &&
-			rawMessage->message[*pos+2] == 'R')
+			packet->Data[*pos+2] == 'R')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_ERR;
 		return packetType_ERR;
 	}
 	}
-	else if(rawMessage->message[*pos] == 'O' &&
+	else if(packet->Data[*pos] == 'O' &&
-	        rawMessage->message[*pos+1] == 'P' &&
+	        packet->Data[*pos+1] == 'P' &&
-	        rawMessage->message[*pos+2] == 'N')
+	        packet->Data[*pos+2] == 'N')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_OPN;
 		return packetType_OPN;
 	}
 	}
-	else if(rawMessage->message[*pos] == 'C' &&
+	else if(packet->Data[*pos] == 'C' &&
-	        rawMessage->message[*pos+1] == 'L' &&
+	        packet->Data[*pos+1] == 'L' &&
-	        rawMessage->message[*pos+2] == 'O')
+	        packet->Data[*pos+2] == 'O')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_CLO;
 		return packetType_CLO;
 	}
 	}
-	else if(rawMessage->message[*pos] == 'M' &&
+	else if(packet->Data[*pos] == 'M' &&
-			rawMessage->message[*pos+1] == 'S' &&
+			packet->Data[*pos+1] == 'S' &&
-			rawMessage->message[*pos+2] == 'G')
+			packet->Data[*pos+2] == 'G')
 	{
 	{
+		*pos += 3 * sizeof(Byte);
 		return packetType_MSG;
 		return packetType_MSG;
 	}
 	}
-	else
+
-	{
+
-		return -1;//TODO ERROR no valid message received
+	return -1;//TODO ERROR no valid message received
-	}
+
 }
 }
 
 
 
 
-Int32 TL_process(UA_connection *connection,Int32 packetType, Int32 *pos, AD_RawMessage *rawMessage)
+Int32 TL_process(UA_connection *connection,Int32 packetType, Int32 *pos)
 {
 {
+	Int32 tmpPos = 0;
+	UA_ByteString tmpMessage;
+	Byte reserved;
+	UInt32 messageSize;
+	printf("TL_process - entered \n");
 	struct TL_header tmpHeader;
 	struct TL_header tmpHeader;
 	switch(packetType)
 	switch(packetType)
 	{
 	{
-	packetType_HEL :
+	case packetType_HEL :
 		if(connection->transportLayer.connectionState == connectionState_CLOSED)
 		if(connection->transportLayer.connectionState == connectionState_CLOSED)
 		{
 		{
+			printf("TL_process - extracting header information \n");
+			printf("TL_process - pos = %d \n",*pos);
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,
+			/* extract information from received header */
+			decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,pos,
 					(void*)(&(connection->transportLayer.remoteConf.protocolVersion)));
 					(void*)(&(connection->transportLayer.remoteConf.protocolVersion)));
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,
+			printf("TL_process - protocolVersion = %d \n",connection->transportLayer.remoteConf.protocolVersion);
+
+			decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,pos,
 					(void*)(&(connection->transportLayer.remoteConf.recvBufferSize)));
 					(void*)(&(connection->transportLayer.remoteConf.recvBufferSize)));
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,
+			printf("TL_process - recvBufferSize = %d \n",connection->transportLayer.remoteConf.recvBufferSize);
+
+			decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,pos,
 					(void*)(&(connection->transportLayer.remoteConf.sendBufferSize)));
 					(void*)(&(connection->transportLayer.remoteConf.sendBufferSize)));
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,
+			printf("TL_process - sendBufferSize = %d \n",connection->transportLayer.remoteConf.sendBufferSize);
+
+			decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,pos,
 					(void*)(&(connection->transportLayer.remoteConf.maxMessageSize)));
 					(void*)(&(connection->transportLayer.remoteConf.maxMessageSize)));
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,UINT32,&pos,
+			printf("TL_process - maxMessageSize = %d \n",connection->transportLayer.remoteConf.maxMessageSize);
+
+			decoder_decodeBuiltInDatatype(connection->readData.Data,UINT32,pos,
 					(void*)(&(connection->transportLayer.remoteConf.maxChunkCount)));
 					(void*)(&(connection->transportLayer.remoteConf.maxChunkCount)));
 
 
+			printf("TL_process - maxChunkCount = %d \n",connection->transportLayer.remoteConf.maxChunkCount);
 
 
-			decoder_decodeBuiltInDatatype(rawMessage->message,STRING,&pos,
+			decoder_decodeBuiltInDatatype(connection->readData.Data,STRING,pos,
 					(void*)(&(connection->transportLayer.endpointURL)));
 					(void*)(&(connection->transportLayer.endpointURL)));
 
 
+			/* send back acknowledge */
+			tmpMessage.Data = (Byte*)opcua_malloc(SIZE_OF_ACKNOWLEDGE_MESSAGE);
+			if(tmpMessage.Data == NULL)
+			{
+				printf("TL_process - memory allocation failed \n");
+			}
+			tmpMessage.Length = SIZE_OF_ACKNOWLEDGE_MESSAGE;
+			printf("TL_process - allocated memory \n");
+			/* ------------------------ Header ------------------------ */
+			// MessageType
+			tmpMessage.Data[0] = 'A';
+			tmpMessage.Data[1] = 'C';
+			tmpMessage.Data[2] = 'K';
+			tmpPos += 3;
+			// Chunk
+			reserved = 'F';
+			encoder_encodeBuiltInDatatype(&reserved, BYTE, &tmpPos, tmpMessage.Data);
+			// MessageSize
+			messageSize = SIZE_OF_ACKNOWLEDGE_MESSAGE;
+			encoder_encodeBuiltInDatatype(&messageSize,UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - Size messageToSend = %d \n",messageSize);
+
+			/* ------------------------ Body ------------------------ */
+			// protocol version
+			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.protocolVersion),
+					UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - localConf.protocolVersion = %d \n",connection->transportLayer.localConf.protocolVersion);
+
+			//receive buffer size
+			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.recvBufferSize),
+					UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - localConf.recvBufferSize = %d \n", connection->transportLayer.localConf.recvBufferSize);
+			//send buffer size
+			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.sendBufferSize),
+					UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - localConf.sendBufferSize = %d \n", connection->transportLayer.localConf.sendBufferSize);
+			//maximum message size
+			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.maxMessageSize),
+					UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - localConf.maxMessageSize = %d \n", connection->transportLayer.localConf.maxMessageSize);
+			//maximum chunk count
+			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.maxChunkCount),
+					UINT32, &tmpPos, tmpMessage.Data);
+			printf("TL_process - localConf.maxChunkCount = %d \n", connection->transportLayer.localConf.maxChunkCount);
+
+			TL_send(connection, &tmpMessage);
 		}
 		}
 		else
 		else
 		{
 		{
+			printf("TL_process - wrong connection state \n");
 			return UA_ERROR_MULTIPLY_HEL;
 			return UA_ERROR_MULTIPLY_HEL;
 		}
 		}
+		break;
+	default:
+		return UA_ERROR;
 	}
 	}
 	return UA_NO_ERROR;
 	return UA_NO_ERROR;
 }
 }
@@ -252,9 +277,22 @@ Int32 TL_process(UA_connection *connection,Int32 packetType, Int32 *pos, AD_RawM
  */
  */
 
 
 
 
-TL_send(AD_RawMessage *rawMessage)
+TL_send(UA_connection *connection, UA_ByteString *packet)
 {
 {
-	//call tcp function or callback
+	printf("TL_send - entered \n");
+	connection->newDataToWrite = 1;
+	if(packet->Length < connection->transportLayer.remoteConf.maxMessageSize)
+	{
+		connection->writeData.Data = packet->Data;
+		connection->writeData.Length = packet->Length;
+		printf("TL_send - packet length = %d \n", packet->Length);
+	}
+	else
+	{
+		printf("TL_send - ERROR: packet size greater than remote buffer size", packet->Length);
+		//server error
+	}
+
 }
 }
 
 
 
 

+ 15 - 14
open62541Stack/src/opcua_transportLayer.h

@@ -16,10 +16,15 @@
 
 
 //TODO : Implement this interface
 //TODO : Implement this interface
 #include "tcp_layer.h"
 #include "tcp_layer.h"
+/*------------------Defined Error Codes------------------*/
 //transport errors begin at 1000
 //transport errors begin at 1000
 #define UA_ERROR_MULTIPLY_HEL 1000
 #define UA_ERROR_MULTIPLY_HEL 1000
 #define UA_ERROR_RCV_ERROR 1001
 #define UA_ERROR_RCV_ERROR 1001
 
 
+
+/*------------------Defined Lengths------------------*/
+#define SIZE_OF_ACKNOWLEDGE_MESSAGE 28
+
 //constants
 //constants
 static const UInt32 TL_HEADER_LENGTH = 8;
 static const UInt32 TL_HEADER_LENGTH = 8;
 static const UInt32 TL_MESSAGE_TYPE_LEN = 3;
 static const UInt32 TL_MESSAGE_TYPE_LEN = 3;
@@ -32,12 +37,12 @@ static const TL_SERVER_MAX_MESSAGE_SIZE = 8192;
 
 
 enum TL_messageType_td
 enum TL_messageType_td
 {
 {
-	TL_HEL,
+	TL_HEL = 1,
-	TL_ACK,
+	TL_ACK = 2,
-	TL_ERR,
+	TL_ERR = 3,
-	TL_OPN,
+	TL_OPN = 4,
-	TL_CLO,
+	TL_CLO = 5,
-	TL_MSG
+	TL_MSG = 6
 }TL_messageType;
 }TL_messageType;
 
 
 struct TL_header
 struct TL_header
@@ -85,19 +90,15 @@ struct TL_messageBodyERR
  * @param TL_message
  * @param TL_message
  * @return
  * @return
  */
  */
-Int32 TL_check(UA_connection *connection, AD_RawMessage *TL_message);
+Int32 TL_check(UA_connection *connection);
 /**
 /**
  *
  *
  * @param connection
  * @param connection
  * @param TL_message
  * @param TL_message
  */
  */
-Int32 TL_receive(UA_connection *connection, AD_RawMessage *TL_message);
+Int32 TL_receive(UA_connection *connection,UA_ByteString *packet);
-
+Int32 TL_send(UA_connection *connection, UA_ByteString *packet);
-Int32 TL_getPacketType(Int32 *pos, AD_RawMessage *rawMessage);
+Int32 TL_getPacketType(UA_ByteString *packet, Int32 *pos);
-void TL_getMessageHeader(struct TL_header *messageHeader,AD_RawMessage *rawMessage);
 
 
-//Test
-void TL_processHELMessage_test();
 
 
-void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage);
 #endif /* OPCUA_TRANSPORTLAYER_H_ */
 #endif /* OPCUA_TRANSPORTLAYER_H_ */

Datei-Diff unterdrückt, da er zu groß ist
+ 157 - 161
open62541Stack/src/opcua_types.h


+ 10 - 1
open62541Stack/src/tcp_layer.h

@@ -8,9 +8,18 @@
 #ifndef TCP_LAYER_H_
 #ifndef TCP_LAYER_H_
 #define TCP_LAYER_H_
 #define TCP_LAYER_H_
 #include "opcua_connectionHelper.h"
 #include "opcua_connectionHelper.h"
+#ifdef LINUX
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/socketvar.h>
+
+#endif
 /*
 /*
  * returns the length of read bytes
  * returns the length of read bytes
  */
  */
-UInt32 receive(UA_connection *connection, AD_RawMessage *message,UInt32 bufferLength);
+
+
 
 
 #endif /* TCP_LAYER_H_ */
 #endif /* TCP_LAYER_H_ */

+ 11 - 9
open62541Stack/tests/check_stack.c

@@ -1,6 +1,6 @@
 /*
 /*
  ============================================================================
  ============================================================================
- Name        : opcuaServer.c
+ Name        : check_stack.c
  Author      :
  Author      :
  Version     :
  Version     :
  Copyright   : Your copyright notice
  Copyright   : Your copyright notice
@@ -200,17 +200,19 @@ START_TEST(encodeUInt32_test)
 	UInt32 value = 0x0101FF00;
 	UInt32 value = 0x0101FF00;
 	//EncodeUInt16
 	//EncodeUInt16
 
 
-	rawMessage.message = (char*)opcua_malloc(sizeof(UInt32));
+	rawMessage.message = (char*)opcua_malloc(2 * sizeof(UInt32));
 
 
-	rawMessage.length = 4;
+	rawMessage.length = 8;
 
 
-	Int32 p = 0;
+	Int32 p = 4;
-	encodeUInt32(value, &p,rawMessage.message);
+	//encodeUInt32(value, &p,rawMessage.message);
+	encoder_encodeBuiltInDatatype(&value,UINT32,&p,rawMessage.message);
+	ck_assert_uint_eq((Byte)rawMessage.message[4],0x00);
+	ck_assert_uint_eq((Byte)rawMessage.message[5],0xFF);
+	ck_assert_uint_eq((Byte)rawMessage.message[6],0x01);
+	ck_assert_uint_eq((Byte)rawMessage.message[7],0x01);
+	ck_assert_int_eq(p,8);
 
 
-	ck_assert_uint_eq((Byte)rawMessage.message[0],0x00);
-	ck_assert_uint_eq((Byte)rawMessage.message[1],0xFF);
-	ck_assert_uint_eq((Byte)rawMessage.message[2],0x01);
-	ck_assert_uint_eq((Byte)rawMessage.message[3],0x01);
 
 
 }
 }
 END_TEST
 END_TEST