Leon Urbas пре 11 година
родитељ
комит
96b497ed9e

+ 3 - 3
Makefile.am

@@ -1,8 +1,8 @@
-
+AM_CFLAGS = -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
 if DEBUG
-AM_CFLAGS = -g -O0 -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
+AM_CFLAGS += -g3 -O0  
 else
-AM_CFLAGS = -O2 -std=c99 -pedantic -pipe -fPIC -fno-exceptions -fstack-protector -Wl,-z,relro -Wl,-z,now -fvisibility=hidden -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wformat -Wreturn-type -Wsign-compare -Wmultichar -Wformat-nonliteral -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -Werror
+AM_CFLAGS += -O2 
 endif
 
 export GLOBAL_AM_CFLAGS = $(AM_CFLAGS)

+ 28 - 4
examples/src/simpleTest.c

@@ -6,14 +6,38 @@
  */
 #include <stdio.h>
 #include "opcua.h"
-int main() {
+void testString() {
+	UA_Int32 pos = 0;
+	UA_Int32 retval = UA_SUCCESS;
+	UA_String string;
+
+	UA_Byte binString[12] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
+	UA_ByteString src = { 12, binString };
+
+	retval = UA_String_decodeBinary(&src, &pos, &string);
+	UA_String_deleteMembers(&string);
+
+}
+void testVariant() {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_Byte data[] = { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_ByteString src = { sizeof(data), data };
 	UA_Variant dst;
 	// when
-	UA_Int32 retval = UA_Variant_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_Variant_decodeBinary(&src, &pos, &dst);
 	UA_Variant_deleteMembers(&dst);
+}
+void testByte() {
+	// given
+	UA_Byte dst;
+	UA_Byte data[] = { 0x08 };
+	UA_ByteString src = { 1, data };
+	UA_Int32 pos = 0;
+	// when
+	UA_Int32 retval = UA_Byte_decodeBinary(&src, &pos, &dst);
+}
+int main() {
+	testByte();
 	return 0;
 }
-

+ 29 - 18
include/opcua_basictypes.h

@@ -33,6 +33,14 @@ typedef int64_t UA_Int64;
 typedef uint64_t UA_UInt64;
 typedef float UA_Float;
 typedef double UA_Double;
+/* ByteString - Part: 6, Chapter: 5.2.2.7, Page: 17 */
+typedef struct T_UA_ByteString
+{
+	UA_Int32 	length;
+	UA_Byte*	data;
+}
+UA_ByteString;
+
 
 /* Function return values */
 #define UA_SUCCESS 0
@@ -65,16 +73,16 @@ UA_Int32 _UA_alloc(void ** dst, int size,char*,int);
 
 /* Array operations */
 UA_Int32 UA_Array_calcSize(UA_Int32 noElements, UA_Int32 type, void const ** const ptr);
-UA_Int32 UA_Array_encode(void const **src, UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, UA_Byte * dst);
-UA_Int32 UA_Array_decode(UA_Byte const * src,UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, void ** const dst);
+UA_Int32 UA_Array_encodeBinary(void const **src, UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, UA_ByteString * dst);
+UA_Int32 UA_Array_decodeBinary(UA_ByteString const * src,UA_Int32 noElements, UA_Int32 type, UA_Int32* pos, void ** const dst);
 UA_Int32 UA_Array_delete(void **p,UA_Int32 noElements, UA_Int32 type);
 UA_Int32 UA_Array_init(void **p,UA_Int32 noElements, UA_Int32 type);
 UA_Int32 UA_Array_new(void **p,UA_Int32 noElements, UA_Int32 type);
 
 #define UA_TYPE_METHOD_PROTOTYPES(TYPE) \
 UA_Int32 TYPE##_calcSize(TYPE const * ptr);\
-UA_Int32 TYPE##_encode(TYPE const * src, UA_Int32* pos, UA_Byte * dst);\
-UA_Int32 TYPE##_decode(UA_Byte const * src, UA_Int32* pos, TYPE * dst);\
+UA_Int32 TYPE##_encodeBinary(TYPE const * src, UA_Int32* pos, UA_ByteString * dst);\
+UA_Int32 TYPE##_decodeBinary(UA_ByteString const * src, UA_Int32* pos, TYPE * dst);\
 UA_Int32 TYPE##_delete(TYPE * p);\
 UA_Int32 TYPE##_deleteMembers(TYPE * p); \
 UA_Int32 TYPE##_init(TYPE * p); \
@@ -107,14 +115,14 @@ UA_Int32 TYPE##_deleteMembers(TYPE * p) { return UA_SUCCESS; }
 #define UA_TYPE_METHOD_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
 UA_Int32 TYPE##_deleteMembers(TYPE * p) { return TYPE_AS##_deleteMembers((TYPE_AS*) p);}
 
-#define UA_TYPE_METHOD_DECODE_AS(TYPE,TYPE_AS) \
-UA_Int32 TYPE##_decode(UA_Byte const * src, UA_Int32* pos, TYPE *dst) { \
-	return TYPE_AS##_decode(src,pos,(TYPE_AS*) dst); \
+#define UA_TYPE_METHOD_DECODEBINARY_AS(TYPE,TYPE_AS) \
+UA_Int32 TYPE##_decodeBinary(UA_ByteString const * src, UA_Int32* pos, TYPE *dst) { \
+	return TYPE_AS##_decodeBinary(src,pos,(TYPE_AS*) dst); \
 }
 
-#define UA_TYPE_METHOD_ENCODE_AS(TYPE,TYPE_AS) \
-UA_Int32 TYPE##_encode(TYPE const * src, UA_Int32* pos, UA_Byte *dst) { \
-	return TYPE_AS##_encode((TYPE_AS*) src,pos,dst); \
+#define UA_TYPE_METHOD_ENCODEBINARY_AS(TYPE,TYPE_AS) \
+UA_Int32 TYPE##_encodeBinary(TYPE const * src, UA_Int32* pos, UA_ByteString *dst) { \
+	return TYPE_AS##_encodeBinary((TYPE_AS*) src,pos,dst); \
 }
 
 #define UA_TYPE_METHOD_INIT_AS(TYPE, TYPE_AS) \
@@ -122,6 +130,15 @@ UA_Int32 TYPE##_init(TYPE * p){ \
 	return TYPE_AS##_init((TYPE_AS*)p); \
 }
 
+#define UA_TYPE_METHOD_PROTOTYPES_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_CALCSIZE_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_ENCODEBINARY_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_DECODEBINARY_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_DELETE_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_DELETEMEMBERS_AS(TYPE, TYPE_AS) \
+UA_TYPE_METHOD_INIT_AS(TYPE, TYPE_AS)
+
+
 #define UA_TYPE_METHOD_NEW_DEFAULT(TYPE) \
 UA_Int32 TYPE##_new(TYPE ** p){ \
 	UA_Int32 retval = UA_SUCCESS;\
@@ -172,8 +189,8 @@ UA_TYPE_METHOD_PROTOTYPES (UA_IntegerId)
 typedef struct T_UA_VTable {
 	UA_UInt32 Id;
 	UA_Int32 (*calcSize)(void const * ptr);
-	UA_Int32 (*decode)(UA_Byte const * src, UA_Int32* pos, void* dst);
-	UA_Int32 (*encode)(void const * src, UA_Int32* pos, UA_Byte* dst);
+	UA_Int32 (*decodeBinary)(UA_ByteString const * src, UA_Int32* pos, void* dst);
+	UA_Int32 (*encodeBinary)(void const * src, UA_Int32* pos, UA_ByteString* dst);
 	UA_Int32 (*new)(void ** p);
 	UA_Int32 (*delete)(void * p);
 } UA_VTable;
@@ -210,12 +227,6 @@ 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
-{
-	UA_Int32 	length;
-	UA_Byte*	data;
-}
-UA_ByteString;
 UA_TYPE_METHOD_PROTOTYPES (UA_ByteString)
 UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2);
 UA_Int32 UA_ByteString_copy(UA_ByteString const * src, UA_ByteString* dst);

+ 76 - 76
src/UA_stackInternalTypes.c

@@ -7,25 +7,25 @@ UA_Int32 UA_MessageType_calcSize(UA_MessageType const * ptr){
 	 + 3 * sizeof(UA_Byte);
 }
 
-UA_Int32 UA_MessageType_encode(UA_MessageType const * src, UA_Int32* pos, UA_Byte* dst){
+UA_Int32 UA_MessageType_encodeBinary(UA_MessageType const * src, UA_Int32* pos, UA_ByteString* dst){
 	UA_Int32 retval = UA_SUCCESS;
 	UA_Byte tmpBuf[3];
 	tmpBuf[0] = (UA_Byte)((((UA_Int32)*src) >> 16) );
 	tmpBuf[1] = (UA_Byte)((((UA_Int32)*src) >> 8));
 	tmpBuf[2] = (UA_Byte)(((UA_Int32)*src));
 
-	retval |= UA_Byte_encode(&(tmpBuf[0]),pos,dst);
-	retval |= UA_Byte_encode(&(tmpBuf[1]),pos,dst);
-	retval |= UA_Byte_encode(&(tmpBuf[2]),pos,dst);
+	retval |= UA_Byte_encodeBinary(&(tmpBuf[0]),pos,dst);
+	retval |= UA_Byte_encodeBinary(&(tmpBuf[1]),pos,dst);
+	retval |= UA_Byte_encodeBinary(&(tmpBuf[2]),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_MessageType_decode(UA_Byte const * src, UA_Int32* pos, UA_MessageType* dst){
+UA_Int32 UA_MessageType_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_MessageType* dst){
 	UA_Int32 retval = UA_SUCCESS;
 	UA_Byte tmpBuf[3];
-	retval |= UA_Byte_decode(src,pos,&(tmpBuf[0]));//messageType to Byte representation
-	retval |= UA_Byte_decode(src,pos,&(tmpBuf[1]));
-	retval |= UA_Byte_decode(src,pos,&(tmpBuf[2]));
+	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[0]));//messageType to Byte representation
+	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[1]));
+	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[2]));
 	*dst = (UA_MessageType)((UA_Int32)(tmpBuf[0]<<16) + (UA_Int32)(tmpBuf[1]<<8) + (UA_Int32)(tmpBuf[2]));
 	return retval;
 }
