Переглянути джерело

changes in comments and function heads

FlorianPalm 11 роки тому
батько
коміт
d8d24614c1

+ 18 - 0
OPCUAServer/config.log

@@ -641,3 +641,21 @@ target_vendor='pc'
 #define LT_OBJDIR ".libs/"
 
 configure: exit 0
+
+## ---------------------- ##
+## Running config.status. ##
+## ---------------------- ##
+
+This file was extended by OPCUAServer config.status 1.0, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
+
+  CONFIG_FILES    = 
+  CONFIG_HEADERS  = 
+  CONFIG_LINKS    = 
+  CONFIG_COMMANDS = 
+  $ ./config.status src/Makefile depfiles
+
+on opcua-VirtualBox
+
+config.status:1024: creating src/Makefile
+config.status:1196: executing depfiles commands

+ 2 - 0
OPCUAServer/src/Makefile.am

@@ -24,12 +24,14 @@ lib_LTLIBRARIES = libstack.la
 libstack_la_SOURCES = 	opcua_builtInDatatypes.c\
 						opcua_binaryEncDec.c\
 						opcua_transportLayer.c\
+						opcua_encodingLayer.c\
 						opcua_builtInDatatypes.h\
 						opcua_binaryEncDec.h\
 						opcua_transportLayer.h\
 						opcua_advancedDatatypes.h\
 						opcua_types.h\
 						opcua_connectionHelper.h\
+						opcua_encodingLayer.h\
 						tcp_layer.h
 
 bin_PROGRAMS= $(top_builddir)/bin/stackTest.out

+ 5 - 1
OPCUAServer/src/Makefile.in

@@ -89,7 +89,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
 libstack_la_LIBADD =
 am_libstack_la_OBJECTS = opcua_builtInDatatypes.lo \
-	opcua_binaryEncDec.lo opcua_transportLayer.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)
@@ -249,12 +250,14 @@ lib_LTLIBRARIES = libstack.la
 libstack_la_SOURCES = opcua_builtInDatatypes.c\
 						opcua_binaryEncDec.c\
 						opcua_transportLayer.c\
+						opcua_encodingLayer.c\
 						opcua_builtInDatatypes.h\
 						opcua_binaryEncDec.h\
 						opcua_transportLayer.h\
 						opcua_advancedDatatypes.h\
 						opcua_types.h\
 						opcua_connectionHelper.h\
+						opcua_encodingLayer.h\
 						tcp_layer.h
 
 __top_builddir__bin_stackTest_out_SOURCES = opcuaServer.c
@@ -385,6 +388,7 @@ distclean-compile:
 @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@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcua_transportLayer.Plo@am__quote@
 
 .c.o:

+ 2 - 2
OPCUAServer/src/opcua_advancedDatatypes.h

@@ -693,13 +693,13 @@ struct BED_RelativePath
 */
 struct BED_RequestHeader
 {
-	struct BED_SessionAuthenticationToken authenticationToken;		//ToDo
+	UA_NodeId authenticationToken;		//ToDo
 	UA_DateTime timestamp;
 	BED_IntegerId requestHandle;
 	UInt32 returnDiagnostics;
 	UA_String auditEntryId;
 	UInt32 timeoutHint;
-	T_ExtensibleParameter additionalHeader;
+	UA_ExtensionObject additionalHeader;
 };
 
 

+ 7 - 16
OPCUAServer/src/opcua_binaryEncDec.c

@@ -8,18 +8,14 @@
 #include "opcua_binaryEncDec.h"
 #include "opcua_types.h"
 
-/*
- * convert byte array to Byte
- */
+
 Byte convertToByte(const char *buf, Int32 *pos)
 {
 	*pos = (*pos) + 1;
 	return (Byte) buf[(*pos)-1];
 
 }
-/*
- * convert byte array to UInt16
- */
+
 UInt16 convertToUInt16(const char* buf, Int32 *pos)
 {
 
@@ -28,9 +24,6 @@ UInt16 convertToUInt16(const char* buf, Int32 *pos)
 	*pos += 2;
 	return t1 + t2;
 }
-/*
- * convert byte array to Int32
- */
 Int32 convertToInt32(const char* buf, Int32 *pos)
 {
 
@@ -41,9 +34,8 @@ Int32 convertToInt32(const char* buf, Int32 *pos)
 	*pos += 4;
 	return t1 + t2 + t3 + t4;
 }
-/*
- * convert byte array to UInt32
- */
+
+
 UInt32 convertToUInt32(const char* buf, Int32 *pos)
 {
 	Byte t1 = buf[*pos];
@@ -64,9 +56,8 @@ void convertUInt32ToByteArray(UInt32 value, char *dstBuf, Int32 *pos)
 	 buf[pos + 3] = (char)((value >> 24) && 0xFF);
 	 */
 }
-/*
- * convert byte array to Int64
- */
+
+
 Int64 convertToInt64(const char* buf, Int32 *pos)
 {
 
@@ -82,7 +73,7 @@ Int64 convertToInt64(const char* buf, Int32 *pos)
 	return t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8;
 }
 
-convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
+Int32 convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString)
 {
 
 	dstUAString->Length = convertToInt32(buf, pos);

+ 54 - 1
OPCUAServer/src/opcua_binaryEncDec.h

@@ -20,6 +20,15 @@
  * @return
  */
 Byte convertToByte(const char* buf, Int32 *pos);
+
+
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+UInt16 convertToUInt16(const char* buf, Int32 *pos);
 /**
  *
  * @param buf  			binary encoded message
@@ -35,7 +44,13 @@ Int32 convertToInt32(const char* buf, Int32 *pos);
  * @return				encoded data
  */
 UInt32 convertToUInt32(const char* buf, Int32 *pos);
-
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+Int64 convertToInt64(const char* buf, Int32 *pos);
 /**
  *
  * @param buf  			binary encoded message
@@ -44,5 +59,43 @@ UInt32 convertToUInt32(const char* buf, Int32 *pos);
  * @param return		success = 0
  */
 Int32 convertToUANodeId(const char* buf, Int32 *pos, UA_NodeId *dstNodeId);
+/**
+ *
+ * @param buf
+ * @param pos
+ * @param dstGUID
+ * @return
+ */
+Int32 convertToUAGuid(const char *buf, Int32 *pos, UA_Guid *dstGUID);
+
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+UA_StatusCode convertToUAStatusCode(const char* buf, Int32 *pos);
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+UA_DateTime convertToUADateTime(const char *buf, Int32 *pos);
+/**
+ *
+ * @param buf
+ * @param pos
+ * @param dstUAString
+ * @return
+ */
+Int32 convertToUAString(const char* buf, Int32 *pos, UA_String *dstUAString);
+/**
+ *
+ * @param value
+ * @param dstBuf
+ * @param pos
+ */
+void convertUInt32ToByteArray(UInt32 value, char *dstBuf, Int32 *pos);
 
 #endif /* OPCUA_BINARYENCDEC_NEU_H_ */

+ 8 - 7
OPCUAServer/src/opcua_encodingLayer.c

@@ -33,7 +33,7 @@ Int32 convertToDiagnosticInfo(char* buf, Int32 *pos, T_DiagnosticInfo* dstDiagno
 	dstDiagnosticInfo->symbolicId = convertToInt32(buf, pos);
 	dstDiagnosticInfo->locale = convertToInt32(buf, pos);
 	dstDiagnosticInfo->localizesText = convertToInt32(buf, pos);
-	dstDiagnosticInfo->additionalInfo = convertToUAString(buf, pos);
+	convertToUAString(buf, pos,dstDiagnosticInfo->additionalInfo.Data);
 	dstDiagnosticInfo->innerStatusCode = convertToUAStatusCode(buf, pos);
 
 	//If the Flag InnerDiagnosticInfo is set, then the DiagnosticInfo will be encoded
@@ -65,6 +65,7 @@ Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
 	convertToUAString(srcRaw->message, pos, &dstRequestHeader->auditEntryId);
 	dstRequestHeader->timeoutHint = convertToUInt32(srcRaw->message, pos);
 
+
 	// AdditionalHeader will stay empty, need to be changed if there is relevant information
 
 	return 0;
@@ -76,15 +77,15 @@ Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
  * Chapter: 7.27
  * Page: 133
  */
-/** \copydoc decodeResponseHeader */
-Int32 decodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *buf)
+/** \copydoc encodeResponseHeader */
+Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf)
 {
-	responseHeader->timestamp = convertToUADateTime(buf->message, pos);
-	responseHeader->requestHandle = convertToTIntegerId(buf->message, pos);
-	responseHeader->serviceResult = convertToUAStatusCode(buf->message,
+	responseHeader->timestamp = convertToUADateTime(dstBuf->message, pos);
+	responseHeader->requestHandle = convertToIntegerId(dstBuf->message, pos);
+	responseHeader->serviceResult = convertToUAStatusCode(dstBuf->message,
 			pos);
 
-	responseHeader->serviceDiagnostics = convertToTDiagnosticInfo(buf->message,
+	responseHeader->serviceDiagnostics = convertToDiagnosticInfo(dstBuf->message,
 			pos);
 	return 0;
 }

+ 17 - 16
OPCUAServer/src/opcua_encodingLayer.h

@@ -8,38 +8,39 @@
 #ifndef OPCUA_ENCODINGLAYER_H_
 #define OPCUA_ENCODINGLAYER_H_
 
+#include "opcua_builtInDatatypes.h"
+#include "opcua_advancedDatatypes.h"
+#include "opcua_types.h"
 /**
- *  \brief function to decode a request header message
- *
+ * \brief
  * \param srcRaw             pointer to raw data which holds the encoded data
+ * \param pos
  * \param dstRequestHeader   pointer to a structure which hold the encoded header
  * \return                   0 = success
  */
-Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, T_RequestHeader *dstRequestHeader);
+Int32 decodeRequestHeader(const AD_RawMessage *srcRaw,Int32 *pos, T_RequestHeader *dstRequestHeader);
 
 
 
 /**
- *  \brief function to encode a request header message
  *
- * \param srcHeader        pointer to header which should be encoded
- * \param dstRaw           pointer to the destination buffer which receives the encoded data
- * \return				   0 = success
+ * @param srcHeader
+ * @param pos
+ * @param dstRaw
+ * @return
  */
-Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,AD_RawMessage *dstRaw);
+Int32 encodeRequestHeader(const T_RequestHeader *srcHeader,Int32 *pos,AD_RawMessage *dstRaw);
 
 
 
 /**
- *  \brief function to decode a response header message
  *
- * \param srcRaw             pointer to raw data which holds the encoded data
- * \param dstResponseHeader  pointer to ResponseHeader structure in which the encoded structure is copied
- * \return                   0 = success
+ * @param srcRaw
+ * @param pos
+ * @param dstResponseHeader
+ * @return
  */
-Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, T_ResponseHeader *dstResponseHeader);
-
-
+Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, Int32 *pos, T_ResponseHeader *dstResponseHeader);
 
 /**
  *  \brief function to encode a secureChannelRequestHeader
@@ -48,7 +49,7 @@ Int32 decodeResponseHeader(const AD_RawMessage *srcRaw, T_ResponseHeader *dstRes
  * \param dstBuf   pointer to a structure which hold the encoded header
  * \return
  */
-Int32 encodeResponseHeader(T_ResponseHeader *header,AD_RawMessage* *dstBuf);
+Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf);