Browse Source

changed function names, convertTo -> decode

FlorianPalm 11 years ago
parent
commit
970e7b9e5d

+ 1 - 0
OPCUAServer/.cproject

@@ -499,6 +499,7 @@
 			</target>
 			<target name="Server" path="src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 				<buildCommand>make</buildCommand>
+				<buildArguments/>
 				<buildTarget>Server</buildTarget>
 				<stopOnError>true</stopOnError>
 				<useDefaultCommand>true</useDefaultCommand>

+ 1 - 1
OPCUAServer/.settings/language.settings.xml

@@ -12,7 +12,7 @@
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
 		</extension>
 	</configuration>

+ 5 - 5
OPCUAServer/src/Makefile.am

@@ -20,8 +20,8 @@
 #					  opcua_transportLayer.h\
 #					  opcua_advancedDatatypes.h\
 #					  opcua_connectionHelper.h	
-lib_LTLIBRARIES = libstack.la
-libstack_la_SOURCES = 	opcua_builtInDatatypes.c\
+lib_LTLIBRARIES = libOpen62541.la
+libOpen62541_la_SOURCES = 	opcua_builtInDatatypes.c\
 						opcua_binaryEncDec.c\
 						opcua_transportLayer.c\
 						opcua_encodingLayer.c\
@@ -34,7 +34,7 @@ libstack_la_SOURCES = 	opcua_builtInDatatypes.c\
 						opcua_encodingLayer.h\
 						tcp_layer.h
 
-bin_PROGRAMS= $(top_builddir)/bin/stackTest.out
-__top_builddir__bin_stackTest_out_SOURCES = opcuaServer.c
-__top_builddir__bin_stackTest_out_LADD = libstack.la		  										
+#bin_PROGRAMS= $(top_builddir)/bin/open62541.out
+#__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
+__top_builddir__bin_libOpen62541_out_LADD = libOpen62541.la		  										
 

+ 33 - 96
OPCUAServer/src/Makefile.in

@@ -27,7 +27,6 @@
 #											opcua_connectionHelper.h\
 #											tcp_layer.h
 
-
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
@@ -48,7 +47,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-bin_PROGRAMS = $(top_builddir)/bin/stackTest.out$(EXEEXT)
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -85,19 +83,13 @@ am__uninstall_files_from_dir = { \
     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
          $(am__cd) "$$dir" && rm -f $$files; }; \
   }
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
+am__installdirs = "$(DESTDIR)$(libdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libstack_la_LIBADD =
-am_libstack_la_OBJECTS = opcua_builtInDatatypes.lo \
+libOpen62541_la_LIBADD =
+am_libOpen62541_la_OBJECTS = opcua_builtInDatatypes.lo \
 	opcua_binaryEncDec.lo opcua_transportLayer.lo \
 	opcua_encodingLayer.lo
