Browse Source

More than one client can now browse the server (not Multithreading safe atm)
There is still an issue with the result of compare/equal functions (UA_EQUAL not equal to UA_TRUE...)
which lead to inconsistences

FlorianPalm 10 years ago
parent
commit
8c0c8c8543

+ 1 - 1
examples/src/opcuaServer.c

@@ -39,7 +39,7 @@ int main(int argc, char** argv) {
 
 	struct timeval tv = {1, 0}; // 1 second
 
-	SL_ChannelManager_init(2,3600000, 873, 23, &nl->endpointUrl);
+	SL_ChannelManager_init(6,3600000, 873, 23, &nl->endpointUrl);
 	UA_SessionManager_init(2,30000,5);
 	//UA_TL_ConnectionManager_init(10);
   	NL_msgLoop(nl, &tv, serverCallback, argv[0]);

+ 3 - 3
src/ua_stack_channel.c

@@ -226,11 +226,11 @@ UA_Int32 SL_Channel_setState(SL_Channel channel, SL_channelState channelState) {
 
 
 
-UA_Boolean SL_Channel_equal(SL_Channel channel1, SL_Channel channel2) {
+UA_Boolean SL_Channel_compare(SL_Channel channel1, SL_Channel channel2) {
 	return (((SL_ChannelType*) channel1)->channelId
 			== ((SL_ChannelType*) channel2)->channelId) ?
-	UA_EQUAL :
-															UA_NOT_EQUAL;
+	UA_TRUE :
+															UA_FALSE;
 }
 
 UA_Int32 SL_Channel_bind(SL_Channel channel, UA_TL_Connection connection) {

+ 1 - 1
src/ua_stack_channel.h

@@ -52,7 +52,7 @@ UA_Int32 SL_Channel_checkRequestId(SL_Channel channel, UA_UInt32 requestId);
 
 UA_Int32 SL_Channel_checkSequenceNumber(SL_Channel channel,
 		UA_UInt32 sequenceNumber);
-UA_Boolean SL_Channel_equal(SL_Channel channel1, SL_Channel channel2);
+UA_Boolean SL_Channel_compare(SL_Channel channel1, SL_Channel channel2);
 //getters
 UA_Int32 SL_Channel_getChannelId(SL_Channel channel, UA_UInt32 *channelId);
 UA_Int32 SL_Channel_getTokenId(SL_Channel channel, UA_UInt32 *tokenlId);

+ 15 - 1
src/ua_stack_channel_manager.c

@@ -149,7 +149,7 @@ UA_Int32 SL_ChannelManager_removeChannel(UA_Int32 channelId)
 	UA_Int32 retval = UA_SUCCESS;
 	SL_ChannelManager_getChannel(channelId, &channel);
 
-	UA_list_Element *element =  UA_list_search(&channelManager->channels, (UA_list_PayloadComparer)SL_Channel_equal, &channel);
+	UA_list_Element *element =  UA_list_search(&channelManager->channels, (UA_list_PayloadComparer)SL_Channel_compare, &channel);
 	if(element){
 		retval |= UA_list_removeElement(element,(UA_list_PayloadVisitor)SL_Channel_delete);
 		return retval;
@@ -173,6 +173,10 @@ UA_Int32 SL_ChannelManager_getChannelLifeTime(UA_DateTime *lifeTime)
 UA_Int32 SL_ChannelManager_getChannel(UA_UInt32 channelId, SL_Channel *channel)
 {
 	UA_UInt32 tmpChannelId;
+	if(channelManager==UA_NULL){
+		*channel = UA_NULL;
+		return UA_ERROR;
+	}
  	UA_list_Element* current = channelManager->channels.first;
 	while (current)
 	{
@@ -188,6 +192,16 @@ UA_Int32 SL_ChannelManager_getChannel(UA_UInt32 channelId, SL_Channel *channel)
 		}
 		current = current->next;
 	}
+	SL_Channel c1 = *(SL_Channel*)(channelManager->channels.first->payload);
+	SL_Channel c2 = *(SL_Channel*)(channelManager->channels.last->payload);
+	UA_UInt32 id1,id2;
+
+	SL_Channel_getChannelId(c1,&id1);
+	SL_Channel_getChannelId(c2,&id2);
+
+	printf("SL_ChannelManager_getChannel c1: %i \n",id1);
+	printf("SL_ChannelManager_getChannel c2: %i \n",id2);
+
 	*channel = UA_NULL;
 	return UA_ERROR;
 }

+ 6 - 4
src/ua_stack_session.c

@@ -116,10 +116,12 @@ UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2)
 {
 	if(session1 && session2){
 
-		return UA_NodeId_equal(&((UA_SessionType*)session1)->sessionId,
-				&((UA_SessionType*)session2)->sessionId);
+		if (UA_NodeId_equal(&((UA_SessionType*)session1)->sessionId,
+				&((UA_SessionType*)session2)->sessionId) == UA_EQUAL){
+			return UA_TRUE;
+		}
 	}
-	return UA_NOT_EQUAL;
+	return UA_FALSE;
 }
 
 UA_Boolean UA_Session_compareByToken(UA_Session session, UA_NodeId *token)
@@ -188,7 +190,7 @@ UA_Boolean UA_Session_verifyChannel(UA_Session session, SL_Channel channel)
 {
 	if(session && channel)
 	{
-		if(SL_Channel_equal(((UA_SessionType*)session)->channel, channel) == UA_EQUAL) {
+		if(SL_Channel_compare(((UA_SessionType*)session)->channel, channel) == UA_TRUE) {
 				return UA_TRUE;
 		}
 	}

+ 1 - 1
src/ua_stack_session.h

@@ -41,7 +41,7 @@ UA_Int32 UA_Session_delete(UA_Session *session);
  * @brief compares two session objects
  * @param session1
  * @param session2
- * @return UA_EQUAL if it is the same session, UA_NOT_EQUAL else
+ * @return UA_TRUE if it is the same session, UA_FALSE else
  */
 UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2);
 /**

+ 0 - 2
src/ua_stack_session_manager.c

@@ -11,8 +11,6 @@
 typedef struct UA_SessionManagerType
 {
 	UA_list_List sessions;
-
-
 	UA_UInt32 maxSessionCount;
 	UA_Int32 lastSessionId;
 	UA_UInt32 currentSessionCount;

+ 2 - 0
src/ua_transport_binary_secure.c

@@ -457,6 +457,8 @@ UA_Int32 SL_Process(const UA_ByteString* msg,
 	}
 	else
 	{
+		printf("SL_process - ERROR could not find channel with id: %i \n",
+				secureChannelId);
 		//TODO generate ERROR_Bad_SecureChannelUnkown
 	}