Browse Source

major modifications to incorporate generated files. Please run
autogen.sh and configure to renew all the makefiles.

Leon Urbas 11 years ago
parent
commit
d8b1420560

+ 2 - 2
Makefile.am

@@ -8,10 +8,10 @@ endif
 export GLOBAL_AM_CFLAGS = $(AM_CFLAGS)
 
 if HAVE_CHECK
-    SUBS=src tests tool
+    SUBS=tool include src tests
 
 else 
-    SUBS=src tool
+    SUBS=tool include src
 endif
 
 SUBDIRS = $(SUBS) examples/src	

+ 1 - 1
configure.ac

@@ -47,6 +47,6 @@ AM_COND_IF([DEBUG],
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_FILES(Makefile src/Makefile tool/Makefile tests/Makefile examples/src/Makefile)
+AC_CONFIG_FILES(Makefile include/Makefile src/Makefile tool/Makefile tests/Makefile examples/src/Makefile)
 AC_OUTPUT
 

+ 11 - 15
examples/src/opcuaServer.c

@@ -10,13 +10,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <memory.h> // bzero
 
 
-
-#include "opcua_binaryEncDec.h"
-#include "opcua_builtInDatatypes.h"
+#include "opcua.h"
 #include "opcua_transportLayer.h"
-#include "opcua_types.h"
 
 #ifdef LINUX
 
@@ -79,7 +77,7 @@ void server_run()
 	}
 
 	/* Initialize socket structure */
-	bzero((char *) &serv_addr, sizeof(serv_addr));
+	bzero((void *) &serv_addr, sizeof(serv_addr));
 	portno = PORT;
 	serv_addr.sin_family = AF_INET;
 	serv_addr.sin_addr.s_addr = INADDR_ANY;
@@ -124,8 +122,8 @@ void server_run()
 		if (n > 0)
 		{
 			printf("received: %s\n",buffer);
-			connection.readData.Data = buffer;
-			connection.readData.Length = n;
+			connection.readData.data = buffer;
+			connection.readData.length = n;
 			connection.newDataToRead = 1;
 
 			//TL_receive(&connection, &slMessage);
@@ -140,20 +138,18 @@ void server_run()
 		if(connection.newDataToWrite)
 		{
 			printf("data will be sent \n");
-			n = write(newsockfd,connection.writeData.Data,connection.writeData.Length);
+			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;
+			UA_free(connection.writeData.data);
+			connection.writeData.data = NULL;
+			connection.writeData.length = 0;
 		}
 
-		connection.readData.Data = NULL;
-		connection.readData.Length = 0;
+		connection.readData.data = NULL;
+		connection.readData.length = 0;
 		connection.newDataToRead = 0;
 
-
-
 	}
   }
 

+ 8 - 0
include/Makefile.am

@@ -0,0 +1,8 @@
+TOOL_DIR = ../tool
+
+all-local: opcua.h opcua_namespace_0.h
+
+opcua.h: $(TOOL_DIR)/opcua.h
+	cp $< $@
+opcua_namespace_0.h: $(TOOL_DIR)/opcua_namespace_0.h
+	cp $< $@

+ 1 - 1
include/UA_config.h

@@ -5,7 +5,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "opcua_builtInDatatypes.h"
+#include "opcua.h"
 #include "UA_abbr.h"
 
 

+ 1 - 1
include/UA_indexedList.h

@@ -1,7 +1,7 @@
 #ifndef UA_INDEXEDLIST_H_
 #define UA_INDEXEDLIST_H_
 
-#include "opcua_builtInDatatypes.h"
+#include "opcua.h"
 /* UA_indexedList reuses many types of UA_list */
 #include "UA_list.h"
 

+ 3 - 2
include/UA_list.h

@@ -1,7 +1,7 @@
 #ifndef UA_LIST_H_
 #define UA_LIST_H_
 
-#include "opcua_builtInDatatypes.h"
+#include "opcua.h"
 
 /*
  * Double Linked Lists
@@ -24,7 +24,8 @@ typedef struct T_UA_list_List {
 
 typedef void (*UA_list_ElementVisitor)(UA_list_Element* payload);
 
-typedef Boolean (*UA_list_PayloadMatcher)(void* payload);
+//typedef Boolean (*UA_list_PayloadMatcher)(void* payload);
+typedef _Bool (*UA_list_PayloadMatcher)(void* payload);
 
 void UA_list_defaultFreer(void* payload);
 

+ 23 - 2
tool/opcua_basictypes.h

@@ -38,7 +38,14 @@ typedef double UA_Double;
 #define UA_FALSE (!UA_TRUE)
 #define FALSE UA_FALSE
 
+/* Compare values */
+#define UA_EQUAL 0
+#define UA_NOT_EQUAL (!UA_EQUAL)
+
+
 /* heap memory functions */
+#define UA_NULL ((void*)0)
+extern void const * UA_alloc_lastptr;
 UA_Int32 UA_free(void * ptr);
 UA_Int32 UA_memcpy(void *dst, void const *src, int size);
 UA_Int32 UA_alloc(void ** dst, int size);
@@ -47,8 +54,6 @@ UA_Int32 UA_alloc(void ** dst, int size);
 UA_Int32 UA_Array_calcSize(UA_Int32 noElements, UA_Int32 type, void const ** ptr);
 UA_Int32 UA_Array_encode(void const **src, UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, char * dst);
 UA_Int32 UA_Array_decode(char const * src,UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, void const **dst);
-#define UA_NULL ((void*)0)
-// #define NULL UA_NULL
 
 #define UA_TYPE_METHOD_PROTOTYPES(TYPE) \
 UA_Int32 TYPE##_calcSize(TYPE const * ptr);\
@@ -150,6 +155,10 @@ typedef struct T_UA_String
 }
 UA_String;
 UA_TYPE_METHOD_PROTOTYPES (UA_String)
+UA_Int32 UA_String_compare(UA_String *string1, UA_String *string2);
+void UA_String_printf(char* label, UA_String* string);
+void UA_String_printx(char* label, UA_String* string);
+void UA_String_printx_hex(char* label, UA_String* string);
 
 /* ByteString - Part: 6, Chapter: 5.2.2.7, Page: 17 */
 typedef struct T_UA_ByteString
@@ -159,6 +168,7 @@ typedef struct T_UA_ByteString
 }
 UA_ByteString;
 UA_TYPE_METHOD_PROTOTYPES (UA_ByteString)
+UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2);
 
 /** LocalizedTextBinaryEncoding - Part: 6, Chapter: 5.2.2.14, Page: 21 */
 typedef struct T_UA_LocalizedText
@@ -257,6 +267,17 @@ typedef struct UA_DataValue {
 } UA_DataValue;
 UA_TYPE_METHOD_PROTOTYPES(UA_DataValue)
 