-libstack_la_OBJECTS = $(am_libstack_la_OBJECTS)
-PROGRAMS = $(bin_PROGRAMS)
-am___top_builddir__bin_stackTest_out_OBJECTS = opcuaServer.$(OBJEXT)
-__top_builddir__bin_stackTest_out_OBJECTS =  \
-	$(am___top_builddir__bin_stackTest_out_OBJECTS)
-__top_builddir__bin_stackTest_out_LDADD = $(LDADD)
-am__dirstamp = $(am__leading_dot)dirstamp
+libOpen62541_la_OBJECTS = $(am_libOpen62541_la_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
@@ -111,10 +103,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(libstack_la_SOURCES) \
-	$(__top_builddir__bin_stackTest_out_SOURCES)
-DIST_SOURCES = $(libstack_la_SOURCES) \
-	$(__top_builddir__bin_stackTest_out_SOURCES)
+SOURCES = $(libOpen62541_la_SOURCES)
+DIST_SOURCES = $(libOpen62541_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -246,8 +236,8 @@ top_srcdir = @top_srcdir@
 #					  opcua_transportLayer.h\
 #					  opcua_advancedDatatypes.h\
 #					  opcua_connectionHelper.h	
-lib_LTLIBRARIES = libstack.la
-libstack_la_SOURCES = opcua_builtInDatatypes.c\
+lib_LTLIBRARIES = libOpen62541.la
+libOpen62541_la_SOURCES = opcua_builtInDatatypes.c\
 						opcua_binaryEncDec.c\
 						opcua_transportLayer.c\
 						opcua_encodingLayer.c\
@@ -260,8 +250,10 @@ libstack_la_SOURCES = opcua_builtInDatatypes.c\
 						opcua_encodingLayer.h\
 						tcp_layer.h
 
-__top_builddir__bin_stackTest_out_SOURCES = opcuaServer.c
-__top_builddir__bin_stackTest_out_LADD = libstack.la		  										
+
+#bin_PROGRAMS= $(top_builddir)/bin/open62541.out
+#__top_builddir__bin_libOpen62541_out_SOURCES = opcuaServer.c
+__top_builddir__bin_libOpen62541_out_LADD = libOpen62541.la		  										
 all: all-am
 
 .SUFFIXES:
@@ -327,57 +319,8 @@ clean-libLTLIBRARIES:
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libstack.la: $(libstack_la_OBJECTS) $(libstack_la_DEPENDENCIES) $(EXTRA_libstack_la_DEPENDENCIES) 
-	$(LINK) -rpath $(libdir) $(libstack_la_OBJECTS) $(libstack_la_LIBADD) $(LIBS)
-install-binPROGRAMS: $(bin_PROGRAMS)
-	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
-	for p in $$list; do echo "$$p $$p"; done | \
-	sed 's/$(EXEEXT)$$//' | \
-	while read p p1; do if test -f $$p || test -f $$p1; \
-	  then echo "$$p"; echo "$$p"; else :; fi; \
-	done | \
-	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
-	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
-	sed 'N;N;N;s,\n, ,g' | \
-	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
-	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
-	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
-	    else { print "f", $$3 "/" $$4, $$1; } } \
-	  END { for (d in files) print "f", d, files[d] }' | \
-	while read type dir files; do \
-	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
-	    test -z "$$files" || { \
-	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
-	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
-	    } \
-	; done
-
-uninstall-binPROGRAMS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
-	files=`for p in $$list; do echo "$$p"; done | \
-	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-	      -e 's/$$/$(EXEEXT)/' `; \
-	test -n "$$list" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(bindir)" && rm -f $$files
-
-clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
-	echo " rm -f" $$list; \
-	rm -f $$list || exit $$?; \
-	test -n "$(EXEEXT)" || exit 0; \
-	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
-	echo " rm -f" $$list; \
-	rm -f $$list
-$(top_builddir)/bin/$(am__dirstamp):
-	@$(MKDIR_P) $(top_builddir)/bin
-	@: > $(top_builddir)/bin/$(am__dirstamp)
-$(top_builddir)/bin/stackTest.out$(EXEEXT): $(__top_builddir__bin_stackTest_out_OBJECTS) $(__top_builddir__bin_stackTest_out_DEPENDENCIES) $(EXTRA___top_builddir__bin_stackTest_out_DEPENDENCIES) $(top_builddir)/bin/$(am__dirstamp)
-	@rm -f $(top_builddir)/bin/stackTest.out$(EXEEXT)
-	$(LINK) $(__top_builddir__bin_stackTest_out_OBJECTS) $(__top_builddir__bin_stackTest_out_LDADD) $(LIBS)
+libOpen62541.la: $(libOpen62541_la_OBJECTS) $(libOpen62541_la_DEPENDENCIES) $(EXTRA_libOpen62541_la_DEPENDENCIES) 
+	$(LINK) -rpath $(libdir) $(libOpen62541_la_OBJECTS) $(libOpen62541_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -385,7 +328,6 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcuaServer.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcua_binaryEncDec.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcua_builtInDatatypes.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcua_encodingLayer.Plo@am__quote@
@@ -416,7 +358,6 @@ mostlyclean-libtool:
 	-rm -f *.lo
 
 clean-libtool:
-	-rm -rf $(top_builddir)/bin/.libs $(top_builddir)/bin/_libs
 	-rm -rf .libs _libs
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -503,11 +444,9 @@ distdir: $(DISTFILES)
 	done
 check-am: all-am
 check: check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
-install-binPROGRAMS: install-libLTLIBRARIES
-
+all-am: Makefile $(LTLIBRARIES)
 installdirs:
-	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \
+	for dir in "$(DESTDIR)$(libdir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-am
@@ -536,15 +475,14 @@ clean-generic:
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-	-test -z "$(top_builddir)/bin/$(am__dirstamp)" || rm -f $(top_builddir)/bin/$(am__dirstamp)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
-	clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+	mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -570,7 +508,7 @@ install-dvi: install-dvi-am
 
 install-dvi-am:
 
-install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
+install-exec-am: install-libLTLIBRARIES
 
 install-html: install-html-am
 
@@ -610,24 +548,23 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES
+uninstall-am: uninstall-libLTLIBRARIES
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libLTLIBRARIES clean-libtool ctags \
-	distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-binPROGRAMS \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-libLTLIBRARIES \
-	install-man install-pdf install-pdf-am install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-binPROGRAMS uninstall-libLTLIBRARIES
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-libLTLIBRARIES
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

+ 34 - 37
OPCUAServer/src/opcua_binaryEncDec.c

@@ -9,7 +9,7 @@
 #include "opcua_types.h"
 
 
-Byte convertToByte(const char *buf, Int32 *pos)
+Byte decodeByte(const char *buf, Int32 *pos)
 {
 	*pos = (*pos) + 1;
 	return (Byte) buf[(*pos)-1];
@@ -23,7 +23,7 @@ void encodeByte(Byte encodeByte, Int32 *pos, AD_RawMessage *dstBuf)
 
 }
 
-UInt16 convertToUInt16(const char* buf, Int32 *pos)
+UInt16 decodeUInt16(const char* buf, Int32 *pos)
 {
 
 	Byte t1 = buf[*pos];
@@ -31,15 +31,15 @@ UInt16 convertToUInt16(const char* buf, Int32 *pos)
 	*pos += 2;
 	return t1 + t2;
 }
-void encodeUInt16(UInt16 encodeUInt16, Int32 *pos, AD_RawMessage *dstBuf)
+
+void encodeUInt16(UInt16 value, Int32 *pos, AD_RawMessage *dstBuf)
 {
-	dstBuf->message[*pos] = encodeUInt16;
-	dstBuf->message[*pos +1 ] = encodeUInt16 >>8;
+	memcpy(dstBuf->message, &value, 2);
 	*pos = (*pos) + sizeof(UInt16);
-	dstBuf->length = dstBuf->length + sizeof(UInt16);
+
 }
 
-Int16 convertToInt16(const char* buf, Int32 *pos)
+Int16 decodeInt16(const char* buf, Int32 *pos)
 {
 
 	Byte t1 = buf[*pos];
@@ -47,7 +47,7 @@ Int16 convertToInt16(const char* buf, Int32 *pos)
 	*pos += 2;
 	return t1 + t2;
 }
-Int32 convertToInt32(const char* buf, Int32 *pos)
+Int32 decodeInt32(const char* buf, Int32 *pos)
 {
 
 	SByte t1 = buf[*pos];
@@ -59,7 +59,7 @@ Int32 convertToInt32(const char* buf, Int32 *pos)
 }
 
 
-UInt32 convertToUInt32(const char* buf, Int32 *pos)
+UInt32 decodeUInt32(const char* buf, Int32 *pos)
 {
 	Byte t1 = buf[*pos];
 	UInt32 t2 = (UInt32) (buf[*pos + 1] << 8);
@@ -69,19 +69,15 @@ UInt32 convertToUInt32(const char* buf, Int32 *pos)
 	return t1 + t2 + t3 + t4;
 }
 
-void convertUInt32ToByteArray(UInt32 value, char *dstBuf, Int32 *pos)
+void encodeUInt32(UInt32 value, char *dstBuf, Int32 *pos)
 {
 	memcpy(&(dstBuf[*pos]), &value, sizeof(value));
 	pos += 4;
-	/*buf[pos] = (char)(value && 0xFF);
-	 buf[pos + 1] = (char)((value >> 8) && 0xFF);
-	 buf[pos + 2] = (char)((value >> 16) && 0xFF);
-	 buf[pos + 3] = (char)((value >> 24) && 0xFF);
-	 */
+
 }
 
 
-Int64 convertToInt64(const char* buf, Int32 *pos)
+Int64 decodeInt64(const char* buf, Int32 *pos)
 {
 
 	SByte t1 = buf[*pos];
@@ -96,10 +92,10 @@ Int64 convertToInt64(const char* buf, Int32 *pos)
 	return t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 }
 
-Int32 convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
+Int32 decodeUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
 {
 
-	dstUAString->Length = convertToInt32(buf, pos);
+	dstUAString->Length = decodeInt32(buf, pos);
 	if (dstUAString->Length > 0)
 	{
 		dstUAString->Data = &(buf[*pos]);
@@ -112,34 +108,35 @@ Int32 convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
 	*pos += dstUAString->Length;
 }
 
-Int32 convertToUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID)
+Int32 decodeUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID)
 {
-	dstGUID->Data1 = convertToUInt32(buf, pos);
-	dstGUID->Data2 = convertToUInt16(buf, pos);
-	dstGUID->Data3 = convertToUInt16(buf, pos);
-	convertToUAByteString(buf, pos, &(dstGUID->Data4));
+	dstGUID->Data1 = decodeUInt32(buf, pos);
+	dstGUID->Data2 = decodeUInt16(buf, pos);
+	dstGUID->Data3 = decodeUInt16(buf, pos);
+	decodeUAByteString(buf, pos, &(dstGUID->Data4));
 	return 0;
 }
 
-convertToUAByteString(const char *buf, Int32* pos, UA_ByteString *dstBytestring)
+void decodeUAByteString(const char *buf, Int32* pos, UA_ByteString *dstBytestring)
 {
-	convertToUAString(buf,pos,dstBytestring);
+
+	decodeUAString(buf,pos,dstBytestring->Data);
 }
 
-UA_DateTime convertToUADateTime(const char *buf, Int32 *pos)
+UA_DateTime decodeUADateTime(const char *buf, Int32 *pos)
 {
-	return convertToInt64(buf, pos);
+	return decodeInt64(buf, pos);
 }
 
-UA_StatusCode convertToUAStatusCode(const char* buf, Int32 *pos)
+UA_StatusCode decodeUAStatusCode(const char* buf, Int32 *pos)
 {
-	return convertToUInt32(buf, pos);
+	return decodeUInt32(buf, pos);
 }
 
-Int32 convertToUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId)
+Int32 decodeUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId)
 {
 
-	dstNodeId->EncodingByte = convertToInt32(buf, pos);
+	dstNodeId->EncodingByte = decodeInt32(buf, pos);
 
 
 	switch (dstNodeId->EncodingByte)
@@ -147,34 +144,34 @@ Int32 convertToUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId)
 	case NIEVT_TWO_BYTE:
 	{
 
-		dstNodeId->Identifier.Numeric = convertToByte(buf, pos);
+		dstNodeId->Identifier.Numeric = decodeByte(buf, pos);
 		break;
 	}
 	case NIEVT_FOUR_BYTE:
 	{
-		dstNodeId->Identifier.Numeric = convertToInt16(buf, pos);
+		dstNodeId->Identifier.Numeric = decodeInt16(buf, pos);
 		break;
 	}
 	case NIEVT_NUMERIC:
 	{
 
-		dstNodeId->Identifier.Numeric = convertToInt32(buf, pos);
+		dstNodeId->Identifier.Numeric = decodeInt32(buf, pos);
 		break;
 	}
 	case NIEVT_STRING:
 	{
-		convertToUAString(buf, pos, &dstNodeId->Identifier.String);
+		decodeUAString(buf, pos, &dstNodeId->Identifier.String);
 		break;
 	}
 	case NIEVT_GUID:
 	{
-		convertToUAGuid(buf, pos, &(dstNodeId->Identifier.Guid));
+		decodeUAGuid(buf, pos, &(dstNodeId->Identifier.Guid));
 		break;
 	}
 	case NIEVT_BYTESTRING:
 	{
 
-		convertToUAByteString(buf, pos,&(dstNodeId->Identifier.OPAQUE));
+		decodeUAByteString(buf, pos,&(dstNodeId->Identifier.OPAQUE));
 		break;
 	}
 	case NIEVT_NAMESPACE_URI_FLAG:

