Quellcode durchsuchen

added missing files

FlorianPalm vor 11 Jahren
Ursprung
Commit
d7b2ded7da
2 geänderte Dateien mit 183 neuen und 0 gelöschten Zeilen
  1. 135 0
      src/ua_transport_connection.c
  2. 48 0
      src/ua_transport_connection.h

+ 135 - 0
src/ua_transport_connection.c

@@ -0,0 +1,135 @@
+/*
+ * ua_transport_connection.c
+ *
+ *  Created on: 10.05.2014
+ *      Author: open62541
+ */
+
+#include "ua_transport_connection.h"
+#include "ua_transport.h"
+typedef struct TL_Connection{
+	UA_Int32 connectionHandle;
+	UA_UInt32 state;
+	TL_Buffer localConf;
+	TL_Buffer remoteConf;
+	TL_Writer writer;
+	UA_String localEndpointUrl;
+	UA_String remoteEndpointUrl;
+} TL_Connection;
+
+
+UA_Int32 UA_TL_Connection_new(UA_TL_Connection1 *connection, TL_Buffer localBuffers,TL_Writer writer)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	retval |= UA_alloc((void**)connection,sizeof(TL_Connection));
+	if(retval == UA_SUCCESS)
+	{
+		(*((TL_Connection**)connection))->localConf = localBuffers;
+		(*((TL_Connection**)connection))->writer = writer;
+
+	//	((TL_Connection*)connection)->localConf.maxChunkCount = localBuffers->maxChunkCount;
+	//	((TL_Connection*)connection)->localConf.maxMessageSize = localBuffers->maxMessageSize;
+	//	((TL_Connection*)connection)->localConf.protocolVersion = localBuffers->protocolVersion;
+	//	((TL_Connection*)connection)->localConf.recvBufferSize = localBuffers->recvBufferSize;
+	//	((TL_Connection*)connection)->localConf.sendBufferSize = localBuffers->sendBufferSize;
+	}
+	return retval;
+}
+
+UA_Int32 UA_TL_Connection_delete(UA_TL_Connection1 connection)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	retval |= UA_free((void*)connection);
+	return retval;
+}
+UA_Int32 UA_TL_Connection_close(UA_TL_Connection1 connection)
+{
+	((TL_Connection*)connection)->state = CONNECTIONSTATE_CLOSED;
+	return UA_SUCCESS;
+}
+UA_Int32 UA_TL_Connection_configByHello(UA_TL_Connection1 connection, UA_OPCUATcpHelloMessage *helloMessage)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	((TL_Connection*)connection)->remoteConf.maxChunkCount = helloMessage->maxChunkCount;
+	((TL_Connection*)connection)->remoteConf.maxMessageSize = helloMessage->maxMessageSize;
+	((TL_Connection*)connection)->remoteConf.protocolVersion = helloMessage->protocolVersion;
+	((TL_Connection*)connection)->remoteConf.recvBufferSize = helloMessage->receiveBufferSize;
+	((TL_Connection*)connection)->remoteConf.sendBufferSize = helloMessage->sendBufferSize;
+	((TL_Connection*)connection)->state = CONNECTIONSTATE_ESTABLISHED;
+	retval |= UA_String_copy(&helloMessage->endpointUrl,&connection->remoteEndpointUrl);
+
+	return UA_SUCCESS;
+}
+
+UA_Int32 UA_TL_Connection_callWriter(UA_TL_Connection1 connection, const UA_ByteString** gather_bufs, UA_Int32 gather_len)
+{
+	return ((TL_Connection*)connection)->writer(((TL_Connection*)connection)->connectionHandle,gather_bufs, gather_len);
+}
+
+//setters
+UA_Int32 UA_TL_Connection_setWriter(UA_TL_Connection1 connection, TL_Writer writer)
+{
+	((TL_Connection*)connection)->writer = writer;
+	return UA_SUCCESS;
+}
+
+//getters
+UA_Int32 UA_TL_Connection_getState(UA_TL_Connection1 connection, UA_Int32 *connectionState)
+{
+	if(connection)
+	{
+		*connectionState = ((TL_Connection*)connection)->state;
+		return UA_SUCCESS;
+	}else{
+		*connectionState = -1;
+		return UA_ERROR;
+	}
+}
+
+UA_Int32 UA_TL_Connection_getProtocolVersion(UA_TL_Connection1 connection, UA_UInt32 *protocolVersion)
+{
+	if(connection)
+	{
+		*protocolVersion = ((TL_Connection*)connection)->localConf.protocolVersion;
+		return UA_SUCCESS;
+	}else{
+		*protocolVersion = 0xFF;
+		return UA_ERROR;
+	}
+}
+UA_Int32 UA_TL_Connection_getLocalConfiguration(UA_TL_Connection1 connection, TL_Buffer *localConfiguration)
+{
+	if(connection)
+	{
+		return UA_memcpy(localConfiguration,&((TL_Connection*)connection)->localConf, sizeof(TL_Buffer));
+
+	}else{
+		localConfiguration = UA_NULL;
+		return UA_ERROR;
+	}
+}
+UA_Int32 UA_TL_Connection_getId(UA_TL_Connection1 connection, UA_UInt32 *connectionId)
+{
+	if(connection)
+	{
+		*connectionId = ((TL_Connection*)connection)->connectionHandle;
+		return UA_SUCCESS;
+	}else{
+			connectionId = 0;
+			return UA_ERROR;
+		}
+}
+
+UA_Int32 UA_TL_Connection_bind(UA_TL_Connection1 connection, UA_Int32 handle)
+{
+	if(connection)
+	{
+
+		((TL_Connection*)connection)->connectionHandle = handle;
+		return UA_SUCCESS;
+	}else{
+
+		return UA_ERROR;
+	}
+
+}

