Fast DDS  Version 3.6.1.0
Fast DDS
TCPv4TransportDescriptor.hpp
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 
20 #ifndef FASTDDS_RTPS_TRANSPORT__TCPV4TRANSPORTDESCRIPTOR_HPP
21 #define FASTDDS_RTPS_TRANSPORT__TCPV4TRANSPORTDESCRIPTOR_HPP
22 
23 #include <sstream>
24 
25 #include <fastdds/rtps/transport/TCPTransportDescriptor.hpp>
26 #include <fastdds/rtps/common/Types.hpp>
27 
28 namespace eprosima {
29 namespace fastdds {
30 namespace rtps {
31 
41 {
43  virtual ~TCPv4TransportDescriptor() = default;
44 
45  virtual TransportInterface* create_transport() const override;
46 
49 
56  {
57  wan_addr[0] = o1;
58  wan_addr[1] = o2;
59  wan_addr[2] = o3;
60  wan_addr[3] = o4;
61  }
62 
65  const std::string& in_address)
66  {
67  std::stringstream ss(in_address);
68  int a, b, c, d; //to store the 4 ints
69  char ch; //to temporarily store the '.'
70  ss >> a >> ch >> b >> ch >> c >> ch >> d;
75  }
76 
78  std::string get_WAN_address()
79  {
80  std::stringstream ss;
81  ss << static_cast<int>(wan_addr[0]) << "."
82  << static_cast<int>(wan_addr[1]) << "."
83  << static_cast<int>(wan_addr[2]) << "."
84  << static_cast<int>(wan_addr[3]);
85  return ss.str();
86  }
87 
89  FASTDDS_EXPORTED_API TCPv4TransportDescriptor();
90 
92  FASTDDS_EXPORTED_API TCPv4TransportDescriptor(
93  const TCPv4TransportDescriptor& t);
94 
96  FASTDDS_EXPORTED_API TCPv4TransportDescriptor& operator =(
97  const TCPv4TransportDescriptor& t);
98 
100  FASTDDS_EXPORTED_API bool operator ==(
101  const TCPv4TransportDescriptor& t) const;
102 };
103 
104 } // namespace rtps
105 } // namespace fastdds
106 } // namespace eprosima
107 
108 #endif // FASTDDS_RTPS_TRANSPORT__TCPV4TRANSPORTDESCRIPTOR_HPP
Interface against which to implement a transport layer, decoupled from Fast DDS internals.
Definition: TransportInterface.hpp:64
uint8_t octet
Definition: Types.hpp:83
TCP Transport configuration.
Definition: TCPTransportDescriptor.hpp:70
TCPv4 Transport configuration.
Definition: TCPv4TransportDescriptor.hpp:41
FASTDDS_EXPORTED_API TCPv4TransportDescriptor(const TCPv4TransportDescriptor &t)
Copy constructor.
std::string get_WAN_address()
Get the public IP address.
Definition: TCPv4TransportDescriptor.hpp:78
FASTDDS_EXPORTED_API bool operator==(const TCPv4TransportDescriptor &t) const
Comparison operator.
FASTDDS_EXPORTED_API TCPv4TransportDescriptor & operator=(const TCPv4TransportDescriptor &t)
Copy assignment.
fastdds::rtps::octet wan_addr[4]
Public IP address.
Definition: TCPv4TransportDescriptor.hpp:48
FASTDDS_EXPORTED_API TCPv4TransportDescriptor()
Constructor.
void set_WAN_address(const std::string &in_address)
Set the public IP address.
Definition: TCPv4TransportDescriptor.hpp:64
virtual ~TCPv4TransportDescriptor()=default
Destructor.
void set_WAN_address(fastdds::rtps::octet o1, fastdds::rtps::octet o2, fastdds::rtps::octet o3, fastdds::rtps::octet o4)
Set the public IP address.
Definition: TCPv4TransportDescriptor.hpp:51
virtual TransportInterface * create_transport() const override
Factory method pattern.