Browse Source

remove appMockup global object.

Julius Pfrommer 10 years ago
parent
commit
69df6e32de

+ 5 - 2
examples/networklayer.c

@@ -26,6 +26,8 @@
 #include <pthread.h>
 #endif
 
+static UA_Server *global_server; // this is bad!!!!
+
 NL_Description NL_Description_TcpBinary  = {
 	NL_UA_ENCODING_BINARY,
 	NL_CONNECTIONTYPE_TCPV4,
@@ -103,9 +105,10 @@ char* strerror(int errno) {
 }
 #endif
 
-UA_Int32 NL_msgLoop(NL_data* nl, struct timeval *tv, UA_Int32(*worker)(void*), void *arg, UA_Boolean *running)  {
+UA_Int32 NL_msgLoop(NL_data* nl, struct timeval *tv, UA_Server *server, UA_Int32(*worker)(void*), void *arg, UA_Boolean *running) {
 	UA_Int32 result;
 	UA_Int32 err;
+	global_server = server;
 	while (*running) {
 		// determine the largest handle
 		nl->maxReaderHandle = 0;
@@ -217,7 +220,7 @@ void* NL_TCP_reader(NL_Connection *c) {
 				UA_NodeId_printf("NL_TCP_reader - Service Type\n",&serviceRequestType);
 			}
 #endif
-			TL_Process((c->connection),&readBuffer);
+			TL_Process((c->connection),global_server, &readBuffer);
 		} else {
 			perror("NL_TCP_reader - ERROR reading from socket");
 			UA_TL_Connection_setState(c->connection, CONNECTIONSTATE_CLOSE);

+ 1 - 1
examples/networklayer.h

@@ -61,7 +61,7 @@ typedef struct NL_Connection {
 
 NL_data* NL_init(NL_Description* tlDesc, UA_Int32 port);
 UA_Int32 NL_Connection_close(UA_TL_Connection *connection);
-UA_Int32 NL_msgLoop(NL_data* nl, struct timeval *tv, UA_Int32(*worker)(void*), void *arg, UA_Boolean *running);
+UA_Int32 NL_msgLoop(NL_data* nl, struct timeval *tv, UA_Server *server, UA_Int32(*worker)(void*), void *arg, UA_Boolean *running);
 UA_Int32 NL_TCP_writer(UA_Int32 connectionHandle, UA_ByteString const * const * gather_buf, UA_UInt32 gather_len);
 
 #endif /* NETWORKLAYER_H_ */

+ 16 - 11
examples/opcuaServer.c

@@ -17,6 +17,9 @@
 #include "ua_channel_manager.h"
 #include "ua_session_manager.h"
 #include "ua_server.h"
+#include "networklayer.h"
+#include "ua_application.h"
+
 
 UA_Boolean running = UA_TRUE;
 
@@ -28,25 +31,27 @@ UA_Int32 serverCallback(void * arg) {
 	char *name = (char *) arg;
 	printf("%s does whatever servers do\n",name);
 
-	Namespace* ns0 = (Namespace*)UA_indexedList_find(appMockup.namespaces, 0)->payload;
-	UA_Int32 retval;
-	const UA_Node * node;
-	UA_ExpandedNodeId serverStatusNodeId; NS0EXPANDEDNODEID(serverStatusNodeId, 2256);
-	retval = Namespace_get(ns0, &serverStatusNodeId.nodeId, &node);
-	if(retval == UA_SUCCESS){
-		((UA_ServerStatusDataType*)(((UA_VariableNode*)node)->value.data))->currentTime = UA_DateTime_now();
-	}
+	/* Namespace* ns0 = (Namespace*)UA_indexedList_find(appMockup.namespaces, 0)->payload; */
+	/* UA_Int32 retval; */
+	/* const UA_Node * node; */
+	/* UA_ExpandedNodeId serverStatusNodeId; NS0EXPANDEDNODEID(serverStatusNodeId, 2256); */
+	/* retval = Namespace_get(ns0, &serverStatusNodeId.nodeId, &node); */
+	/* if(retval == UA_SUCCESS){ */
+	/* 	((UA_ServerStatusDataType*)(((UA_VariableNode*)node)->value.data))->currentTime = UA_DateTime_now(); */
+	/* } */
 
 	return UA_SUCCESS;
 }
 
-
 int main(int argc, char** argv) {
 	UA_Int32 retval;
 	/* gets called at ctrl-c */
 	signal(SIGINT, stopHandler);
+
+	UA_Server server;
+	UA_alloc((void**)&server.application, sizeof(UA_Application));
+	UA_Application_init(server.application);
 	
-	appMockup_init();
 	NL_data* nl = NL_init(&NL_Description_TcpBinary, 16664);
 	UA_String endpointUrl;
 	UA_String_copycstring("no endpoint url",&endpointUrl);
@@ -54,7 +59,7 @@ int main(int argc, char** argv) {
 	UA_SessionManager_init(10,3600000,25);
 	struct timeval tv = {1, 0}; // 1 second
 
-	retval = NL_msgLoop(nl, &tv, serverCallback, argv[0], &running);
+	retval = NL_msgLoop(nl, &tv, &server, serverCallback, argv[0], &running);
 
 	return retval == UA_SUCCESS ? 0 : retval;
 }

+ 5 - 9
src/server/ua_application.c

@@ -6,10 +6,6 @@
 #include <stdlib.h>
 
 UA_indexedList_List nsMockup;
-Application appMockup = {
-		( UA_ApplicationDescription*) UA_NULL,
-		&nsMockup
-};
 
 UA_Node* create_node_ns0(UA_Int32 class, UA_Int32 nodeClass, UA_Int32 const id, char const * qn, char const * dn, char const * desc) {
 	UA_Node* n; UA_.types[class].new((void **)&n);
@@ -23,7 +19,7 @@ UA_Node* create_node_ns0(UA_Int32 class, UA_Int32 nodeClass, UA_Int32 const id,
 	return n;
 }
 
-void appMockup_init() {
+void UA_Application_init(UA_Application *application) {
 	//fill the UA_borrowed_ table that has been declaed in ua_namespace.c
 	for(UA_Int32 i=0;i<SIZE_UA_VTABLE;i++){
 		UA_borrowed_.types[i] = UA_.types[i];
@@ -40,9 +36,9 @@ void appMockup_init() {
 	Namespace_new(&local, 1); //C2UA_STRING("http://localhost:16664/open62541/"));
 
 	// add to list of namespaces
-	UA_indexedList_init(appMockup.namespaces);
-	UA_indexedList_addValueToFront(appMockup.namespaces,0,ns0);
-	UA_indexedList_addValueToFront(appMockup.namespaces,1,local);
+	UA_indexedList_init(application->namespaces);
+	UA_indexedList_addValueToFront(application->namespaces,0,ns0);
+	UA_indexedList_addValueToFront(application->namespaces,1,local);
 
 	/**************/
 	/* References */
@@ -562,7 +558,7 @@ void appMockup_init() {
 	uint32_t i;
 	for (i=0;i < ns0->size;i++) {
 		if (ns0->entries[i].node != UA_NULL) {
-			printf("appMockup_init - entries[%d]={",i);
+			printf("application_init - entries[%d]={",i);
 			UA_Node_print(ns0->entries[i].node, stdout);
 			printf("}\n");
 		}

+ 3 - 4
src/server/ua_application.h

@@ -5,11 +5,10 @@
 #include "ua_namespace.h"
 #include "util/ua_indexedList.h"
 
-typedef struct Application {
+typedef struct UA_Application {
 	UA_ApplicationDescription *description;
 	UA_indexedList_List *namespaces; // each entry is a namespace
-} Application;
+} UA_Application;
 
-extern Application appMockup;
-void appMockup_init();
+void UA_Application_init(UA_Application *application);
 #endif

+ 0 - 6
src/server/ua_server.c

@@ -1,8 +1,2 @@
 #include "ua_server.h"
-#include "ua_application.h"
 
-struct UA_Server {
-	// SL_ChannelManager *cm;
-	// UA_SessionManager sm;
-	Application application;
-};

+ 7 - 1
src/server/ua_server.h

@@ -1,7 +1,13 @@
 #ifndef UA_SERVER_H_
 #define UA_SERVER_H_
 
+#include "ua_application.h"
+
 struct UA_Server;
-typedef struct UA_Server UA_Server;
+typedef struct UA_Server {
+	// SL_ChannelManager *cm;
+	// UA_SessionManager sm;
+	UA_Application *application;
+} UA_Server;
 
 #endif /* UA_SERVER_H_ */

+ 2 - 2
src/server/ua_services.h

@@ -9,7 +9,7 @@
 
 #include "ua_types.h"
 #include "ua_types_generated.h"
-#include "ua_application.h"
+#include "ua_server.h"
 #include "ua_transport_binary_secure.h"
 #include "ua_session_manager.h"
 #include "ua_channel_manager.h"
@@ -80,7 +80,7 @@ UA_Int32 Service_CloseSecureChannel(SL_Channel *channel, const UA_CloseSecureCha
  * logs and in the Server’s address space. The second is the authenticationToken
  * which is used to associate an incoming request with a Session.
  */
-UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response);
+UA_Int32 Service_CreateSession(SL_Channel *channel, UA_Server *server, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response);
 
 /**
  * @brief This Service is used by the Client to submit its SoftwareCertificates

+ 4 - 4
src/server/ua_services_attribute.c

@@ -33,7 +33,7 @@ enum UA_AttributeId {
 		break;													   \
 	}															   \
 
-static UA_DataValue service_read_node(Application *app, const UA_ReadValueId *id) {
+static UA_DataValue service_read_node(UA_Application *app, const UA_ReadValueId *id) {
 	UA_DataValue v;
 	UA_DataValue_init(&v);
 
@@ -224,7 +224,7 @@ static UA_DataValue service_read_node(Application *app, const UA_ReadValueId *id
 }
 UA_Int32 Service_Read(UA_Session *session, const UA_ReadRequest *request,
                       UA_ReadResponse *response) {
-	Application *application = UA_NULL;
+	UA_Application *application = UA_NULL;
 	UA_Int32 readsize;
 	if(session == UA_NULL)
 		return UA_ERROR;
@@ -254,7 +254,7 @@ UA_Int32 Service_Read(UA_Session *session, const UA_ReadRequest *request,
 	return UA_SUCCESS;
 }
 
-UA_Int32 Service_Write_writeNode(Application *app, UA_WriteValue *writeValue, UA_StatusCode *result)
+UA_Int32 Service_Write_writeNode(UA_Application *app, UA_WriteValue *writeValue, UA_StatusCode *result)
 {
 	UA_Int32 retval = UA_SUCCESS;
 	Namespace *ns = UA_indexedList_findValue(app->namespaces, writeValue->nodeId.namespaceIndex);
@@ -408,7 +408,7 @@ UA_Int32 Service_Write(UA_Session *session, const UA_WriteRequest *request,
                       UA_WriteResponse *response) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_Int32 i;
-	Application *application = UA_NULL;
+	UA_Application *application = UA_NULL;
 	UA_Session_getApplicationPointer(session, &application);
 	if(session == UA_NULL || application == UA_NULL)
 		return UA_ERROR;    // TODO: Return error message

+ 2 - 2
src/server/ua_services_nodemanagement.c

@@ -11,7 +11,7 @@
 		goto GOTO; \
 	} } while(0) \
 
-static UA_AddNodesResult addSingleNode(Application *app, UA_AddNodesItem *item) {
+static UA_AddNodesResult addSingleNode(UA_Application *app, UA_AddNodesItem *item) {
 	UA_AddNodesResult result;
 	UA_AddNodesResult_init(&result);
 
@@ -68,7 +68,7 @@ static UA_AddNodesResult addSingleNode(Application *app, UA_AddNodesItem *item)
 
 UA_Int32 Service_AddNodes(UA_Session *session, const UA_AddNodesRequest *request, UA_AddNodesResponse *response) {
 
-	Application *application;
+	UA_Application *application;
 	if(session == UA_NULL)
 		return UA_ERROR;	// TODO: Return error message
 	UA_Session_getApplicationPointer(session,&application);

+ 4 - 9
src/server/ua_services_session.c

@@ -1,8 +1,7 @@
 #include "ua_services.h"
-#include "ua_application.h"
+#include "ua_server.h"
 
-
-UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response) {
+UA_Int32 Service_CreateSession(SL_Channel *channel, UA_Server *server, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response) {
 #ifdef DEBUG
 	UA_String_printf("CreateSession Service - endpointUrl=", &(request->endpointUrl));
 #endif
@@ -12,6 +11,7 @@ UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionReques
 	UA_SessionManager_getSessionTimeout(&timeout);
 	UA_Session_new(&newSession);
 	//TODO get maxResponseMessageSize
+	UA_Session_setApplicationPointer(newSession, server->application); // todo: select application according to the endpointurl in the request
 	UA_Session_init(newSession, (UA_String*)&request->sessionName,
 	request->requestedSessionTimeout,
 	request->maxResponseMessageSize,
@@ -27,13 +27,8 @@ UA_Int32 Service_CreateSession(SL_Channel *channel, const UA_CreateSessionReques
 	return UA_SUCCESS;
 }
 
-UA_Int32 Service_ActivateSession(SL_Channel *channel, UA_Session *session,
-		const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response)
-{
-
+UA_Int32 Service_ActivateSession(SL_Channel *channel, UA_Session *session, const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response) {
 	UA_Session_bind(session, channel);
-
-	UA_Session_setApplicationPointer(session, &appMockup);
 #ifdef DEBUG
 	UA_NodeId_printf("ActivateSession - authToken=", &(request->requestHeader.authenticationToken));
 	// 321 == AnonymousIdentityToken_Encoding_DefaultBinary

+ 1 - 1
src/server/ua_services_view.c

@@ -186,7 +186,7 @@ static void Service_Browse_getBrowseResult(Namespace *ns, UA_BrowseDescription *
 
 UA_Int32 Service_Browse(UA_Session *session, const UA_BrowseRequest *request, UA_BrowseResponse *response) {
 	UA_Int32 retval = UA_SUCCESS;
-	Application *application;
+	UA_Application *application;
 	if(session == UA_NULL)
 	{
 		return UA_ERROR;

+ 3 - 3
src/ua_session.c

@@ -7,7 +7,7 @@ struct UA_Session {
 	UA_NodeId authenticationToken;
 	UA_NodeId sessionId;
 	UA_String name;
-	Application *application;
+	UA_Application *application;
 //	UA_list_List pendingRequests;
 	SL_Channel *channel;
 	UA_UInt32 maxRequestMessageSize;
@@ -163,7 +163,7 @@ UA_Boolean UA_Session_verifyChannel(UA_Session *session, SL_Channel *channel) {
 	return SL_Channel_compare(session->channel, channel);
 }
 
-UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, Application** application) {
+UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, UA_Application** application) {
 	if(!session) {
 		*application = UA_NULL;
 		return UA_ERROR;
@@ -173,7 +173,7 @@ UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, Application** app
 	return UA_SUCCESS;
 }
 
-UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, Application* application) {
+UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, UA_Application* application) {
 	if(!session)
 		return UA_ERROR;
 

+ 2 - 2
src/ua_session.h

@@ -118,7 +118,7 @@ UA_Int32 UA_Session_getPendingLifetime(UA_Session *session,UA_Double *pendingLif
  * @param application return value
  * @return  error code
  */
-UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, Application** application);
+UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, UA_Application** application);
 
 /**
  * @brief Sets the application pointer to the application
@@ -126,6 +126,6 @@ UA_Int32 UA_Session_getApplicationPointer(UA_Session *session, Application** app
  * @param application return value
  * @return error code
  */
-UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, Application* application);
+UA_Int32 UA_Session_setApplicationPointer(UA_Session *session, UA_Application* application);
 
 #endif /* UA_SESSION_H_ */

+ 1 - 1
src/ua_transport.h

@@ -16,7 +16,7 @@ typedef enum UA_ConnectionState {
 
 typedef struct Session {
 	UA_Int32 sessionId;
-	Application *application;
+	UA_Application *application;
 } Session;
 
 typedef enum SecurityTokenRequestType {

+ 11 - 12
src/ua_transport_binary.c

@@ -4,7 +4,6 @@
 #include "ua_transport.h"
 #include "ua_transport_binary_secure.h"
 
-
 static UA_Int32 TL_handleHello(UA_TL_Connection *connection, const UA_ByteString* msg, UA_UInt32* pos){
 	UA_Int32 retval = UA_SUCCESS;
 	UA_UInt32 tmpPos = 0;
@@ -59,7 +58,7 @@ static UA_Int32 TL_handleHello(UA_TL_Connection *connection, const UA_ByteString
 	return retval;
 }
 
-static UA_Int32 TL_handleOpen(UA_TL_Connection *connection, const UA_ByteString* msg, UA_UInt32* pos) {
+static UA_Int32 TL_handleOpen(UA_TL_Connection *connection, UA_Server *server, const UA_ByteString* msg, UA_UInt32* pos) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_Int32 state;
 	SL_Channel *channel;
@@ -75,12 +74,12 @@ static UA_Int32 TL_handleOpen(UA_TL_Connection *connection, const UA_ByteString*
 			retval |= SL_Channel_new(&newChannel);//just create channel
 			retval |= SL_Channel_init(newChannel, connection,SL_ChannelManager_generateChannelId, SL_ChannelManager_generateToken);
 			retval |= SL_Channel_bind(newChannel,connection);
-			retval |= SL_ProcessOpenChannel(newChannel, msg, pos);
+			retval |= SL_ProcessOpenChannel(newChannel, server, msg, pos);
 			retval |= SL_ChannelManager_addChannel(newChannel);
 			return retval;
 		}
 		// channel already exists, renew token?
-		retval |= SL_ProcessOpenChannel(channel, msg, pos);
+		retval |= SL_ProcessOpenChannel(channel, server, msg, pos);
 		return retval;
 	}else{
 		printf("TL_handleOpen - ERROR: could not create new secureChannel");
@@ -89,25 +88,25 @@ static UA_Int32 TL_handleOpen(UA_TL_Connection *connection, const UA_ByteString*
 	return UA_ERR_INVALID_VALUE;
 }
 
-static UA_Int32 TL_handleMsg(UA_TL_Connection *connection, const UA_ByteString* msg, UA_UInt32* pos) {
+static UA_Int32 TL_handleMsg(UA_TL_Connection *connection, UA_Server *server, const UA_ByteString* msg, UA_UInt32* pos) {
 	UA_Int32 state;
 	UA_TL_Connection_getState(connection,&state);
 	if (state == CONNECTIONSTATE_ESTABLISHED) {
-		return SL_Process(msg, pos);
+		return SL_Process(server, msg, pos);
 	}
 	return UA_ERR_INVALID_VALUE;
 }
 
-static UA_Int32 TL_handleClo(UA_TL_Connection *connection, const UA_ByteString* msg, UA_UInt32* pos) {
+static UA_Int32 TL_handleClo(UA_TL_Connection *connection, UA_Server *server, const UA_ByteString* msg, UA_UInt32* pos) {
 	UA_Int32 retval = UA_SUCCESS;
-	SL_Process(msg,pos);
+	SL_Process(server, msg,pos);
 	// just prepare closing, closing and freeing structures is done elsewhere
 	// UA_TL_Connection_close(connection);
 	UA_TL_Connection_setState(connection, CONNECTIONSTATE_CLOSE);
 	return retval;
 }
 
-UA_Int32 TL_Process(UA_TL_Connection *connection, const UA_ByteString* msg) {
+UA_Int32 TL_Process(UA_TL_Connection *connection, UA_Server *server, const UA_ByteString* msg) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_UInt32 pos = 0;
 	UA_OPCUATcpMessageHeader tcpMessageHeader;
@@ -124,13 +123,13 @@ UA_Int32 TL_Process(UA_TL_Connection *connection, const UA_ByteString* msg) {
 				retval = TL_handleHello(connection, msg, &pos);
 				break;
 			case UA_MESSAGETYPE_OPN:
-				retval = TL_handleOpen(connection, msg, &pos);
+				retval = TL_handleOpen(connection, server, msg, &pos);
 				break;
 			case UA_MESSAGETYPE_MSG:
-				retval = TL_handleMsg(connection, msg, &pos);
+				retval = TL_handleMsg(connection, server, msg, &pos);
 				break;
 			case UA_MESSAGETYPE_CLO:
-				retval = TL_handleClo(connection, msg, &pos);
+				retval = TL_handleClo(connection, server, msg, &pos);
 				break;
 			default: // dispatch processing to secureLayer
 				//Invalid packet was received which could have led to a wrong offset (pos).

+ 2 - 1
src/ua_transport_binary.h

@@ -5,6 +5,7 @@
 
 #include "ua_transport_binary.h"
 #include "ua_transport_connection.h"
+#include "ua_server.h"
 
 //transport errors begin at 1000
 #define UA_ERROR_MULTIPLE_HEL 1000
@@ -35,6 +36,6 @@ typedef struct TL_Connection_T {
 */
 
 UA_Int32 TL_Send(UA_TL_Connection *connection, const UA_ByteString** gather_buf, UA_UInt32 gather_len);
-UA_Int32 TL_Process(UA_TL_Connection *connection, const UA_ByteString* msg);
+UA_Int32 TL_Process(UA_TL_Connection *connection, UA_Server *server, const UA_ByteString* msg);
 
 #endif /* OPCUA_TRANSPORT_BINARY_H_ */

+ 8 - 10
src/ua_transport_binary_secure.c

@@ -148,7 +148,7 @@ static void init_response_header(UA_RequestHeader const * p, UA_ResponseHeader *
 	UA_##TYPE##Response_deleteMembers(&r); \
 
 
-UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
+UA_Int32 SL_handleRequest(SL_Channel *channel, UA_Server *server, const UA_ByteString* msg, UA_UInt32 *pos) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_UInt32 recvOffset = *pos;
 	UA_UInt32 sendOffset = 0;
@@ -181,7 +181,7 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg, UA_UInt
 		responsetype = UA_CLOSESECURECHANNELRESPONSE_NS0;
 	} else if (serviceid == UA_CREATESESSIONREQUEST_NS0) {
 		RESPONSE_PREPARE(CreateSession);
-		Service_CreateSession(channel,&p, &r);
+		Service_CreateSession(channel, server, &p, &r);
 		RESPONSE_CLEANUP(CreateSession);
 		responsetype = UA_CREATESESSIONRESPONSE_NS0;
 	}
@@ -322,7 +322,7 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg, UA_UInt
 	return retval;
 }
 
-UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
+UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, UA_Server *server, const UA_ByteString* msg, UA_UInt32 *pos) {
 	UA_Int32 retval = UA_SUCCESS;
 	UA_SequenceHeader sequenceHeader;
 	UA_AsymmetricAlgorithmSecurityHeader asymHeader;
@@ -331,7 +331,7 @@ UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg, UA
 
 	//init remote security settings from the security header
 	SL_Channel_setRemoteSecuritySettings(channel,&asymHeader,&sequenceHeader);
-	return SL_handleRequest(channel, msg, pos) | retval;
+	return SL_handleRequest(channel, server, msg, pos) | retval;
 }
 
 /* not used anymore */
@@ -341,7 +341,7 @@ UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg, UA
 //	return SL_handleRequest(channel, msg, pos);
 //}
 
-UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos) {
+UA_Int32 SL_Process(UA_Server *server, const UA_ByteString* msg, UA_UInt32* pos) {
 	DBG_VERBOSE(printf("SL_process - entered \n"));
 	UA_UInt32 secureChannelId;
 	UA_UInt32 foundChannelId;
@@ -353,21 +353,19 @@ UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos) {
 	//FIXME: we assume SAS, need to check if AAS or SAS
 	UA_SymmetricAlgorithmSecurityHeader symAlgSecHeader;
 	// if (connection->securityMode == UA_MESSAGESECURITYMODE_NONE) {
-	UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos,
-			&symAlgSecHeader);
+	UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos, &symAlgSecHeader);
 
  	if (SL_ChannelManager_getChannel(secureChannelId, &channel) == UA_SUCCESS) {
 		SL_Channel_getChannelId(channel, &foundChannelId);
 		printf("SL_process - received msg, with channel id: %i \n", foundChannelId);
 
 		//sequence number processing
-		UA_SequenceHeader_decodeBinary(msg, pos,
-				&sequenceHeader);
+		UA_SequenceHeader_decodeBinary(msg, pos, &sequenceHeader);
 		SL_Channel_checkSequenceNumber(channel,sequenceHeader.sequenceNumber);
 		SL_Channel_checkRequestId(channel,sequenceHeader.requestId);
 		//request id processing
 
-		SL_handleRequest(channel, msg, pos);
+		SL_handleRequest(channel, server, msg, pos);
 	} else {
 		printf("SL_process - ERROR could not find channel with id: %i \n",
 				secureChannelId);

+ 5 - 18
src/ua_transport_binary_secure.h

@@ -5,20 +5,9 @@
 #include "ua_transport_binary.h"
 #include "ua_channel.h"
 #include "ua_channel_manager.h"
+#include "ua_server.h"
 
-/*inputs for secure Channel which must be provided once
-endPointUrl
-securityPolicyUrl
-securityMode
-revisedLifetime
-*/
-
-/*inputs for secure Channel Manager which must be provided once
- maxChannelCount
-
- */
-
-UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos);
+UA_Int32 SL_Process(UA_Server *server, const UA_ByteString* msg, UA_UInt32* pos);
 
 /**
  * @brief Wrapper function, to encapsulate handleRequest for openSecureChannel requests
@@ -26,10 +15,8 @@ UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos);
  * @param msg Message which holds the binary encoded request
  * @param pos Position in the message at which the request begins
  * @return Returns UA_SUCCESS if successful executed, UA_ERROR in any other case
-
  */
-UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg,
-		UA_UInt32 *pos);
-UA_Int32 SL_ProcessCloseChannel(SL_Channel *channel, const UA_ByteString* msg,
-		UA_UInt32 *pos);
+UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, UA_Server *server, const UA_ByteString* msg, UA_UInt32 *pos);
+UA_Int32 SL_ProcessCloseChannel(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos);
+
 #endif /* OPCUA_TRANSPORT_BINARY_SECURE_H_ */