Browse Source

issue #43 almost fixed, redef of UA_TL_connection still open

Leon Urbas 11 years ago
parent
commit
2e99aaf30a

+ 4 - 4
examples/src/Makefile.am

@@ -2,15 +2,15 @@
 bin_PROGRAMS= $(top_builddir)/bin/exampleServer $(top_builddir)/bin/exampleServerMT $(top_builddir)/bin/exampleServerACPLT
 #__top_builddir__bin_exampleServer_LDFLAGS = -all-static
 __top_builddir__bin_exampleServer_CFLAGS = -I$(top_builddir)/src -I$(top_builddir)/include
-__top_builddir__bin_exampleServer_SOURCES = opcuaServer.c
+__top_builddir__bin_exampleServer_SOURCES = opcuaServer.c networklayer.c
 __top_builddir__bin_exampleServer_LDADD= $(top_builddir)/lib/libopen62541.a
 
 __top_builddir__bin_exampleServerMT_CFLAGS = -I$(top_builddir)/src -I$(top_builddir)/include
-__top_builddir__bin_exampleServerMT_SOURCES = opcuaServerMT.c
+__top_builddir__bin_exampleServerMT_SOURCES = opcuaServerMT.c networklayer.c
 __top_builddir__bin_exampleServerMT_LDADD= $(top_builddir)/lib/libopen62541.a -lpthread
 
 __top_builddir__bin_exampleServerACPLT_CFLAGS = -I$(top_builddir)/src -I$(top_builddir)/include
-__top_builddir__bin_exampleServerACPLT_SOURCES = opcuaServerMT.c
-__top_builddir__bin_exampleServerACPLT_LDADD= $(top_builddir)/lib/libopen62541.a -lpthread
+__top_builddir__bin_exampleServerACPLT_SOURCES = opcuaServerACPLT.c 
+__top_builddir__bin_exampleServerACPLT_LDADD= $(top_builddir)/lib/libopen62541.a
 
 AM_CFLAGS = $(GLOBAL_AM_CFLAGS)

+ 77 - 81
src/ua_stack.c

@@ -10,18 +10,18 @@
 #include <memory.h> // memset
 #include <fcntl.h> // fcntl
 
-#include "ua_stack.h"
+#include "networklayer.h"
 #include "ua_transportLayer.h"
 