+ 21 - 12
OPCUAServer/src/opcua_binaryEncDec.h

@@ -13,6 +13,7 @@
 #include "opcua_advancedDatatypes.h"
 
 
+
 //functions
 /**
  *
@@ -20,7 +21,7 @@
  * @param pos  			position at which the data is located in/out, parser position after the conversion
  * @return
  */
-Byte convertToByte(const char* buf, Int32 *pos);
+Byte decodeByte(const char* buf, Int32 *pos);
 
 /**
  *
@@ -36,21 +37,29 @@ void encodeByte(Byte encodeByte, Int32 *pos, AD_RawMessage *dstBuf);
  * @param pos
  * @return
  */
-Int16 convertToInt16(const char* buf, Int32 *pos);
+Int16 decodeInt16(const char* buf, Int32 *pos);
+
+/**
+ *
+ * @param value
+ * @param pos
+ * @param dstBuf
+ */
+void encodeUInt16(UInt16 value, Int32 *pos, AD_RawMessage *dstBuf);
 /**
  *
  * @param buf
  * @param pos
  * @return
  */
-UInt16 convertToUInt16(const char* buf, Int32 *pos);
+UInt16 decodeUInt16(const char* buf, Int32 *pos);
 /**
  *
  * @param buf  			binary encoded message
  * @param pos  			position at which the data is located in/out, parser position after the conversion
  * @return
  */
-Int32 convertToInt32(const char* buf, Int32 *pos);
+Int32 decodeInt32(const char* buf, Int32 *pos);
 
 /**
  *
@@ -58,14 +67,14 @@ Int32 convertToInt32(const char* buf, Int32 *pos);
  * @param pos  			position at which the data is located in/out, parser position after the conversion
  * @return				encoded data
  */
-UInt32 convertToUInt32(const char* buf, Int32 *pos);
+UInt32 decodeUInt32(const char* buf, Int32 *pos);
 /**
  *
  * @param buf
  * @param pos
  * @return
  */
-Int64 convertToInt64(const char* buf, Int32 *pos);
+Int64 decodeInt64(const char* buf, Int32 *pos);
 /**
  *
  * @param buf  			binary encoded message
@@ -73,7 +82,7 @@ Int64 convertToInt64(const char* buf, Int32 *pos);
  * @param dstNodeId		receiver of the nodeid structure
  * @param return		success = 0
  */
-Int32 convertToUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
+Int32 decodeUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
 /**
  *
  * @param buf
@@ -81,7 +90,7 @@ Int32 convertToUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
  * @param dstGUID
  * @return
  */
-Int32 convertToUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
+Int32 decodeUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
 
 /**
  *
@@ -89,14 +98,14 @@ Int32 convertToUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
  * @param pos
  * @return
  */
-UA_StatusCode convertToUAStatusCode(const char* buf, Int32 *pos);
+UA_StatusCode decodeUAStatusCode(const char* buf, Int32 *pos);
 /**
  *
  * @param buf
  * @param pos
  * @return
  */
-UA_DateTime convertToUADateTime(const char *buf, Int32 *pos);
+UA_DateTime decodeUADateTime(const char *buf, Int32 *pos);
 /**
  *
  * @param buf
@@ -104,13 +113,13 @@ UA_DateTime convertToUADateTime(const char *buf, Int32 *pos);
  * @param dstUAString
  * @return
  */
-Int32 convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString);
+Int32 decodeUAString(const char* buf, Int32 *pos, UA_String *dstUAString);
 /**
  *
  * @param value
  * @param dstBuf
  * @param pos
  */
-void convertUInt32ToByteArray(UInt32 value, char *dstBuf, Int32 *pos);
+void encodeUInt32(UInt32 value, char *dstBuf, Int32 *pos);
 
 #endif /* OPCUA_BINARYENCDEC_NEU_H_ */

+ 2 - 2
OPCUAServer/src/opcua_connectionHelper.h

@@ -40,8 +40,8 @@ struct TL_connection
 {
 	Int32 socket;
 	UInt32 connectionState;
-	TL_buffer clientBuffers;
-	TL_buffer serverBuffers;
+	TL_buffer clientConf;
+	TL_buffer serverConf;
 	UA_String endpointURL;
 };
 

+ 16 - 16
OPCUAServer/src/opcua_encodingLayer.c

@@ -15,9 +15,9 @@
  * Chapter: 7.13
  * Page: 118
  */
-T_IntegerId convertToIntegerId(char* buf, Int32 *pos)
+T_IntegerId decodeIntegerId(char* buf, Int32 *pos)
 {
-	return convertToUInt32(buf, pos);
+	return decodeUInt32(buf, pos);
 }
 
 /**
@@ -26,21 +26,21 @@ T_IntegerId convertToIntegerId(char* buf, Int32 *pos)
  * Chapter: 7.9
  * Page: 116
  */
