ua_services_securechannel.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "ua_server_internal.h"
  2. #include "ua_services.h"
  3. #include "ua_securechannel_manager.h"
  4. void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection,
  5. const UA_OpenSecureChannelRequest *request,
  6. UA_OpenSecureChannelResponse *response) {
  7. // todo: if(request->clientProtocolVersion != protocolVersion)
  8. if(request->requestType == UA_SECURITYTOKENREQUESTTYPE_ISSUE) {
  9. response->responseHeader.serviceResult =
  10. UA_SecureChannelManager_open(&server->secureChannelManager, connection, request, response);
  11. if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD)
  12. UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
  13. "Connection %i | SecureChannel %i | OpenSecureChannel: Opened SecureChannel",
  14. connection->sockfd, response->securityToken.channelId);
  15. else
  16. UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
  17. "Connection %i | OpenSecureChannel: Opening a SecureChannel failed",
  18. connection->sockfd);
  19. } else {
  20. response->responseHeader.serviceResult =
  21. UA_SecureChannelManager_renew(&server->secureChannelManager, connection, request, response);
  22. if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD)
  23. UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
  24. "Connection %i | SecureChannel %i | OpenSecureChannel: SecureChannel renewed",
  25. connection->sockfd, response->securityToken.channelId);
  26. else
  27. UA_LOG_DEBUG(server->config.logger, UA_LOGCATEGORY_SECURECHANNEL,
  28. "Connection %i | OpenSecureChannel: Renewing SecureChannel failed",
  29. connection->sockfd);
  30. }
  31. }
  32. /* The server does not send a CloseSecureChannel response */
  33. void Service_CloseSecureChannel(UA_Server *server, UA_SecureChannel *channel) {
  34. UA_LOG_INFO_CHANNEL(server->config.logger, channel, "CloseSecureChannel");
  35. UA_SecureChannelManager_close(&server->secureChannelManager, channel->securityToken.channelId);
  36. }