Browse Source

The following functions has been created.
QualifiedName_calcSize
LocalizedText_calcSize
ExtensionObject_calcSize
Variant_calcSize
The function Varian_calcSize has just the body. It needs the function to calc the size of a VariantUnion.

MaximilianBauer 11 years ago
parent
commit
f653f297f4
6 changed files with 116 additions and 41 deletions
  1. 10 10
      Makefile
  2. 10 10
      examples/src/Makefile
  3. 10 10
      src/Makefile
  4. 74 0
      src/opcua_binaryEncDec.c
  5. 10 10
      tests/Makefile
  6. 2 1
      tests/check_stack.c

+ 10 - 10
Makefile

@@ -105,13 +105,13 @@ distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
 distcleancheck_listfiles = find . -type f -print
-ACLOCAL = ${SHELL} /home/opcua/git/opcUaStack/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/opcua/git/open62541/missing --run aclocal-1.11
 AMTAR = $${TAR-tar}
 AR = ar
 AS = as
-AUTOCONF = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/opcua/git/opcUaStack/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/opcua/git/open62541/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/opcua/git/open62541/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/opcua/git/open62541/missing --run automake-1.11
 AWK = mawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -146,7 +146,7 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/opcua/git/opcUaStack/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/opcua/git/open62541/missing --run makeinfo
 MANIFEST_TOOL = :
 MKDIR_P = /bin/mkdir -p
 NM = /usr/bin/nm -B
@@ -172,10 +172,10 @@ SET_MAKE =
 SHELL = /bin/bash
 STRIP = strip
 VERSION = 1.0
-abs_builddir = /home/opcua/git/opcUaStack
-abs_srcdir = /home/opcua/git/opcUaStack
-abs_top_builddir = /home/opcua/git/opcUaStack
-abs_top_srcdir = /home/opcua/git/opcUaStack
+abs_builddir = /home/opcua/git/open62541
+abs_srcdir = /home/opcua/git/open62541
+abs_top_builddir = /home/opcua/git/open62541
+abs_top_srcdir = /home/opcua/git/open62541
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -204,7 +204,7 @@ host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/opcua/git/opcUaStack/install-sh
+install_sh = ${SHELL} /home/opcua/git/open62541/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale

+ 10 - 10
examples/src/Makefile

@@ -75,13 +75,13 @@ DIST_SOURCES = $(__top_builddir__bin_exampleServer_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/opcua/git/opcUaStack/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/opcua/git/open62541/missing --run aclocal-1.11
 AMTAR = $${TAR-tar}
 AR = ar
 AS = as
-AUTOCONF = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/opcua/git/opcUaStack/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/opcua/git/open62541/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/opcua/git/open62541/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/opcua/git/open62541/missing --run automake-1.11
 AWK = mawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -116,7 +116,7 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/opcua/git/opcUaStack/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/opcua/git/open62541/missing --run makeinfo
 MANIFEST_TOOL = :
 MKDIR_P = /bin/mkdir -p
 NM = /usr/bin/nm -B
@@ -142,10 +142,10 @@ SET_MAKE =
 SHELL = /bin/bash
 STRIP = strip
 VERSION = 1.0
-abs_builddir = /home/opcua/git/opcUaStack/examples/src
-abs_srcdir = /home/opcua/git/opcUaStack/examples/src
-abs_top_builddir = /home/opcua/git/opcUaStack
-abs_top_srcdir = /home/opcua/git/opcUaStack
+abs_builddir = /home/opcua/git/open62541/examples/src
+abs_srcdir = /home/opcua/git/open62541/examples/src
+abs_top_builddir = /home/opcua/git/open62541
+abs_top_srcdir = /home/opcua/git/open62541
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -174,7 +174,7 @@ host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/opcua/git/opcUaStack/install-sh
+install_sh = ${SHELL} /home/opcua/git/open62541/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale

+ 10 - 10
src/Makefile

@@ -112,13 +112,13 @@ DIST_SOURCES = $(libopen62541_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/opcua/git/opcUaStack/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/opcua/git/open62541/missing --run aclocal-1.11
 AMTAR = $${TAR-tar}
 AR = ar
 AS = as
-AUTOCONF = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/opcua/git/opcUaStack/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/opcua/git/open62541/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/opcua/git/open62541/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/opcua/git/open62541/missing --run automake-1.11
 AWK = mawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -153,7 +153,7 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/opcua/git/opcUaStack/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/opcua/git/open62541/missing --run makeinfo
 MANIFEST_TOOL = :
 MKDIR_P = /bin/mkdir -p
 NM = /usr/bin/nm -B
@@ -179,10 +179,10 @@ SET_MAKE =
 SHELL = /bin/bash
 STRIP = strip
 VERSION = 1.0
-abs_builddir = /home/opcua/git/opcUaStack/src
-abs_srcdir = /home/opcua/git/opcUaStack/src
-abs_top_builddir = /home/opcua/git/opcUaStack
-abs_top_srcdir = /home/opcua/git/opcUaStack
+abs_builddir = /home/opcua/git/open62541/src
+abs_srcdir = /home/opcua/git/open62541/src
+abs_top_builddir = /home/opcua/git/open62541
+abs_top_srcdir = /home/opcua/git/open62541
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -211,7 +211,7 @@ host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/opcua/git/opcUaStack/install-sh
+install_sh = ${SHELL} /home/opcua/git/open62541/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale

+ 74 - 0
src/opcua_binaryEncDec.c

@@ -1086,6 +1086,16 @@ Int32 encodeQualifiedName(UA_QualifiedName *qualifiedName, Int32 *pos,
 			dstBuf);
 	return UA_NO_ERROR;
 }
+Int32 QualifiedName_calcSize(UA_QualifiedName *qualifiedName)
+{
+	Int32 length = 0;
+
+	length += sizeof(UInt16); 							//qualifiedName->NamespaceIndex
+	length += UAString_calcSize(&(qualifiedName->Name));	//qualifiedName->Name
+	length += sizeof(UInt16); 							//qualifiedName->Reserved
+
+	return length;
+}
 
 Int32 decodeLocalizedText(char * const buf, Int32 *pos,
 		UA_LocalizedText *dstLocalizedText)
@@ -1114,6 +1124,22 @@ Int32 encodeLocalizedText(UA_LocalizedText *localizedText, Int32 *pos,
 	}
 	return UA_NO_ERROR;
 }