-Int32 convertToDiagnosticInfo(char* buf, Int32 *pos, T_DiagnosticInfo* dstDiagnosticInfo)
+Int32 decodeToDiagnosticInfo(char* buf, Int32 *pos, T_DiagnosticInfo* dstDiagnosticInfo)
 {
 
-	dstDiagnosticInfo->namespaceUri = convertToInt32(buf,pos);
-	dstDiagnosticInfo->symbolicId = convertToInt32(buf, pos);
-	dstDiagnosticInfo->locale = convertToInt32(buf, pos);
-	dstDiagnosticInfo->localizesText = convertToInt32(buf, pos);
+	dstDiagnosticInfo->namespaceUri = decodeInt32(buf,pos);
+	dstDiagnosticInfo->symbolicId = decodeInt32(buf, pos);
+	dstDiagnosticInfo->locale = decodeInt32(buf, pos);
+	dstDiagnosticInfo->localizesText = decodeInt32(buf, pos);
 
-	convertToUAByteString(buf, pos, dstDiagnosticInfo->additionalInfo);
-	dstDiagnosticInfo->innerStatusCode = convertToUAStatusCode(buf, pos);
+	decodeUAByteString(buf, pos, dstDiagnosticInfo->additionalInfo);
+	dstDiagnosticInfo->innerStatusCode = decodeUAStatusCode(buf, pos);
 
 	//If the Flag InnerDiagnosticInfo is set, then the DiagnosticInfo will be encoded
 	if ((dstDiagnosticInfo->innerStatusCode & DIEMT_INNER_DIAGNOSTIC_INFO) == 1)
 	{
-		dstDiagnosticInfo->innerDiagnosticInfo = convertToTDiagnosticInfo(buf,
+		dstDiagnosticInfo->innerDiagnosticInfo = decodeTDiagnosticInfo(buf,
 				pos);
 	}
 
@@ -59,12 +59,12 @@ Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
 		T_RequestHeader *dstRequestHeader)
 {
 
-	convertToUANodeId(srcRaw->message, pos,&(dstRequestHeader->authenticationToken));
-	dstRequestHeader->timestamp = convertToUADateTime(srcRaw->message, pos);
-	dstRequestHeader->requestHandle = convertToIntegerId(srcRaw->message, pos);
-	dstRequestHeader->returnDiagnostics = convertToUInt32(srcRaw->message, pos);
-	convertToUAString(srcRaw->message, pos, &dstRequestHeader->auditEntryId);
-	dstRequestHeader->timeoutHint = convertToUInt32(srcRaw->message, pos);
+	decodeUANodeId(srcRaw->message, pos,&(dstRequestHeader->authenticationToken));
+	dstRequestHeader->timestamp = decodeUADateTime(srcRaw->message, pos);
+	dstRequestHeader->requestHandle = decodeIntegerId(srcRaw->message, pos);
+	dstRequestHeader->returnDiagnostics = decodeUInt32(srcRaw->message, pos);
+	decodeUAString(srcRaw->message, pos, &dstRequestHeader->auditEntryId);
+	dstRequestHeader->timeoutHint = decodeUInt32(srcRaw->message, pos);
 
 
 	// AdditionalHeader will stay empty, need to be changed if there is relevant information

+ 5 - 5
OPCUAServer/src/opcua_secureChannelLayer.c

@@ -163,9 +163,9 @@ UInt32 SL_secureChannel_SCMHeader_get(UA_connection *connection,
 	pos += TL_MESSAGE_TYPE_LEN;
 	SC_Header->IsFinal = rawMessage[pos];
 	pos += sizeof(Byte);
-	SC_Header->MessageSize = convertToUInt32(rawMessage, pos);
+	SC_Header->MessageSize = decodeUInt32(rawMessage, pos);
 	pos += sizeof(UInt32);
-	SC_Header->SecureChannelId = convertToUInt32(rawMessage, pos);
+	SC_Header->SecureChannelId = decodeUInt32(rawMessage, pos);
 	pos += sizeof(UInt32);
 	return pos;
 
@@ -178,7 +178,7 @@ UInt32 SL_secureChannel_AASHeader_get(UA_connection *connection,
 	SL_AsymmetricAlgorithmSecurityHeader* AAS_Header)
 {
 
-	AAS_Header->SecurityPolicyUri.Length = convertToInt32(rawMessage, pos);
+	AAS_Header->SecurityPolicyUri.Length = decodeInt32(rawMessage, pos);
 
 	pos += sizeof(Int32);
 	AAS_Header->SecurityPolicyUri.Data = rawMessage[pos];
@@ -189,7 +189,7 @@ UInt32 SL_secureChannel_AASHeader_get(UA_connection *connection,
 	}
 	pos += AAS_Header->SecurityPolicyUri.Length;
 
-	AAS_Header->SenderCertificate.Length = convertToInt32(rawMessage, pos);
+	AAS_Header->SenderCertificate.Length = decodeInt32(rawMessage, pos);
 	pos += sizeof(Int32);
 	if (AAS_Header->SenderCertificate.Length < 0)
 	{
@@ -199,7 +199,7 @@ UInt32 SL_secureChannel_AASHeader_get(UA_connection *connection,
 
 	pos += AAS_Header->SenderCertificate.Length;
 
-	AAS_Header->ReceiverThumbprint.Length = convertToInt32(rawMessage, pos);
+	AAS_Header->ReceiverThumbprint.Length = decodeInt32(rawMessage, pos);
 	pos += sizeof(Int32);
 
 	if (AAS_Header->ReceiverThumbprint.Length < 0)

+ 49 - 54
OPCUAServer/src/opcua_transportLayer.c

@@ -14,7 +14,7 @@ void TL_sendACK(UA_connection *connection)
 	//get memory for message
 	//
 	//build message
-	//connection->transportLayer.serverBuffers.maxChunkCount;
+	//connection->transportLayer.serverConf.maxChunkCount;
 
 	//call send function
 
@@ -31,16 +31,16 @@ void TL_open(UA_connection *connection, AD_RawMessage *rawMessage)
 		{
 			//process the connection values received by the client
 			TL_processHELMessage(&tmpConnection,rawMessage);
-			connection->transportLayer.serverBuffers.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
+			connection->transportLayer.serverConf.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
 
-			connection->transportLayer.serverBuffers.recvBufferSize =
-					tmpConnection.transportLayer.serverBuffers.recvBufferSize;
+			connection->transportLayer.serverConf.recvBufferSize =
+					tmpConnection.transportLayer.serverConf.recvBufferSize;
 
-			connection->transportLayer.serverBuffers.sendBufferSize =
-					tmpConnection.transportLayer.serverBuffers.sendBufferSize;
+			connection->transportLayer.serverConf.sendBufferSize =
+					tmpConnection.transportLayer.serverConf.sendBufferSize;
 
-			connection->transportLayer.serverBuffers.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
-			connection->transportLayer.serverBuffers.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
+			connection->transportLayer.serverConf.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
+			connection->transportLayer.serverConf.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
 
 		    TL_sendACK(connection);
 			connection->transportLayer.connectionState = connectionState_ESTABLISHED;
@@ -59,10 +59,22 @@ void TL_open(UA_connection *connection, AD_RawMessage *rawMessage)
 		}
 	}
 }
+Int32 TL_checkMessage(UA_connection *connection, AD_RawMessage *TL_messsage)
+{
+	Int32 position = 4;
+	TL_getPacketType(TL_messsage);
 
+	Int32 messageLen = decodeUInt32(TL_messsage->message, &position);
+	if (messageLen == TL_messsage->length &&
+		messageLen < (connection->transportLayer.serverConf.maxMessageSize));
+	{
+		return 1;
+	}
+	return 0;
+}
 void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 {
-	UInt32 bufferSize = connection->transportLayer.serverBuffers.recvBufferSize = 8192;
+	UInt32 bufferSize = connection->transportLayer.serverConf.recvBufferSize = 8192;
 	UInt32 length = 0;
 
 	AD_RawMessage tmpRawMessage;
@@ -78,6 +90,7 @@ void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 	}
 
 
+
 	tmpRawMessage.length = length;
 	if(tmpRawMessage.length > 0)
 	{
@@ -86,8 +99,16 @@ void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 		packetType_MSG:
 		packetType_OPN:
 		packetType_CLO:
-			TL_message->length = tmpRawMessage.length;
-			TL_message->message = tmpRawMessage.message;
+			//CHECK MESSAGE SIZE
+			if (TL_checkMessage(connection,TL_message))
+			{
+				TL_message->length = tmpRawMessage.length;
+				TL_message->message = tmpRawMessage.message;
+			}
+			else
+			{
+				// SEND BACK ERROR MESSAGE
+			}
 			break;
 		packetType_HEL:
 			TL_message->length = 0;
@@ -111,33 +132,7 @@ void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 
 }
 
-void TL_getMessageHeader_test()
-{
-
-	Byte data[] = {0x48,0x45,0x4c,0x46,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0x88,0x13,0x00,0x00,0x36,0x00,0x00,0x00,0x6f,0x70,0x63,0x2e,0x74,0x63,0x70,0x3a,0x2f,0x2f,0x43,0x61,0x6e,0x6f,0x70,0x75,0x73,0x2e,0x70,0x6c,0x74,0x2e,0x72,0x77,0x74,0x68,0x2d,0x61,0x61,0x63,0x68,0x65,0x6e,0x2e,0x64,0x65,0x3a,0x31,0x36,0x36,0x36,0x34,0x2f,0x34,0x43,0x45,0x55,0x41,0x53,0x65,0x72,0x76,0x65,0x72};
-
-	AD_RawMessage rawMessage;
-	rawMessage.message = data;
-	rawMessage.length = 86;
-
 
-	struct TL_messageBodyHEL HELmessage;
-	struct TL_header header;
-	printf("TL_getMessageHeader_test");
-
-	TL_getMessageHeader(&header, &rawMessage);
-
-	if(header.MessageSize == 86 &&
-	   header.MessageType == TL_HEL &&
-	   header.Reserved == 0x46)
-	{
-		printf(" - passed \n");
-	}
-	else
-	{
-		printf(" - failed \n");
-	}
-}
 /*
  * get the message header
  */
@@ -188,9 +183,9 @@ void TL_getMessageHeader(struct TL_header *header, AD_RawMessage *rawMessage)
 
 	pos = pos + TL_MESSAGE_TYPE_LEN;
 
-	header->Reserved = convertToByte(rawMessage->message,pos);
+	header->Reserved = decodeByte(rawMessage->message,pos);
 	pos = pos + TL_RESERVED_LEN;
-	header->MessageSize = convertToUInt32(rawMessage->message,pos);
+	header->MessageSize = decodeUInt32(rawMessage->message,pos);
 
 }
 Int32 TL_getPacketType(AD_RawMessage *rawMessage)
@@ -257,11 +252,11 @@ void TL_processHELMessage_test()
 
 	TL_processHELMessage(&con, &rawMessage);
 
-	if(con.transportLayer.clientBuffers.protocolVersion == 0 &&
-	   con.transportLayer.clientBuffers.recvBufferSize == 65536 &&
-	   con.transportLayer.clientBuffers.sendBufferSize == 65536 &&
-	   con.transportLayer.clientBuffers.maxMessageSize == 16777216 &&
-	   con.transportLayer.clientBuffers.maxChunkCount == 5000)
+	if(con.transportLayer.clientConf.protocolVersion == 0 &&
+	   con.transportLayer.clientConf.recvBufferSize == 65536 &&
+	   con.transportLayer.clientConf.sendBufferSize == 65536 &&
+	   con.transportLayer.clientConf.maxMessageSize == 16777216 &&
+	   con.transportLayer.clientConf.maxChunkCount == 5000)
 	{
 		printf(" - passed \n");
 	}
@@ -282,23 +277,23 @@ void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage)
 	UInt32 pos = TL_HEADER_LENGTH;
 	struct TL_header tmpHeader;
 
-	connection->transportLayer.clientBuffers.protocolVersion =
-			convertToUInt32(rawMessage->message,pos);
+	connection->transportLayer.clientConf.protocolVersion =
+			decodeUInt32(rawMessage->message,pos);
 	pos = pos + sizeof(UInt32);
 
-	connection->transportLayer.clientBuffers.recvBufferSize =
-			convertToUInt32(rawMessage->message,pos);
+	connection->transportLayer.clientConf.recvBufferSize =
+			decodeUInt32(rawMessage->message,pos);
 	pos = pos +  sizeof(UInt32);
 
-	connection->transportLayer.clientBuffers.sendBufferSize =
-			convertToUInt32(rawMessage->message,pos);
+	connection->transportLayer.clientConf.sendBufferSize =
+			decodeUInt32(rawMessage->message,pos);
 	pos = pos +  sizeof(UInt32);
-	connection->transportLayer.clientBuffers.maxMessageSize =
-			convertToUInt32(rawMessage->message,pos);
+	connection->transportLayer.clientConf.maxMessageSize =
+			decodeUInt32(rawMessage->message,pos);
 	pos = pos +  sizeof(UInt32);
 
-	connection->transportLayer.clientBuffers.maxChunkCount =
-			convertToUInt32(rawMessage->message,pos);
+	connection->transportLayer.clientConf.maxChunkCount =
+			decodeUInt32(rawMessage->message,pos);
 	pos = pos +  sizeof(UInt32);
 
 	connection->transportLayer.endpointURL.Data = &(rawMessage->message[pos]);

+ 1 - 1
OPCUAServer/tests/Makefile.am

@@ -5,4 +5,4 @@ check_stack_SOURCES = check_stack.c $(top_builddir)/src/opcua_transportLayer.h\
 						$(top_builddir)/src/opcua_connectionHelper.h
 
 check_stack_CFLAGS = @CHECK_CFLAGS@
-check_stack_LDADD = $(top_builddir)/src/libstack.la @CHECK_LIBS@
+check_stack_LDADD = $(top_builddir)/src/libOpen62541.la @CHECK_LIBS@

+ 95 - 29
OPCUAServer/tests/check_stack.c

@@ -11,7 +11,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "../src/opcua_transportLayer.h"
-
+#include "../src/opcua_binaryEncDec.h"
+#include "../src/opcua_encodingLayer.h"
 #include "../src/opcua_advancedDatatypes.h"
 #include "check.h"
 
@@ -28,56 +29,94 @@ START_TEST(test_getPacketType_validParameter)
 }
 END_TEST
 
-
-START_TEST(test_decodeRequestHeader_validParameter)
+/*
+START_TEST(decodeRequestHeader_test_validParameter)
 {
 		char testMessage = {0x00,0x00,0x72,0xf1,0xdc,0xc9,0x87,0x0b,
+
 							0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
 							0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,
 							0x00,0x00,0x00,0x00,0x00};
 		AD_RawMessage rawMessage;
-		rawMessage.message = testMessage;
+		rawMessage.message = &testMessage;
 		rawMessage.length = 29;
 		Int32 position = 0;
 		T_RequestHeader requestHeader;
-		decodeRequestHeader(rawMessage,&position,requestHeader);
+		decodeRequestHeader(rawMessage,&position,&requestHeader);
 
 		ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
 
 		ck_assert_int_eq(requestHeader.returnDiagnostics,0);
 
 		ck_assert_int_eq(requestHeader.authenticationToken.EncodingByte,0);
+
 }
 END_TEST
+*/
 
-START_TEST(test_binaryEncDec_encoding)
+START_TEST(encodeByte_test)
 {
-
 	AD_RawMessage rawMessage;
 	Int32 position = 0;
 	//EncodeByte
-		char testChar = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-		rawMessage.message = &testChar;
+		char *mem = malloc(sizeof(Byte));
+		rawMessage.message = &mem;
 		Byte testByte = 0x08;
-		rawMessage.length = 0;
+		rawMessage.length = 1;
 		position = 0;
+
 		encodeByte(testByte, &position, &rawMessage);
 
 		ck_assert_int_eq(rawMessage.message[0], 0x08);
 		ck_assert_int_eq(rawMessage.length, 1);
 		ck_assert_int_eq(position, 1);
+		free(mem);
+}
+END_TEST
+
+START_TEST(decodeUInt16_test)
+{
+
+	AD_RawMessage rawMessage;
+	Int32 position = 0;
 	//EncodeUInt16
-		char testChar1 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-		rawMessage.message = &testChar1;
-		UInt16 testUInt16 = 0XABCD;
-		rawMessage.length = 0;
-		position = 0;
-		encodeUInt16(testUInt16, &position, &rawMessage);
+	char mem[2] = {0x01,0x00};
+
+	rawMessage.message = &mem;
+
+	rawMessage.length = 2;
+
+	//encodeUInt16(testUInt16, &position, &rawMessage);
+
+	Int32 p = 0;
+	UInt16 val = decodeUInt16(rawMessage.message,&p);
+	ck_assert_int_eq(val,1);
+	//ck_assert_int_eq(p, 2);
+	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
+
+}
+END_TEST
+START_TEST(encodeUInt16_test)
+{
+
+	AD_RawMessage rawMessage;
+	Int32 position = 0;
+	//EncodeUInt16
+	char *mem = malloc(sizeof(UInt16));
+	rawMessage.message = &mem;
+	UInt16 testUInt16 = 1;
+	rawMessage.length = 2;
+	position = 0;
+
+	encodeUInt16(testUInt16, &position, &rawMessage);
+	//encodeUInt16(testUInt16, &position, &rawMessage);
+
+	ck_assert_int_eq(position, 2);
+	Int32 p = 0;
+	Int16 val = decodeUInt16(rawMessage.message,&p);
+	ck_assert_int_eq(val,testUInt16);
+	//ck_assert_int_eq(rawMessage.message[0], 0xAB);
 
-		ck_assert_int_eq(rawMessage.length, 2);
-		ck_assert_int_eq(position, 2);
-		ck_assert_int_eq((Byte) rawMessage.message[1], 0xAB);
-		ck_assert_int_eq((Byte) rawMessage.message[0], 0xCD);
 }
 END_TEST
 
@@ -90,17 +129,32 @@ Suite* TL_testSuite_getPacketType(void)
 	suite_add_tcase(s,tc_core);
 	return s;
 }
