Browse Source

added several encoding/decoding functions (expandedNodeId, QualifiedName, LocalizedText, ExtensionObject, Variant DataValue)
changed the structure of the decoding/encoding,
so decoding/encoding functions can be called recursively.

FlorianPalm 11 years ago
parent
commit
dc3a08ed84

File diff suppressed because it is too large
+ 575 - 176
OPCUAServer/src/opcua_binaryEncDec.c


+ 57 - 5
OPCUAServer/src/opcua_binaryEncDec.h

@@ -14,8 +14,37 @@
 #include "opcua_types.h"
 
 
-
+#define UA_TRUE 1
+#define UA_FALSE 0
 //functions
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+Boolean decodeBoolean(char * const buf, Int32 *pos);
+/**
+ *
+ * @param value
+ * @param pos
+ * @param dstBuf
+ */
+void encodeBoolean(Boolean value, Int32 *pos, char *dstBuf);
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+SByte decodeSByte(char * const buf, Int32 *pos);
+/**
+ *
+ * @param value
+ * @param pos
+ * @param dstBuf
+ */
+void encodeSByte(SByte value, Int32 *pos, char *dstBuf);
 /**
  *
  * @param buf  			binary encoded message
@@ -25,11 +54,11 @@
 Byte decodeByte(char *const buf, Int32 *pos);
 /**
  *
- * @param encodeByte 	byte that should be encoded
- * @param pos 			position at which the data is located in/out, parser position after the conversion
- * @param dstBuf		rawMessage where the Byte is encoded in
+ * @param value
+ * @param pos
+ * @param dstBuf
  */
-void encodeByte(Byte encodeByte, Int32 *pos, char *dstBuf);
+void encodeByte(Byte value, Int32 *pos, char *dstBuf);
 /**
  *
  * @param buf
@@ -190,6 +219,14 @@ UA_StatusCode decodeUAStatusCode(char *const buf, Int32 *pos);
  * @return
  */
 UA_DateTime decodeUADateTime(char *const buf, Int32 *pos);
+/**
+ *
+ * @param time
+ * @param pos
+ * @param dstBuf
+ * @return
+ */
+void encodeUADateTime(UA_DateTime time, Int32 *pos, char *dstBuf);
 /**
  *
  * @param buf
@@ -204,6 +241,21 @@ Int32 decodeUAString(char *const buf, Int32 *pos, UA_String *dstUAString);
  * @return length of the binary encoded data
  */
 Int32 UAByteString_calcSize(UA_ByteString *byteString);
+/**
+ *
+ * @param buf
+ * @param pos
+ * @return
+ */
+T_IntegerId decodeIntegerId(char* buf, Int32 *pos);
+/**
+ *
+ * @param integerId
+ * @param pos
+ * @param buf
+
+ */
+void encodeIntegerId(T_IntegerId integerId, Int32 *pos, char *buf);
 /**
  * \brief
  * \param srcRaw             pointer to raw data which holds the encoded data

+ 14 - 15
OPCUAServer/src/opcua_builtInDatatypes.h

@@ -41,7 +41,7 @@ typedef enum _UA_BuiltInDataTypes
 	LOCALIZED_TEXT = 	21,
 	EXTENSION_OBJECT = 	22,
 	DATA_VALUE = 		23,
-	VARIAN = 			24,
+	VARIANT = 			24,
 	DIAGNOSTIC_INFO = 	25
 }
 UA_BuiltInDataTypes;
@@ -116,6 +116,13 @@ typedef struct _UA_ByteString
 }
 UA_ByteString;
 
+
+typedef struct
+{
+	Int32 Length;
+	Int32 *Data;
+}IntegerString;
+
 /* GuidType
 * Part: 6
 * Chapter: 5.2.2.6
@@ -139,7 +146,7 @@ UA_Guid;
 //Überlegung ob man es direkt als ByteString speichert oder als String
 typedef struct _UA_XmlElement
 {
-	UA_String Data;
+	UA_ByteString Data;
 }
 UA_XmlElement;
 
@@ -199,7 +206,7 @@ typedef struct _UA_NodeId
         UInt32 Numeric;
         UA_String String;
         UA_Guid Guid;
-        UA_ByteString OPAQUE;
+        UA_ByteString ByteString;
     }
     Identifier;
 
@@ -215,18 +222,10 @@ UA_NodeId;
 */
 typedef struct _UA_ExpandedNodeId
 {
+	UA_NodeId NodeId;
 	Int32 EncodingByte; //enum BID_NodeIdEncodingValuesType
-	UInt16 Namespace;
+	UA_String NamespaceUri;
 	UInt32 ServerIndex;
-
-    union
-    {
-        UInt32 Numeric;
-        UA_String String;
-        UA_Guid Guid;
-        UA_ByteString ByteString;
-    }
-    Identifier;
 }
 UA_ExpandedNodeId;
 
@@ -299,7 +298,7 @@ typedef struct _UA_LocalizedText
 {
 	Byte EncodingMask;
 	UA_String Locale;
-	UA_String Test;
+	UA_String Text;
 }
 UA_LocalizedText;
 
@@ -322,7 +321,7 @@ typedef struct _UA_ExtensionObject
 	UA_NodeId TypeId;
 	Byte Encoding; //Type of the Enum UA_ExtensionObjectEncodingMaskType
 	Int32 Length;
-	Byte *Body;
+	UA_ByteString Body;
 }
 UA_ExtensionObject;
 

+ 1 - 1
OPCUAServer/src/opcua_secureChannelLayer.c

@@ -25,7 +25,7 @@ Int32 SL_secureChannel_ResponseHeader_get(const UA_connection *connection, T_Res
 	responseHeader->serviceDiagnostics->EncodingMask = 0;
 	responseHeader->noOfStringTable = 0;
 
-	responseHeader->additionalHeader.Body = 0;
+	responseHeader->additionalHeader.Body.Length = 0;
 	responseHeader->additionalHeader.Encoding = 0;
 	responseHeader->additionalHeader.Length = 0;
 

+ 6 - 0
OPCUAServer/src/opcua_types.h

@@ -22,6 +22,12 @@ typedef enum _T_ApplicationType
 }
 T_ApplicationType;
 
+typedef struct
+{
+	Int32 Length;
+	Int32 *Data;
+
+}IntegerString;
 
 /**
 * Index