+Int32 LocalizedText_calcSize(UA_LocalizedText *localizedText)
+{
+	Int32 length = 0;
+
+	length += localizedText->EncodingMask;
+	if (localizedText->EncodingMask & 0x01)
+	{
+		length += UAString_calcSize(&(localizedText->Locale));
+	}
+	if (localizedText->EncodingMask & 0x02)
+	{
+		length += UAString_calcSize(&(localizedText->Text));
+	}
+
+	return length;
+}
 
 Int32 decodeExtensionObject(char * const buf, Int32 *pos,
 		UA_ExtensionObject *dstExtensionObject)
@@ -1156,6 +1182,27 @@ Int32 encodeExtensionObject(UA_ExtensionObject *extensionObject, Int32 *pos,
 	}
 	return UA_NO_ERROR;
 }
+Int32 ExtensionObject_calcSize(UA_ExtensionObject *extensionObject)
+{
+	Int32 length = 0;
+
+	length += nodeId_calcSize(&(extensionObject->TypeId));
+	length += sizeof(Byte);								//extensionObject->Encoding
+	switch (extensionObject->Encoding)
+	{
+	case 0x00:
+		length += sizeof(Int32);//extensionObject->Body.Length
+		break;
+	case 0x01:
+		length += UAByteString_calcSize(&(extensionObject->Body));
+		break;
+	case 0x02:
+		length += UAByteString_calcSize(&(extensionObject->Body));
+		break;
+	}
+
+	return length;
+}
 
 Int32 decodeVariant(char * const buf, Int32 *pos, UA_Variant *dstVariant)
 {
@@ -1206,6 +1253,33 @@ Int32 encodeVariant(UA_Variant *variant, Int32 *pos, char *dstBuf)
 	}
 	return UA_NO_ERROR;
 }
+Int32 Variant_calcSize(UA_Variant *variant)
+{
+	Int32 length = 0;
+
+	length += sizeof(Byte);	//variant->EncodingMask
+	if (variant->EncodingMask & (1 << 7)) // array length is encoded
+	{
+		length += sizeof(Int32);//variant->ArrayLength
+		if (variant->ArrayLength > 0)
+		{
+			//encode array as given by variant type
+			//ToDo: tobeInsert: length += the calcSize for VariantUnions
+		}
+		//single value to encode
+		//ToDo: tobeInsert: length += the calcSize for VariantUnions
+	}
+	else //single value to encode
+	{
+		//ToDo: tobeInsert: length += the calcSize for VariantUnions
+	}
+	if (variant->EncodingMask & (1 << 6)) // encode array dimension field
+	{
+		//ToDo: tobeInsert: length += the calcSize for VariantUnions
+	}
+
+	return length;
+}
 
 Int32 decodeDataValue(char* const buf, Int32 *pos, UA_DataValue *dstDataValue)
 {

+ 10 - 10
tests/Makefile

@@ -71,13 +71,13 @@ CTAGS = ctags
 am__tty_colors = \
 red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/opcua/git/opcUaStack/missing --run aclocal-1.11
+ACLOCAL = ${SHELL} /home/opcua/git/open62541/missing --run aclocal-1.11
 AMTAR = $${TAR-tar}
 AR = ar
 AS = as
-AUTOCONF = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/opcua/git/opcUaStack/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/opcua/git/opcUaStack/missing --run automake-1.11
+AUTOCONF = ${SHELL} /home/opcua/git/open62541/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/opcua/git/open62541/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/opcua/git/open62541/missing --run automake-1.11
 AWK = mawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -112,7 +112,7 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/opcua/git/opcUaStack/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/opcua/git/open62541/missing --run makeinfo
 MANIFEST_TOOL = :
 MKDIR_P = /bin/mkdir -p
 NM = /usr/bin/nm -B
@@ -138,10 +138,10 @@ SET_MAKE =
 SHELL = /bin/bash
 STRIP = strip
 VERSION = 1.0
-abs_builddir = /home/opcua/git/opcUaStack/tests
-abs_srcdir = /home/opcua/git/opcUaStack/tests
-abs_top_builddir = /home/opcua/git/opcUaStack
-abs_top_srcdir = /home/opcua/git/opcUaStack
+abs_builddir = /home/opcua/git/open62541/tests
+abs_srcdir = /home/opcua/git/open62541/tests
+abs_top_builddir = /home/opcua/git/open62541
+abs_top_srcdir = /home/opcua/git/open62541
 ac_ct_AR = ar
 ac_ct_CC = gcc
 ac_ct_DUMPBIN = 
@@ -170,7 +170,7 @@ host_vendor = pc
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/opcua/git/opcUaStack/install-sh
+install_sh = ${SHELL} /home/opcua/git/open62541/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale

+ 2 - 1
tests/check_stack.c

@@ -467,8 +467,9 @@ END_TEST
 
 START_TEST(responseHeader_calcSize_test)
 {
-	Int32 valreal = 0;
+	Int32 valreal = 1;
 	Int32 valcalc = 0;
+
 	T_ResponseHeader responseHeader;
 	UA_DiagnosticInfo diagnosticInfo;
 	UA_ExtensionObject extensionObject;