-UA_TL_Description UA_TransportLayerDescriptorTcpBinary  = {
-		UA_TL_ENCODING_BINARY,
-		UA_TL_CONNECTIONTYPE_TCPV4,
-		UA_TL_MAXCONNECTIONS_DEFAULT,
+NL_Description NL_Description_TcpBinary  = {
+		NL_THREADINGTYPE_SINGLE,
+		NL_CONNECTIONTYPE_TCPV4,
+		NL_MAXCONNECTIONS_DEFAULT,
 		{-1,8192,8192,16384,1}
 };
 
 // TODO: We currently need a variable global to the module!
-UA_TL_data theTL;
+NL_data theNL;
 
 _Bool connectionComparer(void *p1, void* p2) {
 	UA_TL_connection* c1 = (UA_TL_connection*) p1;
@@ -29,7 +29,7 @@ _Bool connectionComparer(void *p1, void* p2) {
 	return (c1->connectionHandle == c2->connectionHandle);
 }
 
-int UA_TL_TCP_SetNonBlocking(int sock) {
+int NL_TCP_SetNonBlocking(int sock) {
 	int opts = fcntl(sock,F_GETFL);
 	if (opts < 0) {
 		perror("fcntl(F_GETFL)");
@@ -45,18 +45,18 @@ int UA_TL_TCP_SetNonBlocking(int sock) {
 
 /** the tcp reader thread - single shot if single-threaded, looping until CLOSE if multi-threaded
  */
-void* UA_TL_TCP_reader(UA_TL_connection *c) {
+void* NL_TCP_reader(UA_TL_connection *c) {
 
 	UA_ByteString readBuffer;
 	UA_alloc((void**)&(readBuffer.data),c->localConf.recvBufferSize);
 
 	if (c->connectionState != connectionState_CLOSE) {
 		do {
-			printf("UA_TL_TCP_reader - enter read\n");
+			printf("NL_TCP_reader - enter read\n");
 			readBuffer.length = read(c->connectionHandle, readBuffer.data, c->localConf.recvBufferSize);
-			printf("UA_TL_TCP_reader - leave read\n");
+			printf("NL_TCP_reader - leave read\n");
 
-			printf("UA_TL_TCP_reader - %*.s ",c->remoteEndpointUrl.length,c->remoteEndpointUrl.data);
+			printf("NL_TCP_reader - %*.s ",c->remoteEndpointUrl.length,c->remoteEndpointUrl.data);
 			UA_ByteString_printx("received=",&readBuffer);
 
 			if (readBuffer.length  > 0) {
@@ -65,27 +65,26 @@ void* UA_TL_TCP_reader(UA_TL_connection *c) {
 				c->connectionState = connectionState_CLOSE;
 				perror("ERROR reading from socket1");
 			}
-		} while (c->connectionState != connectionState_CLOSE && theTL.threaded == UA_STACK_MULTITHREADED);
+		} while (c->connectionState != connectionState_CLOSE && theNL.threaded == NL_THREADINGTYPE_PTHREAD);
 	}
 	if (c->connectionState == connectionState_CLOSE) {
 		// clean up: socket, buffer, connection
 		// free resources allocated with socket
-		if (theTL.threaded == UA_STACK_SINGLETHREADED) {
+		if (theNL.threaded == NL_THREADINGTYPE_SINGLE) {
 			printf("UA_TL_TCP_reader - remove handle=%d from fd_set\n",c->connectionHandle);
 			// FD_CLR(c->connectionHandle,&(theTL.readerHandles));
 		}
-		printf("UA_TL_TCP_reader - shutdown\n");
-		printf("UA_TL_TCP_reader - enter shutdown\n");
+		printf("NL_TCP_reader - enter shutdown\n");
 		shutdown(c->connectionHandle,2);
-		printf("UA_TL_TCP_reader - enter close\n");
+		printf("NL_TCP_reader - enter close\n");
 		close(c->connectionHandle);
-		printf("UA_TL_TCP_reader - leave close\n");
+		printf("NL_TCP_reader - leave close\n");
 		c->connectionState = connectionState_CLOSED;
 
 		UA_ByteString_deleteMembers(&readBuffer);
-		printf("UA_TL_TCP_reader - search element to remove\n");
-		UA_list_Element* lec = UA_list_search(&theTL.connections,connectionComparer,c);
-		printf("UA_TL_TCP_reader - remove handle=%d\n",((UA_TL_connection*)lec->payload)->connectionHandle);
+		printf("NL_TCP_reader - search element to remove\n");
+		UA_list_Element* lec = UA_list_search(&theNL.connections,connectionComparer,c);
+		printf("NL_TCP_reader - remove handle=%d\n",((UA_TL_connection*)lec->payload)->connectionHandle);
 		UA_list_removeElement(lec,UA_NULL);
 		UA_free(c);
 	}
@@ -93,15 +92,15 @@ void* UA_TL_TCP_reader(UA_TL_connection *c) {
 }
 
 /** write to a tcp transport layer connection */
-UA_Int32 UA_TL_TCP_writer(struct T_TL_connection* c, UA_ByteString* msg) {
+UA_Int32 NL_TCP_writer(struct T_TL_connection* c, UA_ByteString* msg) {
 	UA_ByteString_printx("write data:", msg);
 	int nWritten = 0;
 	while (nWritten < msg->length) {
 		int n=0;
 		do {
-			printf("UA_TL_TCP_write - enter write\n");
+			printf("NL_TCP_writer - enter write\n");
 			n = write(c->connectionHandle, &(msg->data[nWritten]), msg->length-nWritten);
-			printf("UA_TL_TCP_write - leave write with n=%d,errno=%d\n",n,errno);
+			printf("NL_TCP_writer - leave write with n=%d,errno=%d\n",n,errno);
 		} while (n == -1L && errno == EINTR);
 		if (n >= 0) {
 			nWritten += n;
@@ -115,88 +114,78 @@ UA_Int32 UA_TL_TCP_writer(struct T_TL_connection* c, UA_ByteString* msg) {
 /** the tcp listener routine.
  *  does a single shot if single threaded, runs forever if multithreaded
  */
-void* UA_TL_TCP_listen(void *p) {
-	UA_TL_data* tld = (UA_TL_data*) p;
+void* NL_TCP_listen(void *p) {
+	NL_data* tld = (NL_data*) p;
 
 	UA_String_printf("open62541-server at ",&(tld->endpointUrl));
 	do {
-		printf("UA_TL_TCP_listen - enter listen\n");
+		printf("NL_TCP_listen - enter listen\n");
 		int retval = listen(tld->listenerHandle, tld->tld->maxConnections);
-		printf("UA_TL_TCP_listen - leave listen, retval=%d\n",retval);
+		printf("NL_TCP_listen - leave listen, retval=%d\n",retval);
 
 		if (retval < 0) {
 			// TODO: Error handling
-			printf("UA_TL_TCP_listen retval=%d, errno=%d\n",retval,errno);
+			printf("NL_TCP_listen retval=%d, errno=%d\n",retval,errno);
 		} else if (tld->tld->maxConnections == -1 || tld->connections.size < tld->tld->maxConnections) {
 			// accept only if not max number of connections exceede
 			struct sockaddr_in cli_addr;
 			socklen_t cli_len = sizeof(cli_addr);
-			printf("UA_TL_TCP_listen - enter accept\n");
+			printf("NL_TCP_listen - enter accept\n");
 			int newsockfd = accept(tld->listenerHandle, (struct sockaddr *) &cli_addr, &cli_len);
-			printf("UA_TL_TCP_listen - leave accept\n");
+			printf("NL_TCP_listen - leave accept\n");
 			if (newsockfd < 0) {
 				printf("UA_TL_TCP_listen - accept returns errno=%d\n",errno);
 				perror("ERROR on accept");
 			} else {
-				printf("UA_TL_TCP_listen - new connection on %d\n",newsockfd);
+				printf("NL_TCP_listen - new connection on %d\n",newsockfd);
 				UA_TL_connection* c;
 				UA_Int32 retval = UA_SUCCESS;
 				retval |= UA_alloc((void**)&c,sizeof(UA_TL_connection));
 				TL_Connection_init(c, tld);
 				c->connectionHandle = newsockfd;
-				c->writerCallback = UA_TL_TCP_writer;
-				c->readerCallback = UA_TL_TCP_reader;
+				c->writerCallback = NL_TCP_writer;
+				c->readerCallback = NL_TCP_reader;
 				// add to list
 				UA_list_addPayloadToBack(&(tld->connections),c);
-				if (tld->threaded == UA_STACK_MULTITHREADED) {
+				if (tld->threaded == NL_THREADINGTYPE_PTHREAD) {
 					// TODO: handle retval of pthread_create
-					pthread_create( &(c->readerThread), NULL, (void*(*)(void*)) UA_TL_TCP_reader, (void*) c);
+					pthread_create( &(c->readerThread), NULL, (void*(*)(void*)) NL_TCP_reader, (void*) c);
 				} else {
-					UA_TL_TCP_SetNonBlocking(c->connectionHandle);
+					NL_TCP_SetNonBlocking(c->connectionHandle);
 				}
 			}
 		} else {
 			// no action necessary to reject connection
 		}
-	} while (tld->threaded == UA_STACK_MULTITHREADED);
+	} while (tld->threaded == NL_THREADINGTYPE_PTHREAD);
 	return UA_NULL;
 }
 
-void checkFdSet(void* payload) {
-  UA_TL_connection* c = (UA_TL_connection*) payload;
-  if (FD_ISSET(c->connectionHandle, &(theTL.readerHandles))) {
-	  c->readerCallback((void*)c);
-  }
-}
 
 int maxHandle;
-void UA_TL_addHandleToSet(UA_Int32 handle) {
-	FD_SET(handle, &(theTL.readerHandles));
+void NL_addHandleToSet(UA_Int32 handle) {
+	FD_SET(handle, &(theNL.readerHandles));
 	maxHandle = (handle > maxHandle) ? handle : maxHandle;
 }
-void setFdSet(void* payload) {
+void NL_setFdSet(void* payload) {
   UA_TL_connection* c = (UA_TL_connection*) payload;
-  UA_TL_addHandleToSet(c->connectionHandle);
+  NL_addHandleToSet(c->connectionHandle);
 }
-
-
-UA_Int32 UA_Stack_addReaderHandle(UA_Int32 handle, UA_TL_reader reader) {
-	UA_Int32 retval = UA_SUCCESS;
-	UA_TL_connection* c;
-	retval = UA_alloc((void**)&c,sizeof(UA_TL_connection));
-	c->connectionHandle = handle;
-	c->connectionState = connectionState_ESTABLISHED;
-	c->readerCallback = reader;
-	return retval;
+void NL_checkFdSet(void* payload) {
+  UA_TL_connection* c = (UA_TL_connection*) payload;
+  if (FD_ISSET(c->connectionHandle, &(theNL.readerHandles))) {
+	  c->readerCallback((void*)c);
+  }
 }
 
-UA_Int32 UA_Stack_msgLoop(struct timeval *tv, UA_Int32(*worker)(void*), void *arg)  {
+
+UA_Int32 NL_msgLoop(struct timeval *tv, UA_Int32(*worker)(void*), void *arg)  {
 	UA_Int32 result;
 	while (UA_TRUE) {
 		// determine the largest handle
 		maxHandle = 0;
-		UA_list_iteratePayload(&theTL.connections,setFdSet);
-		UA_TL_addHandleToSet(theTL.listenerHandle);
+		UA_list_iteratePayload(&theNL.connections,NL_setFdSet);
+		NL_addHandleToSet(theNL.listenerHandle);
 		printf("UA_Stack_msgLoop - maxHandle=%d\n", maxHandle);
 
 		// copy tv, some unixes do overwrite and return the remaining time
@@ -205,7 +194,7 @@ UA_Int32 UA_Stack_msgLoop(struct timeval *tv, UA_Int32(*worker)(void*), void *ar
 
 		// and wait
 		printf("UA_Stack_msgLoop - enter select sec=%d,usec=%d\n",(UA_Int32) tmptv.tv_sec, (UA_Int32) tmptv.tv_usec);
-		result = select(maxHandle + 1, &(theTL.readerHandles), UA_NULL, UA_NULL,&tmptv);
+		result = select(maxHandle + 1, &(theNL.readerHandles), UA_NULL, UA_NULL,&tmptv);
 		printf("UA_Stack_msgLoop - leave select result=%d,sec=%d,usec=%d\n",result, (UA_Int32) tmptv.tv_sec, (UA_Int32) tmptv.tv_usec);
 		if (result == 0) {
 			int err = errno;
@@ -225,18 +214,18 @@ UA_Int32 UA_Stack_msgLoop(struct timeval *tv, UA_Int32(*worker)(void*), void *ar
 				printf("UA_Stack_msgLoop - result=%d\n",err);
 				worker(arg);
 			}
-		} else if (FD_ISSET(theTL.listenerHandle,&theTL.readerHandles)) { // activity on listener port
+		} else if (FD_ISSET(theNL.listenerHandle,&theNL.readerHandles)) { // activity on listener port
 			printf("UA_Stack_msgLoop - connection request\n");
-			UA_TL_TCP_listen((void*)&theTL);
+			NL_TCP_listen((void*)&theNL);
 		} else { // activity on client ports
 			printf("UA_Stack_msgLoop - activities on %d handles\n",result);
-			UA_list_iteratePayload(&theTL.connections,checkFdSet);
+			UA_list_iteratePayload(&theNL.connections,NL_checkFdSet);
 		}
 	}
 	return UA_SUCCESS;
 }
 
-UA_Int32 UA_TL_TCP_init(UA_TL_data* tld, UA_Int32 port) {
+UA_Int32 NL_TCP_init(NL_data* tld, UA_Int32 port) {
 	UA_Int32 retval = UA_SUCCESS;
 	// socket variables
 	int optval = 1;
@@ -271,34 +260,41 @@ UA_Int32 UA_TL_TCP_init(UA_TL_data* tld, UA_Int32 port) {
 	}
 	// finally
 	if (retval == UA_SUCCESS) {
-		if (tld->threaded == UA_STACK_MULTITHREADED) {
+		if (tld->threaded == NL_THREADINGTYPE_PTHREAD) {
 			// TODO: handle retval of pthread_create
-			pthread_create( &tld->listenerThreadHandle, NULL, UA_TL_TCP_listen, (void*) tld);
+			pthread_create( &tld->listenerThreadHandle, NULL, NL_TCP_listen, (void*) tld);
 		} else {
-			UA_TL_TCP_SetNonBlocking(tld->listenerHandle);
+			NL_TCP_SetNonBlocking(tld->listenerHandle);
 			FD_ZERO(&(tld->readerHandles));
 		}
 	}
 	return retval;
 }
 
+UA_Int32 TL_Connection_init(UA_TL_connection* c, NL_data* tld)
+{
+	c->connectionHandle = -1;
+	c->connectionState = connectionState_CLOSED;
+	c->readerThread = -1;
+	c->writerCallback = UA_NULL;
+	c->readerCallback = UA_NULL;
+	memcpy(&(c->localConf),&(tld->tld->localConf),sizeof(TL_buffer));
+	memset(&(c->remoteConf),0,sizeof(TL_buffer));
+	UA_String_copy(&(tld->endpointUrl), &(c->localEndpointUrl));
+	return UA_SUCCESS;
+}
+
+
 /** checks arguments and dispatches to worker or refuses to init */
-UA_Int32 UA_TL_init(UA_TL_Description* tlDesc, UA_Int32 port, UA_Int32 threaded) {
+UA_Int32 NL_init(NL_Description* tlDesc, UA_Int32 port, UA_Int32 threaded) {
 	UA_Int32 retval = UA_SUCCESS;
-	if (tlDesc->connectionType == UA_TL_CONNECTIONTYPE_TCPV4 && tlDesc->encoding == UA_TL_ENCODING_BINARY) {
-		theTL.tld = tlDesc;
-		theTL.threaded = threaded;
-		UA_list_init(&theTL.connections);
-		retval |= UA_TL_TCP_init(&theTL,port);
+	if (tlDesc->connectionType == NL_CONNECTIONTYPE_TCPV4 && tlDesc->encoding == NL_UA_ENCODING_BINARY) {
+		theNL.tld = tlDesc;
+		theNL.threaded = threaded;
+		UA_list_init(&theNL.connections);
+		retval |= NL_TCP_init(&theNL,port);
 	} else {
 		retval = UA_ERR_NOT_IMPLEMENTED;
 	}
 	return retval;
 }
-
-/** checks arguments and dispatches to worker or refuses to init */
-UA_Int32 UA_Stack_init(UA_TL_Description* tlDesc, UA_Int32 port, UA_Int32 threaded) {
-	UA_Int32 retval = UA_SUCCESS;
-	retval = UA_TL_init(tlDesc,port,threaded);
-	return retval;
-}

+ 55 - 0
examples/src/networklayer.h

@@ -0,0 +1,55 @@
+/*
+ * networklayer.h
+ *
+ *  Created on: 04.04.2014
+ *      Author: mrt
+ */
+
+#ifndef NETWORKLAYER_H_
+#define NETWORKLAYER_H_
+
+#include "opcua.h"
+#include "ua_connection.h"
+#include "ua_list.h"
+
+#include <pthread.h> // pthreadcreate, pthread_t
+#include <sys/select.h> // FD_ZERO, FD_SET
+
+#define NL_MAXCONNECTIONS_DEFAULT 10
+
+enum NL_UA_ENCODING_enum {
+	NL_UA_ENCODING_BINARY = 0,
+	NL_UA_ENCODING_XML = 1,
+};
+enum NL_CONNECTIONTYPE_enum {
+	NL_CONNECTIONTYPE_TCPV4 = 0,
+	NL_CONNECTIONTYPE_TCPV6 = 1,
+};
+typedef struct T_NL_Description {
+	UA_Int32 encoding;
+	UA_Int32 connectionType;
+	UA_Int32 maxConnections;
+	TL_buffer localConf;
+} NL_Description;
+
+extern NL_Description NL_Description_TcpBinary;
+
+enum NL_THREADINGTYPE_enum {
+	NL_THREADINGTYPE_SINGLE = 0,
+	NL_THREADINGTYPE_PTHREAD = 1,
+};
+
+typedef struct T_NL_data {
+	NL_Description* tld;
+	UA_String endpointUrl;
+	int listenerHandle;
+	pthread_t listenerThreadHandle;
+	UA_list_List connections;
+	UA_Int32 threaded;	// NL_THREADINGTYPE_enum
+	fd_set readerHandles;
+} NL_data;
+
+
+UA_Int32 NL_init(NL_Description* tlDesc, UA_Int32 port, UA_Int32 threaded);
+UA_Int32 NL_msgLoop(struct timeval* tv,UA_Int32 (*timeoutCallBack)(void*),void *arg);
+#endif /* NETWORKLAYER_H_ */

+ 3 - 4
examples/src/opcuaServer.c

@@ -11,8 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "ua_stack.h"
-#include <pthread.h> // to get the type for the
+#include "networklayer.h"
 
 UA_Int32 serverCallback(void * arg) {
 	char *name = (char *) arg;
@@ -28,6 +27,6 @@ int pthread_create(pthread_t* newthread, const pthread_attr_t* attr, void *(*sta
 
 int main(int argc, char** argv) {
 	struct timeval tv = {2, 0}; // 2 seconds
-	UA_Stack_init(&UA_TransportLayerDescriptorTcpBinary,16664,UA_STACK_SINGLETHREADED);
-	UA_Stack_msgLoop(&tv,serverCallback,argv[0]);
+	NL_init(&NL_Description_TcpBinary,16664,NL_THREADINGTYPE_SINGLE);
+	NL_msgLoop(&tv,serverCallback,argv[0]);
 }

+ 5 - 2
examples/src/opcuaServerACPLT.c

@@ -13,6 +13,7 @@
 #include <memory.h> // bzero
 
 #include "opcua.h"
+#include "ua_connection.h"
 
 #ifdef LINUX
 
@@ -53,10 +54,12 @@ typedef struct T_Server {
 } Server;
 
 Server server;
-void server_writer(UA_TL_connection connection, UA_ByteString* msg) {
+UA_Int32 server_writer(UA_TL_connection* connection, UA_ByteString* msg) {
 	UA_ByteString_copy(msg,&server.writeData);
 	server.newDataToWrite = 1;
+	return UA_SUCCESS;
 }
+
 void server_run() {
 
 	UA_TL_connection connection;
@@ -124,7 +127,7 @@ void server_run() {
 			if (n > 0) {
 				slMessage.data = buffer;
 				slMessage.length = n;
-				UA_ByteString_printx("server_run - received=",slMessage);
+				UA_ByteString_printx("server_run - received=",&slMessage);
 				TL_process(&connection, &slMessage);
 			} else if (n < 0) {
 				perror("ERROR reading from socket1");

+ 2 - 2
examples/src/opcuaServerMT.c

@@ -11,11 +11,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "ua_stack.h"
+#include "networklayer.h"
 
 
 int main(int argc, char** argv) {
-	UA_Stack_init(&UA_TransportLayerDescriptorTcpBinary,16664,UA_STACK_MULTITHREADED);
+	NL_init(&NL_Description_TcpBinary,16664,NL_THREADINGTYPE_PTHREAD);
 	while (UA_TRUE) {
 		printf("%s does whatever servers do\n",argv[0]);
 		sleep(2);

+ 0 - 54
include/ua_stack.h

@@ -1,54 +0,0 @@
-/*
- * ua_stack.h
- *
- *  Created on: 04.04.2014
- *      Author: mrt
- */
-
-#ifndef UA_STACK_H_
-#define UA_STACK_H_
-
-#include "opcua.h"
-#include "ua_connection.h"
-#include "ua_list.h"
-
-#include <pthread.h> // pthreadcreate, pthread_t
-#include <sys/select.h> // FD_ZERO, FD_SET
-
-#define UA_TL_MAXCONNECTIONS_DEFAULT 10
-
-enum UA_TRANSPORTLAYERDESCRIPTION_ENCODING_enum {
-	UA_TL_ENCODING_BINARY = 0,
-	UA_TL_ENCODING_XML = 1,
-};
-enum UA_TRANSPORTLAYERDESCRIPTION_CONNECTION_enum {
-	UA_TL_CONNECTIONTYPE_TCPV4 = 0,
-	UA_TL_CONNECTIONTYPE_TCPV6 = 1,
-};
-typedef struct T_UA_TL_Description {
-	UA_Int32 encoding;
-	UA_Int32 connectionType;
-	UA_Int32 maxConnections;
-	TL_buffer localConf;
-} UA_TL_Description;
-
-extern UA_TL_Description UA_TransportLayerDescriptorTcpBinary;
-
-typedef struct T_UA_TL_data {
-	UA_TL_Description* tld;
-	UA_String endpointUrl;
-	int listenerHandle;
-	pthread_t listenerThreadHandle;
-	UA_list_List connections;
-	UA_Int32 threaded;
-	fd_set readerHandles;
-} UA_TL_data;
-
-enum UA_STACK_THREADS_enum {
-	UA_STACK_SINGLETHREADED = 0,
-	UA_STACK_MULTITHREADED = 1,
-};
-
-UA_Int32 UA_Stack_init(UA_TL_Description* tlDesc, UA_Int32 port, UA_Int32 threaded);
-UA_Int32 UA_Stack_msgLoop(struct timeval* tv,UA_Int32 (*timeoutCallBack)(void*),void *arg);
-#endif /* UA_STACK_H_ */

+ 1 - 2
src/Makefile.am

@@ -62,8 +62,7 @@ libopen62541_la_SOURCES = opcua.c\
 						ua_secureLayer.c\
 						util/ua_list.c\
 						util/ua_indexedList.c\
-						ua_namespace.c\
-						ua_stack.c
+						ua_namespace.c
 						
 						
 

+ 0 - 14
src/ua_transportLayer.c

@@ -1,23 +1,9 @@
 #include <memory.h> // memset, memcpy
-#include "ua_stack.h"
 #include "ua_connection.h"
 #include "ua_transportLayer.h"
 
 #include "ua_secureLayer.h" // SL_process
 
-UA_Int32 TL_Connection_init(UA_TL_connection* c, UA_TL_data* tld)
-{
-	c->connectionHandle = -1;
-	c->connectionState = connectionState_CLOSED;
-	c->readerThread = -1;
-	c->writerCallback = UA_NULL;
-	c->readerCallback = UA_NULL;
-	memcpy(&(c->localConf),&(tld->tld->localConf),sizeof(TL_buffer));
-	memset(&(c->remoteConf),0,sizeof(TL_buffer));
-	UA_String_copy(&(tld->endpointUrl), &(c->localEndpointUrl));
-	return UA_SUCCESS;
-}
-
 UA_Int32 TL_check(UA_TL_connection* connection, UA_ByteString* msg, int checkLocal)
 {
 	UA_Int32 retval = UA_SUCCESS;

+ 0 - 3
src/ua_transportLayer.h

@@ -10,7 +10,6 @@
 #include <stdio.h>
 
 #include "opcua.h"
-#include "ua_stack.h"
 #include "ua_connection.h"
 #include "ua_stackInternalTypes.h"
 
@@ -104,6 +103,4 @@ UA_Int32 TL_getPacketType(UA_ByteString *packet, UA_Int32 *pos);
 UA_Int32 TL_process(UA_TL_connection *connection, UA_ByteString *packet);
 
 
-UA_Int32 TL_Connection_init(UA_TL_connection *c, UA_TL_data* tld);
-
 #endif /* OPCUA_TRANSPORTLAYER_H_ */