Fast RTPS  Version 2.1.0
Fast RTPS
IPLocator.h
1 // Copyright 2016 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 IP_LOCATOR_H_
21 #define IP_LOCATOR_H_
22 
23 #include <vector>
24 #include <string>
25 
26 #include <fastdds/rtps/common/Locator.h>
27 
28 namespace eprosima {
29 namespace fastrtps {
30 namespace rtps {
35 class IPLocator
36 {
37  public:
45  RTPS_DllAPI static void createLocator(
46  int32_t kindin,
47  const std::string& address,
48  uint32_t portin,
49  Locator_t& locator);
50 
52  RTPS_DllAPI static bool setIPv4(
53  Locator_t& locator,
54  const unsigned char* addr);
55 
57  RTPS_DllAPI static bool setIPv4(
58  Locator_t& locator,
59  octet o1,
60  octet o2,
61  octet o3,
62  octet o4);
63 
65  RTPS_DllAPI static bool setIPv4(
66  Locator_t& locator,
67  const std::string& ipv4);
68 
70  RTPS_DllAPI static bool setIPv4(
71  Locator_t& destlocator,
72  const Locator_t& origlocator);
73 
75  RTPS_DllAPI static const octet* getIPv4(const Locator_t& locator);
76 
78  RTPS_DllAPI static bool hasIPv4(const Locator_t& locator);
79 
81  RTPS_DllAPI static std::string toIPv4string(const Locator_t& locator);
82 
84  RTPS_DllAPI static bool copyIPv4(
85  const Locator_t& locator,
86  unsigned char* dest);
87 
88  // IPv6
90  RTPS_DllAPI static bool setIPv6(
91  Locator_t& locator,
92  const unsigned char* addr);
93 
95  RTPS_DllAPI static bool setIPv6(
96  Locator_t& locator,
97  uint16_t group0,
98  uint16_t group1,
99  uint16_t group2,
100  uint16_t group3,
101  uint16_t group4,
102  uint16_t group5,
103  uint16_t group6,
104  uint16_t group7);
105 
107  RTPS_DllAPI static bool setIPv6(
108  Locator_t& locator,
109  const std::string& ipv6);
110 
112  RTPS_DllAPI static bool setIPv6(
113  Locator_t& destlocator,
114  const Locator_t& origlocator);
115 
117  RTPS_DllAPI static const octet* getIPv6(const Locator_t& locator);
118 
120  RTPS_DllAPI static bool hasIPv6(const Locator_t& locator);
121 
123  RTPS_DllAPI static std::string toIPv6string(const Locator_t& locator);
124 
126  RTPS_DllAPI static bool copyIPv6(
127  const Locator_t& locator,
128  unsigned char* dest);
129 
131  RTPS_DllAPI static bool ip(
132  Locator_t& locator,
133  const std::string& ip);
134 
136  RTPS_DllAPI static std::string ip_to_string(const Locator_t& locator);
137 
138  // TCP
140  RTPS_DllAPI static bool setLogicalPort(
141  Locator_t& locator,
142  uint16_t port);
143 
145  RTPS_DllAPI static uint16_t getLogicalPort(const Locator_t& locator);
146 
148  RTPS_DllAPI static bool setPhysicalPort(
149  Locator_t& locator,
150  uint16_t port);
151 
153  RTPS_DllAPI static uint16_t getPhysicalPort(const Locator_t& locator);
154 
155  // TCPv4
157  RTPS_DllAPI static bool setWan(
158  Locator_t& locator,
159  octet o1,
160  octet o2,
161  octet o3,
162  octet o4);
163 
165  RTPS_DllAPI static bool setWan(
166  Locator_t& locator,
167  const std::string& wan);
168 
170  RTPS_DllAPI static const octet* getWan(const Locator_t& locator);
171 
173  RTPS_DllAPI static bool hasWan(const Locator_t& locator);
174 
176  RTPS_DllAPI static std::string toWanstring(const Locator_t& locator);
177 
179  RTPS_DllAPI static bool setLanID(
180  Locator_t& locator,
181  const std::string& lanId);
182 
184  RTPS_DllAPI static const octet* getLanID(const Locator_t& locator);
185 
187  RTPS_DllAPI static std::string toLanIDstring(const Locator_t& locator);
188 
190  RTPS_DllAPI static Locator_t toPhysicalLocator(const Locator_t& locator);
191 
193  RTPS_DllAPI static bool ip_equals_wan(const Locator_t& locator);
194 
195  // Common
197  RTPS_DllAPI static bool setPortRTPS(
198  Locator_t& locator,
199  uint16_t port);
200 
202  RTPS_DllAPI static uint16_t getPortRTPS(Locator_t& locator);
203 
205  RTPS_DllAPI static bool isLocal(const Locator_t& locator);
206 
208  RTPS_DllAPI static bool isAny(const Locator_t& locator);
209 
211  RTPS_DllAPI static bool compareAddress(
212  const Locator_t& loc1,
213  const Locator_t& loc2,
214  bool fullAddress = false);
215 
217  RTPS_DllAPI static bool compareAddressAndPhysicalPort(
218  const Locator_t& loc1,
219  const Locator_t& loc2);
220 
222  RTPS_DllAPI static std::string to_string(const Locator_t& locator);
223 
224  // UDP
226  RTPS_DllAPI static bool isMulticast(const Locator_t& locator);
227 
228  private:
229  IPLocator();
230 
231  virtual ~IPLocator();
232 };
233 
234 }
235 }
236 } /* namespace eprosima */
237 
238 #endif /* IP_LOCATOR_H_ */
Class IPLocator, to provide helper functions to the IP based transports.
Definition: IPLocator.h:36
static RTPS_DllAPI bool setIPv6(Locator_t &destlocator, const Locator_t &origlocator)
Copies locator's IPv6.
static RTPS_DllAPI bool hasIPv6(const Locator_t &locator)
Check if the locator has IPv6.
static RTPS_DllAPI const octet * getWan(const Locator_t &locator)
Gets locator's WAN address (as in RTCP protocol)
static RTPS_DllAPI bool copyIPv6(const Locator_t &locator, unsigned char *dest)
Copies locator's IPv6.
static RTPS_DllAPI bool setIPv6(Locator_t &locator, uint16_t group0, uint16_t group1, uint16_t group2, uint16_t group3, uint16_t group4, uint16_t group5, uint16_t group6, uint16_t group7)
Sets locator's IPv6.
static RTPS_DllAPI bool ip_equals_wan(const Locator_t &locator)
Checks if a locator WAN address and IP address are the same (as in RTCP protocol).
static RTPS_DllAPI const octet * getIPv4(const Locator_t &locator)
Retrieves locator's IPv4 as octet array.
static RTPS_DllAPI bool isLocal(const Locator_t &locator)
Checks if a locator has local IP address.
static RTPS_DllAPI bool setIPv6(Locator_t &locator, const std::string &ipv6)
Sets locator's IPv6.
static RTPS_DllAPI std::string toIPv6string(const Locator_t &locator)
Returns a string representation of the locator's IPv6.
static RTPS_DllAPI uint16_t getLogicalPort(const Locator_t &locator)
Gets locator's logical port (as in RTCP protocol)
static RTPS_DllAPI bool setIPv4(Locator_t &destlocator, const Locator_t &origlocator)
Copies locator's IPv4.
static RTPS_DllAPI bool setWan(Locator_t &locator, octet o1, octet o2, octet o3, octet o4)
Sets locator's WAN address (as in RTCP protocol)
static RTPS_DllAPI bool compareAddressAndPhysicalPort(const Locator_t &loc1, const Locator_t &loc2)
Checks if a both locators has the same IP address and physical port (as in RTCP protocol).
static RTPS_DllAPI bool hasWan(const Locator_t &locator)
Checks if the locator has WAN address (as in RTCP protocol)
static RTPS_DllAPI bool setPortRTPS(Locator_t &locator, uint16_t port)
Sets locator's RTPC port. Physical for UDP and logical for TCP (as in RTCP protocol)
static RTPS_DllAPI std::string ip_to_string(const Locator_t &locator)
Returns a string representation of the locator's IP.
static RTPS_DllAPI bool setLogicalPort(Locator_t &locator, uint16_t port)
Sets locator's logical port (as in RTCP protocol)
static RTPS_DllAPI const octet * getLanID(const Locator_t &locator)
Gets locator's LAN ID (as in RTCP protocol)
static RTPS_DllAPI bool setLanID(Locator_t &locator, const std::string &lanId)
Sets locator's LAN ID (as in RTCP protocol)
static RTPS_DllAPI bool setIPv6(Locator_t &locator, const unsigned char *addr)
Sets locator's IPv6.
static RTPS_DllAPI const octet * getIPv6(const Locator_t &locator)
Retrieves locator's IPv6 as octet array.
static RTPS_DllAPI bool isMulticast(const Locator_t &locator)
Checks if the locator has a multicast IP address.
static RTPS_DllAPI bool copyIPv4(const Locator_t &locator, unsigned char *dest)
Copies locator's IPv4.
static RTPS_DllAPI bool hasIPv4(const Locator_t &locator)
Check if the locator has IPv4.
static RTPS_DllAPI bool setIPv4(Locator_t &locator, octet o1, octet o2, octet o3, octet o4)
Sets locator's IPv4.
static RTPS_DllAPI bool setPhysicalPort(Locator_t &locator, uint16_t port)
Sets locator's physical port (as in RTCP protocol)
static RTPS_DllAPI std::string toLanIDstring(const Locator_t &locator)
Retrieves a string representation of the locator's LAN ID (as in RTCP protocol)
static RTPS_DllAPI bool isAny(const Locator_t &locator)
Checks if a locator has any IP address.
static RTPS_DllAPI uint16_t getPortRTPS(Locator_t &locator)
Gets locator's RTPC port. Physical for UDP and logical for TCP (as in RTCP protocol)
static RTPS_DllAPI std::string toWanstring(const Locator_t &locator)
Retrieves a string representation of the locator's WAN address (as in RTCP protocol)
static RTPS_DllAPI Locator_t toPhysicalLocator(const Locator_t &locator)
Returns a new locator without logical port (as in RTCP protocol).
static RTPS_DllAPI bool setIPv4(Locator_t &locator, const unsigned char *addr)
Sets locator's IPv4.
static RTPS_DllAPI bool setWan(Locator_t &locator, const std::string &wan)
Sets locator's WAN address (as in RTCP protocol)
static RTPS_DllAPI std::string toIPv4string(const Locator_t &locator)
Returns a string representation of the locator's IPv4.
static RTPS_DllAPI bool compareAddress(const Locator_t &loc1, const Locator_t &loc2, bool fullAddress=false)
Checks if a both locators has the same IP address.
static RTPS_DllAPI std::string to_string(const Locator_t &locator)
Returns a string representation of the given locator.
static RTPS_DllAPI uint16_t getPhysicalPort(const Locator_t &locator)
Gets locator's physical port (as in RTCP protocol)
static RTPS_DllAPI void createLocator(int32_t kindin, const std::string &address, uint32_t portin, Locator_t &locator)
Fills locator with the given parameters.
static RTPS_DllAPI bool setIPv4(Locator_t &locator, const std::string &ipv4)
Sets locator's IPv4.
static RTPS_DllAPI bool ip(Locator_t &locator, const std::string &ip)
Sets locator's IP.
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23