ua_services_securechannel.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL,
  13. "Opened SecureChannel %i on Connection %i",
  14. response->securityToken.channelId, connection->sockfd);
  15. else
  16. UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL,
  17. "Opening SecureChannel on Connection %i failed", connection->sockfd);
  18. } else {
  19. response->responseHeader.serviceResult =
  20. UA_SecureChannelManager_renew(&server->secureChannelManager, connection, request, response);
  21. if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD)
  22. UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL,
  23. "Renewed SecureChannel %i on Connection %i",
  24. response->securityToken.channelId, connection->sockfd);
  25. else
  26. UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL,
  27. "Renewing SecureChannel on Connection %i failed", connection->sockfd);
  28. }
  29. }
  30. /* The server does not send a CloseSecureChannel response */
  31. void Service_CloseSecureChannel(UA_Server *server, UA_Int32 channelId) {
  32. UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL,
  33. "Closing SecureChannel %i", channelId);
  34. UA_SecureChannelManager_close(&server->secureChannelManager, channelId);
  35. }