TCPv4TransportDescriptor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_TCPV4_TRANSPORT_DESCRIPTOR_
  15. #define _FASTDDS_TCPV4_TRANSPORT_DESCRIPTOR_
  16. #include <fastdds/rtps/transport/TCPTransportDescriptor.h>
  17. #include <fastdds/rtps/common/Types.h>
  18. namespace eprosima{
  19. namespace fastdds{
  20. namespace rtps{
  21. class TCPTransportInterface;
  22. /**
  23. * Transport configuration
  24. * @ingroup TRANSPORT_MODULE
  25. */
  26. typedef struct TCPv4TransportDescriptor: public TCPTransportDescriptor {
  27. virtual ~TCPv4TransportDescriptor(){}
  28. virtual TransportInterface* create_transport() const override;
  29. fastrtps::rtps::octet wan_addr[4];
  30. void set_WAN_address(fastrtps::rtps::octet o1,fastrtps::rtps::octet o2,fastrtps::rtps::octet o3,fastrtps::rtps::octet o4){
  31. wan_addr[0] = o1;
  32. wan_addr[1] = o2;
  33. wan_addr[2] = o3;
  34. wan_addr[3] = o4;
  35. }
  36. void set_WAN_address(const std::string& in_address)
  37. {
  38. std::stringstream ss(in_address);
  39. int a,b,c,d; //to store the 4 ints
  40. char ch; //to temporarily store the '.'
  41. ss >> a >> ch >> b >> ch >> c >> ch >> d;
  42. wan_addr[0] = (fastrtps::rtps::octet)a;
  43. wan_addr[1] = (fastrtps::rtps::octet)b;
  44. wan_addr[2] = (fastrtps::rtps::octet)c;
  45. wan_addr[3] = (fastrtps::rtps::octet)d;
  46. }
  47. RTPS_DllAPI TCPv4TransportDescriptor();
  48. RTPS_DllAPI TCPv4TransportDescriptor(const TCPv4TransportDescriptor& t);
  49. RTPS_DllAPI TCPv4TransportDescriptor& operator=(const TCPv4TransportDescriptor& t);
  50. } TCPv4TransportDescriptor;
  51. } // namespace rtps
  52. } // namespace fastdds
  53. } // namespace eprosima
  54. #endif // _FASTDDS_TCPV4_TRANSPORT_DESCRIPTOR_