-
-Suite* TL_testSuite_encode(void)
+Suite* TL_testSuite_decodeUInt16(void)
 {
-	Suite *s = suite_create("encoding");
+	Suite *s = suite_create("decodeUInt16_test");
 	TCase *tc_core = tcase_create("Core");
-	tcase_add_test(tc_core,test_binaryEncDec_encoding);
+	tcase_add_test(tc_core, decodeUInt16_test);
 	suite_add_tcase(s,tc_core);
 	return s;
 }
-
-
+Suite* TL_testSuite_encodeUInt16(void)
+{
+	Suite *s = suite_create("encodeUInt16_test");
+	TCase *tc_core = tcase_create("Core");
+	tcase_add_test(tc_core, encodeUInt16_test);
+	suite_add_tcase(s,tc_core);
+	return s;
+}
+/*
+Suite* TL_testSuite_encodeByte(void)
+{
+	Suite *s = suite_create("encodeByte_test");
+	TCase *tc_core = tcase_create("Core");
+	tcase_add_test(tc_core, encodeByte_test);
+	suite_add_tcase(s,tc_core);
+	return s;
+}
+*/
 /*
 Suite* TL_<TESTSUITENAME>(void)
 {
@@ -114,7 +168,7 @@ Suite* TL_<TESTSUITENAME>(void)
 
 int main (void)
 {
-	int number_failed;
+	int number_failed = 0;
 
 	Suite *s = TL_testSuite_getPacketType();
 	SRunner *sr = srunner_create(s);
@@ -122,13 +176,24 @@ int main (void)
 	number_failed = srunner_ntests_failed(sr);
 	srunner_free(sr);
 
-	s = TL_testSuite_encode();
+	s = TL_testSuite_decodeUInt16();
 	sr = srunner_create(s);
 	srunner_run_all(sr,CK_NORMAL);
 	number_failed += srunner_ntests_failed(sr);
 	srunner_free(sr);
 
-
+	s = TL_testSuite_encodeUInt16();
+	sr = srunner_create(s);
+	srunner_run_all(sr,CK_NORMAL);
+	number_failed += srunner_ntests_failed(sr);
+	srunner_free(sr);
+/*
+	s = TL_testSuite_encodeByte();
+	sr = srunner_create(s);
+	srunner_run_all(sr,CK_NORMAL);
+	number_failed += srunner_ntests_failed(sr);
+	srunner_free(sr);
+*/
 	/* <TESTSUITE_TEMPLATE>
 	s =  <TESTSUITENAME>;
 	sr = srunner_create(s);
@@ -137,6 +202,7 @@ int main (void)
 	srunner_free(sr);
 	*/
 	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+
 }