+/** 62541-6, §5.2.2.17, Table 15 */
+enum UA_DataValue_EncodingMaskType_enum
+{
+	UA_DataValue_variant = 	0x01,
+	UA_DataValue_statusCode = 	0x02,
+	UA_DataValue_sourceTimestamp = 	0x04,
+	UA_DataValue_serverTimestamp = 	0x08,
+	UA_DataValue_sourcePicoseconds = 	0x10,
+	UA_DataValue_serverPicoseconds = 	0x20
+};
+
 /* DiagnosticInfo - Part: 6, Chapter: 5.2.2.12, Page: 20 */
 typedef struct T_UA_DiagnosticInfo {
 	UA_Byte encodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType

+ 10 - 12
src/Makefile.am

@@ -1,3 +1,8 @@
+TOOL_DIR = ../tool
+opcua.c: $(TOOL_DIR)/opcua.c
+	cp $< $@
+opcua_namespace_0.c: $(TOOL_DIR)/opcua_namespace_0.c
+	cp $< $@
 
 #__top_builddir__bin_stackTest_out_SOURCES =	opcuaServer.c\
 #											opcua_builtInDatatypes.c\
@@ -18,27 +23,20 @@
 #					  opcua_connectionHelper.h	
 lib_LTLIBRARIES = libopen62541.la
 libopen62541_la_LDFLAGS = -avoid-version -no-undefined
-libopen62541_la_SOURCES = opcua_builtInDatatypes.c\
-						opcua_binaryEncDec.c\
+libopen62541_la_SOURCES = include/opcua.h\
+						opcua.c\
+						opcua_basictypes.c\
+						opcua_namespace_0.c\
 						opcua_transportLayer.c\
-						opcua_encodingLayer.c\
 						opcua_secureChannelLayer.c\
-						opcua_memory.c\
-						opcua_time.c\
 						tcp_layer.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\
-						opcua_memory.h\
-						opcua_time.h\
 						tcp_layer.h\
 						util/UA_list.c\
-						util/UA_indexedList.c						
+						util/UA_indexedList.c
 libopen62541_la_CFLAGS = -I $(top_builddir)/include
 
 #bin_PROGRAMS= $(top_builddir)/bin/open62541.out

+ 0 - 973
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_
-
-#include "opcua_builtInDatatypes.h"
-typedef struct AD_RawMessage_t AD_RawMessage;
-
-struct AD_RawMessage_t
-{
-	char *message;
-	UA_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 UA_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?
-	UA_Int32 namespaceUri;
-	UA_Int32 symbolicId;
-	UA_Int32 locale;
-	UA_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;
-	UA_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 UA_UInt32 BED_Index;
-
-
-/**
-* IntegerId
-* Part: 4
-* Chapter: 7.13
-* Page: 118
-*/
-typedef UA_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;
-	UA_UInt32 deadbandType;
-	UA_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;
-	UA_Byte percentDataBad;
-	UA_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
-{
-	UA_UInt32 specifiedAttribute;	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	UA_Byte eventNotifier;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-/**
-* VariableAttributes parameters
-* Part: 4
-* Chapter: 7.18.3
-* Page: 125
-*/
-struct BED_VariableAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-//ToDo	DefinedByTheDataTypeAttribte??? value				//ToDo
-//	struct UA_NodeId dataType;
-	UA_Int32 valueRank;
-//	UInt32 arrayDimensions[];
-	UA_Byte accessLevel;
-	UA_Byte userAccesLevel;
-//ToDo	Duration???? minimumSamplingInterval;			//ToDo
-	Boolean historizing;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-/**
-* MethodAttributes parameters
-* Part: 4
-* Chapter: 7.18.4
-* Page: 125
-*/
-struct BED_MethodAttributes
-{
-	UA_UInt32 specifiedAttributes;	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean executable;
-	Boolean userExecutable;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-/**
-* ObjectTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.5
-* Page: 125
-*/
-struct BED_ObjectTypeAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	UA_UInt32 wirteMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-/**
-* VariableTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.6
-* Page: 126
-*/
-struct BED_VariableTypeAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-//ToDo	DefinedByTheDataTypeAttribte??? value			//ToDo
-//	struct UA_NodeId dataType;
-	UA_Int32 valueRank;
-//	UInt32 arrayDimesions[];
-	Boolean isAbstract;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-/**
-* ReferenceTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.7
-* Page: 126
-*/
-struct BED_ReferenceTypeAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	Boolean symmetric;
-//	struct UA_LocalizedText inverseName;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-
-/**
-* DataTypeAttributes parameters
-* Part: 4
-* Chapter: 7.18.8
-* Page: 126
-*/
-struct BED_DataTypeAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean isAbstract;
-	UA_UInt32 writeMask;
-	UA_UInt32 userWriteMask;
-};
-
-
-
-/**
-* ViewAttributes parameters
-* Part: 4
-* Chapter: 7.18.9
-* Page: 127
-*/
-struct BED_ViewAttributes
-{
-	UA_UInt32 specifiedAttributes; 	//BitMask corresponding to BED_NodeAttributesBitMask
-//	struct UA_LocalizedText displayName;
-//	struct UA_LocalizedText description;
-	Boolean containsNoLoops;
-	UA_Byte eventNotifier;
-	UA_UInt32 writeMask;
-	UA_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;
-	UA_UInt32 returnDiagnostics;
-	UA_String auditEntryId;
-	UA_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
-*/
-/*typedef struct UA_AD_ResponseHeader
-{
-	UA_DateTime timestamp;
-	UInt32 requestHandle;
-	UA_StatusCode serviceResult;
-	UA_DiagnosticInfo *serviceDiagnostics;
-	UA_String *stringTable;
-    UA_AD_ExtensibleParameter *additionalHeader;
-}UA_AD_ResponseHeader;
-*/
-
-/**
-* 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
-{
-	UA_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;
-	UA_UInt32 viewVersion;
-};
-
-
-#endif /* OPCUA_ADVANCEDDATATYPES_H_ */

+ 152 - 106
tool/opcua_basictypes.c

@@ -4,10 +4,10 @@
  *  Created on: 13.03.2014
  *      Author: mrt
  */
-#include "opcua.h"
 #include <stdio.h>	// printf
 #include <stdlib.h>	// alloc, free
 #include <string.h>
+#include "opcua.h"
 #include "opcua_basictypes.h"
 
 
@@ -38,12 +38,9 @@ UA_Int32 UA_Array_calcSize(UA_Int32 nElements, UA_Int32 type, void const ** data
 	return length;
 }
 UA_Int32 UA_Array_encode(void const **src, UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, char * dst) {
-	UA_Int32 length = sizeof(UA_Int32);
-	UA_Int32 retVal = 0;
+	UA_Int32 retVal = UA_SUCCESS;
 	UA_Int32 i = 0;
 
-	char** ptr = (char**)src;
-
 	UA_Int32_encode(&noElements, pos, dst);
 	for(i=0; i<noElements; i++) {
 		retVal |= UA_[type].encode((void*)src[i], pos, dst);
@@ -53,12 +50,9 @@ UA_Int32 UA_Array_encode(void const **src, UA_Int32 noElements, UA_Int32 type, U
 }
 
 UA_Int32 UA_Array_decode(char const * src,UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, void const **dst) {
-	UA_Int32 length = sizeof(UA_Int32);
-	UA_Int32 retval = 0;
+	UA_Int32 retval = UA_SUCCESS;
 	UA_Int32 i = 0;
 
-	char** ptr = (char**)src;
-
 	for(i=0; i<noElements; i++) {
 		retval |= UA_[type].decode(src, pos, (void*)dst[i]);
 	}
@@ -66,18 +60,21 @@ UA_Int32 UA_Array_decode(char const * src,UA_Int32 noElements, UA_Int32 type, UA
 }
 
 UA_Int32 UA_free(void * ptr){
+	printf("UA_free - ptr=%p\n",ptr);
 	free(ptr);
 	return UA_SUCCESS;
 }
 
+void const * UA_alloc_lastptr;
 UA_Int32 UA_alloc(void ** ptr, int size){
-	*ptr = malloc(size);
+	UA_alloc_lastptr = *ptr = malloc(size);
 	printf("UA_alloc - ptr=%p, size=%d\n",*ptr,size);
 	if(*ptr == UA_NULL) return UA_ERR_NO_MEMORY;
 	return UA_SUCCESS;
 }
 
 UA_Int32 UA_memcpy(void * dst, void const * src, int size){
+	printf("UA_memcpy - dst=%p, src=%p, size=%d\n",dst,src,size);
 	memcpy(dst, src, size);
 	return UA_SUCCESS;
 }
@@ -100,11 +97,11 @@ UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_Boolean)
 
 UA_TYPE_METHOD_CALCSIZE_SIZEOF(UA_Byte)
 UA_Int32 UA_Byte_encode(UA_Byte const * src, UA_Int32* pos, char * dst) {
-	*dst = src[(*pos)++];
+	dst[(*pos)++] = *src;
 	return UA_SUCCESS;
 }
 UA_Int32 UA_Byte_decode(char const * src, UA_Int32* pos, UA_Byte * dst) {
-	memcpy(&(dst[(*pos)++]), src, sizeof(UA_Byte));
+	*dst = src[(*pos)++];
 	return UA_SUCCESS;
 }
 UA_TYPE_METHOD_DELETE_FREE(UA_Byte)
@@ -279,7 +276,7 @@ UA_Int32 UA_String_encode(UA_String const * src, UA_Int32* pos, char *dst) {
 	UA_Int32_encode(&(src->length),pos,dst);
 
 	if (src->length > 0) {
-		UA_memcpy((void*)&(dst[*pos]), src->data, src->length);
+		UA_memcpy(&(dst[*pos]), src->data, src->length);
 		*pos += src->length;
 	}
 	return UA_SUCCESS;
@@ -289,7 +286,7 @@ UA_Int32 UA_String_decode(char const * src, UA_Int32* pos, UA_String * dst) {
 	retval |= UA_Int32_decode(src,pos,&(dst->length));
 	if (dst->length > 0) {
 		retval |= UA_alloc((void**)&(dst->data),dst->length);
-		retval |= UA_memcpy((void*)&(src[*pos]),dst->data,dst->length);
+		retval |= UA_memcpy(dst->data,&(src[*pos]),dst->length);
 		*pos += dst->length;
 	} else {
 		dst->data = UA_NULL;
@@ -314,12 +311,71 @@ UA_String UA_String_null = { -1, UA_NULL };
 UA_Byte UA_Byte_securityPoliceNoneData[] = "http://opcfoundation.org/UA/SecurityPolicy#None";
 UA_String UA_String_securityPoliceNone = { sizeof(UA_Byte_securityPoliceNoneData), UA_Byte_securityPoliceNoneData };
 
+UA_Int32 UA_String_compare(UA_String* string1, UA_String* string2) {
+	UA_Int32 i;
+	UA_Int32 retval;
+
+	if (string1->length == 0 && string2->length == 0) {
+		retval = UA_EQUAL;
+	} else if (string1->length == -1 && string2->length == -1) {
+		retval = UA_EQUAL;
+	} else if (string1->length != string2->length) {
+		retval = UA_NOT_EQUAL;
+	} else {
+		retval = strncmp(string1->data,string2->data,string1->length);
+	}
+	return retval;
+}
+void UA_String_printf(char* label, UA_String* string) {
+	printf("%s {Length=%d, Data=%.*s}\n", label, string->length, string->length,
+			(char*) string->data);
+}
+void UA_String_printx(char* label, UA_String* string) {
+	int i;
+	printf("%s {Length=%d, Data=", label, string->length);
+	if (string->length > 0) {
+		for (i = 0; i < string->length; i++) {
+			printf("%c%d", i == 0 ? '{' : ',', (string->data)[i]);
+			if (i > 0 && !(i%20)) { printf("\n\t"); }
+		}
+	} else {
+		printf("{");
+	}
+	printf("}}\n");
+}
+void UA_String_printx_hex(char* label, UA_String* string) {
+	int i;
+	printf("%s {Length=%d, Data=", label, string->length);
+	if (string->length > 0) {
+		for (i = 0; i < string->length; i++) {
+			printf("%c%x", i == 0 ? '{' : ',', (string->data)[i]);
+		}
+	} else {
+		printf("{");
+	}
+	printf("}}\n");
+}
+
+
 // TODO: should we really handle UA_String and UA_ByteString the same way?
 UA_TYPE_METHOD_CALCSIZE_AS(UA_ByteString, UA_String)
 UA_TYPE_METHOD_ENCODE_AS(UA_ByteString, UA_String)
 UA_TYPE_METHOD_DECODE_AS(UA_ByteString, UA_String)
 UA_TYPE_METHOD_DELETE_AS(UA_ByteString, UA_String)
 UA_TYPE_METHOD_DELETEMEMBERS_AS(UA_ByteString, UA_String)
+UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2) {
+	return UA_String_compare((UA_String*) string1, (UA_String*) string2);
+}
+void UA_ByteString_printf(char* label, UA_ByteString* string) {
+	return UA_String_printf(label, (UA_String*) string);
+}
+void UA_ByteString_printx(char* label, UA_String* string) {
+	return UA_String_printx(label, (UA_String*) string);
+}
+void UA_ByteString_printx_hex(char* label, UA_String* string) {
+	return UA_String_printx_hex(label, (UA_String*) string);
+}
+
 
 UA_Int32 UA_Guid_calcSize(UA_Guid const * p) {
 	if (p == UA_NULL) {
@@ -531,6 +587,41 @@ UA_Int32 UA_NodeId_deleteMembers(UA_NodeId* p) {
 	}
 	return retval;
 }
+void UA_NodeId_printf(char* label, UA_NodeId* node) {
+	printf("%s {encodingByte=%d, namespace=%d, ", label,
+			(int) node->encodingByte, (int) node->namespace);
+	switch (node->encodingByte) {
+	case UA_NodeIdType_TwoByte:
+	case UA_NodeIdType_FourByte:
+	case UA_NodeIdType_Numeric:
+		printf("identifier=%d", node->identifier.numeric);
+		break;
+	case UA_NodeIdType_String:
+		printf("identifier={length=%d, data=%.*s}",
+				node->identifier.string.length, node->identifier.string.length,
+				(char*) (node->identifier.string.data));
+		break;
+	case UA_NodeIdType_ByteString:
+		printf("identifier={Length=%d, data=%.*s}",
+				node->identifier.byteString.length, node->identifier.byteString.length,
+				(char*) (node->identifier.byteString.data));
+		break;
+	case UA_NodeIdType_Guid:
+		printf(
+				"guid={data1=%d, data2=%d, data3=%d, data4={length=%d, data=%.*s}}",
+				node->identifier.guid.data1, node->identifier.guid.data2,
+				node->identifier.guid.data3, node->identifier.guid.data4.length,
+				node->identifier.guid.data4.length,
+				(char*) (node->identifier.guid.data4.data));
+		break;
+	default:
+		printf("ups! shit happens");
+		break;
+	}
+	printf("}\n");
+}
+
+
 //FIXME: Sten Where do these two flags come from?
 #define NIEVT_NAMESPACE_URI_FLAG 0x80 	//Is only for ExpandedNodeId required
 #define NIEVT_SERVERINDEX_FLAG 0x40 //Is only for ExpandedNodeId required
@@ -592,14 +683,11 @@ UA_Int32 UA_ExtensionObject_calcSize(UA_ExtensionObject const * p) {
 		length += UA_NodeId_calcSize(&(p->typeId));
 		length += sizeof(UA_Byte); //p->encoding
 		switch (p->encoding) {
-		case 0x00:
-			length += sizeof(UA_Int32); //p->body.length
-			break;
-		case 0x01:
+		case UA_ExtensionObject_BodyIsByteString:
 			length += UA_ByteString_calcSize(&(p->body));
 			break;
-		case 0x02:
-			length += UA_ByteString_calcSize(&(p->body));
+		case UA_ExtensionObject_BodyIsXml:
+			length += UA_XmlElement_calcSize(&(p->body));
 			break;
 		}
 	}
@@ -644,11 +732,6 @@ UA_Int32 UA_ExtensionObject_deleteMembers(UA_ExtensionObject *p) {
 	return retval;
 }
 
-// TODO: UA_DataValue_encode
-// TODO: UA_DataValue_decode
-// TODO: UA_DataValue_delete
-// TODO: UA_DataValue_deleteMembers
-
 /** DiagnosticInfo - Part: 4, Chapter: 7.9, Page: 116 */
 UA_Int32 UA_DiagnosticInfo_decode(char const * src, UA_Int32 *pos, UA_DiagnosticInfo *dst) {
 	UA_Int32 retval = UA_SUCCESS;
@@ -773,6 +856,25 @@ UA_TYPE_METHOD_ENCODE_AS(UA_DateTime,UA_Int64)
 UA_TYPE_METHOD_DECODE_AS(UA_DateTime,UA_Int64)
 UA_TYPE_METHOD_DELETE_FREE(UA_DateTime)
 UA_TYPE_METHOD_DELETEMEMBERS_NOACTION(UA_DateTime)
+#include <sys/time.h>
+
+// Number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC
+#define FILETIME_UNIXTIME_BIAS_SEC 11644473600LL
+// Factors
+#define HUNDRED_NANOSEC_PER_USEC 10LL
+#define HUNDRED_NANOSEC_PER_SEC (HUNDRED_NANOSEC_PER_USEC * 1000000LL)
+
+// IEC 62541-6 §5.2.2.5  A DateTime value shall be encoded as a 64-bit signed integer
+// which represents the number of 100 nanosecond intervals since January 1, 1601 (UTC).
+UA_DateTime UA_DateTime_now() {
+	UA_DateTime dateTime;
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	dateTime = (tv.tv_sec + FILETIME_UNIXTIME_BIAS_SEC)
+			* HUNDRED_NANOSEC_PER_SEC + tv.tv_usec * HUNDRED_NANOSEC_PER_USEC;
+	return dateTime;
+}
+
 
 UA_TYPE_METHOD_CALCSIZE_AS(UA_XmlElement, UA_ByteString)
 UA_TYPE_METHOD_ENCODE_AS(UA_XmlElement, UA_ByteString)
@@ -916,25 +1018,25 @@ UA_Int32 UA_Variant_decode(char const * src, UA_Int32 *pos, UA_Variant *dst) {
 UA_Int32 UA_DataValue_decode(char const * src, UA_Int32* pos, UA_DataValue* dst) {
 	UA_Int32 retval = UA_SUCCESS;
 	retval |= UA_Byte_decode(src,pos,&(dst->encodingMask));
-	if (dst->encodingMask & 0x01) {
+	if (dst->encodingMask & UA_DataValue_variant) {
 		retval |= UA_Variant_decode(src,pos,&(dst->value));
 	}
-	if (dst->encodingMask & 0x02) {
+	if (dst->encodingMask & UA_DataValue_statusCode) {
 		retval |= UA_StatusCode_decode(src,pos,&(dst->status));
 	}
-	if (dst->encodingMask & 0x04) {
+	if (dst->encodingMask & UA_DataValue_sourceTimestamp) {
 		retval |= UA_DateTime_decode(src,pos,&(dst->sourceTimestamp));
 	}
-	if (dst->encodingMask & 0x08) {
-		retval |= UA_DateTime_decode(src,pos,&(dst->serverTimestamp));
-	}
-	if (dst->encodingMask & 0x10) {
+	if (dst->encodingMask & UA_DataValue_sourcePicoseconds) {
 		retval |= UA_Int16_decode(src,pos,&(dst->sourcePicoseconds));
 		if (dst->sourcePicoseconds > MAX_PICO_SECONDS) {
 			dst->sourcePicoseconds = MAX_PICO_SECONDS;
 		}
 	}
-	if (dst->encodingMask & 0x20) {
+	if (dst->encodingMask & UA_DataValue_serverTimestamp) {
+		retval |= UA_DateTime_decode(src,pos,&(dst->serverTimestamp));
+	}
+	if (dst->encodingMask & UA_DataValue_serverPicoseconds) {
 		retval |= UA_Int16_decode(src,pos,&(dst->serverPicoseconds));
 		if (dst->serverPicoseconds > MAX_PICO_SECONDS) {
 			dst->serverPicoseconds = MAX_PICO_SECONDS;
@@ -945,22 +1047,22 @@ UA_Int32 UA_DataValue_decode(char const * src, UA_Int32* pos, UA_DataValue* dst)
 UA_Int32 UA_DataValue_encode(UA_DataValue const * src, UA_Int32* pos, char *dst) {
 	UA_Int32 retval = UA_SUCCESS;
 	retval |= UA_Byte_encode(&(src->encodingMask),pos,dst);
-	if (src->encodingMask & 0x01) {
+	if (src->encodingMask & UA_DataValue_variant) {
 		retval |= UA_Variant_encode(&(src->value),pos,dst);
 	}
-	if (src->encodingMask & 0x02) {
+	if (src->encodingMask & UA_DataValue_statusCode) {
 		retval |= UA_StatusCode_encode(&(src->status),pos,dst);
 	}
-	if (src->encodingMask & 0x04) {
+	if (src->encodingMask & UA_DataValue_sourceTimestamp) {
 		retval |= UA_DateTime_encode(&(src->sourceTimestamp),pos,dst);
 	}
-	if (src->encodingMask & 0x08) {
-		retval |= UA_DateTime_encode(&(src->serverTimestamp),pos,dst);
-	}
-	if (src->encodingMask & 0x10) {
+	if (src->encodingMask & UA_DataValue_sourcePicoseconds) {
 		retval |= UA_Int16_encode(&(src->sourcePicoseconds),pos,dst);
 	}
-	if (src->encodingMask & 0x10) {
+	if (src->encodingMask & UA_DataValue_serverTimestamp) {
+		retval |= UA_DateTime_encode(&(src->serverTimestamp),pos,dst);
+	}
+	if (src->encodingMask & UA_DataValue_serverPicoseconds) {
 		retval |= UA_Int16_encode(&(src->serverPicoseconds),pos,dst);
 	}
 	return retval;
@@ -973,22 +1075,22 @@ UA_Int32 UA_DataValue_calcSize(UA_DataValue const * p) {
 		length = sizeof(UA_DataValue);
 	} else { // get decoding size
 		length = sizeof(UA_Byte);
-		if (p->encodingMask & 0x01) {
+		if (p->encodingMask & UA_DataValue_variant) {
 			length += UA_Variant_calcSize(&(p->value));
 		}
-		if (p->encodingMask & 0x02) {
+		if (p->encodingMask & UA_DataValue_statusCode) {
 			length += sizeof(UA_UInt32); //dataValue->status
 		}
-		if (p->encodingMask & 0x04) {
-			length += sizeof(UA_Int64); //dataValue->sourceTimestamp
-		}
-		if (p->encodingMask & 0x08) {
-			length += sizeof(UA_Int64); //dataValue->serverTimestamp
+		if (p->encodingMask & UA_DataValue_sourceTimestamp) {
+			length += sizeof(UA_DateTime); //dataValue->sourceTimestamp
 		}
-		if (p->encodingMask & 0x10) {
+		if (p->encodingMask & UA_DataValue_sourcePicoseconds) {
 			length += sizeof(UA_Int64); //dataValue->sourcePicoseconds
 		}
-		if (p->encodingMask & 0x20) {
+		if (p->encodingMask & UA_DataValue_serverTimestamp) {
+			length += sizeof(UA_DateTime); //dataValue->serverTimestamp
+		}
+		if (p->encodingMask & UA_DataValue_serverPicoseconds) {
 			length += sizeof(UA_Int64); //dataValue->serverPicoseconds
 		}
 	}
@@ -1034,31 +1136,6 @@ Int32 decoder_decodeRequestHeader(char const * message, Int32 *pos,
 }
 ***/
 
-/**
- * ResponseHeader
- * Part: 4
- * Chapter: 7.27
- * Page: 133
- */
-/** \copydoc encodeResponseHeader */
-/*** Sten: removed to compile
-Int32 encodeResponseHeader(UA_AD_ResponseHeader const * responseHeader,
-		Int32 *pos, UA_ByteString *dstBuf) {
-	encodeUADateTime(responseHeader->timestamp, pos, dstBuf->data);
-	encodeIntegerId(responseHeader->requestHandle, pos, dstBuf->data);
-	encodeUInt32(responseHeader->serviceResult, pos, dstBuf->data);
-	encodeDiagnosticInfo(responseHeader->serviceDiagnostics, pos, dstBuf->data);
-
-	encoder_encodeBuiltInDatatypeArray(responseHeader->stringTable,
-			responseHeader->noOfStringTable, STRING_ARRAY, pos, dstBuf->data);
-
-	encodeExtensionObject(responseHeader->additionalHeader, pos, dstBuf->data);
-
-	//Kodieren von String Datentypen
-
-	return 0;
-}
-***/
 /*** Sten: removed to compile
 Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject) {
 	Int32 length = 0;
@@ -1073,34 +1150,3 @@ Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject) {
 	return length;
 }
 ***/
-
-/*** Sten: removed to compile
-Int32 responseHeader_calcSize(UA_AD_ResponseHeader *responseHeader) {
-	Int32 i;
-	Int32 length = 0;
-
-	// UtcTime timestamp	8
-	length += sizeof(UA_DateTime);
-
-	// IntegerId requestHandle	4
-	length += sizeof(UA_AD_IntegerId);
-
-	// StatusCode serviceResult	4
-	length += sizeof(UA_StatusCode);
-
-	// DiagnosticInfo serviceDiagnostics
-	length += diagnosticInfo_calcSize(responseHeader->serviceDiagnostics);
-
-	// String stringTable[], see 62541-6 § 5.2.4
-	length += sizeof(UA_Int32); // Length of Stringtable always
-	if (responseHeader->noOfStringTable > 0) {
-		for (i = 0; i < responseHeader->noOfStringTable; i++) {
-			length += UAString_calcSize(responseHeader->stringTable[i]);
-		}
-	}
-
-	// ExtensibleObject additionalHeader
-	length += extensionObject_calcSize(responseHeader->additionalHeader);
-	return length;
-}
-***/

File diff suppressed because it is too large
+ 0 - 1574
src/opcua_binaryEncDec.c


+ 0 - 368
src/opcua_binaryEncDec.h

@@ -1,368 +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"
-//#include "opcua_types.h"
-
-
-#define UA_TRUE 1
-#define UA_FALSE 0
-
-#define MAX_PICO_SECONDS 9999
-//functions
-/**
- *
- * @param srcBuf
- * @param type
- * @param pos
- * @param dstStructure
- * @return
- */
-UA_Int32 decoder_decodeBuiltInDatatype(char const * srcBuf, UA_Int32 type, UA_Int32 *pos,
-		void *dstStructure);
-/**
- *
- * @param data
- * @param type
- * @param pos
- * @param dstBuf
- * @return
- */
-UA_Int32 encoder_encodeBuiltInDatatype(void *data, UA_Int32 type, UA_Int32 *pos, char *dstBuf);
-
-
-/**
- *
- * @param data
- * @param size
- * @param type
- * @param pos
- * @param dstBuf
- * @return
- */
-UA_Int32 encoder_encodeBuiltInDatatypeArray(void **data, UA_Int32 size,
-		UA_Int32 arrayType, UA_Int32 *pos,
-		char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeBoolean(char const * buf, UA_Int32 *pos, Boolean *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeBoolean(Boolean value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeSByte(char const * buf, UA_Int32 *pos, UA_SByte *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeSByte(UA_SByte value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeByte(char const * buf, UA_Int32 *pos,UA_Byte *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeByte(UA_Byte value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UA_Int32 decodeUInt16(char const * buf, UA_Int32 *pos, UInt16 *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeUInt16(UInt16 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeInt16(char const * buf, UA_Int32 *pos, UA_Int16 *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeInt16(UA_Int16 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeInt32(char const * buf, UA_Int32 *pos, UA_Int32 *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeInt32(UA_Int32 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeUInt32(char const * const buf, UA_Int32 *pos, UA_UInt32 *dst);
-/**
- *
- * @param value
- * @param dstBuf
- * @param pos
- */
-void encodeUInt32(UA_UInt32 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeInt64(char const * buf, UA_Int32 *pos,UA_Int64 *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeInt64(UA_Int64 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeUInt64(char const * buf, UA_Int32 *pos, UA_UInt64 *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- */
-void encodeUInt64(UA_UInt64 value, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @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
- */
-UA_Int32 decodeUANodeId(char const * buf, UA_Int32 *pos, UA_NodeId *dstNodeId);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeFloat(char const * buf, UA_Int32 *pos, Float *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- * @return
- */
-UA_Int32 encodeFloat(Float value,UA_Int32 *pos,char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeDouble(char const * buf, UA_Int32 *pos, UA_Double *dst);
-/**
- *
- * @param value
- * @param pos
- * @param dstBuf
- * @return
- */
-UA_Int32 encodeDouble(UA_Double value, UA_Int32 *pos,char *dstBuf);
-/**
- *
- * @param srcNodeId
- * @param pos
- * @param buf
- * @return
- */
-UA_Int32 encodeUANodeId(UA_NodeId *srcNodeId, UA_Int32 *pos, char *buf);
-/**
- *
- * @param srcGuid
- * @param pos
- * @param buf
- * @return
- */
-UA_Int32 encodeUAGuid(UA_Guid *srcGuid, UA_Int32 *pos, char *buf);
-/**
- *
- * @param buf
- * @param pos
- * @param dstGUID
- * @return
- */
-UA_Int32 decodeUAGuid(char const * buf, UA_Int32 *pos, UA_Guid *dstGUID);
-/**
- *
- * @param buf
- * @param pos
- * @param dst
- * @return
- */
-UA_Int32 decodeUAStatusCode(char const * buf, UA_Int32 *pos,UA_StatusCode* dst);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UA_Int32 decodeUADateTime(char const * buf, UA_Int32 *pos,UA_DateTime *dst);
-/**
- *
- * @param time
- * @param pos
- * @param dstBuf
- * @return
- */
-void encodeUADateTime(UA_DateTime time, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param dstUAString
- * @return
- */
-UA_Int32 decodeUAString(char const * buf, UA_Int32 *pos, UA_String *dstUAString);
-/**
- *
- * @param byteString
- * @return length of the binary encoded data
- */
-UA_Int32 UAByteString_calcSize(UA_ByteString *byteString);
-/**
- *
- * @param xmlElement
- * @param pos
- * @param dstBuf
- * @return
- */
-UA_Int32 encodeXmlElement(UA_XmlElement *xmlElement, UA_Int32 *pos, char *dstBuf);
-/**
- *
- * @param buf
- * @param pos
- * @param xmlElement
- * @return
- */
-UA_Int32 decodeXmlElement(char const * buf, UA_Int32* pos, UA_XmlElement *xmlElement);
-/**
- *
- * @param buf
- * @param pos
- * @return
- */
-UA_Int32 decodeIntegerId(char const * buf, UA_Int32 *pos, UA_Int32* dst);
-/**
- *
- * @param integerId
- * @param pos
- * @param buf
-
- */
-void encodeIntegerId(UA_AD_IntegerId integerId, UA_Int32 *pos, char *buf);
-/**
- * \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
- */
-UA_Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,UA_Int32 *pos, UA_AD_RequestHeader *dstRequestHeader);
-/**
- *
- * @param srcHeader
- * @param pos
- * @param dstRaw
- * @return
- */
-UA_Int32 encodeRequestHeader(const UA_AD_RequestHeader *srcHeader,UA_Int32 *pos,UA_ByteString *dstRaw);
-/**
- *
- * @param srcRaw
- * @param pos
- * @param dstResponseHeader
- * @return
- */
-UA_Int32 decodeResponseHeader(const UA_ByteString *srcRaw, UA_Int32 *pos, UA_AD_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
- */
-UA_Int32 encodeResponseHeader(const UA_AD_ResponseHeader *responseHeader, UA_Int32 *pos, UA_ByteString *dstBuf);
-/**
- *
- * @param diagnosticInfo
- * @return length of the binary encoded data
- */
-UA_Int32 diagnosticInfo_calcSize(UA_DiagnosticInfo *diagnosticInfo);
-/**
- *
- * @param extensionObject
- * @return length of the binary encoded data
- */
-UA_Int32 extensionObject_calcSize(UA_ExtensionObject *extensionObject);
-
-
-
-#endif /* OPCUA_BINARYENCDEC_NEU_H_ */

+ 0 - 100
src/opcua_builtInDatatypes.c

@@ -1,100 +0,0 @@
-/*
- * opcua_BuiltInDatatypes.c
- *
- *  Created on: Dec 19, 2013
- *      Author: opcua
- */
-#include "opcua_builtInDatatypes.h"
-#include <stdio.h>
-
-UA_ExtensionObject the_empty_UA_ExtensionObject = { { NIEVT_TWO_BYTE, 0 }, NO_BODY_IS_ENCODED};
-UA_DiagnosticInfo the_empty_UA_DiagnosticInfo = { 0x00 };
-
-UA_Int32 UA_String_compare(UA_String *string1, UA_String *string2) {
-	UA_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;
-}
-
-UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2) {
-	return UA_String_compare((UA_String*) string1, (UA_String*) string2);
-}
-
-void UA_String_printf(char* label, UA_ByteString* string) {
-	printf("%s {Length=%d, Data=%.*s}\n", label, string->Length, string->Length,
-			(char*) string->Data);
-}
-
-void UA_ByteString_printx(char* label, UA_ByteString* string) {
-	int i;
-	printf("%s {Length=%d, Data=", label, string->Length);
-	if (string->Length > 0) {
-		for (i = 0; i < string->Length; i++) {
-			printf("%c%d", i == 0 ? '{' : ',', (string->Data)[i]);
-			if (i > 0 && !(i%20)) { printf("\n\t"); }
-		}
-	} else {
-		printf("{");
-	}
-	printf("}}\n");
-}
-void UA_ByteString_printx_hex(char* label, UA_ByteString* string) {
-	int i;
-	printf("%s {Length=%d, Data=", label, string->Length);
-	if (string->Length > 0) {
-		for (i = 0; i < string->Length; i++) {
-			printf("%c%x", i == 0 ? '{' : ',', (string->Data)[i]);
-		}
-	} else {
-		printf("{");
-	}
-	printf("}}\n");
-}
-
-void UA_NodeId_printf(char* label, UA_NodeId* node) {
-	printf("%s {EncodingByte=%d, Namespace=%d, ", label,
-			(int) node->EncodingByte, (int) node->Namespace);
-	switch (node->EncodingByte) {
-	case NIEVT_TWO_BYTE:
-	case NIEVT_FOUR_BYTE:
-	case NIEVT_NUMERIC:
-		printf("Identifier=%d", node->Identifier.Numeric);
-		break;
-	case NIEVT_STRING:
-	case NIEVT_BYTESTRING:
-		// TODO: This implementation does not distinguish between String and Bytestring. Error?
-		printf("Identifier={Length=%d, Data=%.*s}",
-				node->Identifier.String.Length, node->Identifier.String.Length,
-				(char*) (node->Identifier.String.Data));
-		break;
-	case NIEVT_GUID:
-		printf(
-				"Guid={Data1=%d, Data2=%d, Data3=%d, Data4=={Length=%d, Data=%.*s}}",
-				node->Identifier.Guid.Data1, node->Identifier.Guid.Data2,
-				node->Identifier.Guid.Data3, node->Identifier.Guid.Data4.Length,
-				node->Identifier.Guid.Data4.Length,
-				(char*) (node->Identifier.Guid.Data4.Data));
-		break;
-	default:
-		printf("ups! shit happens");
-		break;
-	}
-	printf("}\n");
-}
-

+ 0 - 778
src/opcua_builtInDatatypes.h

@@ -1,778 +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_
-
-#define TRUE (42==42)
-#define FALSE (!TRUE)
-
-/**
-* Enumerations:
-*	All Enumerations should be encoded as Int32 values
-*
-*
-*/
-#define UA_NOT_EQUAL 0
-#define UA_EQUAL 1
-
-#define UA_NO_ERROR 0
-#define UA_ERROR 1
-
-typedef enum
-{
-	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,
-	VARIANT = 			24,
-	DIAGNOSTIC_INFO = 	25
-}
-UA_BuiltInDataTypes;
-
-
-
-
-typedef enum
-{
-	BOOLEAN_ARRAY = 	129,
-	SBYTE_ARRAY = 	130,
-	BYTE_ARRAY = 		131,
-	INT16_ARRAY = 	132,
-	UINT16_ARRAY = 	133,
-	INT32_ARRAY = 	134,
-	UINT32_ARRAY = 	135,
-	INT64_ARRAY = 	136,
-	UINT64_ARRAY = 	137,
-	FLOAT_ARRAY = 	138,
-	DOUBLE_ARRAY = 	139,
-	STRING_ARRAY = 	140,
-	DATE_TIME_ARRAY = 141,
-	GUID_ARRAY = 		142,
-	BYTE_STRING_ARRAY = 143,
-	XML_ELEMENT_ARRAY = 144,
-	NODE_ID_ARRAY = 	145,
-	EXPANDED_NODE_ID_ARRAY = 145,
-	STATUS_CODE_ARRAY = 146,
-	QUALIFIED_NAME_ARRAY = 147,
-	LOCALIZED_TEXT_ARRAY = 	148,
-	EXTENSION_OBJECT_ARRAY = 149,
-	DATA_VALUE_ARRAY = 150,
-	VARIANT_ARRAY = 151,
-	DIAGNOSTIC_INFO_ARRAY = 152
-}
-UA_BuiltInDataTypes_Array;
-
-typedef enum
-{
-	BOOLEAN_MATRIX = 193,
-	SBYTE_MATRIX = 	194,
-	BYTE_MATRIX = 	195,
-	INT16_MATRIX = 	196,
-	UINT16_MATRIX = 197,
-	INT32_MATRIX = 	198,
-	UINT32_MATRIX = 199,
-	INT64_MATRIX =  200,
-	UINT64_MATRIX = 201,
-	FLOAT_MATRIX = 	202,
-	DOUBLE_MATRIX = 203,
-	STRING_MATRIX = 204,
-	DATE_TIME_MATRIX = 205,
-	GUID_MATRIX = 206,
-	BYTE_STRING_MATRIX = 207,
-	XML_ELEMENT_MATRIX = 208,
-	NODE_ID_MATRIX = 209,
-	EXPANDED_NODE_ID_MATRIX = 210,
-	STATUS_CODE_MATRIX = 211,
-	QUALIFIED_NAME_MATRIX = 212,
-	LOCALIZED_TEXT_MATRIX = 213,
-	EXTENSION_OBJECT_MATRIX = 214,
-	DATA_VALUE_MATRIX = 215,
-	VARIANT_MATRIX = 216,
-	DIAGNOSTIC_INFO_MATRIX = 217
-}
-UA_BuiltInDataTypes_Matrix;
-
-
-
-/**
-* BasicBuiltInDatatypes
-* Part: 6
-* Chapter: 5.2.2.1 - 5.2.2.3
-* Page: 15
-*/
-typedef _Bool Boolean;
-
-typedef int8_t UA_SByte;
-
-typedef uint8_t UA_Byte;
-
-typedef int16_t UA_Int16;
-
-typedef uint16_t UInt16;
-
-typedef int32_t UA_Int32;
-
-typedef uint32_t UA_UInt32;
-
-typedef int64_t UA_Int64;
-
-typedef uint64_t UA_UInt64;
-
-typedef float Float;
-
-typedef double Double;
-
-
-/**
-* String
-* Part: 6
-* Chapter: 5.2.2.4
-* Page: 16
-*/
-typedef struct UA_String
-{
-	UA_Int32 Length;
-	char *Data;
-}
-UA_String;
-
-/**
-* DateTime
-* Part: 6
-* Chapter: 5.2.2.5
-* Page: 16
-*/
-typedef UA_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
-{
-	UA_Int32 Length;
-	UA_Byte *Data;
-}
-UA_ByteString;
-
-
-/* GuidType
-* Part: 6
-* Chapter: 5.2.2.6
-* Page: 17
-*/
-typedef struct UA_Guid
-{
-	UA_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_ByteString Data;
-}
-UA_XmlElement;
-
-
-typedef struct UA_XmlElementEncoded
-{
-	UA_UInt32 Length;
-	UA_Byte StartTag[3];
-	UA_Byte *Message;
-	UA_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;
-
-/**
- * NodeIds
-* Part: 6
-* Chapter: 5.2.2.9
-* Table 5
-*/
-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
-{
-	UA_Byte   EncodingByte; //enum BID_NodeIdEncodingValuesType
-	UInt16 Namespace;
-
-    union
-    {
-        UA_UInt32 Numeric;
-        UA_String String;
-        UA_Guid Guid;
-        UA_ByteString ByteString;
-    }
-    Identifier;
-
-}
-UA_NodeId;
-
-
-/**
-* ExpandedNodeId
-* Part: 6
-* Chapter: 5.2.2.10
-* Page: 19
-*/
-typedef struct UA_ExpandedNodeId
-{
-	UA_NodeId NodeId;
-	UA_Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
-	UA_String NamespaceUri;
-	UA_UInt32 ServerIndex;
-}
-UA_ExpandedNodeId;
-
-
-/**
-* StatusCodeBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.11
-* Page: 20
-*/
-typedef UA_UInt32 UA_StatusCode;
-typedef enum UA_StatusCodes
-{
-	// Some Values are called the same as previous Enumerations so we need
-	//names that are unique
-	SC_Good 			= 			0x00
-} UA_StatusCodes;
-
-
-/**
-* DiagnoticInfoBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.12
-* Page: 20
-*/
-typedef struct UA_DiagnosticInfo
-{
-	UA_Byte EncodingMask; //Type of the Enum UA_DiagnosticInfoEncodingMaskType
-	UA_Int32 SymbolicId;
-	UA_Int32 NamespaceUri;
-	UA_Int32 LocalizedText;
-	UA_Int32 Locale;
-	UA_String AdditionalInfo;
-	UA_StatusCode InnerStatusCode;
-	struct UA_DiagnosticInfo* InnerDiagnosticInfo;
-}
-UA_DiagnosticInfo;
-extern UA_DiagnosticInfo the_empty_UA_DiagnosticInfo;
-
-typedef enum UA_DiagnosticInfoEncodingMaskType
-{
-	// Some Values are called the same as previous Enumerations so we need
-	//names that are unique
-	DIEMT_SYMBOLIC_ID = 			0x01,
-	DIEMT_NAMESPACE = 				0x02,
-	DIEMT_LOCALIZED_TEXT = 			0x04,
-	DIEMT_LOCALE = 					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
-{
-	UA_Byte EncodingMask;
-	UA_String Locale;
-	UA_String Text;
-}
-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;
-	UA_Byte Encoding; //Type of the Enum UA_ExtensionObjectEncodingMaskType
-	UA_ByteString Body;
-}
-UA_ExtensionObject;
-
-typedef enum UA_ExtensionObjectEncodingMaskType
-{
-	NO_BODY_IS_ENCODED = 	0x00,
-	BODY_IS_BYTE_STRING = 	0x01,
-	BODY_IS_XML_ELEMENT = 	0x02
-}
-UA_ExtensionObjectEncodingMaskType;
-
-// the empty extensionobject
-extern UA_ExtensionObject the_empty_UA_ExtensionObject;
-
-typedef UA_VariantUnion;
-/**
-* VariantBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.16
-* Page: 22
-*/
-typedef struct UA_Variant
-{
-	UA_Byte EncodingMask; //Type of Enum UA_VariantTypeEncodingMaskType
-	UA_Int32 ArrayLength;
-	UA_VariantUnion *Value;
-}
-UA_Variant;
-
-/**
-* DataValueBinaryEncoding
-* Part: 6
-* Chapter: 5.2.2.17
-* Page: 23
-*/
-typedef struct UA_DataValue
-{
-	UA_Byte EncodingMask;
-	UA_Variant Value;
-	UA_StatusCode Status;
-	UA_DateTime SourceTimestamp;
-	UA_Int16 SourcePicoseconds;
-	UA_DateTime ServerTimestamp;
-	UA_Int16 ServerPicoseconds;
-}
-UA_DataValue;
-
-typedef struct IntegerString
-{
-	UA_Int32 *data;
-	UA_Int32 length;
-}IntegerString;
-
-typedef struct Int32_Array
-{
-	UA_Int32 *data;
-	UA_Int32 arrayLength;
-	IntegerString dimensions;
-}Int32_Array;
-
-
-// Array types of builtInDatatypes
-typedef struct SBYte_Array
-{
-	UA_SByte *data;
-	UA_Int32 arrayLength;
-	IntegerString dimensions;
-}SBYte_Array;
-
-typedef struct Boolean_Array
-{
-	Boolean *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Boolean_Array;
-
-typedef struct
-{
-	UA_SByte *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}SByte_Array;
-
-typedef struct Byte_Array
-{
-	UA_Byte *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Byte_Array;
-
-typedef struct Int16_Array
-{
-	UA_Int16 *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Int16_Array;
-
-typedef struct UInt16_Array
-{
-	UInt16 *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}UInt16_Array;
-
-
-typedef struct UInt32_Array
-{
-	UA_UInt32 *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}UInt32_Array;
-
-typedef struct
-{
-	UA_Int64 *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Int64_Array;
-
-typedef struct UInt64_Array
-{
-	UA_UInt64 *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}UInt64_Array;
-
-typedef struct Float_Array
-{
-	Float *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Float_Array;
-
-typedef struct Double_Array
-{
-	UA_Double *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Double_Array;
-
-typedef struct String_Array
-{
-	UA_String *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}String_Array;
-
-typedef struct DateTime_Array
-{
-	UA_DateTime *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}DateTime_Array;
-
-typedef struct Guid_Array
-{
-	UA_Guid *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Guid_Array;
-
-typedef struct ByteString_Array
-{
-	UA_ByteString *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}ByteString_Array;
-
-typedef struct XmlElement_Array
-{
-	UA_XmlElement *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}XmlElement_Array;
-
-typedef struct NodeId_Array
-{
-	UA_NodeId *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}NodeId_Array;
-
-typedef struct ExpandedNodeId_Array
-{
-	UA_ExpandedNodeId *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}ExpandedNodeId_Array;
-
-
-typedef struct StatusCode_Array
-{
-	UA_StatusCode *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}StatusCode_Array;
-
-typedef struct QualifiedName_Array
-{
-	UA_QualifiedName *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}QualifiedName_Array;
-
-typedef struct LocalizedText_Array
-{
-	UA_LocalizedText *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}LocalizedText_Array;
-
-typedef struct ExtensionObject_Array
-{
-	UA_ExtensionObject *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}ExtensionObject_Array;
-
-typedef struct
-{
-	struct UA_DataValue *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}DataValue_Array;
-
-typedef struct Variant_Array
-{
-	struct UA_Variant *data;
-	UA_Int32 arrayLength;
-	IntegerString  dimensions;
-}Variant_Array;
-
-typedef struct DiagnosticInfo_Array
-{
-	UA_DiagnosticInfo *data;
-	UA_Int32 arrayLength;
-	IntegerString dimensions;
-}DiagnosticInfo_Array;
-
-
-typedef union UA_VariantArrayUnion
-{
-    void*         Array;
-    Boolean_Array BooleanArray;
-    SByte_Array   SByteArray;
-    Byte_Array    ByteArray;
-    Int16_Array   Int16Array;
-    UInt16_Array  UInt16Array;
-    Int32_Array   Int32Array;
-    UInt32_Array  UInt32Array;
-    Int64_Array   Int64Array;
-    UInt64_Array  UInt64Array;
-    Float_Array   FloatArray;
-    Double_Array            DoubleArray;
-    String_Array            StringArray;
-    DateTime_Array          DateTimeArray;
-    Guid_Array              GuidArray;
-    ByteString_Array        ByteStringArray;
-    ByteString_Array        XmlElementArray;
-    NodeId_Array            NodeIdArray;
-    ExpandedNodeId_Array    ExpandedNodeIdArray;
-    StatusCode_Array        StatusCodeArray;
-    QualifiedName_Array     QualifiedNameArray;
-    LocalizedText_Array     LocalizedTextArray;
-    ExtensionObject_Array   ExtensionObjectArray;
-    DataValue_Array DataValueArray;
-    Variant_Array   VariantArray;
-}
-UA_VariantArrayUnion;
-
-
-typedef struct UA_VariantArrayValue
-{
-	//Byte TypeEncoding;
-    UA_Int32  Length;
-    UA_VariantArrayUnion Value;
-}
-UA_VariantArrayValue;
-
-typedef struct
-{
-    UA_Int32 NoOfDimensions;
-    UA_Int32* Dimensions;
-    UA_VariantArrayUnion Value;
-}
-UA_VariantMatrixValue;
-
-union UA_VariantUnion
-{
-    Boolean Boolean;
-    UA_SByte SByte;
-    UA_Byte Byte;
-    UA_Int16 Int16;
-    UInt16 UInt16;
-    UA_Int32 Int32;
-    UA_UInt32 UInt32;
-    UA_Int64 Int64;
-    UA_UInt64 UInt64;
-    Float Float;
-    UA_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;
-    UA_DataValue *DataValue;
-    UA_VariantArrayValue  Array;
-    UA_VariantMatrixValue Matrix;
-};
-
-
-
-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;
-
-
-
-
-typedef UA_UInt32 IntegerId;
-
-
-/**
-* Duration
-* Part: 3
-* Chapter: 8.13
-* Page: 74
-*/
-typedef double UA_Duration;
-
-/**
- *
- * @param string1
- * @param string2
- * @return
- */
-UA_Int32 UA_String_compare(UA_String *string1, UA_String *string2);
-/**
- *
- * @param string1
- * @param string2
- * @return
- */
-UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2);
-
-#endif /* OPCUA_BUILTINDATATYPES_H_ */

+ 3 - 4
src/opcua_connectionHelper.h

@@ -7,8 +7,7 @@
 
 #ifndef OPCUA_CONNECTIONHELPER_H_
 #define OPCUA_CONNECTIONHELPER_H_
-#include "opcua_builtInDatatypes.h"
-#include "opcua_types.h"
+#include "opcua.h"
 
 enum packetType
 {
@@ -94,9 +93,9 @@ typedef struct
 	struct SL_connection secureLayer;
 	struct SS_connection serviceLayer;
 
-	Boolean newDataToRead;
+	UA_Boolean newDataToRead;
 	UA_ByteString readData;
-	Boolean newDataToWrite;
+	UA_Boolean newDataToWrite;
 	UA_ByteString writeData;
 }UA_connection;
 

+ 0 - 10
src/opcua_encodingLayer.c

@@ -1,10 +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"

+ 0 - 14
src/opcua_encodingLayer.h

@@ -1,14 +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"
-#endif

+ 0 - 19
src/opcua_memory.c

@@ -1,19 +0,0 @@
-/*
- * opcua_memory.c
- *
- *  Created on: Jan 30, 2014
- *      Author: opcua
- */
-
-#include "opcua_memory.h"
-void *opcua_malloc(size_t size)
-{
-
-	return malloc(size);
-}
-
-
-void opcua_free(void *pointer)
-{
-	free(pointer);
-}

+ 0 - 25
src/opcua_memory.h

@@ -1,25 +0,0 @@
-/*
- * opcua_memory.h
- *
- *  Created on: Jan 30, 2014
- *      Author: opcua
- */
-
-#ifndef OPCUA_MEMORY_H_
-#define OPCUA_MEMORY_H_
-#include <stdint.h>
-#include <stdlib.h>
-/**
- *
- * @param size
- */
-void* opcua_malloc(size_t size);
-
-/**
- *
- * @param pointer
- */
-void opcua_free(void* pointer);
-
-
-#endif /* OPCUA_MEMORY_H_ */

+ 75 - 77
src/opcua_secureChannelLayer.c

@@ -4,9 +4,9 @@
  *  Created on: Jan 13, 2014
  *      Author: opcua
  */
-#include "opcua_secureChannelLayer.h"
 #include <stdio.h>
-#include "opcua_time.h"
+#include <memory.h> // memcpy
+#include "opcua_secureChannelLayer.h"
 
 #define SIZE_SECURECHANNEL_HEADER 12
 #define SIZE_SEQHEADER_HEADER 8
@@ -19,20 +19,19 @@ UA_Int32 SL_initConnectionObject(UA_connection *connection)
 {
 
 	//TODO: fill with valid information
-	connection->secureLayer.localtAsymAlgSettings.ReceiverCertificateThumbprint.data = NULL;
-	connection->secureLayer.localtAsymAlgSettings.ReceiverCertificateThumbprint.length = 0;
+	connection->secureLayer.localAsymAlgSettings.ReceiverCertificateThumbprint.data = NULL;
+	connection->secureLayer.localAsymAlgSettings.ReceiverCertificateThumbprint.length = 0;
 
-	connection->secureLayer.localtAsymAlgSettings.SecurityPolicyUri.data = "http://opcfoundation.org/UA/SecurityPolicy#None";
-	connection->secureLayer.localtAsymAlgSettings.SecurityPolicyUri.length = 47;
+	connection->secureLayer.localAsymAlgSettings.SecurityPolicyUri.data = "http://opcfoundation.org/UA/SecurityPolicy#None";
+	connection->secureLayer.localAsymAlgSettings.SecurityPolicyUri.length = 47;
 
-	connection->secureLayer.localtAsymAlgSettings.SenderCertificate.data = NULL;
-	connection->secureLayer.localtAsymAlgSettings.SenderCertificate.length = 0;
+	connection->secureLayer.localAsymAlgSettings.SenderCertificate.data = NULL;
+	connection->secureLayer.localAsymAlgSettings.SenderCertificate.length = 0;
 
 	connection->secureLayer.remoteNonce.data = NULL;
 	connection->secureLayer.remoteNonce.length = 0;
 
-	connection->secureLayer.localNonce.data = (UA_Byte*)opcua_malloc(sizeof(UA_Byte));
-	*connection->secureLayer.localNonce.data = sizeof(UA_Byte);
+	UA_alloc((void**)&(connection->secureLayer.localNonce.data),sizeof(UA_Byte));
 	connection->secureLayer.localNonce.length = 1;
 
 	connection->secureLayer.connectionState = connectionState_CLOSED;
@@ -44,7 +43,7 @@ UA_Int32 SL_initConnectionObject(UA_connection *connection)
 	connection->secureLayer.secureChannelId.data = NULL;
 	connection->secureLayer.secureChannelId.length = 0;
 
-	connection->secureLayer.securityMode = securityMode_INVALID;
+	connection->secureLayer.securityMode = UA_SecurityMode_INVALID;
 	//TODO set a valid start secureChannelId number
 	connection->secureLayer.securityToken.secureChannelId = 25;
 
@@ -68,9 +67,9 @@ UA_Int32 SL_send(UA_connection *connection, UA_ByteString responseMessage, UA_In
 
 
 	sizeAsymAlgHeader = 3 * sizeof(UA_UInt32) +
-			connection->secureLayer.localtAsymAlgSettings.SecurityPolicyUri.length +
-			connection->secureLayer.localtAsymAlgSettings.SenderCertificate.length +
-			connection->secureLayer.localtAsymAlgSettings.ReceiverCertificateThumbprint.length;
+			connection->secureLayer.localAsymAlgSettings.SecurityPolicyUri.length +
+			connection->secureLayer.localAsymAlgSettings.SenderCertificate.length +
+			connection->secureLayer.localAsymAlgSettings.ReceiverCertificateThumbprint.length;
 	pos = 0;
 	//sequence header
 	sequenceNumber = connection->secureLayer.sequenceNumber;
@@ -92,7 +91,7 @@ UA_Int32 SL_send(UA_connection *connection, UA_ByteString responseMessage, UA_In
 				sizeSignature;
 
 		//get memory for response
-		responsePacket.data = (char*)opcua_malloc(packetSize);
+		UA_alloc((void**)&(responsePacket.data),packetSize);
 
 		responsePacket.length = packetSize;
 
@@ -105,25 +104,24 @@ UA_Int32 SL_send(UA_connection *connection, UA_ByteString responseMessage, UA_In
 		//encode Chunk Type - set to final
 		responsePacket.data[3] = 'F';
 		pos += 1;
-		encoder_encodeBuiltInDatatype(&packetSize,INT32,&pos,responsePacket.data);
-		encoder_encodeBuiltInDatatype(&(connection->secureLayer.securityToken.secureChannelId),
-				INT32,&pos,responsePacket.data);
+		UA_Int32_encode(&packetSize,&pos,responsePacket.data);
+		UA_Int32_encode(&(connection->secureLayer.securityToken.secureChannelId),&pos,responsePacket.data);
 
 		/*---encode Asymmetric Algorithm Header ---*/
-		encoder_encodeBuiltInDatatype(&(connection->secureLayer.localtAsymAlgSettings.SecurityPolicyUri),
-						BYTE_STRING,&pos,responsePacket.data);
-		encoder_encodeBuiltInDatatype(&(connection->secureLayer.localtAsymAlgSettings.SenderCertificate),
-						BYTE_STRING,&pos,responsePacket.data );
-		encoder_encodeBuiltInDatatype(&(connection->secureLayer.localtAsymAlgSettings.ReceiverCertificateThumbprint),
-						BYTE_STRING,&pos,responsePacket.data );
+		UA_ByteString_encode(&(connection->secureLayer.localAsymAlgSettings.SecurityPolicyUri),
+						&pos,responsePacket.data);
+		UA_ByteString_encode(&(connection->secureLayer.localAsymAlgSettings.SenderCertificate),
+						&pos,responsePacket.data );
+		UA_ByteString_encode(&(connection->secureLayer.localAsymAlgSettings.ReceiverCertificateThumbprint),
+						&pos,responsePacket.data );
 	}
 
 
 
 
 	/*---encode Sequence Header ---*/
-	encoder_encodeBuiltInDatatype(&sequenceNumber,UINT32,&pos,responsePacket.data);
-	encoder_encodeBuiltInDatatype(&requestId,UINT32,&pos,responsePacket.data);
+	UA_UInt32_encode(&sequenceNumber,&pos,responsePacket.data);
+	UA_UInt32_encode(&requestId,&pos,responsePacket.data);
 
 	/*---add encoded Message ---*/
 	memcpy(&(responsePacket.data[pos]), responseMessage.data, responseMessage.length);
@@ -143,13 +141,13 @@ UA_Int32 SL_send(UA_connection *connection, UA_ByteString responseMessage, UA_In
  * opens a secure channel
  */
 UA_Int32 SL_openSecureChannel(UA_connection *connection,
-		UA_AD_RequestHeader *requestHeader,
+		UA_RequestHeader *requestHeader,
 		UA_StatusCode serviceResult)
 {
 
 
 
-	UA_AD_ResponseHeader responseHeader;
+	UA_ResponseHeader responseHeader;
 	UA_ExtensionObject additionalHeader;
 	SL_ChannelSecurityToken securityToken;
 	UA_ByteString serverNonce;
@@ -179,7 +177,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	/*--------------type ----------------------*/
 
 	//Four Bytes Encoding
-	responseType.encodingByte = NIEVT_FOUR_BYTE;
+	responseType.encodingByte = UA_NodeIdType_FourByte;
 	//openSecureChannelResponse = 449
 	responseType.identifier.numeric = 449;
 	responseType.namespace = 0;
@@ -196,7 +194,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	 */
 	//current time
 
-	responseHeader.timestamp = opcua_time_now();
+	responseHeader.timestamp = UA_DateTime_now();
 	//request Handle which client sent
 	responseHeader.requestHandle = requestHeader->requestHandle;
 	// StatusCode which informs client about quality of response
@@ -205,7 +203,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	responseHeader.serviceDiagnostics = &serviceDiagnostics;
 
 	//text of fields defined in the serviceDiagnostics
-	responseHeader.noOfStringTable = 0;
+	responseHeader.stringTableSize = 0;
 	responseHeader.stringTable = NULL;
 
 
@@ -223,7 +221,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	printf("SL_openSecureChannel - built response header\n");
 
 	//calculate the size
-	sizeRespHeader = responseHeader_calcSize(&responseHeader);
+	sizeRespHeader = UA_ResponseHeader_calcSize(&responseHeader);
 	printf("SL_openSecureChannel - size response header =%d\n",sizeRespHeader);
 	/*--------------responseMessage-------------*/
 	/* 	Res-2) UInt32 ServerProtocolVersion
@@ -244,7 +242,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	//fill token structure with default server information
 	securityToken.secureChannelId = connection->secureLayer.securityToken.secureChannelId;
 	securityToken.tokenId = connection->secureLayer.securityToken.tokenId;
-	securityToken.createdAt = opcua_time_now();
+	securityToken.createdAt = UA_DateTime_now();
 	securityToken.revisedLifetime = connection->secureLayer.securityToken.revisedLifetime;
 
 	serverProtocolVersion = connection->transportLayer.localConf.protocolVersion;
@@ -255,42 +253,42 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 
 
 	//get memory for response
-	sizeResponseType = nodeId_calcSize(&responseType);
+	sizeResponseType = UA_NodeId_calcSize(&responseType);
 
 	response.length = sizeResponseType + sizeRespHeader + sizeRespMessage;
 
 	//get memory for response
-	response.data = (char*)opcua_malloc(nodeId_calcSize(&responseType) + sizeRespHeader + sizeRespMessage);
+	UA_alloc(&(response.data), UA_NodeId_calcSize(&responseType) + sizeRespHeader + sizeRespMessage);
 	pos = 0;
 	//encode responseType (NodeId)
 	UA_NodeId_printf("SL_openSecureChannel - TypeId =",&responseType);
-	encoder_encodeBuiltInDatatype(&responseType, NODE_ID, &pos, response.data);
+	UA_NodeId_encode(&responseType, &pos, response.data);
 
 	//encode header
 	printf("SL_openSecureChannel - encoding response header \n");
 
-	encodeResponseHeader(&responseHeader, &pos, &response);
+	UA_ResponseHeader_encode(&responseHeader, &pos, &response);
 	printf("SL_openSecureChannel - response header encoded \n");
 
 	//encode message
 	printf("SL_openSecureChannel - serverProtocolVersion = %d \n",serverProtocolVersion);
-	encoder_encodeBuiltInDatatype(&serverProtocolVersion, UINT32, &pos,response.data);
+	UA_UInt32_encode(&serverProtocolVersion, &pos,response.data);
 	printf("SL_openSecureChannel - secureChannelId = %d \n",securityToken.secureChannelId);
-	encoder_encodeBuiltInDatatype(&(securityToken.secureChannelId), UINT32, &pos,response.data);
+	UA_UInt32_encode(&(securityToken.secureChannelId), &pos,response.data);
 	printf("SL_openSecureChannel - tokenId = %d \n",securityToken.tokenId);
-	encoder_encodeBuiltInDatatype(&(securityToken.tokenId), INT32, &pos,response.data);
+	UA_Int32_encode(&(securityToken.tokenId), &pos,response.data);
 
-	encoder_encodeBuiltInDatatype(&(securityToken.createdAt), DATE_TIME, &pos,response.data);
+	UA_DateTime_encode(&(securityToken.createdAt), &pos,response.data);
 	printf("SL_openSecureChannel - revisedLifetime = %d \n",securityToken.revisedLifetime);
-	encoder_encodeBuiltInDatatype(&(securityToken.revisedLifetime), INT32, &pos,response.data);
+	UA_Int32_encode(&(securityToken.revisedLifetime), &pos,response.data);
 
-	encoder_encodeBuiltInDatatype(&serverNonce, BYTE_STRING, &pos,response.data);
+	UA_ByteString_encode(&serverNonce, &pos,response.data);
 
 	printf("SL_openSecureChannel - response.length = %d \n",response.length);
 	//449 = openSecureChannelResponse
 	SL_send(connection, response, 449);
 
-	return UA_NO_ERROR;
+	return UA_SUCCESS;
 }
 /*
 Int32 SL_openSecureChannel_responseMessage_calcSize(SL_Response *response,
@@ -319,7 +317,7 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 	UA_DiagnosticInfo serviceDiagnostics;
 
 	UA_Int32 pos = 0;
-	UA_AD_RequestHeader requestHeader;
+	UA_RequestHeader requestHeader;
 	UA_UInt32 clientProtocolVersion;
 	UA_NodeId serviceRequestType;
 	UA_Int32 requestType;
@@ -329,18 +327,18 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 	UA_StatusCode serviceResult;
 
 	// Every Message starts with a NodeID which names the serviceRequestType
-	decoder_decodeBuiltInDatatype(message.data, NODE_ID, &pos,
+	UA_NodeId_decode(message.data, &pos,
 			&serviceRequestType);
 	UA_NodeId_printf("SL_processMessage - serviceRequestType=",
 			&serviceRequestType);
 
-	if (serviceRequestType.encodingByte == NIEVT_FOUR_BYTE
+	if (serviceRequestType.encodingByte == UA_NodeIdType_FourByte
 			&& serviceRequestType.identifier.numeric == 446) {
 		/* OpenSecureChannelService, defined in 62541-6 §6.4.4, Table 34.
 		 * Note that part 6 adds ClientProtocolVersion and ServerProtocolVersion
 		 * to the definition in part 4 */
 		// 	Req-1) RequestHeader requestHeader
-		UA_AD_RequestHeader requestHeader;
+		UA_RequestHeader requestHeader;
 		// 	Req-2) UInt32 ClientProtocolVersion
 		UA_UInt32 clientProtocolVersion;
 		// 	Req-3) Enum SecurityTokenRequestType requestType
@@ -355,7 +353,7 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 		UA_ByteString_printx("SL_processMessage - message=", &message);
 
 		// Req-1) RequestHeader requestHeader
-		decoder_decodeRequestHeader(message.data, &pos, &requestHeader);
+		UA_RequestHeader_decode(message.data, &pos, &requestHeader);
 		UA_String_printf("SL_processMessage - requestHeader.auditEntryId=",
 				&requestHeader.auditEntryId);
 		UA_NodeId_printf(
@@ -363,7 +361,7 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 				&requestHeader.authenticationToken);
 
 		// 	Req-2) UInt32 ClientProtocolVersion
-		decoder_decodeBuiltInDatatype(message.data, UINT32, &pos,
+		UA_UInt32_decode(message.data, &pos,
 				&clientProtocolVersion);
 		printf("SL_processMessage - clientProtocolVersion=%d\n",
 				clientProtocolVersion);
@@ -377,7 +375,7 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 		}
 
 		// 	Req-3) SecurityTokenRequestType requestType
-		decoder_decodeBuiltInDatatype(message.data, INT32, &pos, &requestType);
+		UA_Int32_decode(message.data, &pos, &requestType);
 		printf("SL_processMessage - requestType=%d\n", requestType);
 		switch (requestType) {
 		case securityToken_ISSUE:
@@ -404,33 +402,33 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 		}
 
 		// 	Req-4) MessageSecurityMode SecurityMode
-		decoder_decodeBuiltInDatatype(message.data, INT32, &pos, &securityMode);
+		UA_UInt32_decode(message.data, &pos, &securityMode);
 		printf("SL_processMessage - securityMode=%d\n", securityMode);
 		switch (securityMode) {
-		case UA_securityMode_INVALID:
+		case UA_SecurityMode_INVALID:
 			connection->secureLayer.remoteNonce.data = NULL;
 			connection->secureLayer.remoteNonce.length = 0;
 			printf("SL_processMessage - client demands no security \n");
 			break;
 
-		case UA_securityMode_SIGN:
+		case UA_SecurityMode_SIGN:
 			printf("SL_processMessage - client demands signed \n");
 			//TODO check if senderCertificate and ReceiverCertificateThumbprint are present
 			break;
 
-		case UA_securityMode_SIGNANDENCRYPT:
+		case UA_SecurityMode_SIGNANDENCRYPT:
 			printf("SL_processMessage - client demands signed & encrypted \n");
 			//TODO check if senderCertificate and ReceiverCertificateThumbprint are present
 			break;
 		}
 
 		//  Req-5) ByteString ClientNonce
-		decoder_decodeBuiltInDatatype(message.data, BYTE_STRING, &pos,
+		UA_ByteString_decode(message.data, &pos,
 				&clientNonce);
-		UA_String_printf("SL_processMessage - clientNonce=", &clientNonce);
+		UA_ByteString_printf("SL_processMessage - clientNonce=", &clientNonce);
 
 		//  Req-6) Int32 RequestLifetime
-		decoder_decodeBuiltInDatatype(message.data, INT32, &pos,
+		UA_Int32_decode(message.data, &pos,
 				&requestedLifetime);
 		printf("SL_processMessage - requestedLifeTime=%d\n", requestedLifetime);
 		//TODO process requestedLifetime
@@ -443,7 +441,7 @@ UA_Int32 SL_processMessage(UA_connection *connection, UA_ByteString message) {
 		return UA_ERROR;
 
 	}
-	return UA_NO_ERROR;
+	return UA_SUCCESS;
 }
 /*
  * receive and process data from underlying layer
@@ -478,7 +476,7 @@ void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage) {
 					&(AAS_Header.ReceiverThumbprint));
 			UA_String_printf("SL_receive - AAS_Header.SecurityPolicyUri=",
 					&(AAS_Header.SecurityPolicyUri));
-			UA_String_printf("SL_receive - AAS_Header.SenderCertificate=",
+			UA_ByteString_printf("SL_receive - AAS_Header.SenderCertificate=",
 					&(AAS_Header.SenderCertificate));
 			if (SCM_Header.SecureChannelId != 0) {
 
@@ -609,9 +607,9 @@ UA_Int32 decodeSCMHeader(UA_ByteString *rawMessage, UA_Int32 *pos,
 	SC_Header->MessageType = TL_getPacketType(rawMessage, pos);
 	SC_Header->IsFinal = rawMessage->data[*pos];
 	*pos += 1;
-	decodeUInt32(rawMessage->data, pos, &(SC_Header->MessageSize));
-	decodeUInt32(rawMessage->data, pos, &(SC_Header->SecureChannelId));
-	return UA_NO_ERROR;
+	UA_UInt32_decode(rawMessage->data, pos, &(SC_Header->MessageSize));
+	UA_UInt32_decode(rawMessage->data, pos, &(SC_Header->SecureChannelId));
+	return UA_SUCCESS;
 
 }
 /*
@@ -649,9 +647,9 @@ Int32 encodeSCMHeader(SL_SecureConversationMessageHeader *SC_Header, Int32 *pos,
 
 UA_Int32 decodeSequenceHeader(UA_ByteString *rawMessage, UA_Int32 *pos,
 		SL_SequenceHeader *SequenceHeader) {
-	decodeUInt32(rawMessage->data, pos, &(SequenceHeader->SequenceNumber));
-	decodeUInt32(rawMessage->data, pos, &(SequenceHeader->RequestId));
-	return UA_NO_ERROR;
+	UA_UInt32_decode(rawMessage->data, pos, &(SequenceHeader->SequenceNumber));
+	UA_UInt32_decode(rawMessage->data, pos, &(SequenceHeader->RequestId));
+	return UA_SUCCESS;
 }
 
 /*
@@ -660,23 +658,23 @@ UA_Int32 decodeSequenceHeader(UA_ByteString *rawMessage, UA_Int32 *pos,
 UA_Int32 decodeAASHeader(UA_ByteString *rawMessage, UA_Int32 *pos,
 		SL_AsymmetricAlgorithmSecurityHeader* AAS_Header) {
 	UA_Int32 err = 0;
-	err += decodeUAByteString(rawMessage->data, pos,
+	err |= UA_String_decode(rawMessage->data, pos,
 			&(AAS_Header->SecurityPolicyUri));
-	err += decodeUAByteString(rawMessage->data, pos,
+	err |= UA_ByteString_decode(rawMessage->data, pos,
 			&(AAS_Header->SenderCertificate));
-	err += decodeUAByteString(rawMessage->data, pos,
+	err |= UA_String_decode(rawMessage->data, pos,
 			&(AAS_Header->ReceiverThumbprint));
 	return err;
 }
 
 UA_Int32 encodeAASHeader(SL_AsymmetricAlgorithmSecurityHeader *AAS_Header,
-		UA_Int32 *pos, AD_RawMessage* dstRawMessage) {
-	encodeUAString(AAS_Header->SecurityPolicyUri, pos,
-			&dstRawMessage->message[*pos]);
-	encodeUAString(AAS_Header->SenderCertificate, pos,
-			&dstRawMessage->message[*pos]);
-	encodeUAString(AAS_Header->ReceiverThumbprint, pos,
-			&dstRawMessage->message[*pos]);
-	return UA_NO_ERROR;
+		UA_Int32 *pos, UA_ByteString* dstRawMessage) {
+	UA_String_encode(&(AAS_Header->SecurityPolicyUri), pos,
+			dstRawMessage->data);
+	UA_ByteString_encode(&(AAS_Header->SenderCertificate), pos,
+			dstRawMessage->data);
+	UA_String_encode(&(AAS_Header->ReceiverThumbprint), pos,
+			dstRawMessage->data);
+	return UA_SUCCESS;
 }
 

+ 0 - 31
src/opcua_time.c

@@ -1,31 +0,0 @@
-/*
- * opcua_time.c
- *
- *  Created on: Feb 5, 2014
- *      Author: opcua
- *
- * code inspired by
- * http://stackoverflow.com/questions/3585583/convert-unix-linux-time-to-windows-filetime
- */
-#include "opcua_builtInDatatypes.h"
-#include "opcua_advancedDatatypes.h"
-#include <sys/time.h>
-
-// Number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC
-#define FILETIME_UNIXTIME_BIAS_SEC 11644473600LL
-// Factors
-#define HUNDRED_NANOSEC_PER_USEC 10LL
-#define HUNDRED_NANOSEC_PER_SEC (HUNDRED_NANOSEC_PER_USEC * 1000000LL)
-
-// IEC 62541-6 §5.2.2.5  A DateTime value shall be encoded as a 64-bit signed integer
-// which represents the number of 100 nanosecond intervals since January 1, 1601 (UTC).
-UA_DateTime opcua_time_now() {
-	UA_DateTime dateTime;
-	struct timeval tv;
-	gettimeofday(&tv, NULL);
-	dateTime = (tv.tv_sec + FILETIME_UNIXTIME_BIAS_SEC)
-			* HUNDRED_NANOSEC_PER_SEC + tv.tv_usec * HUNDRED_NANOSEC_PER_USEC;
-	return dateTime;
-}
-
-

+ 0 - 15
src/opcua_time.h

@@ -1,15 +0,0 @@
-/*
- * opcua_time.h
- *
- *  Created on: Feb 5, 2014
- *      Author: opcua
- */
-
-#ifndef OPCUA_TIME_H_
-#define OPCUA_TIME_H_
-#include <time.h>
-
-UA_DateTime opcua_time_now();
-
-#endif /* OPCUA_TIME_H_ */
-

+ 25 - 32
src/opcua_transportLayer.c

@@ -12,8 +12,8 @@ UA_Int32 TL_initConnectionObject(UA_connection *connection)
 {
 
 	connection->newDataToRead = 0;
-	connection->readData->data = NULL;
-	connection->readData->length = 0;
+	connection->readData.data = UA_NULL;
+	connection->readData.length = 0;
 	connection->transportLayer.connectionState = connectionState_CLOSED;
 	connection->transportLayer.localConf.maxChunkCount = 1;
 	connection->transportLayer.localConf.maxMessageSize = 16384;
@@ -31,11 +31,11 @@ UA_Int32 TL_check(UA_connection *connection)
 	printf("TL_check - entered \n");
 
 
-	decoder_decodeBuiltInDatatype(connection->readData->data,UINT32,&position,&messageLength);
+	UA_UInt32_decode(connection->readData.data,&position,&messageLength);
 
 	printf("TL_check - messageLength = %d \n",messageLength);
 
-	if (messageLength == connection->readData->length &&
+	if (messageLength == connection->readData.length &&
 			messageLength < (connection->transportLayer.localConf.maxMessageSize))
 	{
 		printf("TL_check - no error \n");
@@ -54,7 +54,6 @@ UA_Int32 TL_receive(UA_connection *connection, UA_ByteString *packet)
 	UA_UInt32 length = 0;
 	UA_Int32 pos = 0;
 
-	AD_RawMessage tmpRawMessage;
 	struct TL_header tmpHeader;
 	printf("TL_receive - entered \n");
 
@@ -186,37 +185,31 @@ UA_Int32 TL_process(UA_connection *connection,UA_Int32 packetType, UA_Int32 *pos
 			printf("TL_process - pos = %d \n",*pos);
 
 			/* extract information from received header */
-			decoder_decodeBuiltInDatatype(connection->readData.data,UINT32,pos,
-					(void*)(&(connection->transportLayer.remoteConf.protocolVersion)));
+			UA_UInt32_decode(connection->readData.data,pos,(&(connection->transportLayer.remoteConf.protocolVersion)));
 
 			printf("TL_process - protocolVersion = %d \n",connection->transportLayer.remoteConf.protocolVersion);
 
-			decoder_decodeBuiltInDatatype(connection->readData.data,UINT32,pos,
-					(void*)(&(connection->transportLayer.remoteConf.recvBufferSize)));
+			UA_UInt32_decode(connection->readData.data,pos,(&(connection->transportLayer.remoteConf.recvBufferSize)));
 
 			printf("TL_process - recvBufferSize = %d \n",connection->transportLayer.remoteConf.recvBufferSize);
 
-			decoder_decodeBuiltInDatatype(connection->readData.data,UINT32,pos,
-					(void*)(&(connection->transportLayer.remoteConf.sendBufferSize)));
+			UA_UInt32_decode(connection->readData.data,pos,(&(connection->transportLayer.remoteConf.sendBufferSize)));
 
 			printf("TL_process - sendBufferSize = %d \n",connection->transportLayer.remoteConf.sendBufferSize);
 
-			decoder_decodeBuiltInDatatype(connection->readData.data,UINT32,pos,
-					(void*)(&(connection->transportLayer.remoteConf.maxMessageSize)));
+			UA_UInt32_decode(connection->readData.data,pos,(&(connection->transportLayer.remoteConf.maxMessageSize)));
 
 			printf("TL_process - maxMessageSize = %d \n",connection->transportLayer.remoteConf.maxMessageSize);
 
-			decoder_decodeBuiltInDatatype(connection->readData.data,UINT32,pos,
-					(void*)(&(connection->transportLayer.remoteConf.maxChunkCount)));
+			UA_UInt32_decode(connection->readData.data,pos,(&(connection->transportLayer.remoteConf.maxChunkCount)));
 
 			printf("TL_process - maxChunkCount = %d \n",connection->transportLayer.remoteConf.maxChunkCount);
 
-			decoder_decodeBuiltInDatatype(connection->readData.data,STRING,pos,
-					(void*)(&(connection->transportLayer.endpointURL)));
+			UA_String_decode(connection->readData.data,pos,(&(connection->transportLayer.endpointURL)));
 
 			/* send back acknowledge */
-			tmpMessage.data = (UA_Byte*)opcua_malloc(SIZE_OF_ACKNOWLEDGE_MESSAGE);
-			if(tmpMessage.data == NULL)
+			UA_alloc((void**)&(tmpMessage.data),SIZE_OF_ACKNOWLEDGE_MESSAGE);
+			if(tmpMessage.data == UA_NULL)
 			{
 				printf("TL_process - memory allocation failed \n");
 			}
@@ -230,33 +223,33 @@ UA_Int32 TL_process(UA_connection *connection,UA_Int32 packetType, UA_Int32 *pos
 			tmpPos += 3;
 			// Chunk
 			reserved = 'F';
-			encoder_encodeBuiltInDatatype(&reserved, BYTE, &tmpPos, tmpMessage.data);
+			UA_Byte_encode(&reserved, &tmpPos, tmpMessage.data);
 			// MessageSize
 			messageSize = SIZE_OF_ACKNOWLEDGE_MESSAGE;
-			encoder_encodeBuiltInDatatype(&messageSize,UINT32, &tmpPos, tmpMessage.data);
+			UA_UInt32_encode(&messageSize,&tmpPos, tmpMessage.data);
 			printf("TL_process - Size messageToSend = %d \n",messageSize);
 
 			/* ------------------------ Body ------------------------ */
 			// protocol version
-			encoder_encodeBuiltInDatatype(&(connection->transportLayer.localConf.protocolVersion),
-					UINT32, &tmpPos, tmpMessage.data);
+			UA_UInt32_encode(&(connection->transportLayer.localConf.protocolVersion),
+					&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);
+			UA_UInt32_encode(&(connection->transportLayer.localConf.recvBufferSize),
+					&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);
+			UA_UInt32_encode(&(connection->transportLayer.localConf.sendBufferSize),
+					&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);
+			UA_UInt32_encode(&(connection->transportLayer.localConf.maxMessageSize),
+					&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);
+			UA_UInt32_encode(&(connection->transportLayer.localConf.maxChunkCount),
+					&tmpPos, tmpMessage.data);
 			printf("TL_process - localConf.maxChunkCount = %d \n", connection->transportLayer.localConf.maxChunkCount);
 
 			TL_send(connection, &tmpMessage);
@@ -270,7 +263,7 @@ UA_Int32 TL_process(UA_connection *connection,UA_Int32 packetType, UA_Int32 *pos
 	default:
 		return UA_ERROR;
 	}
-	return UA_NO_ERROR;
+	return UA_SUCCESS;
 }
 /*
  * respond to client request

+ 1 - 2
src/opcua_transportLayer.h

@@ -9,8 +9,7 @@
 #define OPCUA_TRANSPORTLAYER_H_
 #include <stdio.h>
 
-#include "opcua_binaryEncDec.h"
-#include "opcua_advancedDatatypes.h"
+#include "opcua.h"
 #include "opcua_connectionHelper.h"
 
 

File diff suppressed because it is too large
+ 0 - 1047
src/opcua_types.h


+ 9 - 7
src/util/UA_list.c

@@ -3,7 +3,7 @@
 
 void UA_list_defaultFreer(void* payload){
 	if(payload){
-		opcua_free(payload);
+		UA_free(payload);
 	}
 }
 
@@ -44,7 +44,8 @@ UA_Int32 UA_list_addElementToFront(UA_list_List* const list, UA_list_Element* co
 
 UA_Int32 UA_list_addPayloadToFront(UA_list_List* const list, void* const payload){
 	if(list==NULL)return UA_ERROR;
-	UA_list_Element* elem = (UA_list_Element*)opcua_malloc(sizeof(*elem));
+	UA_list_Element* elem;
+	UA_alloc((void**)&elem, sizeof(*elem));
 	UA_list_initElement(elem);
 	elem->payload = payload;
 	UA_list_addElementToFront(list, elem);
@@ -71,7 +72,8 @@ UA_Int32 UA_list_addElementToBack(UA_list_List* const list, UA_list_Element* con
 
 UA_Int32 UA_list_addPayloadToBack(UA_list_List* const list, void* const payload){
 	if(list==NULL)return UA_ERROR;
-	UA_list_Element* elem = (UA_list_Element*)opcua_malloc(sizeof(*elem));
+	UA_list_Element* elem;
+	UA_alloc((void**)&elem, sizeof(*elem));
 	UA_list_initElement(elem);
 	elem->payload = payload;
 	UA_list_addElementToBack(list, elem);
@@ -86,7 +88,7 @@ UA_Int32 UA_list_removeFirst(UA_list_List* const list, UA_list_PayloadVisitor vi
 		if(visitor){
 			(*visitor)(list->first->payload);
 		}
-		opcua_free(list->first);
+		UA_free(list->first);
 		list->first = temp;
 		list->size--;
 		if(list->size == 1){
@@ -106,7 +108,7 @@ UA_Int32 UA_list_removeLast(UA_list_List* const list, UA_list_PayloadVisitor vis
 		if(visitor){
 			(*visitor)(list->last->payload);
 		}
-		opcua_free(list->last);
+		UA_free(list->last);
 		list->last = temp;
 		list->size--;
 		if(list->size == 1){
@@ -134,7 +136,7 @@ UA_Int32 UA_list_removeElement(UA_list_Element* const elem, UA_list_PayloadVisit
 			(*visitor)(elem->payload);
 		}
 		(elem->father)->size--;
-		opcua_free(elem);
+		UA_free(elem);
 	}
 	return UA_NO_ERROR;
 }
@@ -148,7 +150,7 @@ UA_Int32 UA_list_destroy(UA_list_List* const list, UA_list_PayloadVisitor visito
 		if(visitor){
 			(*visitor)(current->payload);
 		}
-		opcua_free(current);
+		UA_free(current);
 		current = next;
 	}
 	UA_list_init(list);

+ 2 - 2
tests/Makefile.am

@@ -1,4 +1,4 @@
-TESTS = check_stack check_list check_indexedList
+TESTS = check_stack check_list check_indexedList check_generated
 
 # --- no changes beyond this line needed ---
 INCLUDE = @CHECK_CFLAGS@ -I$(top_builddir)/src -I$(top_builddir)/include
@@ -7,4 +7,4 @@ LDADD = $(top_builddir)/lib/libopen62541.a @CHECK_LIBS@
 check_PROGRAMS = $(TESTS)
 AM_LDFLAGS = $(LDADD)
 
-AM_CFLAGS = $(GLOBAL_AM_CFLAGS)
+AM_CFLAGS = $(GLOBAL_AM_CFLAGS) $(INCLUDE)

tool/check_stack.c → tests/check_generated.c


+ 2 - 2
tests/check_indexedList.c

@@ -14,11 +14,11 @@ void visitor(void* payload){
 void freer(void* payload){
 	if(payload){
 		free_count++;
-		opcua_free(payload);
+		UA_free(payload);
 	}
 }
 
-Boolean matcher(void* payload){
+_Bool matcher(void* payload){
 	if(payload == NULL){
 		return FALSE;
 	}

+ 6 - 5
tests/check_list.c

@@ -14,11 +14,11 @@ void visitor(void* payload){
 void freer(void* payload){
 	if(payload){
 		free_count++;
-		opcua_free(payload);
+		UA_free(payload);
 	}
 }
 
-Boolean matcher(void* payload){
+_Bool matcher(void* payload){
 	if(payload == NULL){
 		return FALSE;
 	}
@@ -36,13 +36,14 @@ START_TEST(list_test_basic)
 
 	ck_assert_int_eq(list.size, 0);
 
-	UA_Int32* payload = (UA_Int32*)opcua_malloc(sizeof(*payload));
+	UA_Int32* payload;
+	UA_alloc((void**)&payload, sizeof(*payload));
 	*payload = 42;
 	UA_list_addPayloadToFront(&list, payload);
-	payload = (UA_Int32*)opcua_malloc(sizeof(*payload));
+	UA_alloc((void**)&payload, sizeof(*payload));
 	*payload = 24;
 	UA_list_addPayloadToFront(&list, payload);
-	payload = (UA_Int32*)opcua_malloc(sizeof(*payload));
+	UA_alloc((void**)&payload, sizeof(*payload));
 	*payload = 1;
 	UA_list_addPayloadToBack(&list, payload);
 

+ 210 - 221
tests/check_stack.c

@@ -10,12 +10,9 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "UA_config.h"
+
+#include "opcua.h"
 #include "opcua_transportLayer.h"
-#include "opcua_binaryEncDec.h"
-#include "opcua_encodingLayer.h"
-#include "opcua_advancedDatatypes.h"
-//#include "check_stdint.h"
 #include "check.h"
 
 
@@ -26,8 +23,9 @@ START_TEST(test_getPacketType_validParameter)
 	char buf[] = {'C','L','O'};
 	UA_Int32 pos = 0;
 	UA_ByteString msg;
-	msg.Data = buf;
-	msg.Length = 3;
+
+	msg.data = buf;
+	msg.length = 3;
 
 	ck_assert_int_eq(TL_getPacketType(&msg, &pos),packetType_CLO);
 }
@@ -36,21 +34,21 @@ END_TEST
 
 START_TEST(decodeByte_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeByte
 		char *mem = malloc(sizeof(UA_Byte));
-		UInt16 Ui16Val;
+		UA_Byte val;
 
-		rawMessage.message = mem;
+		rawMessage.data = mem;
 		rawMessage.length = 1;
 		mem[0] = 0x08;
 
 		position = 0;
 
-		decoder_decodeBuiltInDatatype(rawMessage.message, BYTE, &position, &Ui16Val);
+		UA_Byte_decode(rawMessage.data, &position, &val);
 
-		ck_assert_int_eq(Ui16Val, 0x08);
+		ck_assert_int_eq(val, 0x08);
 		ck_assert_int_eq(position, 1);
 		free(mem);
 }
@@ -58,20 +56,21 @@ END_TEST
 
 START_TEST(encodeByte_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeByte
 		char *mem = malloc(sizeof(UA_Byte));
-		rawMessage.message = mem;
+		rawMessage.data = mem;
 		UA_Byte testByte = 0x08;
 		rawMessage.length = 1;
 		position = 0;
 
-		encodeByte(testByte, &position, rawMessage.message);
+		UA_Byte_encode(&(testByte), &position, rawMessage.data);
 
-		ck_assert_int_eq(rawMessage.message[0], 0x08);
+		ck_assert_int_eq(rawMessage.data[0], 0x08);
 		ck_assert_int_eq(rawMessage.length, 1);
 		ck_assert_int_eq(position, 1);
+
 		free(mem);
 }
 END_TEST
@@ -84,8 +83,8 @@ START_TEST(decodeRequestHeader_test_validParameter)
 							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;
+		UA_ByteString rawMessage;
+		rawMessage.data = &testMessage;
 		rawMessage.length = 29;
 		Int32 position = 0;
 		T_RequestHeader requestHeader;
@@ -105,7 +104,7 @@ START_TEST(decodeInt16_test_positives)
 {
 	UA_Int32 p = 0;
 	UA_Int16 val;
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	char mem[] = {
 			0x00,0x00,	// 0
 			0x01,0x00,	// 1
@@ -113,37 +112,37 @@ START_TEST(decodeInt16_test_positives)
 			0x00,0x01,	// 256
 	};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 	rawMessage.length = sizeof(mem);
 	ck_assert_int_eq(rawMessage.length,8);
 
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,0);
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,1);
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,255);
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,256);
 }
 END_TEST
 START_TEST(decodeInt16_test_negatives)
 {
-	Int32 p = 0;
-	Int16 val;
-	AD_RawMessage rawMessage;
-	char mem[] = {
+	UA_Int32 p = 0;
+	UA_Int16 val;
+	UA_ByteString rawMessage;
+	UA_Byte mem[] = {
 			0xFF,0xFF,	// -1
 			0x00,0x80,	// -32768
 	};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 	rawMessage.length = sizeof(mem);
 	ck_assert_int_eq(rawMessage.length,4);
 
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,-1);
-	decoder_decodeBuiltInDatatype(rawMessage.message,INT16,&p,&val);
+	UA_Int16_decode(rawMessage.data,&p,&val);
 	ck_assert_int_eq(val,-32768);
 }
 END_TEST
@@ -151,134 +150,134 @@ END_TEST
 START_TEST(encodeInt16_test)
 {
 
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeUInt16
-	char *mem = malloc(sizeof(UInt16));
-	rawMessage.message = mem;
-	UInt16 testUInt16 = 1;
+	UA_Byte *mem = malloc(sizeof(UA_UInt16));
+	rawMessage.data = mem;
+	UA_UInt16 testUInt16 = 1;
 	rawMessage.length = 2;
 	position = 0;
 
-	encodeUInt16(testUInt16, &position, rawMessage.message);
-	//encodeUInt16(testUInt16, &position, &rawMessage);
+	UA_UInt16_encode(&testUInt16, &position, rawMessage.data);
 
 	ck_assert_int_eq(position, 2);
 	UA_Int32 p = 0;
 	UA_Int16 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, INT16, &p, &val);
+	UA_UInt16_decode(rawMessage.data, &p, &val);
 	ck_assert_int_eq(val,testUInt16);
-	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
+	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
 
+	free(mem);
 }
 END_TEST
 
 START_TEST(decodeUInt16_test)
 {
 
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeUInt16
-	char mem[2] = {0x01,0x00};
+	UA_Byte mem[2] = {0x01,0x00};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 
 	rawMessage.length = 2;
 
 	//encodeUInt16(testUInt16, &position, &rawMessage);
 
 	UA_Int32 p = 0;
-	UInt16 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message,UINT16,&p,&val);
+	UA_UInt16 val;
+	UA_UInt16_decode(rawMessage.data,&p,&val);
 
 	ck_assert_int_eq(val,1);
 	//ck_assert_int_eq(p, 2);
-	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
+	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
 
 }
 END_TEST
 START_TEST(encodeUInt16_test)
 {
 
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeUInt16
-	char *mem = malloc(sizeof(UInt16));
-	rawMessage.message = mem;
-	UInt16 testUInt16 = 1;
+	UA_Byte *mem = (UA_Byte*) malloc(sizeof(UA_UInt16));
+	rawMessage.data = mem;
+	UA_UInt16 testUInt16 = 1;
 	rawMessage.length = 2;
 	position = 0;
 
-	encodeUInt16(testUInt16, &position, rawMessage.message);
-	//encodeUInt16(testUInt16, &position, &rawMessage);
-
+	UA_UInt16_encode(&testUInt16, &position, rawMessage.data);
 	ck_assert_int_eq(position, 2);
+
 	UA_Int32 p = 0;
-	UInt16 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, UINT16, &p, &val);
+	UA_UInt16 val;
+	UA_UInt16_decode(rawMessage.data, &p, &val);
 	ck_assert_int_eq(val,testUInt16);
-	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
+	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
 
+	free(mem);
 }
 END_TEST
 
 
 START_TEST(decodeUInt32_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeUInt16
-	char mem[4] = {0xFF,0x00,0x00,0x00};
+	UA_Byte mem[4] = {0xFF,0x00,0x00,0x00};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 	rawMessage.length = 4;
 
 	UA_Int32 p = 0;
 	UA_UInt32 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, UINT32, &p, &val);
+	UA_Int32_decode(rawMessage.data, &p, &val);
 	ck_assert_uint_eq(val,255);
 
 }
 END_TEST
 START_TEST(encodeUInt32_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	UA_UInt32 value = 0x0101FF00;
 	//EncodeUInt16
 
-	rawMessage.message = (char*)opcua_malloc(2 * sizeof(UA_UInt32));
+	rawMessage.data = (UA_Byte*) malloc(2 * sizeof(UA_UInt32));
 
 	rawMessage.length = 8;
 
 	UA_Int32 p = 4;
-	//encodeUInt32(value, &p,rawMessage.message);
-	encoder_encodeBuiltInDatatype(&value,UINT32,&p,rawMessage.message);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[4],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[5],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[6],0x01);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[7],0x01);
+	UA_UInt32_encode(&value,&p,rawMessage.data);
+	ck_assert_uint_eq(rawMessage.data[4],0x00);
+	ck_assert_uint_eq(rawMessage.data[5],0xFF);
+	ck_assert_uint_eq(rawMessage.data[6],0x01);
+	ck_assert_uint_eq(rawMessage.data[7],0x01);
 	ck_assert_int_eq(p,8);
 
+	free(rawMessage.data);
 
 }
 END_TEST
 
 START_TEST(decodeInt32_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	//EncodeUInt16
-	char mem[4] = {0x00,0xCA,0x9A,0x3B};
+	UA_Byte mem[4] = {0x00,0xCA,0x9A,0x3B};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 
 	rawMessage.length = 4;
 
 
 	UA_Int32 p = 0;
 	UA_Int32 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, INT32, &p, &val);
+	UA_Int32_decode(rawMessage.data, &p, &val);
 	ck_assert_int_eq(val,1000000000);
 }
 END_TEST
@@ -291,123 +290,120 @@ END_TEST
 
 START_TEST(decodeUInt64_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	UA_UInt64 expectedVal = 0xFF;
 	expectedVal = expectedVal << 56;
-	char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
+	UA_Byte mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
 
-	rawMessage.message = mem;
+	rawMessage.data = mem;
 
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
 	UA_UInt64 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, UINT64, &p, &val);
+	UA_UInt64_decode(rawMessage.data, &p, &val);
 	ck_assert_uint_eq(val, expectedVal);
 }
 END_TEST
 START_TEST(encodeUInt64_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	UA_UInt64 value = 0x0101FF00FF00FF00;
 	//EncodeUInt16
 
-	rawMessage.message = (char*)opcua_malloc(sizeof(UA_UInt32));
+	rawMessage.data = (UA_Byte*) malloc(sizeof(UA_UInt32));
 
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
-	encodeUInt64(value, &p,rawMessage.message);
-
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[0],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[1],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[2],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[3],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[4],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[5],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[6],0x01);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[7],0x01);
+	UA_UInt64_encode(&value, &p,rawMessage.data);
+
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[0],0x00);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[1],0xFF);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[2],0x00);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[3],0xFF);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[4],0x00);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[5],0xFF);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[6],0x01);
+	ck_assert_uint_eq((UA_Byte)rawMessage.data[7],0x01);
+
+	free(rawMessage.data);
 }
 END_TEST
 
 START_TEST(decodeInt64_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	UA_Int64 expectedVal = 0xFF;
 	expectedVal = expectedVal << 56;
-	char mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
-
-	rawMessage.message = mem;
+	UA_Byte mem[8] = {00,00,00,00,0x00,0x00,0x00,0xFF};
 
+	rawMessage.data = mem;
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
 	UA_Int64 val;
-	decoder_decodeBuiltInDatatype(rawMessage.message, INT64, &p, &val);
+	UA_Int64_decode(rawMessage.data, &p, &val);
 	ck_assert_uint_eq(val, expectedVal);
 }
 END_TEST
 START_TEST(encodeInt64_test)
 {
-	AD_RawMessage rawMessage;
+	UA_ByteString rawMessage;
 	UA_Int32 position = 0;
 	UA_UInt64 value = 0x0101FF00FF00FF00;
 	//EncodeUInt16
 
-	rawMessage.message = (char*)opcua_malloc(sizeof(UA_UInt32));
+	rawMessage.data = (UA_Byte*) malloc(sizeof(UA_UInt32));
 
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
-	encodeUInt64(value, &p,rawMessage.message);
-
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[0],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[1],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[2],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[3],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[4],0x00);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[5],0xFF);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[6],0x01);
-	ck_assert_uint_eq((UA_Byte)rawMessage.message[7],0x01);
+	UA_UInt64_encode(&value, &p,rawMessage.data);
+
+	ck_assert_uint_eq(rawMessage.data[0],0x00);
+	ck_assert_uint_eq(rawMessage.data[1],0xFF);
+	ck_assert_uint_eq(rawMessage.data[2],0x00);
+	ck_assert_uint_eq(rawMessage.data[3],0xFF);
+	ck_assert_uint_eq(rawMessage.data[4],0x00);
+	ck_assert_uint_eq(rawMessage.data[5],0xFF);
+	ck_assert_uint_eq(rawMessage.data[6],0x01);
+	ck_assert_uint_eq(rawMessage.data[7],0x01);
+
+	free(rawMessage.data);
 }
 END_TEST
 
 
 START_TEST(decodeFloat_test)
 {
-	Float expectedValue = -6.5;
+	UA_Float expectedValue = -6.5;
 	UA_Int32 pos = 0;
-	char buf[4] = {0x00,0x00,0xD0,0xC0};
+	UA_Byte buf[4] = {0x00,0x00,0xD0,0xC0};
 
 
-	Float calcVal;
+	UA_Float fval;
 
-	decoder_decodeBuiltInDatatype(buf, FLOAT, &pos, &calcVal);
+	UA_Float_decode(buf, &pos, &fval);
 	//val should be -6.5
-
-	UA_Int32 val = (calcVal > -6.501 && calcVal < -6.499);
-
-
+	UA_Int32 val = (fval > -6.501 && fval < -6.499);
 	ck_assert_int_gt(val,0);
-
-	opcua_free(buf);
 }
 END_TEST
 START_TEST(encodeFloat_test)
 {
-	Float value = -6.5;
+	UA_Float value = -6.5;
 	UA_Int32 pos = 0;
-	char *buf = (char*)opcua_malloc(sizeof(Float));
-
-	encodeFloat(value,&pos,buf);
+	UA_Byte* buf = (char*)malloc(sizeof(UA_Float));
 
-	ck_assert_uint_eq((UA_Byte)buf[2],0xD0);
-	ck_assert_uint_eq((UA_Byte)buf[3],0xC0);
-	opcua_free(buf);
+	UA_Float_encode(&value,&pos,buf);
 
+	ck_assert_uint_eq(buf[2],0xD0);
+	ck_assert_uint_eq(buf[3],0xC0);
+	free(buf);
 }
 END_TEST
 
@@ -418,15 +414,15 @@ START_TEST(decodeDouble_test)
 END_TEST
 START_TEST(encodeDouble_test)
 {
-	Float value = -6.5;
+	UA_Double value = -6.5;
 	UA_Int32 pos = 0;
-	char *buf = (char*)opcua_malloc(sizeof(Float));
+	UA_Byte* buf = (char*)malloc(sizeof(UA_Double));
 
-	encodeDouble(value,&pos,buf);
+	UA_Double_encode(&value,&pos,buf);
 
-	ck_assert_uint_eq((UA_Byte)buf[6],0xD0);
-	ck_assert_uint_eq((UA_Byte)buf[7],0xC0);
-	opcua_free(buf);
+	ck_assert_uint_eq(buf[6],0xD0);
+	ck_assert_uint_eq(buf[7],0xC0);
+	free(buf);
 }
 END_TEST
 
@@ -437,12 +433,12 @@ START_TEST(encodeUAString_test)
 	UA_Int32 pos = 0;
 	UA_String string;
 	UA_Int32 l = 11;
-	char mem[11] = "ACPLT OPCUA";
-	char *dstBuf = (char*) malloc(sizeof(UA_Int32)+l);
-	string.Data =  mem;
-	string.Length = 11;
+	UA_Byte mem[11] = "ACPLT OPCUA";
+	UA_Byte *dstBuf = (char*) malloc(sizeof(UA_Int32)+l);
+	string.data =  mem;
+	string.length = 11;
 
-	encodeUAString(&string, &pos, dstBuf);
+	UA_String_encode(&string, &pos, dstBuf);
 
 	ck_assert_int_eq(dstBuf[0],11);
 	ck_assert_int_eq(dstBuf[0+sizeof(UA_Int32)],'A');
@@ -455,19 +451,16 @@ START_TEST(decodeUAString_test)
 
 	UA_Int32 pos = 0;
 	UA_String string;
-	UA_Int32 l = 11;
-	char binString[15] = {11,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
-
-	char *dstBuf = (char*) malloc(l-sizeof(UA_Int32));
-	string.Data = dstBuf;
-	string.Length = 0;
-	decodeUAString(binString, &pos, &string);
+	UA_Int32 l = 12;
+	char binString[12] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
 
+	UA_String_decode(binString, &pos, &string);
 
-	ck_assert_int_eq(string.Length,11);
-	ck_assert_int_eq(string.Data[3],'L');
-
+	ck_assert_int_eq(string.length,8);
+	ck_assert_ptr_eq(string.data,UA_alloc_lastptr);
+	ck_assert_int_eq(string.data[3],'L');
 
+	UA_String_deleteMembers(&string);
 }
 END_TEST
 
@@ -477,16 +470,14 @@ START_TEST(diagnosticInfo_calcSize_test)
 	UA_Int32 valreal = 0;
 	UA_Int32 valcalc = 0;
 	UA_DiagnosticInfo diagnosticInfo;
-	diagnosticInfo.EncodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
-	diagnosticInfo.SymbolicId = 30;
-	diagnosticInfo.NamespaceUri = 25;
-	diagnosticInfo.LocalizedText = 22;
-	diagnosticInfo.AdditionalInfo.Data = "OPCUA";
-	diagnosticInfo.AdditionalInfo.Length = 5;
-
-	valcalc = diagnosticInfo_calcSize(&diagnosticInfo);
-	valreal = 26;
-	ck_assert_int_eq(valcalc,valreal);
+	diagnosticInfo.encodingMask = 0x01 | 0x02 | 0x04 | 0x08 | 0x10;
+	diagnosticInfo.symbolicId = 30;
+	diagnosticInfo.namespaceUri = 25;
+	diagnosticInfo.localizedText = 22;
+	diagnosticInfo.additionalInfo.data = "OPCUA";
+	diagnosticInfo.additionalInfo.length = 5;
+
+	ck_assert_int_eq(UA_DiagnosticInfo_calcSize(&diagnosticInfo),26);
 
 }
 END_TEST
@@ -499,51 +490,48 @@ START_TEST(extensionObject_calcSize_test)
 	UA_Byte data[3] = {1,2,3};
 	UA_ExtensionObject extensionObject;
 
-	// empty ExtensionObject
-	ck_assert_int_eq(extensionObject_calcSize(&the_empty_UA_ExtensionObject), 1 + 1 + 1);
-
 	// empty ExtensionObject, handcoded
-	extensionObject.TypeId.EncodingByte = NIEVT_TWO_BYTE;
-	extensionObject.TypeId.Identifier.Numeric = 0;
-	extensionObject.Encoding = NO_BODY_IS_ENCODED;
-	ck_assert_int_eq(extensionObject_calcSize(&extensionObject), 1 + 1 + 1);
+	extensionObject.typeId.encodingByte = UA_NodeIdType_TwoByte;
+	extensionObject.typeId.identifier.numeric = 0;
+	extensionObject.encoding = UA_ExtensionObject_NoBodyIsEncoded;
+	ck_assert_int_eq(UA_ExtensionObject_calcSize(&extensionObject), 1 + 1 + 1);
 
 	// ExtensionObject with ByteString-Body
-	extensionObject.Encoding = BODY_IS_BYTE_STRING;
-	extensionObject.Body.Data = data;
-	extensionObject.Body.Length = 3;
-	ck_assert_int_eq(extensionObject_calcSize(&extensionObject), 3 + 4 + 3);
-
+	extensionObject.encoding = UA_ExtensionObject_BodyIsByteString;
+	extensionObject.body.data = data;
+	extensionObject.body.length = 3;
+	ck_assert_int_eq(UA_ExtensionObject_calcSize(&extensionObject), 3 + 4 + 3);
 }
 END_TEST
 
 START_TEST(responseHeader_calcSize_test)
 {
-	UA_AD_ResponseHeader responseHeader;
+	UA_ResponseHeader responseHeader;
 	UA_DiagnosticInfo diagnosticInfo;
 	UA_ExtensionObject extensionObject;
-
+	UA_DiagnosticInfo  emptyDO = {0x00};
+	UA_ExtensionObject emptyEO = {{UA_NodeIdType_TwoByte,0},UA_ExtensionObject_NoBodyIsEncoded};
 	//Should have the size of 26 Bytes
-	diagnosticInfo.EncodingMask = DIEMT_SYMBOLIC_ID | DIEMT_NAMESPACE | DIEMT_LOCALIZED_TEXT | DIEMT_LOCALE | DIEMT_ADDITIONAL_INFO;		// Byte:   1
+	diagnosticInfo.encodingMask = UA_DiagnosticInfoEncodingMaskType_SymbolicId | UA_DiagnosticInfoEncodingMaskType_Namespace | UA_DiagnosticInfoEncodingMaskType_LocalizedText | UA_DiagnosticInfoEncodingMaskType_Locale | UA_DiagnosticInfoEncodingMaskType_AdditionalInfo;		// Byte:   1
 	// Indices into to Stringtable of the responseHeader (62541-6 §5.5.12 )
-	diagnosticInfo.SymbolicId = -1;										// Int32:  4
-	diagnosticInfo.NamespaceUri = -1;									// Int32:  4
-	diagnosticInfo.LocalizedText = -1;									// Int32:  4
-	diagnosticInfo.Locale = -1;											// Int32:  4
+	diagnosticInfo.symbolicId = -1;										// Int32:  4
+	diagnosticInfo.namespaceUri = -1;									// Int32:  4
+	diagnosticInfo.localizedText = -1;									// Int32:  4
+	diagnosticInfo.locale = -1;											// Int32:  4
 	// Additional Info
-	diagnosticInfo.AdditionalInfo.Length = 5;							// Int32:  4
-	diagnosticInfo.AdditionalInfo.Data = "OPCUA";						// Byte[]: 5
+	diagnosticInfo.additionalInfo.length = 5;							// Int32:  4
+	diagnosticInfo.additionalInfo.data = "OPCUA";						// Byte[]: 5
 	responseHeader.serviceDiagnostics = &diagnosticInfo;
-	ck_assert_int_eq(diagnosticInfo_calcSize(&diagnosticInfo),1+(4+4+4+4)+(4+5));
+	ck_assert_int_eq(UA_DiagnosticInfo_calcSize(&diagnosticInfo),1+(4+4+4+4)+(4+5));
 
-	responseHeader.noOfStringTable = -1;								// Int32:	4
+	responseHeader.stringTableSize = -1;								// Int32:	4
 	responseHeader.stringTable = NULL;
 
-	responseHeader.additionalHeader = &the_empty_UA_ExtensionObject;	//		    3
-	ck_assert_int_eq(responseHeader_calcSize(&responseHeader),16+26+4+3);
+	responseHeader.additionalHeader = &emptyEO;	//		    3
+	ck_assert_int_eq(UA_ResponseHeader_calcSize(&responseHeader),16+26+4+3);
 
-	responseHeader.serviceDiagnostics = &the_empty_UA_DiagnosticInfo;
-	ck_assert_int_eq(responseHeader_calcSize(&responseHeader),16+1+4+3);
+	responseHeader.serviceDiagnostics = &emptyDO;
+	ck_assert_int_eq(UA_ResponseHeader_calcSize(&responseHeader),16+1+4+3);
 }
 END_TEST
 
@@ -559,68 +547,68 @@ END_TEST
 START_TEST(encodeDataValue_test)
 {
 	UA_DataValue dataValue;
-	UA_Int32 pos = 0;
-	char *buf = (char*)opcua_malloc(15);
+	UA_Int32 pos = 0, retval;
+	UA_Byte* buf = (char*) malloc(15);
 	UA_DateTime dateTime;
 	dateTime = 80;
-	dataValue.ServerTimestamp = dateTime;
+	dataValue.serverTimestamp = dateTime;
 
 	//--without Variant
-	dataValue.EncodingMask = 0x08; //Only the SourvePicoseconds
-	encodeDataValue(&dataValue, &pos, buf);
+	dataValue.encodingMask = UA_DataValue_serverTimestamp; //Only the sourcePicoseconds
+	UA_DataValue_encode(&dataValue, &pos, buf);
 
 	ck_assert_int_eq(pos, 9);// represents the length
-	ck_assert_int_eq(buf[0], 0x08);
-	ck_assert_int_eq(buf[1], 80);
-	ck_assert_int_eq(buf[2], 0);
-	ck_assert_int_eq(buf[3], 0);
-	ck_assert_int_eq(buf[4], 0);
-	ck_assert_int_eq(buf[5], 0);
-	ck_assert_int_eq(buf[6], 0);
-	ck_assert_int_eq(buf[7], 0);
-	ck_assert_int_eq(buf[8], 0);
+	ck_assert_uint_eq(buf[0], 0x08); // encodingMask
+	ck_assert_uint_eq(buf[1], 80); // 8 Byte serverTimestamp
+	ck_assert_uint_eq(buf[2], 0);
+	ck_assert_uint_eq(buf[3], 0);
+	ck_assert_uint_eq(buf[4], 0);
+	ck_assert_uint_eq(buf[5], 0);
+	ck_assert_uint_eq(buf[6], 0);
+	ck_assert_uint_eq(buf[7], 0);
+	ck_assert_uint_eq(buf[8], 0);
 
 	//TestCase for a DataValue with a Variant!
-	//ToDo: Need to be checked after the function for encoding variants has been implemented
-	pos = 0;
-	dataValue.EncodingMask = 0x01 || 0x08; //Variant & SourvePicoseconds
-	UA_Variant variant;
-	variant.ArrayLength = 0;
-	variant.EncodingMask = VTEMT_INT32;
-	UA_VariantUnion variantUnion;
-	//ToDo: needs to be adjusted: variantUnion.Int32 = 45;
-	fail(); ////ToDo: needs to be adjusted: Just to see that see that this needs to be adjusted
-	variant.Value = &variantUnion;
-	dataValue.Value = variant;
-	encodeDataValue(&dataValue, &pos, buf);
-
-	ck_assert_int_eq(pos, 14);// represents the length
-	ck_assert_int_eq(buf[0], 0x08);
-	ck_assert_int_eq(buf[1], 0x06);
-	ck_assert_int_eq(buf[2], 45);
-	ck_assert_int_eq(buf[3], 0);
-	ck_assert_int_eq(buf[4], 0);
-	ck_assert_int_eq(buf[5], 0);
-	ck_assert_int_eq(buf[6], 80);
-	ck_assert_int_eq(buf[7], 0);
+	dataValue.encodingMask = UA_DataValue_variant | UA_DataValue_serverTimestamp; //Variant & SourvePicoseconds
+	dataValue.value.vt = &UA_[UA_INT32];
+	dataValue.value.arrayLength = 0;
+	dataValue.value.encodingMask = UA_INT32_NS0;
+	UA_Int32 data = 45;
+	UA_Int32* pdata = &data;
+	dataValue.value.data = (void**) &pdata;
 
+	pos = 0;
+	retval = UA_DataValue_encode(&dataValue, &pos, buf);
+
+	ck_assert_int_eq(retval, UA_SUCCESS);
+	ck_assert_int_eq(pos, 1+(1+4)+8);// represents the length
+	ck_assert_uint_eq(buf[0], 0x08 | 0x01); // encodingMask
+	ck_assert_uint_eq(buf[1], 0x06); // Variant's Encoding Mask - INT32
+	ck_assert_uint_eq(buf[2], 45);  // the single value
+	ck_assert_uint_eq(buf[3], 0);
+	ck_assert_uint_eq(buf[4], 0);
+	ck_assert_uint_eq(buf[5], 0);
+	ck_assert_uint_eq(buf[6], 80);  // the server timestamp
+	ck_assert_uint_eq(buf[7], 0);
+
+	free(buf);
 }
 END_TEST
 
 START_TEST(DataValue_calcSize_test)
 {
 	UA_DataValue dataValue;
-	dataValue.EncodingMask = 0x02 + 0x04 + 0x10;
-	dataValue.Status = 12;
+	dataValue.encodingMask = UA_DataValue_statusCode |  UA_DataValue_sourceTimestamp |  UA_DataValue_sourcePicoseconds;
+	dataValue.status = 12;
 	UA_DateTime dateTime;
 	dateTime = 80;
-	dataValue.SourceTimestamp = dateTime;
+	dataValue.sourceTimestamp = dateTime;
 	UA_DateTime sourceTime;
 	dateTime = 214;
-	dataValue.SourcePicoseconds = sourceTime;
+	dataValue.sourcePicoseconds = sourceTime;
 
 	int size = 0;
-	size = DataValue_calcSize(&dataValue);
+	size = UA_DataValue_calcSize(&dataValue);
 
 	ck_assert_int_eq(size, 21);
 }
@@ -641,7 +629,7 @@ START_TEST(encode_builtInDatatypeArray_test_String)
 			0xFF, 0xFF, 0xFF, 0xFF		// s2.Length
 	};
 
-	encoder_encodeBuiltInDatatypeArray(array, noElements, BYTE_STRING, &pos, buf);
+	UA_Array_encode((void const**)array, noElements, UA_BYTESTRING, &pos, buf);
 
 	// check size
 	ck_assert_int_eq(pos, 4 + 4 + 6 + 4);
@@ -665,6 +653,7 @@ Suite *testSuite_encodeByte(void)
 {
 	Suite *s = suite_create("encodeByte_test");
 	TCase *tc_core = tcase_create("Core");
+	tcase_add_test(tc_core, decodeByte_test);
 	tcase_add_test(tc_core, encodeByte_test);
 	suite_add_tcase(s,tc_core);
 	return s;

+ 2 - 10
tool/Makefile.am

@@ -1,7 +1,4 @@
-bin_PROGRAMS = check
-check_SOURCES = check_stack.c opcua_basictypes.c opcua.c opcua_namespace_0.c opcua.h opcua_namespace_0.h
-
-check_stack.c: opcua.h opcua_namespace_0.h
+all-local: opcua.c opcua.h opcua_namespace_0.c opcua_namespace_0.h
 
 opcua.c opcua.h: Opc.Ua.Types.bsd generate_builtin.py
 	python generate_builtin.py Opc.Ua.Types.bsd opcua
@@ -14,9 +11,4 @@ clean-autogenerated:
 	rm -rf opcua.c opcua.h
 	rm -rf opcua_namespace_0.c opcua_namespace_0.h
 
-clean-local: clean-autogenerated
-
-INCLUDE = @CHECK_CFLAGS@ -I$(top_builddir)/src -I$(top_builddir)/include
-LDADD = $(top_builddir)/lib/libopen62541.a @CHECK_LIBS@
-
-AM_CFLAGS = $(GLOBAL_AM_CFLAGS)
+clean-local: clean-autogenerated

+ 1 - 1
tool/generate_builtin.py

@@ -162,7 +162,7 @@ def createStructured(element):
             if t in enum_types:
                 print('\n\t + 4 //' + n, end='', file=fc) # enums are all 32 bit
             elif t.find("**") != -1:
-		print("\n\t + 4 //" + n + "Size", end='', file=fc),
+		print("\n\t + 0 //" + n + "Size is included in UA_Array_calcSize", end='', file=fc),
 		print("\n\t + UA_Array_calcSize(ptr->" + n + "Size, UA_" + t[0:t.find("*")].upper() + ", (void const**) ptr->" + n +")", end='', file=fc)
             elif t.find("*") != -1:
                 print('\n\t + ' + "UA_" + t[0:t.find("*")] + "_calcSize(ptr->" + n + ')', end='', file=fc)

+ 1 - 1
tool/generate_namespace.py

@@ -95,7 +95,7 @@ for row in rows2:
 	continue
 
     name = "UA_" + row[0]
-    print('#define '+name.upper()+'_NS0 (UA_namespace_zero['+name.upper()+'].Id)', file=fh)
+    print('#define '+name.upper()+'_NS0 (UA_['+name.upper()+'].Id)', file=fh)
 
     print("\t{" + row[1] + ", (UA_Int32(*)(void const*)) " + name + "_calcSize, (UA_Int32(*)(char const*,UA_Int32*,void*)) " + name + "_decode, (UA_Int32(*)(void const*,UA_Int32*,char*))" + name + "_encode},",end='\n',file=fc)