Przeglądaj źródła

autogenerate transport types

Julius Pfrommer 10 lat temu
rodzic
commit
6a7beb4450

+ 8 - 1
CMakeLists.txt

@@ -14,12 +14,13 @@ set(lib_sources src/ua_types.c
                 ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
                 ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
                 src/ua_transport.c
+                ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
 				src/ua_connection.c
                 src/ua_securechannel.c
                 src/ua_session.c
                 src/util/ua_util.c
                 src/util/ua_list.c
-                src/util/ua_base64.c
+                #src/util/ua_base64.c
                 src/server/ua_server.c
                 src/server/ua_securechannel_manager.c
                 src/server/ua_session_manager.c
@@ -141,6 +142,12 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_0.c
                    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
                            ${CMAKE_CURRENT_SOURCE_DIR}/schema/NodeIds.csv)
 
+add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
+                          ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.h
+                   COMMAND python ${PROJECT_SOURCE_DIR}/tools/generate_builtin.py --additional-includes=ua_transport.h ${PROJECT_SOURCE_DIR}/schema/Custom.Opc.Ua.Transport.bsd ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated
+                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_namespace.py
+                           ${CMAKE_CURRENT_SOURCE_DIR}/schema/Custom.Opc.Ua.Transport.bsd)
+
 # build example server
 add_executable(exampleServer examples/opcuaServer.c
                              examples/logger_stdout.c

+ 8 - 8
schema/Custom.Opc.Ua.Transport.bsd

@@ -9,16 +9,16 @@
 
   <opc:Import Namespace="http://opcfoundation.org/BinarySchema/" />
 
-<!-- 	Types within the Stack Begin  -->
+<!-- Transport types begin  -->
 
-   <opc:StructuredType Name="OPCUATcpMessageHeader">
+   <opc:StructuredType Name="TcpMessageHeader">
     <opc:Documentation>TCP Header</opc:Documentation>
-    <opc:Field Name="MessageType" TypeName="opc:UInt32" />
+    <opc:Field Name="MessageType" TypeName="opc:MessageType" /> <!-- The MessageType type is custom and implemented by hand -->
     <opc:Field Name="IsFinal" TypeName="opc:Byte" />
     <opc:Field Name="MessageSize" TypeName="opc:UInt32" />
   </opc:StructuredType>
   
-   <opc:StructuredType Name="OPCUATcpHelloMessage">
+   <opc:StructuredType Name="TcpHelloMessage">
     <opc:Documentation>Hello Message</opc:Documentation>
     <opc:Field Name="ProtocolVersion" TypeName="opc:UInt32" />
     <opc:Field Name="ReceiveBufferSize" TypeName="opc:UInt32" />
@@ -28,7 +28,7 @@
     <opc:Field Name="EndpointUrl" TypeName="opc:String" />
   </opc:StructuredType>
   
-   <opc:StructuredType Name="OPCUATcpAcknowledgeMessage">
+   <opc:StructuredType Name="TcpAcknowledgeMessage">
     <opc:Documentation>Acknowledge Message</opc:Documentation>
     <opc:Field Name="ProtocolVersion" TypeName="opc:UInt32" />
     <opc:Field Name="ReceiveBufferSize" TypeName="opc:UInt32" />
@@ -37,10 +37,9 @@
 	<opc:Field Name="MaxChunkCount" TypeName="opc:UInt32" />
   </opc:StructuredType>
   
-  
   <opc:StructuredType Name="SecureConversationMessageHeader">
     <opc:Documentation>Secure Layer Sequence Header</opc:Documentation>
-    <opc:Field Name="MessageHeader" TypeName="opc:OPCUATcpMessageHeader" />
+    <opc:Field Name="MessageHeader" TypeName="opc:TcpMessageHeader" />
     <opc:Field Name="SecureChannelId" TypeName="opc:UInt32" />
   </opc:StructuredType>
   
@@ -75,5 +74,6 @@
     <opc:Field Name="Reason" TypeName="opc:String" />
   </opc:StructuredType>
  
-<!-- Types within the Stack End -->
+<!-- Transport types end -->
+
 </opc:TypeDictionary>

+ 15 - 15
src/server/ua_server_binary.c

@@ -4,8 +4,8 @@
 
 static void processHello(UA_Connection *connection, const UA_ByteString *msg,
                          UA_UInt32 *pos) {
-    UA_OPCUATcpHelloMessage helloMessage;
-    if(UA_OPCUATcpHelloMessage_decodeBinary(msg, pos, &helloMessage) != UA_SUCCESS) {
+    UA_TcpHelloMessage helloMessage;
+    if(UA_TcpHelloMessage_decodeBinary(msg, pos, &helloMessage) != UA_SUCCESS) {
         connection->close(connection->callbackHandle);
         return;
     }
@@ -18,24 +18,24 @@ static void processHello(UA_Connection *connection, const UA_ByteString *msg,
     connection->state = UA_CONNECTION_ESTABLISHED;
 
     // build acknowledge response
-    UA_OPCUATcpAcknowledgeMessage ackMessage;
+    UA_TcpAcknowledgeMessage ackMessage;
     ackMessage.protocolVersion   = connection->localConf.protocolVersion;
     ackMessage.receiveBufferSize = connection->localConf.recvBufferSize;
     ackMessage.sendBufferSize    = connection->localConf.sendBufferSize;
     ackMessage.maxMessageSize    = connection->localConf.maxMessageSize;
     ackMessage.maxChunkCount     = connection->localConf.maxChunkCount;
 
-    UA_OPCUATcpMessageHeader ackHeader;
+    UA_TcpMessageHeader ackHeader;
     ackHeader.messageType = UA_MESSAGETYPE_ACK;
     ackHeader.isFinal     = 'F';
-    ackHeader.messageSize = UA_OPCUATcpAcknowledgeMessage_calcSizeBinary(&ackMessage) +
-                            UA_OPCUATcpMessageHeader_calcSizeBinary(&ackHeader);
+    ackHeader.messageSize = UA_TcpAcknowledgeMessage_calcSizeBinary(&ackMessage) +
+                            UA_TcpMessageHeader_calcSizeBinary(&ackHeader);
 
     UA_ByteString ack_msg;
     UA_UInt32 tmpPos = 0;
     UA_ByteString_newMembers(&ack_msg, ackHeader.messageSize);
-    UA_OPCUATcpMessageHeader_encodeBinary(&ackHeader, &ack_msg, &tmpPos);
-    UA_OPCUATcpAcknowledgeMessage_encodeBinary(&ackMessage, &ack_msg, &tmpPos);
+    UA_TcpMessageHeader_encodeBinary(&ackHeader, &ack_msg, &tmpPos);
+    UA_TcpAcknowledgeMessage_encodeBinary(&ackMessage, &ack_msg, &tmpPos);
     UA_ByteStringArray answer_buf = { .stringsSize = 1, .strings = &ack_msg };
     connection->write(connection->callbackHandle, answer_buf);
     UA_ByteString_deleteMembers(&ack_msg);
@@ -75,7 +75,7 @@ static void processOpen(UA_Connection *connection, UA_Server *server,
     Service_OpenSecureChannel(server, connection, &r, &p);
 
     // response
-    UA_OPCUATcpMessageHeader respHeader;
+    UA_TcpMessageHeader respHeader;
     respHeader.messageType = UA_MESSAGETYPE_OPN;
     respHeader.isFinal     = 'F';
     respHeader.messageSize = 8+4; //header + securechannelid
@@ -91,7 +91,7 @@ static void processOpen(UA_Connection *connection, UA_Server *server,
     UA_ByteString resp_msg;
     UA_UInt32 tmpPos = 0;
     UA_ByteString_newMembers(&resp_msg, respHeader.messageSize);
-    UA_OPCUATcpMessageHeader_encodeBinary(&respHeader, &resp_msg, &tmpPos);
+    UA_TcpMessageHeader_encodeBinary(&respHeader, &resp_msg, &tmpPos);
     UA_UInt32_encodeBinary(&p.securityToken.channelId, &resp_msg, &tmpPos);
     UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(&asymHeader, &resp_msg, &tmpPos); // just mirror back
     UA_SequenceHeader_encodeBinary(&seqHeader, &resp_msg, &tmpPos); // just mirror back
@@ -265,11 +265,11 @@ static void processMessage(UA_Connection *connection, UA_Server *server,
     UA_UInt32 rpos = 0;
 
     // header
-    UA_OPCUATcpMessageHeader respHeader;
+    UA_TcpMessageHeader respHeader;
     respHeader.messageType = UA_MESSAGETYPE_MSG;
     respHeader.isFinal     = 'F';
     respHeader.messageSize = header->length + responseBuf.strings[1].length;
-    UA_OPCUATcpMessageHeader_encodeBinary(&respHeader, header, &rpos);
+    UA_TcpMessageHeader_encodeBinary(&respHeader, header, &rpos);
 
     // channel id
     UA_UInt32_encodeBinary(&channel->securityToken.channelId, header, &rpos);
@@ -312,10 +312,10 @@ UA_Int32 UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connec
                                         const UA_ByteString *msg) {
     UA_Int32  retval = UA_SUCCESS;
     UA_UInt32 pos    = 0;
-    UA_OPCUATcpMessageHeader tcpMessageHeader;
+    UA_TcpMessageHeader tcpMessageHeader;
     // todo: test how far pos advanced must be equal to what is said in the messageheader
     do {
-        retval = UA_OPCUATcpMessageHeader_decodeBinary(msg, &pos, &tcpMessageHeader);
+        retval = UA_TcpMessageHeader_decodeBinary(msg, &pos, &tcpMessageHeader);
         if(retval == UA_SUCCESS) {
             // none of the process-functions returns an error its all contained inside.
             switch(tcpMessageHeader.messageType) {
@@ -341,7 +341,7 @@ UA_Int32 UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connec
                 connection->close(connection->callbackHandle);
                 return retval;
             }
-            UA_OPCUATcpMessageHeader_deleteMembers(&tcpMessageHeader);
+            UA_TcpMessageHeader_deleteMembers(&tcpMessageHeader);
         } else {
             printf("TL_Process - ERROR: decoding of header failed \n");
             connection->state = UA_CONNECTION_CLOSING;

+ 7 - 581
src/ua_transport.c

@@ -1,11 +1,12 @@
+#ifdef DEBUG
 #include <stdio.h>
+#endif
 #include "ua_transport.h"
-#include "ua_namespace_0.h" // for the vtable UA_
 
 UA_TYPE_DEFAULT(UA_MessageType)
-UA_Int32 UA_MessageType_calcSize(UA_MessageType const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_MessageType); return 0
-           + 3 * sizeof(UA_Byte);
+UA_Int32 UA_MessageType_calcSizeBinary(UA_MessageType const *ptr) {
+    if(ptr == UA_NULL) return sizeof(UA_MessageType);
+    return 3 * sizeof(UA_Byte);
 }
 
 UA_Int32 UA_MessageType_encodeBinary(UA_MessageType const *src, UA_ByteString *dst, UA_UInt32 *offset) {
@@ -31,584 +32,9 @@ UA_Int32 UA_MessageType_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset
     return retval;
 }
 
+#ifdef DEBUG
 void UA_MessageType_printf(char *label, UA_MessageType *p) {
     UA_Byte *b = (UA_Byte *)p;
     printf("%s{%c%c%c}\n", label, b[2], b[1], b[0]);
 }
-
-UA_Int32 UA_OPCUATcpMessageHeader_calcSizeBinary(UA_OPCUATcpMessageHeader const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_OPCUATcpMessageHeader);
-    return 0
-           + 3                 // messageType
-           + sizeof(UA_Byte)   // isFinal
-           + sizeof(UA_UInt32) // messageSize
-    ;
-}
-
-UA_Int32 UA_OPCUATcpMessageHeader_encodeBinary(UA_OPCUATcpMessageHeader const *src, UA_ByteString *dst,
-                                               UA_UInt32 *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_MessageType_encodeBinary(&src->messageType, dst, offset);
-    retval |= UA_Byte_encodeBinary(&src->isFinal, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->messageSize, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpMessageHeader_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                               UA_OPCUATcpMessageHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_OPCUATcpMessageHeader_init(dst);
-    CHECKED_DECODE(UA_MessageType_decodeBinary(src, offset,
-                                               &dst->messageType), UA_OPCUATcpMessageHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_Byte_decodeBinary(src, offset,
-                                        &dst->isFinal), UA_OPCUATcpMessageHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->messageSize), UA_OPCUATcpMessageHeader_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpMessageHeader_delete(UA_OPCUATcpMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_OPCUATcpMessageHeader_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpMessageHeader_deleteMembers(UA_OPCUATcpMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpMessageHeader_init(UA_OPCUATcpMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_Byte_init(&p->isFinal);
-    retval |= UA_UInt32_init(&p->messageSize);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_OPCUATcpMessageHeader)
-UA_Int32 UA_OPCUATcpMessageHeader_copy(const UA_OPCUATcpMessageHeader *src, UA_OPCUATcpMessageHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL)
-        return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_OPCUATcpMessageHeader));
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_calcSizeBinary(UA_OPCUATcpHelloMessage const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_OPCUATcpHelloMessage);
-    return 0
-           + sizeof(UA_UInt32) // protocolVersion
-           + sizeof(UA_UInt32) // receiveBufferSize
-           + sizeof(UA_UInt32) // sendBufferSize
-           + sizeof(UA_UInt32) // maxMessageSize
-           + sizeof(UA_UInt32) // maxChunkCount
-           + UA_String_calcSizeBinary(&ptr->endpointUrl)
-    ;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_encodeBinary(UA_OPCUATcpHelloMessage const *src, UA_ByteString *dst,
-                                              UA_UInt32 *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_encodeBinary(&src->protocolVersion, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->receiveBufferSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->sendBufferSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->maxMessageSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->maxChunkCount, dst, offset);
-    retval |= UA_String_encodeBinary(&src->endpointUrl, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                              UA_OPCUATcpHelloMessage *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_OPCUATcpHelloMessage_init(dst);
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->protocolVersion), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->receiveBufferSize), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->sendBufferSize), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->maxMessageSize), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->maxChunkCount), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_String_decodeBinary(src, offset,
-                                          &dst->endpointUrl), UA_OPCUATcpHelloMessage_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_delete(UA_OPCUATcpHelloMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_OPCUATcpHelloMessage_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_deleteMembers(UA_OPCUATcpHelloMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_String_deleteMembers(&p->endpointUrl);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpHelloMessage_init(UA_OPCUATcpHelloMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_init(&p->protocolVersion);
-    retval |= UA_UInt32_init(&p->receiveBufferSize);
-    retval |= UA_UInt32_init(&p->sendBufferSize);
-    retval |= UA_UInt32_init(&p->maxMessageSize);
-    retval |= UA_UInt32_init(&p->maxChunkCount);
-    retval |= UA_String_init(&p->endpointUrl);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_OPCUATcpHelloMessage)
-UA_Int32 UA_OPCUATcpHelloMessage_copy(const UA_OPCUATcpHelloMessage *src, UA_OPCUATcpHelloMessage *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_OPCUATcpHelloMessage));
-    retval |= UA_String_copy(&src->endpointUrl, &dst->endpointUrl);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_calcSizeBinary(UA_OPCUATcpAcknowledgeMessage const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_OPCUATcpAcknowledgeMessage);
-    return 0
-           + sizeof(UA_UInt32) // protocolVersion
-           + sizeof(UA_UInt32) // receiveBufferSize
-           + sizeof(UA_UInt32) // sendBufferSize
-           + sizeof(UA_UInt32) // maxMessageSize
-           + sizeof(UA_UInt32) // maxChunkCount
-    ;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_encodeBinary(UA_OPCUATcpAcknowledgeMessage const *src,
-                                                    UA_ByteString                       *dst,
-                                                    UA_UInt32                           *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_encodeBinary(&src->protocolVersion, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->receiveBufferSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->sendBufferSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->maxMessageSize, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->maxChunkCount, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                    UA_OPCUATcpAcknowledgeMessage *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_OPCUATcpAcknowledgeMessage_init(dst);
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->protocolVersion),
-                   UA_OPCUATcpAcknowledgeMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->receiveBufferSize),
-                   UA_OPCUATcpAcknowledgeMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->sendBufferSize),
-                   UA_OPCUATcpAcknowledgeMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->maxMessageSize),
-                   UA_OPCUATcpAcknowledgeMessage_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->maxChunkCount),
-                   UA_OPCUATcpAcknowledgeMessage_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_delete(UA_OPCUATcpAcknowledgeMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_OPCUATcpAcknowledgeMessage_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_deleteMembers(UA_OPCUATcpAcknowledgeMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    return retval;
-}
-
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_init(UA_OPCUATcpAcknowledgeMessage *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_init(&p->protocolVersion);
-    retval |= UA_UInt32_init(&p->receiveBufferSize);
-    retval |= UA_UInt32_init(&p->sendBufferSize);
-    retval |= UA_UInt32_init(&p->maxMessageSize);
-    retval |= UA_UInt32_init(&p->maxChunkCount);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_OPCUATcpAcknowledgeMessage)
-UA_Int32 UA_OPCUATcpAcknowledgeMessage_copy(const UA_OPCUATcpAcknowledgeMessage *src,
-                                            UA_OPCUATcpAcknowledgeMessage       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_OPCUATcpAcknowledgeMessage));
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_calcSizeBinary(UA_SecureConversationMessageHeader const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_SecureConversationMessageHeader);
-    return 0
-           + sizeof(UA_OPCUATcpMessageHeader) // messageHeader CHECK: delete this or use in binary_secure.c
-           + sizeof(UA_UInt32)                // secureChannelId
-    ;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_encodeBinary(UA_SecureConversationMessageHeader const *src,
-                                                         UA_ByteString                            *dst,
-                                                         UA_UInt32                                *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_OPCUATcpMessageHeader_encodeBinary(&src->messageHeader, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->secureChannelId, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                         UA_SecureConversationMessageHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_SecureConversationMessageHeader_init(dst);
-    CHECKED_DECODE(UA_OPCUATcpMessageHeader_decodeBinary(src, offset,
-                                                         &dst->messageHeader),
-                   UA_SecureConversationMessageHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->secureChannelId),
-                   UA_SecureConversationMessageHeader_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_delete(UA_SecureConversationMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_SecureConversationMessageHeader_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_deleteMembers(UA_SecureConversationMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageHeader_init(UA_SecureConversationMessageHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_OPCUATcpMessageHeader_init(&p->messageHeader);
-    retval |= UA_UInt32_init(&p->secureChannelId);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_SecureConversationMessageHeader)
-UA_Int32 UA_SecureConversationMessageHeader_copy(const UA_SecureConversationMessageHeader *src,
-                                                 UA_SecureConversationMessageHeader       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_SecureConversationMessageHeader));
-    return retval;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_calcSizeBinary(UA_AsymmetricAlgorithmSecurityHeader const *ptr)
-{
-    if(ptr == UA_NULL) return sizeof(UA_AsymmetricAlgorithmSecurityHeader);
-    return 0
-           + UA_ByteString_calcSizeBinary(&ptr->securityPolicyUri)
-           + UA_ByteString_calcSizeBinary(&ptr->senderCertificate)
-           + UA_ByteString_calcSizeBinary(&ptr->receiverCertificateThumbprint)
-    ;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(UA_AsymmetricAlgorithmSecurityHeader const *src,
-                                                           UA_ByteString                              *dst,
-                                                           UA_UInt32                                  *offset)
-{
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_ByteString_encodeBinary(&src->securityPolicyUri, dst, offset);
-    retval |= UA_ByteString_encodeBinary(&src->senderCertificate, dst, offset);
-    retval |= UA_ByteString_encodeBinary(&src->receiverCertificateThumbprint, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                           UA_AsymmetricAlgorithmSecurityHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_AsymmetricAlgorithmSecurityHeader_init(dst);
-    CHECKED_DECODE(UA_ByteString_decodeBinary(src, offset,
-                                              &dst->securityPolicyUri),
-                   UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_ByteString_decodeBinary(src, offset,
-                                              &dst->senderCertificate),
-                   UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_ByteString_decodeBinary(src, offset,
-                                              &dst->receiverCertificateThumbprint),
-                   UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_delete(UA_AsymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(UA_AsymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_ByteString_deleteMembers(&p->securityPolicyUri);
-    retval |= UA_ByteString_deleteMembers(&p->senderCertificate);
-    retval |= UA_ByteString_deleteMembers(&p->receiverCertificateThumbprint);
-    return retval;
-}
-
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_init(UA_AsymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_ByteString_init(&p->securityPolicyUri);
-    retval |= UA_ByteString_init(&p->senderCertificate);
-    retval |= UA_ByteString_init(&p->receiverCertificateThumbprint);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_AsymmetricAlgorithmSecurityHeader)
-UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_copy(const UA_AsymmetricAlgorithmSecurityHeader *src,
-                                                   UA_AsymmetricAlgorithmSecurityHeader       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_AsymmetricAlgorithmSecurityHeader));
-    retval |= UA_ByteString_copy(&src->securityPolicyUri, &dst->securityPolicyUri);
-    retval |= UA_ByteString_copy(&src->senderCertificate, &dst->senderCertificate);
-    retval |= UA_ByteString_copy(&src->receiverCertificateThumbprint, &dst->receiverCertificateThumbprint);
-    return retval;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_calcSizeBinary(UA_SymmetricAlgorithmSecurityHeader const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_SymmetricAlgorithmSecurityHeader);
-    return 0
-           + sizeof(UA_UInt32) // tokenId
-    ;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_encodeBinary(UA_SymmetricAlgorithmSecurityHeader const *src,
-                                                          UA_ByteString                             *dst,
-                                                          UA_UInt32                                 *offset)
-{
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_encodeBinary(&src->tokenId, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                          UA_SymmetricAlgorithmSecurityHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_SymmetricAlgorithmSecurityHeader_init(dst);
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->tokenId),
-                   UA_SymmetricAlgorithmSecurityHeader_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_delete(UA_SymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_SymmetricAlgorithmSecurityHeader_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_deleteMembers(UA_SymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    return retval;
-}
-
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_init(UA_SymmetricAlgorithmSecurityHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_init(&p->tokenId);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_SymmetricAlgorithmSecurityHeader)
-UA_Int32 UA_SymmetricAlgorithmSecurityHeader_copy(const UA_SymmetricAlgorithmSecurityHeader *src,
-                                                  UA_SymmetricAlgorithmSecurityHeader       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_SymmetricAlgorithmSecurityHeader));
-    return retval;
-}
-
-UA_Int32 UA_SequenceHeader_calcSizeBinary(UA_SequenceHeader const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_SequenceHeader);
-    return 0
-           + sizeof(UA_UInt32) // sequenceNumber
-           + sizeof(UA_UInt32) // requestId
-    ;
-}
-
-UA_Int32 UA_SequenceHeader_encodeBinary(UA_SequenceHeader const *src, UA_ByteString *dst,
-                                        UA_UInt32 *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_encodeBinary(&src->sequenceNumber, dst, offset);
-    retval |= UA_UInt32_encodeBinary(&src->requestId, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_SequenceHeader_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                        UA_SequenceHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_SequenceHeader_init(dst);
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->sequenceNumber), UA_SequenceHeader_deleteMembers(dst));
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset, &dst->requestId), UA_SequenceHeader_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_SequenceHeader_delete(UA_SequenceHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_SequenceHeader_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_SequenceHeader_deleteMembers(UA_SequenceHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    return retval;
-}
-
-UA_Int32 UA_SequenceHeader_init(UA_SequenceHeader *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_init(&p->sequenceNumber);
-    retval |= UA_UInt32_init(&p->requestId);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_SequenceHeader)
-UA_Int32 UA_SequenceHeader_copy(const UA_SequenceHeader *src, UA_SequenceHeader *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_SequenceHeader));
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_calcSizeBinary(UA_SecureConversationMessageFooter const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_SecureConversationMessageFooter);
-    return 0 + UA_Array_calcSizeBinary(ptr->paddingSize, &UA_.types[UA_BYTE], ptr->padding)
-           + sizeof(UA_Byte) // signature
-    ;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_encodeBinary(UA_SecureConversationMessageFooter const *src,
-                                                         UA_ByteString                            *dst,
-                                                         UA_UInt32                                *offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_Array_encodeBinary(src->padding, src->paddingSize, &UA_.types[UA_BYTE], dst, offset);
-    retval |= UA_Byte_encodeBinary(&src->signature, dst, offset);
-
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                         UA_SecureConversationMessageFooter *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_SecureConversationMessageFooter_init(dst);
-    CHECKED_DECODE(UA_Int32_decodeBinary(src, offset,
-                                         &dst->paddingSize),
-                   UA_SecureConversationMessageFooter_deleteMembers(dst));
-    CHECKED_DECODE(UA_Array_decodeBinary(src, offset, dst->paddingSize, &UA_.types[UA_BYTE],
-                                         (void **)&dst->padding),
-                   UA_SecureConversationMessageFooter_deleteMembers(dst));
-    CHECKED_DECODE(UA_Byte_decodeBinary(src, offset,
-                                        &dst->signature),
-                   UA_SecureConversationMessageFooter_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_delete(UA_SecureConversationMessageFooter *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_SecureConversationMessageFooter_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_deleteMembers(UA_SecureConversationMessageFooter *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_Array_delete((void *)p->padding, p->paddingSize, &UA_.types[UA_BYTE]);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageFooter_init(UA_SecureConversationMessageFooter *p) {
-    if(!p) return UA_ERROR;
-    UA_Int32 retval = UA_SUCCESS;
-    p->paddingSize = 0;
-    p->padding     = UA_NULL;
-    retval |= UA_Byte_init(&p->signature);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_SecureConversationMessageFooter)
-UA_Int32 UA_SecureConversationMessageFooter_copy(const UA_SecureConversationMessageFooter *src,
-                                                 UA_SecureConversationMessageFooter       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_SecureConversationMessageFooter));
-
-
-    retval |= UA_Array_copy(src->padding, src->paddingSize, &UA_.types[UA_BYTE], (void **)&dst->padding);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_calcSizeBinary(
-    UA_SecureConversationMessageAbortBody const *ptr) {
-    if(ptr == UA_NULL) return sizeof(UA_SecureConversationMessageAbortBody);
-    return 0
-           + sizeof(UA_UInt32) // error
-           + UA_String_calcSizeBinary(&ptr->reason)
-    ;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_encodeBinary(
-    UA_SecureConversationMessageAbortBody const *src,
-    UA_ByteString                               *dst,
-    UA_UInt32                                   *
-    offset) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_encodeBinary(&src->error, dst, offset);
-    retval |= UA_String_encodeBinary(&src->reason, dst, offset);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_decodeBinary(UA_ByteString const *src, UA_UInt32 *offset,
-                                                            UA_SecureConversationMessageAbortBody *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    UA_SecureConversationMessageAbortBody_init(dst);
-    CHECKED_DECODE(UA_UInt32_decodeBinary(src, offset,
-                                          &dst->error),
-                   UA_SecureConversationMessageAbortBody_deleteMembers(dst));
-    CHECKED_DECODE(UA_String_decodeBinary(src, offset,
-                                          &dst->reason),
-                   UA_SecureConversationMessageAbortBody_deleteMembers(dst));
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_delete(UA_SecureConversationMessageAbortBody *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_SecureConversationMessageAbortBody_deleteMembers(p);
-    retval |= UA_free(p);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_deleteMembers(UA_SecureConversationMessageAbortBody *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_String_deleteMembers(&p->reason);
-    return retval;
-}
-
-UA_Int32 UA_SecureConversationMessageAbortBody_init(UA_SecureConversationMessageAbortBody *p) {
-    UA_Int32 retval = UA_SUCCESS;
-    retval |= UA_UInt32_init(&p->error);
-    retval |= UA_String_init(&p->reason);
-    return retval;
-}
-
-UA_TYPE_NEW_DEFAULT(UA_SecureConversationMessageAbortBody)
-UA_Int32 UA_SecureConversationMessageAbortBody_copy(const UA_SecureConversationMessageAbortBody *src,
-                                                    UA_SecureConversationMessageAbortBody       *dst) {
-    UA_Int32 retval = UA_SUCCESS;
-    if(src == UA_NULL || dst == UA_NULL) return UA_ERROR;
-    memcpy(dst, src, sizeof(UA_SecureConversationMessageAbortBody));
-    retval |= UA_String_copy(&src->reason, &dst->reason);
-    return retval;
-}
+#endif

+ 4 - 80
src/ua_transport.h

@@ -27,87 +27,11 @@ enum UA_MessageType {
 };
 UA_TYPE_PROTOTYPES(UA_MessageType)
 UA_TYPE_BINARY_ENCODING(UA_MessageType)
+#ifdef DEBUG
 void UA_MessageType_printf(char *label, UA_MessageType *p);
+#endif
 
-/** @brief TCP Header */
-typedef struct UA_OPCUATcpMessageHeader {
-    UA_MessageType messageType;
-    UA_Byte isFinal;
-    UA_UInt32      messageSize;
-} UA_OPCUATcpMessageHeader;
-UA_TYPE_PROTOTYPES(UA_OPCUATcpMessageHeader)
-UA_TYPE_BINARY_ENCODING(UA_OPCUATcpMessageHeader)
-
-/** @brief Hello Message */
-typedef struct UA_OPCUATcpHelloMesage {
-    UA_UInt32 protocolVersion;
-    UA_UInt32 receiveBufferSize;
-    UA_UInt32 sendBufferSize;
-    UA_UInt32 maxMessageSize;
-    UA_UInt32 maxChunkCount;
-    UA_String endpointUrl;
-} UA_OPCUATcpHelloMessage;
-UA_TYPE_PROTOTYPES(UA_OPCUATcpHelloMessage)
-UA_TYPE_BINARY_ENCODING(UA_OPCUATcpHelloMessage)
-
-/** @brief Acknowledge Message */
-typedef struct UA_OPCUATcpAcknowledgeMessage {
-    UA_UInt32 protocolVersion;
-    UA_UInt32 receiveBufferSize;
-    UA_UInt32 sendBufferSize;
-    UA_UInt32 maxMessageSize;
-    UA_UInt32 maxChunkCount;
-} UA_OPCUATcpAcknowledgeMessage;
-UA_TYPE_PROTOTYPES(UA_OPCUATcpAcknowledgeMessage)
-UA_TYPE_BINARY_ENCODING(UA_OPCUATcpAcknowledgeMessage)
-
-/** @brief Secure Layer Sequence Header */
-typedef struct UA_SecureConversationMessageHeader {
-    UA_OPCUATcpMessageHeader messageHeader;
-    UA_UInt32 secureChannelId;
-} UA_SecureConversationMessageHeader;
-UA_TYPE_PROTOTYPES(UA_SecureConversationMessageHeader)
-UA_TYPE_BINARY_ENCODING(UA_SecureConversationMessageHeader)
-
-/** @brief Security Header> */
-typedef struct UA_AsymmetricAlgorithmSecurityHeader {
-    UA_ByteString securityPolicyUri;
-    UA_ByteString senderCertificate;
-    UA_ByteString receiverCertificateThumbprint;
-} UA_AsymmetricAlgorithmSecurityHeader;
-UA_TYPE_PROTOTYPES(UA_AsymmetricAlgorithmSecurityHeader)
-UA_TYPE_BINARY_ENCODING(UA_AsymmetricAlgorithmSecurityHeader)
-
-/** @brief Secure Layer Symmetric Algorithm Header */
-typedef struct UA_SymmetricAlgorithmSecurityHeader {
-    UA_UInt32 tokenId;
-} UA_SymmetricAlgorithmSecurityHeader;
-UA_TYPE_PROTOTYPES(UA_SymmetricAlgorithmSecurityHeader)
-UA_TYPE_BINARY_ENCODING(UA_SymmetricAlgorithmSecurityHeader)
-
-/** @brief Secure Layer Sequence Header */
-typedef struct UA_SequenceHeader {
-    UA_UInt32 sequenceNumber;
-    UA_UInt32 requestId;
-} UA_SequenceHeader;
-UA_TYPE_PROTOTYPES(UA_SequenceHeader)
-UA_TYPE_BINARY_ENCODING(UA_SequenceHeader)
-
-/** @brief Secure Conversation Message Footer */
-typedef struct UA_SecureConversationMessageFooter {
-    UA_Int32 paddingSize;
-    UA_Byte *padding;
-    UA_Byte  signature;
-} UA_SecureConversationMessageFooter;
-UA_TYPE_PROTOTYPES(UA_SecureConversationMessageFooter)
-UA_TYPE_BINARY_ENCODING(UA_SecureConversationMessageFooter)
-
-/** @brief Secure Conversation Message Abort Body */
-typedef struct UA_SecureConversationMessageAbortBody {
-    UA_UInt32 error;
-    UA_String reason;
-} UA_SecureConversationMessageAbortBody;
-UA_TYPE_PROTOTYPES(UA_SecureConversationMessageAbortBody)
-UA_TYPE_BINARY_ENCODING(UA_SecureConversationMessageAbortBody)
+/* All other transport types are auto-generated from a schema definition. */
+#include "ua_transport_generated.h"
 
 #endif /* UA_TRANSPORT_H_ */

+ 3 - 3
tests/CMakeLists.txt

@@ -25,9 +25,9 @@ add_executable(check_list check_list.c)
 target_link_libraries(check_list ${LIBS})
 add_test(list ${CMAKE_CURRENT_BINARY_DIR}/check_list)
 
-add_executable(check_base64 check_base64.c)
-target_link_libraries(check_base64 ${LIBS})
-add_test(base64 ${CMAKE_CURRENT_BINARY_DIR}/check_base64)
+# add_executable(check_base64 check_base64.c)
+# target_link_libraries(check_base64 ${LIBS})
+# add_test(base64 ${CMAKE_CURRENT_BINARY_DIR}/check_base64)
 
 add_executable(check_services_view check_services_view.c)
 target_link_libraries(check_services_view ${LIBS})

+ 6 - 1
tools/generate_builtin.py

@@ -14,6 +14,7 @@ parser.add_argument('--with-xml', action='store_true', help='generate xml encodi
 parser.add_argument('--with-json', action='store_true', help='generate json encoding')
 parser.add_argument('--only-nano', action='store_true', help='generate only the types for the nano profile')
 parser.add_argument('--only-needed', action='store_true', help='generate only types needed for compile')
+parser.add_argument('--additional-includes', action='store', help='include additional header files (separated by comma)')
 parser.add_argument('types', help='path/to/Opc.Ua.Types.bsd')
 parser.add_argument('outfile', help='outfile w/o extension')
 args = parser.parse_args()
@@ -294,7 +295,11 @@ printh('''/**
 #include "ua_types_encoding_binary.h"''')
 if args.with_xml:
 	printh('#include "ua_types_encoding_xml.h"')
-printh('#include "ua_namespace_0.h"\n')
+printh('#include "ua_namespace_0.h"')
+if args.additional_includes:
+    for incl in args.additional_includes.split(","):
+        printh("#include \"" + incl + "\"")
+printh("") # newline
 
 printc('''/**
  * @file '''+sys.argv[2]+'''.c