Browse Source

implemnted CloseSecureChannel request handlig, started to work on handling CLoseSessionRequest, relates to #129

Stasik0 10 years ago
parent
commit
9fa13e6e72
3 changed files with 16 additions and 7 deletions
  1. 12 0
      src/server/ua_server_binary.c
  2. 1 3
      src/server/ua_services.h
  3. 3 4
      src/server/ua_services_securechannel.c

+ 12 - 0
src/server/ua_server_binary.c

@@ -230,6 +230,13 @@ static void processMessage(UA_Connection *connection, UA_Server *server, const U
     }
         break;
 
+    //FIXME: Sten handle closeseesionrequests
+    //being curious: our constant gives 471 while clients query for 473
+    /** case UA_CLOSESESSIONREQUEST_NS0: {
+    }
+    break;
+    **/
+
     case UA_READREQUEST_NS0:
         INVOKE_SERVICE(Read);
         break;
@@ -318,6 +325,11 @@ static void processMessage(UA_Connection *connection, UA_Server *server, const U
 static void processClose(UA_Connection *connection, UA_Server *server, const UA_ByteString *msg, UA_UInt32 *pos) {
     // just read in the sequenceheader
 
+    UA_UInt32 secureChannelId;
+    UA_UInt32_decodeBinary(msg, pos, &secureChannelId);
+
+	//the two last parameter is ignored since no answer is needed
+	Service_CloseSecureChannel(server, secureChannelId);
 }
 
 UA_Int32 UA_Server_processBinaryMessage(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg) {

+ 1 - 3
src/server/ua_services.h

@@ -52,9 +52,7 @@ void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
                                UA_OpenSecureChannelResponse *response);
 
 /** @brief This Service is used to terminate a SecureChannel. */
-void Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel,
-                                const UA_CloseSecureChannelRequest *request,
-                                UA_CloseSecureChannelResponse *response);
+void Service_CloseSecureChannel(UA_Server *server, UA_Int32 channelId);
 /** @} */
 
 /**

+ 3 - 4
src/server/ua_services_securechannel.c

@@ -11,9 +11,8 @@ void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
         UA_SecureChannelManager_renew(server->secureChannelManager, connection, request, response);
 }
 
-void Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel,
-                                const UA_CloseSecureChannelRequest *request,
-                                UA_CloseSecureChannelResponse *response) {
-    UA_SecureChannelManager_close(server->secureChannelManager, channel->securityToken.channelId);
+void Service_CloseSecureChannel(UA_Server *server, UA_Int32 channelId) {
+	//Sten: this service is a bit assymmetric to OpenSecureChannel since CloseSecureChannelRequest does not contain any indormation
+    UA_SecureChannelManager_close(server->secureChannelManager, channelId);
     // 62451 Part 6 Chapter 7.1.4 - The server does not send a CloseSecureChannel response
 }