+ 48 - 0
src/ua_transport_connection.h

@@ -0,0 +1,48 @@
+/*
+ * ua_transport_connection.h
+ *
+ *  Created on: 10.05.2014
+ *      Author: open62541
+ */
+
+#ifndef UA_TRANSPORT_CONNECTION_H_
+#define UA_TRANSPORT_CONNECTION_H_
+
+#include "opcua.h"
+#include "ua_transport.h"
+
+typedef struct TL_Buffer{
+	UA_UInt32 protocolVersion;
+	UA_UInt32 sendBufferSize;
+	UA_UInt32 recvBufferSize;
+	UA_UInt32 maxMessageSize;
+	UA_UInt32 maxChunkCount;
+} TL_Buffer;
+
+typedef struct TL_Connection *UA_TL_Connection1;
+
+
+typedef UA_Int32 (*TL_Writer)(UA_Int32 connectionHandle, const UA_ByteString** gather_bufs, UA_Int32 gather_len); // send mutiple buffer concatenated into one msg (zero copy)
+
+
+UA_Int32 UA_TL_Connection_configByHello(UA_TL_Connection1 connection, UA_OPCUATcpHelloMessage *helloMessage);
+
+UA_Int32 UA_TL_Connection_delete(UA_TL_Connection1 connection);
+UA_Int32 UA_TL_Connection_callWriter(UA_TL_Connection1 connection, const UA_ByteString** gather_bufs, UA_Int32 gather_len);
+
+UA_Int32 UA_TL_Connection_close(UA_TL_Connection1 connection);
+UA_Int32 UA_TL_Connection_new(
+		UA_TL_Connection1 *connection,
+		TL_Buffer localBuffers,TL_Writer writer);
+UA_Int32 UA_TL_Connection_bind(UA_TL_Connection1 connection, UA_Int32 handle);
+
+//getter
+UA_Int32 UA_TL_Connection_getId(UA_TL_Connection1 connection, UA_UInt32 *connectionId);
+UA_Int32 UA_TL_Connection_getProtocolVersion(UA_TL_Connection1 connection, UA_UInt32 *protocolVersion);
+
+UA_Int32 UA_TL_Connection_getState(UA_TL_Connection1 connection, UA_Int32 *connectionState);
+UA_Int32 UA_TL_Connection_getLocalConfiguration(UA_TL_Connection1 connection, TL_Buffer *localConfiguration);
+
+//setter
+UA_Int32 UA_TL_Connection_setWriter(UA_TL_Connection1 connection, TL_Writer writer);
+#endif /* UA_TRANSPORT_CONNECTION_H_ */