TCPAcceptorSecure.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef _FASTDDS_TCP_ACCEPTOR_SECURE_
  15. #define _FASTDDS_TCP_ACCEPTOR_SECURE_
  16. #include <fastdds/rtps/transport/TCPAcceptor.h>
  17. #include <fastdds/rtps/transport/TCPChannelResourceSecure.h>
  18. #include <asio/ssl.hpp>
  19. namespace eprosima{
  20. namespace fastdds{
  21. namespace rtps{
  22. /**
  23. * TLS TCP Socket acceptor wrapper class.
  24. */
  25. class TCPAcceptorSecure : public TCPAcceptor
  26. {
  27. public:
  28. /**
  29. * Constructor
  30. * @param io_service Reference to the ASIO service.
  31. * @param parent Pointer to the transport that is going to manage the acceptor.
  32. * @param locator Locator with the information about where to accept connections.
  33. */
  34. TCPAcceptorSecure(
  35. asio::io_service& io_service,
  36. TCPTransportInterface* parent,
  37. const fastrtps::rtps::Locator_t& locator);
  38. /**
  39. * Constructor
  40. * @param io_service Reference to the ASIO service.
  41. * @param interface Network interface to bind the socket
  42. * @param locator Locator with the information about where to accept connections.
  43. */
  44. TCPAcceptorSecure(
  45. asio::io_service& io_service,
  46. const std::string& interface,
  47. const fastrtps::rtps::Locator_t& locator);
  48. /**
  49. * Destructor
  50. */
  51. virtual ~TCPAcceptorSecure()
  52. {
  53. acceptor_.cancel();
  54. acceptor_.close();
  55. }
  56. //! Method to start the accepting process.
  57. void accept(
  58. TCPTransportInterface* parent,
  59. asio::ssl::context&);
  60. };
  61. } // namespace rtps
  62. } // namespace fastdds
  63. } // namespace eprosima
  64. #endif // _FASTDDS_TCP_ACCEPTOR_SECURE_