@@ -45,19 +45,19 @@ UA_Int32 UA_OPCUATcpMessageHeader_calcSize(UA_OPCUATcpMessageHeader const * ptr)
 	;
 }
 
-UA_Int32 UA_OPCUATcpMessageHeader_encode(UA_OPCUATcpMessageHeader const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_OPCUATcpMessageHeader_encodeBinary(UA_OPCUATcpMessageHeader const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_MessageType_encode(&(src->messageType),pos,dst);
-	retval |= UA_Byte_encode(&(src->isFinal),pos,dst);
-	retval |= UA_UInt32_encode(&(src->messageSize),pos,dst);
+	retval |= UA_MessageType_encodeBinary(&(src->messageType),pos,dst);
+	retval |= UA_Byte_encodeBinary(&(src->isFinal),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->messageSize),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_OPCUATcpMessageHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpMessageHeader* dst) {
+UA_Int32 UA_OPCUATcpMessageHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpMessageHeader* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_MessageType_decode(src,pos,&(dst->messageType));
-	retval |= UA_Byte_decode(src,pos,&(dst->isFinal));
-	retval |= UA_UInt32_decode(src,pos,&(dst->messageSize));
+	retval |= UA_MessageType_decodeBinary(src,pos,&(dst->messageType));
+	retval |= UA_Byte_decodeBinary(src,pos,&(dst->isFinal));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->messageSize));
 	return retval;
 }
 
@@ -84,25 +84,25 @@ UA_Int32 UA_OPCUATcpHelloMessage_calcSize(UA_OPCUATcpHelloMessage const * ptr) {
 	;
 }
 
-UA_Int32 UA_OPCUATcpHelloMessage_encode(UA_OPCUATcpHelloMessage const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_OPCUATcpHelloMessage_encodeBinary(UA_OPCUATcpHelloMessage const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_encode(&(src->protocolVersion),pos,dst);
-	retval |= UA_UInt32_encode(&(src->receiveBufferSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->sendBufferSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->maxMessageSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->maxChunkCount),pos,dst);
-	retval |= UA_String_encode(&(src->endpointUrl),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->protocolVersion),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->receiveBufferSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->sendBufferSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->maxMessageSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->maxChunkCount),pos,dst);
+	retval |= UA_String_encodeBinary(&(src->endpointUrl),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_OPCUATcpHelloMessage_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpHelloMessage* dst) {
+UA_Int32 UA_OPCUATcpHelloMessage_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpHelloMessage* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_decode(src,pos,&(dst->protocolVersion));
-	retval |= UA_UInt32_decode(src,pos,&(dst->receiveBufferSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->sendBufferSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->maxMessageSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->maxChunkCount));
-	retval |= UA_String_decode(src,pos,&(dst->endpointUrl));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->protocolVersion));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->receiveBufferSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->sendBufferSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->maxMessageSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->maxChunkCount));
+	retval |= UA_String_decodeBinary(src,pos,&(dst->endpointUrl));
 	return retval;
 }
 
@@ -129,23 +129,23 @@ UA_Int32 UA_OPCUATcpAcknowledgeMessage_calcSize(UA_OPCUATcpAcknowledgeMessage co
 	;
 }
 
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_encode(UA_OPCUATcpAcknowledgeMessage const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_OPCUATcpAcknowledgeMessage_encodeBinary(UA_OPCUATcpAcknowledgeMessage const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_encode(&(src->protocolVersion),pos,dst);
-	retval |= UA_UInt32_encode(&(src->receiveBufferSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->sendBufferSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->maxMessageSize),pos,dst);
-	retval |= UA_UInt32_encode(&(src->maxChunkCount),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->protocolVersion),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->receiveBufferSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->sendBufferSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->maxMessageSize),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->maxChunkCount),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpAcknowledgeMessage* dst) {
+UA_Int32 UA_OPCUATcpAcknowledgeMessage_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpAcknowledgeMessage* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_decode(src,pos,&(dst->protocolVersion));
-	retval |= UA_UInt32_decode(src,pos,&(dst->receiveBufferSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->sendBufferSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->maxMessageSize));
-	retval |= UA_UInt32_decode(src,pos,&(dst->maxChunkCount));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->protocolVersion));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->receiveBufferSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->sendBufferSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->maxMessageSize));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->maxChunkCount));
 	return retval;
 }
 
@@ -168,18 +168,18 @@ UA_Int32 UA_SecureConversationMessageHeader_calcSize(UA_SecureConversationMessag
 	;
 }
 
-UA_Int32 UA_SecureConversationMessageHeader_encode(UA_SecureConversationMessageHeader const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_SecureConversationMessageHeader_encodeBinary(UA_SecureConversationMessageHeader const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
 	// retval |= UA_OPCUATcpMessageHeader_encode(src->tcpMessageHeader,pos,dst);
-	retval |= UA_UInt32_encode(&(src->secureChannelId),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->secureChannelId),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_SecureConversationMessageHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageHeader* dst) {
+UA_Int32 UA_SecureConversationMessageHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageHeader* dst) {
 	UA_Int32 retval = UA_SUCCESS;
 	//retval |= UA_alloc((void**)&(dst->tcpMessageHeader),UA_OPCUATcpMessageHeader_calcSize(UA_NULL));
 	//retval |= UA_OPCUATcpMessageHeader_decode(src,pos,dst->tcpMessageHeader);
-	retval |= UA_UInt32_decode(src,pos,&(dst->secureChannelId));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->secureChannelId));
 	return retval;
 }
 
@@ -204,19 +204,19 @@ UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_calcSize(UA_AsymmetricAlgorithmSec
 	;
 }
 
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_encode(UA_AsymmetricAlgorithmSecurityHeader const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(UA_AsymmetricAlgorithmSecurityHeader const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_ByteString_encode(&(src->securityPolicyUri),pos,dst);
-	retval |= UA_ByteString_encode(&(src->senderCertificate),pos,dst);
-	retval |= UA_ByteString_encode(&(src->receiverCertificateThumbprint),pos,dst);
+	retval |= UA_ByteString_encodeBinary(&(src->securityPolicyUri),pos,dst);
+	retval |= UA_ByteString_encodeBinary(&(src->senderCertificate),pos,dst);
+	retval |= UA_ByteString_encodeBinary(&(src->receiverCertificateThumbprint),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_AsymmetricAlgorithmSecurityHeader* dst) {
+UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_AsymmetricAlgorithmSecurityHeader* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_ByteString_decode(src,pos,&(dst->securityPolicyUri));
-	retval |= UA_ByteString_decode(src,pos,&(dst->senderCertificate));
-	retval |= UA_ByteString_decode(src,pos,&(dst->receiverCertificateThumbprint));
+	retval |= UA_ByteString_decodeBinary(src,pos,&(dst->securityPolicyUri));
+	retval |= UA_ByteString_decodeBinary(src,pos,&(dst->senderCertificate));
+	retval |= UA_ByteString_decodeBinary(src,pos,&(dst->receiverCertificateThumbprint));
 	return retval;
 }
 
@@ -242,8 +242,8 @@ UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_init(UA_AsymmetricAlgorithmSecurit
 	return retval;
 }
 
-UA_TYPE_METHOD_DECODE_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
-UA_TYPE_METHOD_ENCODE_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
+UA_TYPE_METHOD_DECODEBINARY_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
+UA_TYPE_METHOD_ENCODEBINARY_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
 UA_TYPE_METHOD_DELETE_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
 UA_TYPE_METHOD_DELETEMEMBERS_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
 UA_TYPE_METHOD_CALCSIZE_AS(UA_SymmetricAlgorithmSecurityHeader, UA_UInt32)
@@ -256,17 +256,17 @@ UA_Int32 UA_SequenceHeader_calcSize(UA_SequenceHeader const * ptr) {
 	;
 }
 
-UA_Int32 UA_SequenceHeader_encode(UA_SequenceHeader const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_SequenceHeader_encodeBinary(UA_SequenceHeader const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_encode(&(src->sequenceNumber),pos,dst);
-	retval |= UA_UInt32_encode(&(src->requestId),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->sequenceNumber),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->requestId),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_SequenceHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_SequenceHeader* dst) {
+UA_Int32 UA_SequenceHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SequenceHeader* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_decode(src,pos,&(dst->sequenceNumber));
-	retval |= UA_UInt32_decode(src,pos,&(dst->requestId));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->sequenceNumber));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->requestId));
 	return retval;
 }
 
@@ -290,20 +290,20 @@ UA_Int32 UA_SecureConversationMessageFooter_calcSize(UA_SecureConversationMessag
 	;
 }
 
