Pārlūkot izejas kodu

added support for session - not implemented yet

FlorianPalm 10 gadi atpakaļ
vecāks
revīzija
7647f984de

+ 2 - 1
examples/src/networklayer.c

@@ -11,7 +11,7 @@
 #include <fcntl.h> // fcntl
 
 #include "networklayer.h"
-
+#include "ua_transport_connection.h"
 NL_Description NL_Description_TcpBinary  = {
 	NL_UA_ENCODING_BINARY,
 	NL_CONNECTIONTYPE_TCPV4,
@@ -116,6 +116,7 @@ void* NL_TCP_reader(NL_Connection *c) {
 	UA_ByteString readBuffer;
 
 	TL_Buffer localBuffers;
+
 	UA_UInt32 connectionId;
 	UA_TL_Connection_getLocalConfiguration(c->connection, &localBuffers);
 	UA_TL_Connection_getId(c->connection, &connectionId);

+ 1 - 0
examples/src/opcuaServerACPLT.c

@@ -7,6 +7,7 @@
 #include "ua_transport_binary.h"
 #include "networklayer.h"
 #include "ua_stack_channel_manager.h"
+#include "ua_transport_connection.h"
 
 #ifdef LINUX
 

+ 2 - 1
src/ua_stack_channel.c

@@ -270,7 +270,8 @@ UA_Int32 SL_Channel_initByRequest(SL_secureChannel channel,
 
 UA_Int32 SL_Channel_delete(SL_secureChannel channel)
 {
-	//TODO implement me!
+	//TODO implement me
+	//((SL_Channel1*)channel)->
 	return UA_SUCCESS;
 }
 

+ 26 - 0
src/ua_stack_session.c

@@ -0,0 +1,26 @@
+/*
+ * ua_stack_session.c
+ *
+ *  Created on: 05.06.2014
+ *      Author: root
+ */
+
+
+#include "ua_stack_session.h"
+typedef struct UA_SessionType
+{
+	UA_NodeId authenticationToken;
+	UA_NodeId sessionId;
+	void *applicationPayload;
+	Application *application;
+}UA_SessionType;
+
+
+UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2)
+{
+	if(session1 && session2)
+	{
+		return (UA_Guid_compare(((UA_SessionType*)session1)->sessionId.identifier,((UA_SessionType*)session2)->sessionId.identifier) == 0);
+	}
+	return UA_FALSE;
+}

+ 22 - 0
src/ua_stack_session.h

@@ -0,0 +1,22 @@
+/*
+ * ua_stack_session.h
+ *
+ *  Created on: 05.06.2014
+ *      Author: root
+ */
+
+#ifndef UA_STACK_SESSION_H_
+#define UA_STACK_SESSION_H_
+
+#include "include/opcua.h"
+
+
+#endif /* UA_STACK_SESSION_H_ */
+
+
+
+typedef UA_SessionType *UA_Session;
+
+
+UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2);
+

+ 41 - 0
src/ua_stack_session_manager.c

@@ -5,6 +5,47 @@
  *      Author: root
  */
 
+#include "ua_stack_session_manager.h"
 
 
+typedef struct UA_SessionManagerType
+{
+	UA_list_List *sessions;
 
+
+	UA_UInt32 maxSessionCount;
+	UA_Int32 lastSessionId;
+	UA_UInt32 currentSessionCount;
+	UA_DateTime maxSessionLifeTime;
+
+	UA_DateTime sessionLifetime;
+}UA_SessionManagerType;
+
+static UA_SessionManagerType *sessionManager;
+UA_Int32 UA_SessionManager_init(UA_UInt32 maxSessionCount,UA_UInt32 sessionLifetime, UA_UInt32 startSessionId)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	retval |= UA_alloc((void**)&sessionManager,sizeof(UA_SessionManagerType));
+	sessionManager->maxSessionCount = maxSessionCount;
+	sessionManager->lastSessionId = startSessionId;
+	sessionManager->sessionLifetime = sessionLifetime;
+	return retval;
+}
+UA_Int32 UA_SessionManager_addSession(UA_Session *session)
+{
+
+
+	if(UA_SessionManager_getSession())
+	UA_list_addElementToBack(sessionManager->sessions,session);
+}
+UA_Int32 UA_SessionManager_removeSession(UA_Int32 channelId);
+
+UA_Int32 UA_SessionManager_getSession(UA_UInt32 sessionId, UA_Session *session);
+
+UA_Int32 UA_SessionManager_updateSessions();
+
+UA_Int32 UA_SessionManager_getSessionLifeTime(UA_DateTime *lifeTime);
+
+UA_Int32 SL_UA_SessionManager_generateToken(SL_secureChannel channel, UA_Int32 requestedLifeTime, SecurityTokenRequestType requestType, UA_ChannelSecurityToken* newToken);
+
+UA_Int32 SL_UA_SessionManager_generateSessionId(UA_UInt32 *newChannelId);

+ 19 - 0
src/ua_stack_session_manager.h

@@ -8,8 +8,27 @@
 #ifndef UA_STACK_SESSION_MANAGER_H_
 #define UA_STACK_SESSION_MANAGER_H_
 
+#include "include/opcua.h"
+#include "include/ua_list.h"
+#include "ua_stack_session.h"
 
 
 
+//hide internal data of channelManager
+typedef struct UA_SessionManagerType *UA_SessionManager;
+
+
+UA_Int32 UA_SessionManager_init(UA_UInt32 maxSessionCount,UA_UInt32 tokenLifetime, UA_UInt32 startChannelId, UA_UInt32 startTokenId, UA_String *endpointUrl);
+UA_Int32 UA_SessionManager_addSession(SL_secureChannel *channel);
+UA_Int32 UA_SessionManager_removeSession(UA_Int32 channelId);
+
+UA_Int32 UA_SessionManager_getSession(UA_UInt32 sessionId, UA_Session *session);
+UA_Int32 UA_SessionManager_updateSessions();
+
+UA_Int32 UA_SessionManager_getSessionLifeTime(UA_DateTime *lifeTime);
+
+UA_Int32 UA_SessionManager_generateToken(SL_secureChannel channel, UA_Int32 requestedLifeTime, SecurityTokenRequestType requestType, UA_ChannelSecurityToken* newToken);
+
+UA_Int32 UA_SessionManager_generateSessionId(UA_UInt32 *newChannelId);
 
 #endif /* UA_STACK_SESSION_MANAGER_H_ */