-UA_Int32 UA_SecureConversationMessageFooter_encode(UA_SecureConversationMessageFooter const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_SecureConversationMessageFooter_encodeBinary(UA_SecureConversationMessageFooter const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_Int32_encode(&(src->paddingSize),pos,dst); // encode size
-	retval |= UA_Array_encode((void const**) (src->padding),src->paddingSize, UA_BYTE,pos,dst);
-	retval |= UA_Byte_encode(&(src->signature),pos,dst);
+	retval |= UA_Int32_encodeBinary(&(src->paddingSize),pos,dst); // encode size
+	retval |= UA_Array_encodeBinary((void const**) (src->padding),src->paddingSize, UA_BYTE,pos,dst);
+	retval |= UA_Byte_encodeBinary(&(src->signature),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_SecureConversationMessageFooter_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageFooter* dst) {
+UA_Int32 UA_SecureConversationMessageFooter_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageFooter* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_Int32_decode(src,pos,&(dst->paddingSize)); // decode size
+	retval |= UA_Int32_decodeBinary(src,pos,&(dst->paddingSize)); // decode size
 	retval |= UA_Array_new((void**)&(dst->padding),dst->paddingSize, UA_BYTE);
-	retval |= UA_Array_decode(src,dst->paddingSize, UA_BYTE,pos,(void ** const) (dst->padding));
-	retval |= UA_Byte_decode(src,pos,&(dst->signature));
+	retval |= UA_Array_decodeBinary(src,dst->paddingSize, UA_BYTE,pos,(void ** const) (dst->padding));
+	retval |= UA_Byte_decodeBinary(src,pos,&(dst->signature));
 	return retval;
 }
 
@@ -327,17 +327,17 @@ UA_Int32 UA_SecureConversationMessageAbortBody_calcSize(UA_SecureConversationMes
 	;
 }
 
-UA_Int32 UA_SecureConversationMessageAbortBody_encode(UA_SecureConversationMessageAbortBody const * src, UA_Int32* pos, UA_Byte* dst) {
+UA_Int32 UA_SecureConversationMessageAbortBody_encodeBinary(UA_SecureConversationMessageAbortBody const * src, UA_Int32* pos, UA_ByteString* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_encode(&(src->error),pos,dst);
-	retval |= UA_String_encode(&(src->reason),pos,dst);
+	retval |= UA_UInt32_encodeBinary(&(src->error),pos,dst);
+	retval |= UA_String_encodeBinary(&(src->reason),pos,dst);
 	return retval;
 }
 
-UA_Int32 UA_SecureConversationMessageAbortBody_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageAbortBody* dst) {
+UA_Int32 UA_SecureConversationMessageAbortBody_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageAbortBody* dst) {
 	UA_Int32 retval = UA_SUCCESS;
-	retval |= UA_UInt32_decode(src,pos,&(dst->error));
-	retval |= UA_String_decode(src,pos,&(dst->reason));
+	retval |= UA_UInt32_decodeBinary(src,pos,&(dst->error));
+	retval |= UA_String_decodeBinary(src,pos,&(dst->reason));
 	return retval;
 }
 

+ 16 - 16
src/UA_stackInternalTypes.h

@@ -29,8 +29,8 @@ UA_TYPE_METHOD_PROTOTYPES(UA_SL_Response)
 /* MessageType */
 typedef UA_Int32 UA_MessageType;
 UA_Int32 UA_MessageType_calcSize(UA_MessageType const * ptr);
-UA_Int32 UA_MessageType_encode(UA_MessageType const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_MessageType_decode(UA_Byte const * src, UA_Int32* pos, UA_MessageType* dst);
+UA_Int32 UA_MessageType_encodeBinary(UA_MessageType const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_MessageType_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_MessageType* dst);
 UA_Int32 UA_MessageType_delete(UA_MessageType* p);
 UA_Int32 UA_MessageType_deleteMembers(UA_MessageType* p);
 void UA_MessageType_printf(char *label, UA_MessageType* p);
@@ -43,8 +43,8 @@ typedef struct T_UA_OPCUATcpMessageHeader {
 	UA_UInt32 messageSize;
 } UA_OPCUATcpMessageHeader;
 UA_Int32 UA_OPCUATcpMessageHeader_calcSize(UA_OPCUATcpMessageHeader const * ptr);
-UA_Int32 UA_OPCUATcpMessageHeader_encode(UA_OPCUATcpMessageHeader const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_OPCUATcpMessageHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpMessageHeader* dst);
+UA_Int32 UA_OPCUATcpMessageHeader_encodeBinary(UA_OPCUATcpMessageHeader const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_OPCUATcpMessageHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpMessageHeader* dst);
 UA_Int32 UA_OPCUATcpMessageHeader_delete(UA_OPCUATcpMessageHeader* p);
 UA_Int32 UA_OPCUATcpMessageHeader_deleteMembers(UA_OPCUATcpMessageHeader* p);
 
@@ -59,8 +59,8 @@ typedef struct T_UA_OPCUATcpHelloMessage {
 	UA_String endpointUrl;
 } UA_OPCUATcpHelloMessage;
 UA_Int32 UA_OPCUATcpHelloMessage_calcSize(UA_OPCUATcpHelloMessage const * ptr);
-UA_Int32 UA_OPCUATcpHelloMessage_encode(UA_OPCUATcpHelloMessage const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_OPCUATcpHelloMessage_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpHelloMessage* dst);
+UA_Int32 UA_OPCUATcpHelloMessage_encodeBinary(UA_OPCUATcpHelloMessage const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_OPCUATcpHelloMessage_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpHelloMessage* dst);
 UA_Int32 UA_OPCUATcpHelloMessage_delete(UA_OPCUATcpHelloMessage* p);
 UA_Int32 UA_OPCUATcpHelloMessage_deleteMembers(UA_OPCUATcpHelloMessage* p);
 
@@ -74,8 +74,8 @@ typedef struct T_UA_OPCUATcpAcknowledgeMessage {
 	UA_UInt32 maxChunkCount;
 } UA_OPCUATcpAcknowledgeMessage;
 UA_Int32 UA_OPCUATcpAcknowledgeMessage_calcSize(UA_OPCUATcpAcknowledgeMessage const * ptr);
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_encode(UA_OPCUATcpAcknowledgeMessage const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_decode(UA_Byte const * src, UA_Int32* pos, UA_OPCUATcpAcknowledgeMessage* dst);
+UA_Int32 UA_OPCUATcpAcknowledgeMessage_encodeBinary(UA_OPCUATcpAcknowledgeMessage const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_OPCUATcpAcknowledgeMessage_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_OPCUATcpAcknowledgeMessage* dst);
 UA_Int32 UA_OPCUATcpAcknowledgeMessage_delete(UA_OPCUATcpAcknowledgeMessage* p);
 UA_Int32 UA_OPCUATcpAcknowledgeMessage_deleteMembers(UA_OPCUATcpAcknowledgeMessage* p);
 
@@ -86,8 +86,8 @@ typedef struct T_UA_SecureConversationMessageHeader {
 	UA_UInt32 secureChannelId;
 } UA_SecureConversationMessageHeader;
 UA_Int32 UA_SecureConversationMessageHeader_calcSize(UA_SecureConversationMessageHeader const * ptr);
-UA_Int32 UA_SecureConversationMessageHeader_encode(UA_SecureConversationMessageHeader const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_SecureConversationMessageHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageHeader* dst);
+UA_Int32 UA_SecureConversationMessageHeader_encodeBinary(UA_SecureConversationMessageHeader const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_SecureConversationMessageHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageHeader* dst);
 UA_Int32 UA_SecureConversationMessageHeader_delete(UA_SecureConversationMessageHeader* p);
 UA_Int32 UA_SecureConversationMessageHeader_deleteMembers(UA_SecureConversationMessageHeader* p);
 
@@ -113,8 +113,8 @@ typedef struct T_UA_SequenceHeader {
 	UA_UInt32 requestId;
 } UA_SequenceHeader;
 UA_Int32 UA_SequenceHeader_calcSize(UA_SequenceHeader const * ptr);
-UA_Int32 UA_SequenceHeader_encode(UA_SequenceHeader const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_SequenceHeader_decode(UA_Byte const * src, UA_Int32* pos, UA_SequenceHeader* dst);
+UA_Int32 UA_SequenceHeader_encodeBinary(UA_SequenceHeader const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_SequenceHeader_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SequenceHeader* dst);
 UA_Int32 UA_SequenceHeader_delete(UA_SequenceHeader* p);
 UA_Int32 UA_SequenceHeader_deleteMembers(UA_SequenceHeader* p);
 
@@ -126,8 +126,8 @@ typedef struct T_UA_SecureConversationMessageFooter {
 	UA_Byte signature;
 } UA_SecureConversationMessageFooter;
 UA_Int32 UA_SecureConversationMessageFooter_calcSize(UA_SecureConversationMessageFooter const * ptr);
-UA_Int32 UA_SecureConversationMessageFooter_encode(UA_SecureConversationMessageFooter const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_SecureConversationMessageFooter_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageFooter* dst);
+UA_Int32 UA_SecureConversationMessageFooter_encodeBinary(UA_SecureConversationMessageFooter const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_SecureConversationMessageFooter_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageFooter* dst);
 UA_Int32 UA_SecureConversationMessageFooter_delete(UA_SecureConversationMessageFooter* p);
 UA_Int32 UA_SecureConversationMessageFooter_deleteMembers(UA_SecureConversationMessageFooter* p);
 
@@ -138,8 +138,8 @@ typedef struct T_UA_SecureConversationMessageAbortBody {
 	UA_String reason;
 } UA_SecureConversationMessageAbortBody;
 UA_Int32 UA_SecureConversationMessageAbortBody_calcSize(UA_SecureConversationMessageAbortBody const * ptr);
-UA_Int32 UA_SecureConversationMessageAbortBody_encode(UA_SecureConversationMessageAbortBody const * src, UA_Int32* pos, UA_Byte* dst);
-UA_Int32 UA_SecureConversationMessageAbortBody_decode(UA_Byte const * src, UA_Int32* pos, UA_SecureConversationMessageAbortBody* dst);
+UA_Int32 UA_SecureConversationMessageAbortBody_encodeBinary(UA_SecureConversationMessageAbortBody const * src, UA_Int32* pos, UA_ByteString* dst);
+UA_Int32 UA_SecureConversationMessageAbortBody_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_SecureConversationMessageAbortBody* dst);
 UA_Int32 UA_SecureConversationMessageAbortBody_delete(UA_SecureConversationMessageAbortBody* p);
 UA_Int32 UA_SecureConversationMessageAbortBody_deleteMembers(UA_SecureConversationMessageAbortBody* p);
 

Разлика између датотеке није приказан због своје велике величине
+ 379 - 381
src/opcua_basictypes.c


+ 19 - 19
src/opcua_secureLayer.c

@@ -55,24 +55,24 @@ UA_Int32 SL_send(UA_SL_Channel* channel, UA_ByteString const * responseMessage,
 	pos += 3;
 	responsePacket.data[3] = 'F';
 	pos += 1;
-	UA_Int32_encode(&packetSize, &pos, responsePacket.data);
-	UA_UInt32_encode(&(channel->securityToken.secureChannelId),
-			&pos, responsePacket.data);
+	UA_Int32_encodeBinary(&packetSize, &pos, &responsePacket);
+	UA_UInt32_encodeBinary(&(channel->securityToken.secureChannelId),
+			&pos, &responsePacket);
 
 	/*---encode Algorithm Security Header ---*/
 	if (isAsym) {
-		UA_AsymmetricAlgorithmSecurityHeader_encode(
+		UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(
 				&(channel->localAsymAlgSettings), &pos,
-				responsePacket.data);
+				&responsePacket);
 	} else {
-		UA_SymmetricAlgorithmSecurityHeader_encode(
+		UA_SymmetricAlgorithmSecurityHeader_encodeBinary(
 				&(channel->securityToken.tokenId), &pos,
-				responsePacket.data);
+				&responsePacket);
 	}
 
 	/*---encode Sequence Header ---*/
-	UA_UInt32_encode(&sequenceNumber, &pos, responsePacket.data);
-	UA_UInt32_encode(&requestId, &pos, responsePacket.data);
+	UA_UInt32_encodeBinary(&sequenceNumber, &pos, &responsePacket);
+	UA_UInt32_encodeBinary(&requestId, &pos, &responsePacket);
 
 	/*---add encoded Message ---*/
 	UA_memcpy(&(responsePacket.data[pos]), responseMessage->data,
@@ -312,7 +312,7 @@ UA_Int32 UA_SL_handleRequest(UA_SL_Channel *channel, UA_ByteString* msg) {
 
 	// Every Message starts with a NodeID which names the serviceRequestType
 	UA_NodeId serviceRequestType;
-	UA_NodeId_decode(msg->data, &pos, &serviceRequestType);
+	UA_NodeId_decodeBinary(msg, &pos, &serviceRequestType);
 	UA_NodeId_printf("SL_processMessage - serviceRequestType=", &serviceRequestType);
 
 	UA_SL_handleRequestTableEntry* hrte = getHRTEntry(serviceRequestType.identifier.numeric);
@@ -324,7 +324,7 @@ UA_Int32 UA_SL_handleRequest(UA_SL_Channel *channel, UA_ByteString* msg) {
 		void * requestObj = UA_NULL;
 		void * responseObj = UA_NULL;
 		UA_[hrte->requestDataTypeId].new(&requestObj);
-		UA_[hrte->requestDataTypeId].decode(msg->data, &pos, requestObj);
+		UA_[hrte->requestDataTypeId].decodeBinary(msg, &pos, requestObj);
 		if (hrte->responseDataTypeId > 0) {
 			UA_[hrte->responseDataTypeId].new(&responseObj);
 			UA_ResponseHeader_initFromRequest((UA_RequestHeader*)requestObj, (UA_ResponseHeader*)responseObj);
@@ -340,8 +340,8 @@ UA_Int32 UA_SL_handleRequest(UA_SL_Channel *channel, UA_ByteString* msg) {
 				UA_ByteString_newMembers(&response, UA_NodeId_calcSize(&responseType) + UA_[hrte->responseDataTypeId].calcSize(responseObj));
 				UA_Int32 pos = 0;
 
-				UA_NodeId_encode(&responseType, &pos, response.data);
-				UA_[hrte->responseDataTypeId].encode(responseObj, &pos, response.data);
+				UA_NodeId_encodeBinary(&responseType, &pos, &response);
+				UA_[hrte->responseDataTypeId].encodeBinary(responseObj, &pos, &response);
 				SL_send(channel, &response, responseType.identifier.numeric);
 
 				UA_NodeId_deleteMembers(&responseType);
@@ -401,11 +401,11 @@ UA_Int32 UA_SL_Channel_new(UA_TL_connection *connection, UA_ByteString* msg, UA_
 	connection->secureChannel = &slc;
 	connection->secureChannel->tlConnection = connection;
 
-	UA_SecureConversationMessageHeader_decode(msg->data, pos, &secureConvHeader);
+	UA_SecureConversationMessageHeader_decodeBinary(msg, pos, &secureConvHeader);
 	// connection->secureChannel->secureChannelId = secureConvHeader.secureChannelId;
-	UA_AsymmetricAlgorithmSecurityHeader_decode(msg->data, pos, &(connection->secureChannel->remoteAsymAlgSettings));
+	UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos, &(connection->secureChannel->remoteAsymAlgSettings));
 	//TODO check that the sequence number is smaller than MaxUInt32 - 1024
-	UA_SequenceHeader_decode(msg->data, pos, &(connection->secureChannel->sequenceHeader));
+	UA_SequenceHeader_decodeBinary(msg, pos, &(connection->secureChannel->sequenceHeader));
 
 	connection->secureChannel->securityToken.tokenId = 4711;
 
@@ -451,19 +451,19 @@ UA_Int32 UA_SL_process(UA_SL_Channel* connection, UA_ByteString* msg, UA_Int32*
 	UA_UInt32 secureChannelId;
 
 	if (connection->connectionState == connectionState_ESTABLISHED) {
-		UA_UInt32_decode(msg->data,pos,&secureChannelId);
+		UA_UInt32_decodeBinary(msg,pos,&secureChannelId);
 
 		//FIXME: we assume SAS, need to check if AAS or SAS
 		UA_SymmetricAlgorithmSecurityHeader symAlgSecHeader;
 //		if (connection->securityMode == UA_MESSAGESECURITYMODE_NONE) {
-			UA_SymmetricAlgorithmSecurityHeader_decode(msg->data, pos, &symAlgSecHeader);
+			UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos, &symAlgSecHeader);
 //		} else {
 //			// FIXME:
 //		}
 
 		printf("UA_SL_process - securityToken received=%d, expected=%d\n",secureChannelId,connection->securityToken.secureChannelId);
 		if (secureChannelId == connection->securityToken.secureChannelId) {
-			UA_SequenceHeader_decode(msg->data, pos, &(connection->sequenceHeader));
+			UA_SequenceHeader_decodeBinary(msg, pos, &(connection->sequenceHeader));
 			// process message
 			UA_ByteString slMessage;
 			slMessage.data = &(msg->data[*pos]);

+ 5 - 5
src/opcua_transportLayer.c

@@ -26,7 +26,7 @@ UA_Int32 TL_check(UA_TL_connection* connection, UA_ByteString* msg, int checkLoc
 
 	DBG_VERBOSE(printf("TL_check - entered \n"));
 
-	UA_Int32_decode(msg->data,&position,&messageLength);
+	UA_Int32_decodeBinary(msg,&position,&messageLength);
 	DBG_VERBOSE(printf("TL_check - messageLength = %d \n",messageLength));
 
 	if (messageLength == -1 || messageLength != msg->length ||
@@ -52,7 +52,7 @@ UA_Int32 UA_TL_handleHello(UA_TL_connection* connection, UA_ByteString* msg, UA_
 
 	if (connection->connectionState == connectionState_CLOSED) {
 		DBG_VERBOSE(printf("TL_process - extracting header information \n"));
-		UA_OPCUATcpHelloMessage_decode(msg->data,pos,&helloMessage);
+		UA_OPCUATcpHelloMessage_decodeBinary(msg,pos,&helloMessage);
 
 		// memorize buffer info and change mode to established
 		connection->remoteConf.protocolVersion = helloMessage.protocolVersion;
@@ -85,8 +85,8 @@ UA_Int32 UA_TL_handleHello(UA_TL_connection* connection, UA_ByteString* msg, UA_
 		ackHeader.messageSize = UA_OPCUATcpAcknowledgeMessage_calcSize(&ackMessage)
 		+ UA_OPCUATcpMessageHeader_calcSize(&ackHeader);
 		UA_ByteString_newMembers(&tmpMessage, ackHeader.messageSize);
-		UA_OPCUATcpMessageHeader_encode(&ackHeader,&tmpPos,tmpMessage.data);
-		UA_OPCUATcpAcknowledgeMessage_encode(&ackMessage,&tmpPos,tmpMessage.data);
+		UA_OPCUATcpMessageHeader_encodeBinary(&ackHeader,&tmpPos,&tmpMessage);
+		UA_OPCUATcpAcknowledgeMessage_encodeBinary(&ackMessage,&tmpPos,&tmpMessage);
 
 		DBG_VERBOSE(printf("TL_process - Size messageToSend = %d, pos=%d\n",ackHeader.messageSize, tmpPos));
 		TL_send(connection, &tmpMessage);
@@ -135,7 +135,7 @@ UA_Int32 TL_process(UA_TL_connection* connection, UA_ByteString* msg)
 
 	DBG_VERBOSE(printf("TL_process - entered \n"));
 
-	if ((retval = UA_OPCUATcpMessageHeader_decode(msg->data, &pos, &tcpMessageHeader)) == UA_SUCCESS) {
+	if ((retval = UA_OPCUATcpMessageHeader_decodeBinary(msg, &pos, &tcpMessageHeader)) == UA_SUCCESS) {
 		printf("TL_process - messageType=%.*s\n",3,msg->data);
 		switch(tcpMessageHeader.messageType) {
 		case UA_MESSAGETYPE_HEL:

+ 110 - 60
tests/check_builtin.c

@@ -508,10 +508,11 @@ START_TEST(UA_Byte_decodeShallCopyAndAdvancePosition)
 {
 	// given
 	UA_Byte dst;
-	UA_Byte src[] = { 0x08 };
+	UA_Byte data[]= { 0x08 };
+	UA_ByteString src = {1, data};
 	UA_Int32 pos = 0;
 	// when
-	UA_Int32 retval = UA_Byte_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_Byte_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_uint_eq(pos, 1);
@@ -522,10 +523,11 @@ START_TEST(UA_Byte_decodeShallModifyOnlyCurrentPosition)
 {
 	// given
 	UA_Byte dst[] = { 0xFF, 0xFF, 0xFF };
-	UA_Byte src[] = { 0x08 };
+	UA_Byte data[] = { 0x08 };
+	UA_ByteString src = {1, data};
 	UA_Int32 pos = 0;
 	// when
-	UA_Int32 retval = UA_Byte_decode(src, &pos, &dst[1]);
+	UA_Int32 retval = UA_Byte_decodeBinary(&src, &pos, &dst[1]);
 	// then
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(pos, 1);
@@ -538,14 +540,15 @@ START_TEST(UA_Int16_decodeShallAssumeLittleEndian)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0x01,0x00,	// 1
-			0x00,0x01,	// 256
+			0x00,0x01	// 256
 	};
+	UA_ByteString src = { 4, data };
 	// when
 	UA_Int16 val_01_00, val_00_01;
-	UA_Int32 retval = UA_Int16_decode(src,&pos,&val_01_00);
-	retval |= UA_Int16_decode(src,&pos,&val_00_01);
+	UA_Int32 retval = UA_Int16_decodeBinary(&src,&pos,&val_01_00);
+	retval |= UA_Int16_decodeBinary(&src,&pos,&val_00_01);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(val_01_00,1);
@@ -557,14 +560,15 @@ START_TEST(UA_Int16_decodeShallRespectSign)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0xFF,0xFF,	// -1
-			0x00,0x80,	// -32768
+			0x00,0x80	// -32768
 	};
+	UA_ByteString src = {4,data};
 	// when
 	UA_Int16 val_ff_ff, val_00_80;
-	UA_Int32 retval = UA_Int16_decode(src,&pos,&val_ff_ff);
-	retval |= UA_Int16_decode(src,&pos,&val_00_80);
+	UA_Int32 retval = UA_Int16_decodeBinary(&src,&pos,&val_ff_ff);
+	retval |= UA_Int16_decodeBinary(&src,&pos,&val_00_80);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(val_ff_ff,-1);
@@ -575,14 +579,15 @@ START_TEST(UA_UInt16_decodeShallNotRespectSign)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0xFF,0xFF,	// (2^16)-1
-			0x00,0x80,	// (2^15)
+			0x00,0x80	// (2^15)
 	};
+	UA_ByteString src = {4,data};
 	// when
 	UA_UInt16 val_ff_ff, val_00_80;
-	UA_Int32 retval = UA_UInt16_decode(src,&pos,&val_ff_ff);
-	retval |= UA_UInt16_decode(src,&pos,&val_00_80);
+	UA_Int32 retval = UA_UInt16_decodeBinary(&src,&pos,&val_ff_ff);
+	retval |= UA_UInt16_decodeBinary(&src,&pos,&val_00_80);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,4);
@@ -594,14 +599,16 @@ START_TEST(UA_Int32_decodeShallAssumeLittleEndian)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0x01,0x00,0x00,0x00,	// 1
 			0x00,0x01,0x00,0x00		// 256
 	};
+	UA_ByteString src = {8,data};
+
 	// when
 	UA_Int32 val_01_00, val_00_01;
-	UA_Int32 retval = UA_Int32_decode(src,&pos,&val_01_00);
-	retval |= UA_Int32_decode(src,&pos,&val_00_01);
+	UA_Int32 retval = UA_Int32_decodeBinary(&src,&pos,&val_01_00);
+	retval |= UA_Int32_decodeBinary(&src,&pos,&val_00_01);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(val_01_00,1);
@@ -613,14 +620,16 @@ START_TEST(UA_Int32_decodeShallRespectSign)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0xFF,0xFF,0xFF,0xFF,	// -1
 			0x00,0x80,0xFF,0xFF		// -32768
 	};
+	UA_ByteString src = {8,data};
+
 	// when
 	UA_Int32 val_ff_ff, val_00_80;
-	UA_Int32 retval = UA_Int32_decode(src,&pos,&val_ff_ff);
-	retval |= UA_Int32_decode(src,&pos,&val_00_80);
+	UA_Int32 retval = UA_Int32_decodeBinary(&src,&pos,&val_ff_ff);
+	retval |= UA_Int32_decodeBinary(&src,&pos,&val_00_80);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(val_ff_ff,-1);
@@ -631,14 +640,16 @@ START_TEST(UA_UInt32_decodeShallNotRespectSign)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {
+	UA_Byte data[] = {
 			0xFF,0xFF,0xFF,0xFF,	// (2^32)-1
 			0x00,0x00,0x00,0x80		// (2^31)
 	};
+	UA_ByteString src = {8,data};
+
 	// when
 	UA_UInt32 val_ff_ff, val_00_80;
-	UA_Int32 retval = UA_UInt32_decode(src,&pos,&val_ff_ff);
-	retval |= UA_UInt32_decode(src,&pos,&val_00_80);
+	UA_Int32 retval = UA_UInt32_decodeBinary(&src,&pos,&val_ff_ff);
+	retval |= UA_UInt32_decodeBinary(&src,&pos,&val_00_80);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,8);
@@ -650,10 +661,11 @@ START_TEST(UA_Float_decodeShallWorkOnExample)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { 0x00,0x00,0xD0,0xC0 }; // -6.5
+	UA_Byte data[] = { 0x00,0x00,0xD0,0xC0 }; // -6.5
+	UA_ByteString src = {4,data};
 	UA_Float dst;
 	// when
-	UA_Int32 retval = UA_Float_decode(src,&pos,&dst);
+	UA_Int32 retval = UA_Float_decodeBinary(&src,&pos,&dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,4);
@@ -666,10 +678,11 @@ START_TEST(UA_Double_decodeShallGiveOne)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x3F }; // 1
+	UA_Byte data[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x3F }; // 1
+	UA_ByteString src = {8,data}; // 1
 	UA_Double dst;
 	// when
-	UA_Int32 retval = UA_Double_decode(src,&pos,&dst);
+	UA_Int32 retval = UA_Double_decodeBinary(&src,&pos,&dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,8);
@@ -682,10 +695,11 @@ START_TEST(UA_Double_decodeShallGiveZero)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; // 1
+	UA_Byte data[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+	UA_ByteString src = {8,data}; // 1
 	UA_Double dst;
 	// when
-	UA_Int32 retval = UA_Double_decode(src,&pos,&dst);
+	UA_Int32 retval = UA_Double_decodeBinary(&src,&pos,&dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,8);
@@ -698,10 +712,12 @@ START_TEST(UA_Double_decodeShallGiveMinusTwo)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0 }; // -2
+	UA_Byte data[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0 }; // -2
+	UA_ByteString src = {8,data};
+
 	UA_Double dst;
 	// when
-	UA_Int32 retval = UA_Double_decode(src,&pos,&dst);
+	UA_Int32 retval = UA_Double_decodeBinary(&src,&pos,&dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,8);
@@ -714,10 +730,11 @@ START_TEST(UA_String_decodeShallAllocateMemoryAndCopyString)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_Byte data[] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_ByteString src = {16,data};
 	UA_String dst;
 	// when
-	UA_Int32 retval = UA_String_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_String_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(dst.length,8);
@@ -731,10 +748,12 @@ START_TEST(UA_String_decodeWithNegativeSizeShallNotAllocateMemoryAndNullPtr)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {0xFF,0xFF,0xFF,0xFF,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_Byte data[] = {0xFF,0xFF,0xFF,0xFF,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_ByteString src = {16,data};
+
 	UA_String dst;
 	// when
-	UA_Int32 retval = UA_String_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_String_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(dst.length,-1);
@@ -745,10 +764,12 @@ START_TEST(UA_String_decodeWithZeroSizeShallNotAllocateMemoryAndNullPtr)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = {0x00,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_Byte data[] = {0x00,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A',0xFF,0xFF,0xFF,0xFF,0xFF};
+	UA_ByteString src = {16,data};
+
 	UA_String dst = { 2, (UA_Byte*) "XX" };
 	// when
-	UA_Int32 retval = UA_String_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_String_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(dst.length,0);
@@ -759,10 +780,12 @@ START_TEST(UA_NodeId_decodeTwoByteShallReadTwoBytesAndSetNamespaceToZero)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_NODEIDTYPE_TWOBYTE, 0x10 };
+	UA_Byte data[] = { UA_NODEIDTYPE_TWOBYTE, 0x10 };
+	UA_ByteString src = {2,data};
+
 	UA_NodeId dst;
 	// when
-	UA_Int32 retval = UA_NodeId_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_NodeId_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,2);
@@ -775,10 +798,12 @@ START_TEST(UA_NodeId_decodeFourByteShallReadFourBytesAndRespectNamespace)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_NODEIDTYPE_FOURBYTE, 0x01, 0x00, 0x01 };
+	UA_Byte data[] = { UA_NODEIDTYPE_FOURBYTE, 0x01, 0x00, 0x01 };
+	UA_ByteString src = {4,data};
+
 	UA_NodeId dst;
 	// when
-	UA_Int32 retval = UA_NodeId_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_NodeId_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,4);
@@ -791,10 +816,12 @@ START_TEST(UA_NodeId_decodeStringShallAllocateMemory)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_NODEIDTYPE_STRING, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 'P', 'L', 'T' };
+	UA_Byte data[]= { UA_NODEIDTYPE_STRING, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 'P', 'L', 'T' };
+	UA_ByteString src = {10,data};
+
 	UA_NodeId dst;
 	// when
-	UA_Int32 retval = UA_NodeId_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_NodeId_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,10);
@@ -811,10 +838,11 @@ START_TEST(UA_Variant_decodeWithOutArrayFlagSetShallSetVTAndAllocateMemoryForArr
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_INT32_NS0, 0xFF, 0x00, 0x00, 0x00};
+	UA_Byte data[] = { UA_INT32_NS0, 0xFF, 0x00, 0x00, 0x00};
+	UA_ByteString src = {5,data};
 	UA_Variant dst;
 	// when
-	UA_Int32 retval = UA_Variant_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_Variant_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,5);
@@ -832,10 +860,12 @@ START_TEST(UA_Variant_decodeWithArrayFlagSetShallSetVTAndAllocateMemoryForArray)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_Byte data[]={ UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_ByteString src = {13,data};
+
 	UA_Variant dst;
 	// when
-	UA_Int32 retval = UA_Variant_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_Variant_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(pos,1+4+2*4);
@@ -855,40 +885,60 @@ START_TEST(UA_Variant_decodeWithOutDeleteMembersShallFailInCheckMem)
 {
 	// given
 	UA_Int32 pos = 0;
-	UA_Byte src[] = { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_Byte data[]= { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_ByteString src = {13,data};
+
 	UA_Variant dst;
 	// when
-	UA_Int32 retval = UA_Variant_decode(src, &pos, &dst);
+	UA_Int32 retval = UA_Variant_decodeBinary(&src, &pos, &dst);
 	// then
 	ck_assert_int_eq(retval,UA_SUCCESS);
 	// finally - unfortunately we cannot express that not freeing three chunks is what we expect
 	// UA_Variant_deleteMembers(&dst);
 }
 END_TEST
+START_TEST(UA_Variant_decodeWithTooSmallSourceShallReturnWithError)
+{
+	// given
+	UA_Int32 pos = 0;
+	UA_Byte data[]= { UA_INT32_NS0 | UA_VARIANT_ENCODINGMASKTYPE_ARRAY, 0x02, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF};
+	UA_ByteString src = {4,data};
+
+	UA_Variant dst;
+	// when
+	UA_Int32 retval = UA_Variant_decodeBinary(&src, &pos, &dst);
+	// then
+	ck_assert_int_ne(retval,UA_SUCCESS);
+	// finally - unfortunately we cannot express that not freeing three chunks is what we expect
+	// UA_Variant_deleteMembers(&dst);
+}
+END_TEST
 
 START_TEST(UA_Byte_encode_test)
 {
 	UA_Byte src;
-	UA_Byte dst[2] = { 0x00, 0xFF };
+	UA_Byte data[] = { 0x00, 0xFF };
+	UA_ByteString dst = {2,data};
+
 	UA_Int32 retval, pos = 0;
 
-	ck_assert_uint_eq(dst[1], 0xFF);
+	ck_assert_uint_eq(dst.data[1], 0xFF);
 
 	src = 8;
-	retval = UA_Byte_encode(&src, &pos, dst);
+	retval = UA_Byte_encodeBinary(&src, &pos, &dst);
 
-	ck_assert_uint_eq(dst[0], 0x08);
-	ck_assert_uint_eq(dst[1], 0xFF);
+	ck_assert_uint_eq(dst.data[0], 0x08);
+	ck_assert_uint_eq(dst.data[1], 0xFF);
 	ck_assert_int_eq(pos, 1);
 	ck_assert_int_eq(retval, UA_SUCCESS);
 
 	src = 0xFF;
-	dst[1] = 0x00;
+	dst.data[1] = 0x00;
 	pos = 0;
-	retval = UA_Byte_encode(&src, &pos, dst);
+	retval = UA_Byte_encodeBinary(&src, &pos, &dst);
 
-	ck_assert_int_eq(dst[0], 0xFF);
-	ck_assert_int_eq(dst[1], 0x00);
+	ck_assert_int_eq(dst.data[0], 0xFF);
+	ck_assert_int_eq(dst.data[1], 0x00);
 	ck_assert_int_eq(pos, 1);
 	ck_assert_int_eq(retval, UA_SUCCESS);
 

+ 18 - 15
tests/check_decode.c

@@ -29,7 +29,7 @@ START_TEST(decodeByte_test)
 
 		position = 0;
 
-		UA_Byte_decode(rawMessage.data, &position, &val);
+		UA_Byte_decodeBinary(&rawMessage, &position, &val);
 
 		ck_assert_int_eq(val, 0x08);
 		ck_assert_int_eq(position, 1);
@@ -52,13 +52,13 @@ START_TEST(decodeInt16_test_positives)
 	rawMessage.length = sizeof(mem);
 	ck_assert_int_eq(rawMessage.length,8);
 
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,0);
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,1);
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,255);
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,256);
 }
 END_TEST
@@ -76,9 +76,9 @@ START_TEST(decodeInt16_test_negatives)
 	rawMessage.length = sizeof(mem);
 	ck_assert_int_eq(rawMessage.length,4);
 
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,-1);
-	UA_Int16_decode(rawMessage.data,&p,&val);
+	UA_Int16_decodeBinary(&rawMessage,&p,&val);
 	ck_assert_int_eq(val,-32768);
 }
 END_TEST
@@ -97,7 +97,7 @@ START_TEST(decodeUInt16_test)
 
 	UA_Int32 p = 0;
 	UA_UInt16 val;
-	UA_UInt16_decode(rawMessage.data,&p,&val);
+	UA_UInt16_decodeBinary(&rawMessage,&p,&val);
 
 	ck_assert_int_eq(val,1);
 	//ck_assert_int_eq(p, 2);
@@ -116,7 +116,7 @@ START_TEST(decodeUInt32_test)
 
 	UA_Int32 p = 0;
 	UA_UInt32 val;
-	UA_UInt32_decode(rawMessage.data, &p, &val);
+	UA_UInt32_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_uint_eq(val,255);
 
 }
@@ -134,7 +134,7 @@ START_TEST(decodeInt32_test)
 
 	UA_Int32 p = 0;
 	UA_Int32 val;
-	UA_Int32_decode(rawMessage.data, &p, &val);
+	UA_Int32_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_int_eq(val,1000000000);
 }
 END_TEST
@@ -151,7 +151,7 @@ START_TEST(decodeUInt64_test)
 
 	UA_Int32 p = 0;
 	UA_UInt64 val;
-	UA_UInt64_decode(rawMessage.data, &p, &val);
+	UA_UInt64_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_uint_eq(val, expectedVal);
 }
 END_TEST
@@ -167,7 +167,7 @@ START_TEST(decodeInt64_test)
 
 	UA_Int32 p = 0;
 	UA_Int64 val;
-	UA_Int64_decode(rawMessage.data, &p, &val);
+	UA_Int64_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_uint_eq(val, expectedVal);
 }
 END_TEST
@@ -175,11 +175,11 @@ START_TEST(decodeFloat_test)
 {
 	UA_Int32 pos = 0;
 	UA_Byte buf[4] = {0x00,0x00,0xD0,0xC0};
-
+	UA_ByteString src = {4,buf};
 
 	UA_Float fval;
 
-	UA_Float_decode(buf, &pos, &fval);
+	UA_Float_decodeBinary(&src, &pos, &fval);
 	//val should be -6.5
 	UA_Int32 val = (fval > -6.501 && fval < -6.499);
 	ck_assert_int_gt(val,0);
@@ -194,11 +194,14 @@ START_TEST(decodeUAString_test)
 {
 
 	UA_Int32 pos = 0;
+	UA_Int32 retval = UA_SUCCESS;
 	UA_String string;
 	UA_Byte binString[12] = {0x08,0x00,0x00,0x00,'A','C','P','L','T',' ','U','A'};
+	UA_ByteString src = { 12, binString };
 
-	UA_String_decode(binString, &pos, &string);
+	retval = UA_String_decodeBinary(&src, &pos, &string);
 
+	ck_assert_int_eq(retval,UA_SUCCESS);
 	ck_assert_int_eq(string.length,8);
 	ck_assert_ptr_eq(string.data,UA_alloc_lastptr);
 	ck_assert_int_eq(string.data[3],'L');

+ 26 - 21
tests/check_encode.c

@@ -27,7 +27,7 @@ START_TEST(encodeByte_test)
 		rawMessage.length = 1;
 		position = 0;
 
-		UA_Byte_encode(&(testByte), &position, rawMessage.data);
+		UA_Byte_encodeBinary(&(testByte), &position, &rawMessage);
 
 		ck_assert_int_eq(rawMessage.data[0], 0x08);
 		ck_assert_int_eq(rawMessage.length, 1);
@@ -48,12 +48,12 @@ START_TEST(encodeInt16_test)
 	rawMessage.length = 2;
 	position = 0;
 
-	UA_UInt16_encode(&testUInt16, &position, rawMessage.data);
+	UA_UInt16_encodeBinary(&testUInt16, &position, &rawMessage);
 
 	ck_assert_int_eq(position, 2);
 	UA_Int32 p = 0;
 	UA_UInt16 val;
-	UA_UInt16_decode(rawMessage.data, &p, &val);
+	UA_UInt16_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_int_eq(val,testUInt16);
 	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
 
@@ -72,12 +72,12 @@ START_TEST(encodeUInt16_test)
 	rawMessage.length = 2;
 	position = 0;
 
-	UA_UInt16_encode(&testUInt16, &position, rawMessage.data);
+	UA_UInt16_encodeBinary(&testUInt16, &position, &rawMessage);
 	ck_assert_int_eq(position, 2);
 
 	UA_Int32 p = 0;
 	UA_UInt16 val;
-	UA_UInt16_decode(rawMessage.data, &p, &val);
+	UA_UInt16_decodeBinary(&rawMessage, &p, &val);
 	ck_assert_int_eq(val,testUInt16);
 	//ck_assert_int_eq(rawMessage.data[0], 0xAB);
 
@@ -95,7 +95,7 @@ START_TEST(encodeUInt32_test)
 	rawMessage.length = 8;
 
 	UA_Int32 p = 4;
-	UA_UInt32_encode(&value,&p,rawMessage.data);
+	UA_UInt32_encodeBinary(&value,&p,&rawMessage);
 	ck_assert_uint_eq(rawMessage.data[4],0x00);
 	ck_assert_uint_eq(rawMessage.data[5],0xFF);
 	ck_assert_uint_eq(rawMessage.data[6],0x01);
@@ -111,9 +111,10 @@ START_TEST(encodeInt32ShallEncodeLittleEndian)
 	// given
 	UA_Int32 value = 0x01020304;
 	UA_Byte  buf[4];
+	UA_ByteString dst = {4,buf};
 	UA_Int32 p = 0;
 	// when
-	UA_Int32_encode(&value,&p,buf);
+	UA_Int32_encodeBinary(&value,&p,&dst);
 	// then
 	ck_assert_int_eq(p,4);
 	ck_assert_uint_eq(buf[0],0x04);
@@ -127,9 +128,10 @@ START_TEST(encodeInt32NegativeShallEncodeLittleEndian)
 	// given
 	UA_Int32 value = -1;
 	UA_Byte  buf[4];
+	UA_ByteString dst = {4,buf};
 	UA_Int32 p = 0;
 	// when
-	UA_Int32_encode(&value,&p,buf);
+	UA_Int32_encodeBinary(&value,&p,&dst);
 	// then
 	ck_assert_int_eq(p,4);
 	ck_assert_uint_eq(buf[0],0xFF);
@@ -149,7 +151,7 @@ START_TEST(encodeUInt64_test)
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
-	UA_UInt64_encode(&value, &p,rawMessage.data);
+	UA_UInt64_encodeBinary(&value, &p,&rawMessage);
 
 	ck_assert_uint_eq((UA_Byte)rawMessage.data[0],0x00);
 	ck_assert_uint_eq((UA_Byte)rawMessage.data[1],0xFF);
@@ -174,7 +176,7 @@ START_TEST(encodeInt64_test)
 	rawMessage.length = 8;
 
 	UA_Int32 p = 0;
-	UA_UInt64_encode(&value, &p,rawMessage.data);
+	UA_UInt64_encodeBinary(&value, &p,&rawMessage);
 
 	ck_assert_uint_eq(rawMessage.data[0],0x00);
 	ck_assert_uint_eq(rawMessage.data[1],0xFF);
@@ -193,8 +195,9 @@ START_TEST(encodeFloat_test)
 	UA_Float value = -6.5;
 	UA_Int32 pos = 0;
 	UA_Byte* buf = (UA_Byte*)malloc(sizeof(UA_Float));
+	UA_ByteString dst = { sizeof(UA_Float), buf };
 
-	UA_Float_encode(&value,&pos,buf);
+	UA_Float_encodeBinary(&value,&pos,&dst);
 
 	ck_assert_uint_eq(buf[2],0xD0);
 	ck_assert_uint_eq(buf[3],0xC0);
@@ -219,18 +222,19 @@ START_TEST(encodeUAString_test)
 
 	UA_Int32 pos = 0;
 	UA_String string;
-	UA_Int32 l = 11;
-	UA_Byte mem[11] = "ACPLT OPCUA";
-	UA_Byte *dstBuf = (UA_Byte*) malloc(sizeof(UA_Int32)+l);
+	UA_Byte mem[] = "ACPLT OPCUA";
 	string.data =  mem;
-	string.length = 11;
+	string.length = sizeof(mem)-1; // w/o trailing \0
 
-	UA_String_encode(&string, &pos, dstBuf);
+	UA_Byte *buf = (UA_Byte*) malloc(sizeof(UA_Int32)+string.length);
+	UA_ByteString dst = {string.length+4, buf};
 
-	ck_assert_int_eq(dstBuf[0],11);
-	ck_assert_int_eq(dstBuf[0+sizeof(UA_Int32)],'A');
+	UA_String_encodeBinary(&string, &pos, &dst);
 
-	free(dstBuf);
+	ck_assert_int_eq(buf[0],11);
+	ck_assert_int_eq(buf[4],'A');
+
+	free(buf);
 }
 END_TEST
 START_TEST(encodeDataValue_test)
@@ -238,13 +242,14 @@ START_TEST(encodeDataValue_test)
 	UA_DataValue dataValue;
 	UA_Int32 pos = 0, retval;
 	UA_Byte* buf = (UA_Byte*) malloc(15);
+	UA_ByteString dst = {15,buf};
 	UA_DateTime dateTime;
 	dateTime = 80;
 	dataValue.serverTimestamp = dateTime;
 
 	//--without Variant
 	dataValue.encodingMask = UA_DATAVALUE_SERVERTIMPSTAMP; //Only the sourcePicoseconds
-	UA_DataValue_encode(&dataValue, &pos, buf);
+	UA_DataValue_encodeBinary(&dataValue, &pos, &dst);
 
 	ck_assert_int_eq(pos, 9);// represents the length
 	ck_assert_uint_eq(buf[0], 0x08); // encodingMask
@@ -267,7 +272,7 @@ START_TEST(encodeDataValue_test)
 	dataValue.value.data = (void**) &pdata;
 
 	pos = 0;
-	retval = UA_DataValue_encode(&dataValue, &pos, buf);
+	retval = UA_DataValue_encodeBinary(&dataValue, &pos, &dst);
 
 	ck_assert_int_eq(retval, UA_SUCCESS);
 	ck_assert_int_eq(pos, 1+(1+4)+8);// represents the length

+ 2 - 1
tests/check_stack.c

@@ -66,6 +66,7 @@ START_TEST(encode_builtInDatatypeArray_test_String)
 	UA_ByteString* array[] = { &s1, &s2	};
 	UA_Int32 pos = 0;
 	UA_Byte buf[256];
+	UA_ByteString dst = { sizeof(buf), buf };
 	UA_Byte result[] = {
 			0x02, 0x00, 0x00, 0x00,		// noElements
 			0x06, 0x00, 0x00, 0x00,		// s1.Length
@@ -73,7 +74,7 @@ START_TEST(encode_builtInDatatypeArray_test_String)
 			0xFF, 0xFF, 0xFF, 0xFF		// s2.Length
 	};
 
-	UA_Array_encode((void const**)array, noElements, UA_BYTESTRING, &pos, buf);
+	UA_Array_encodeBinary((void const**)array, noElements, UA_BYTESTRING, &pos, &dst);
 
 	// check size
 	ck_assert_int_eq(pos, 4 + 4 + 6 + 4);

+ 36 - 29
tool/generate_builtin.py

@@ -1,6 +1,8 @@
 from __future__ import print_function
 import sys
 import time
+import platform
+import getpass
 from collections import OrderedDict
 import re
 from lxml import etree
@@ -88,8 +90,8 @@ def createEnumerated(element):
     print("enum " + name + "_enum { \n\t" + ",\n\t".join(map(lambda (key, value) : key.upper() + " = " + value, valuemap.iteritems())) + "\n};", end='\n', file=fh)
     print("UA_TYPE_METHOD_PROTOTYPES (" + name + ")", end='\n', file=fh)
     print("UA_TYPE_METHOD_CALCSIZE_AS("+name+", UA_UInt32)", end='\n', file=fc)
-    print("UA_TYPE_METHOD_ENCODE_AS("+name+", UA_UInt32)", end='\n', file=fc)
-    print("UA_TYPE_METHOD_DECODE_AS("+name+", UA_UInt32)", end='\n', file=fc)
+    print("UA_TYPE_METHOD_ENCODEBINARY_AS("+name+", UA_UInt32)", end='\n', file=fc)
+    print("UA_TYPE_METHOD_DECODEBINARY_AS("+name+", UA_UInt32)", end='\n', file=fc)
     print("UA_TYPE_METHOD_DELETE_AS("+name+", UA_UInt32)", end='\n', file=fc)
     print("UA_TYPE_METHOD_DELETEMEMBERS_AS("+name+", UA_UInt32)", end='\n', file=fc)
     print("UA_TYPE_METHOD_INIT_AS("+name+", UA_UInt32)", end='\n', file=fc)
@@ -147,9 +149,9 @@ def createStructured(element):
         print("\tUA_Int32 NullRecord; /* avoiding warnings */", end='\n', file=fh)
     print("} " + name + ";", end='\n', file=fh)
 
-    print("UA_Int32 " + name + "_calcSize(" + name + " const * ptr);", end='\n', file=fh)
-    print("UA_Int32 " + name + "_encode(" + name + " const * src, UA_Int32* pos, UA_Byte* dst);", end='\n', file=fh)
-    print("UA_Int32 " + name + "_decode(UA_Byte const * src, UA_Int32* pos, " + name + "* dst);", end='\n', file=fh)
+    print("UA_Int32 " + name + "_calcSize(" + name + " const* ptr);", end='\n', file=fh)
+    print("UA_Int32 " + name + "_encodeBinary(" + name + " const* src, UA_Int32* pos, UA_ByteString* dst);", end='\n', file=fh)
+    print("UA_Int32 " + name + "_decodeBinary(UA_ByteString const* src, UA_Int32* pos, " + name + "* dst);", end='\n', file=fh)
     print("UA_Int32 " + name + "_delete("+ name + "* p);", end='\n', file=fh)
     print("UA_Int32 " + name + "_deleteMembers(" + name + "* p);", end='\n', file=fh)
     print("UA_Int32 " + name + "_init("+ name + " * p);", end='\n', file=fh)
@@ -176,43 +178,43 @@ def createStructured(element):
 
     print("\n\t;\n}\n", end='\n', file=fc)
 
-    print("UA_Int32 "+name+"_encode("+name+" const * src, UA_Int32* pos, UA_Byte* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
+    print("UA_Int32 "+name+"_encodeBinary("+name+" const * src, UA_Int32* pos, UA_ByteString* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
     # code _encode
     for n,t in valuemap.iteritems():
         if t in elementary_size:
-            print('\tretval |= UA_'+t+'_encode(&(src->'+n+'),pos,dst);', end='\n', file=fc)
+            print('\tretval |= UA_'+t+'_encodeBinary(&(src->'+n+'),pos,dst);', end='\n', file=fc)
         else:
             if t in enum_types:
-                print('\tretval |= UA_'+t+'_encode(&(src->'+n+'),pos,dst);', end='\n', file=fc)
+                print('\tretval |= UA_'+t+'_encodeBinary(&(src->'+n+'),pos,dst);', end='\n', file=fc)
             elif t.find("**") != -1:
-                print('\t//retval |= UA_Int32_encode(&(src->'+n+'Size),pos,dst); // encode size managed by UA_Array_encode', end='\n', file=fc)
-		print("\tretval |= UA_Array_encode((void const**) (src->"+n+"),src->"+n+"Size, UA_" + t[0:t.find("*")].upper()+",pos,dst);", end='\n', file=fc)
+                print('\t//retval |= UA_Int32_encodeBinary(&(src->'+n+'Size),pos,dst); // encode size managed by UA_Array_encodeBinary', end='\n', file=fc)
+		print("\tretval |= UA_Array_encodeBinary((void const**) (src->"+n+"),src->"+n+"Size, UA_" + t[0:t.find("*")].upper()+",pos,dst);", end='\n', file=fc)
             elif t.find("*") != -1:
-                print('\tretval |= UA_' + t[0:t.find("*")] + "_encode(src->" + n + ',pos,dst);', end='\n', file=fc)
+                print('\tretval |= UA_' + t[0:t.find("*")] + "_encodeBinary(src->" + n + ',pos,dst);', end='\n', file=fc)
             else:
-                print('\tretval |= UA_'+t+"_encode(&(src->"+n+"),pos,dst);", end='\n', file=fc)
+                print('\tretval |= UA_'+t+"_encodeBinary(&(src->"+n+"),pos,dst);", end='\n', file=fc)
     print("\treturn retval;\n}\n", end='\n', file=fc)
 
     # code _decode
-    print("UA_Int32 "+name+"_decode(UA_Byte const * src, UA_Int32* pos, " + name + "* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
+    print("UA_Int32 "+name+"_decodeBinary(UA_ByteString const * src, UA_Int32* pos, " + name + "* dst) {\n\tUA_Int32 retval = UA_SUCCESS;", end='\n', file=fc)
     for n,t in valuemap.iteritems():
         if t in elementary_size:
-            print('\tretval |= UA_'+t+'_decode(src,pos,&(dst->'+n+'));', end='\n', file=fc)
+            print('\tretval |= UA_'+t+'_decodeBinary(src,pos,&(dst->'+n+'));', end='\n', file=fc)
         else:
             if t in enum_types:
-                print('\tretval |= UA_'+t+'_decode(src,pos,&(dst->'+n+'));', end='\n', file=fc)
+                print('\tretval |= UA_'+t+'_decodeBinary(src,pos,&(dst->'+n+'));', end='\n', file=fc)
             elif t.find("**") != -1:
             	# decode size
-		print('\tretval |= UA_Int32_decode(src,pos,&(dst->'+n+'Size)); // decode size', end='\n', file=fc)
+		print('\tretval |= UA_Int32_decodeBinary(src,pos,&(dst->'+n+'Size)); // decode size', end='\n', file=fc)
 		# allocate memory for array
 		print("\tretval |= UA_Array_new((void**)&(dst->"+n+"),dst->"+n+"Size,UA_"+t[0:t.find("*")].upper()+");", end='\n', file=fc)
-		print("\tretval |= UA_Array_decode(src,dst->"+n+"Size, UA_" + t[0:t.find("*")].upper()+",pos,(void ** const) (dst->"+n+"));", end='\n', file=fc) #not tested
+		print("\tretval |= UA_Array_decodeBinary(src,dst->"+n+"Size, UA_" + t[0:t.find("*")].upper()+",pos,(void ** const) (dst->"+n+"));", end='\n', file=fc) #not tested
             elif t.find("*") != -1:
 		#allocate memory using new
 		print('\tretval |= UA_'+ t[0:t.find("*")] +"_new(&(dst->" + n + "));", end='\n', file=fc)
-		print('\tretval |= UA_' + t[0:t.find("*")] + "_decode(src,pos,dst->"+ n +");", end='\n', file=fc)
+		print('\tretval |= UA_' + t[0:t.find("*")] + "_decodeBinary(src,pos,dst->"+ n +");", end='\n', file=fc)
             else:
-                print('\tretval |= UA_'+t+"_decode(src,pos,&(dst->"+n+"));", end='\n', file=fc)
+                print('\tretval |= UA_'+t+"_decodeBinary(src,pos,&(dst->"+n+"));", end='\n', file=fc)
     print("\treturn retval;\n}\n", end='\n', file=fc)
     
     # code _delete and _deleteMembers
@@ -265,8 +267,8 @@ def createOpaque(element):
     print("typedef UA_ByteString " + name + ";", end='\n', file=fh)
     print("UA_TYPE_METHOD_PROTOTYPES (" + name + ")", end='\n', file=fh)
     print("UA_TYPE_METHOD_CALCSIZE_AS("+name+", UA_ByteString)", end='\n', file=fc)
-    print("UA_TYPE_METHOD_ENCODE_AS("+name+", UA_ByteString)", end='\n', file=fc)
-    print("UA_TYPE_METHOD_DECODE_AS("+name+", UA_ByteString)", end='\n', file=fc)
+    print("UA_TYPE_METHOD_ENCODEBINARY_AS("+name+", UA_ByteString)", end='\n', file=fc)
+    print("UA_TYPE_METHOD_DECODEBINARY_AS("+name+", UA_ByteString)", end='\n', file=fc)
     print("UA_TYPE_METHOD_DELETE_AS("+name+", UA_ByteString)", end='\n', file=fc)
     print("UA_TYPE_METHOD_DELETEMEMBERS_AS("+name+", UA_ByteString)", end='\n', file=fc)
     print("UA_TYPE_METHOD_INIT_AS("+name+", UA_ByteString)", end='\n', file=fc)
@@ -280,10 +282,12 @@ types = tree.xpath("/opc:TypeDictionary/*[not(self::opc:Import)]", namespaces=ns
 fh = open(sys.argv[2] + ".hgen",'w');
 fc = open(sys.argv[2] + ".cgen",'w');
 print('''/**********************************************************
+ * '''+sys.argv[2]+'''.cgen -- do not modify
+ **********************************************************
  * Generated from '''+sys.argv[1]+''' with script '''+sys.argv[0]+'''
- * on node XXX by user XXX at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
- * do not modify
+ * on host '''+platform.uname()[1]+''' by user '''+getpass.getuser()+''' at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
  **********************************************************/
+ 
 #include "''' + sys.argv[2] + '.h"', end='\n', file=fc);
 
 # types for which we create a vector type
@@ -296,14 +300,17 @@ for field in fields:
 deferred_types = OrderedDict()
 
 print('''/**********************************************************
+ * '''+sys.argv[2]+'''.hgen -- do not modify
+ **********************************************************
  * Generated from '''+sys.argv[1]+''' with script '''+sys.argv[0]+'''
- * on node XXX by user XXX at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
- * do not modify
+ * on host '''+platform.uname()[1]+''' by user '''+getpass.getuser()+''' at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
  **********************************************************/
-#ifndef OPCUA_H_''', end='\n', file=fh)
-print('#define OPCUA_H_', end='\n', file=fh)
-print('#include "opcua_basictypes.h"', end='\n', file=fh)
-print('#include "opcua_namespace_0.h"', end='\n', file=fh);
+ 
+#ifndef OPCUA_H_
+#define OPCUA_H_
+
+#include "opcua_basictypes.h"
+#include "opcua_namespace_0.h"''', end='\n', file=fh);
 
 
 #plugin handling

+ 14 - 6
tool/generate_namespace.py

@@ -1,5 +1,7 @@
 from __future__ import print_function
 import sys
+import platform
+import getpass
 from collections import OrderedDict
 import time
 import re
@@ -49,10 +51,12 @@ fh = open(sys.argv[2] + ".hgen",'w');
 fc = open(sys.argv[2] + ".cgen",'w');
 
 print('''/**********************************************************
+ * '''+sys.argv[2]+'''.hgen -- do not modify
+ **********************************************************
  * Generated from '''+sys.argv[1]+''' with script '''+sys.argv[0]+'''
- * on node XXX by user XXX at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
- * do not modify
- **********************************************************/ 
+ * on host '''+platform.uname()[1]+''' by user '''+getpass.getuser()+''' at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
+ **********************************************************/
+ 
 #ifndef OPCUA_NAMESPACE_0_H_
 #define OPCUA_NAMESPACE_0_H_
 
@@ -64,11 +68,14 @@ extern UA_VTable UA_[];
 enum UA_VTableIndex_enum {''', end='\n', file=fh)
 
 print('''/**********************************************************
+ * '''+sys.argv[2]+'''.cgen -- do not modify
+ **********************************************************
  * Generated from '''+sys.argv[1]+''' with script '''+sys.argv[0]+'''
- * on node XXX by user XXX at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
- * do not modify
+ * on host '''+platform.uname()[1]+''' by user '''+getpass.getuser()+''' at '''+ time.strftime("%Y-%m-%d %I:%M:%S")+'''
  **********************************************************/
+ 
 #include "opcua.h"
+
 UA_Int32 UA_toIndex(UA_Int32 id) {
     UA_Int32 retval = -1;
     switch (id) { ''', end='\n',file=fc)
@@ -113,7 +120,7 @@ for row in rows2:
 
     print('#define '+name.upper()+'_NS0 '+row[1], file=fh)
 
-    print("\t{" + row[1] + ", (UA_Int32(*)(void const*)) " + name + "_calcSize, (UA_Int32(*)(UA_Byte const*,UA_Int32*,void*)) " + name + "_decode, (UA_Int32(*)(void const*,UA_Int32*,UA_Byte*))" + name + "_encode, (UA_Int32(*)(void **))" + name + "_new, (UA_Int32(*)(void *))" + name + "_delete},",end='\n',file=fc) 
+    print("\t{" + row[1] + ", (UA_Int32(*)(void const*)) " + name + "_calcSize, (UA_Int32(*)(UA_ByteString const*,UA_Int32*,void*)) " + name + "_decodeBinary, (UA_Int32(*)(void const*,UA_Int32*,UA_ByteString*))" + name + "_encodeBinary, (UA_Int32(*)(void **))" + name + "_new, (UA_Int32(*)(void *))" + name + "_delete},",end='\n',file=fc) 
 
 print("\t{0,UA_NULL,UA_NULL,UA_NULL,UA_NULL,UA_NULL}\n};",file=fc)
 print('#endif /* OPCUA_NAMESPACE_0_H_ */', end='\n', file=fh)
@@ -121,3 +128,4 @@ fh.close()
 fc.close()
 f.close()
 
+2222