Fast RTPS  Version 2.1.0
Fast RTPS
IPFinder.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 IPFINDER_H_
21 #define IPFINDER_H_
22 
23 
24 
25 #include <vector>
26 #include <string>
27 
28 #include <fastdds/rtps/common/Locator.h>
29 
30 namespace eprosima {
31 namespace fastrtps {
32 namespace rtps {
37 class IPFinder
38 {
39  public:
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
44  enum IPTYPE
45  {
46  IP4,
47  IP6,
49  IP6_LOCAL
50  };
54  typedef struct info_IP
55  {
57  std::string name;
58  std::string dev;
59  Locator_t locator;
61 #endif
63  virtual ~IPFinder();
64 
65  RTPS_DllAPI static bool getIPs(std::vector<info_IP>* vec_name, bool return_loopback = false);
66 
71  RTPS_DllAPI static bool getIP4Address(LocatorList_t* locators);
76  RTPS_DllAPI static bool getIP6Address(LocatorList_t* locators);
81  RTPS_DllAPI static bool getAllIPAddress(LocatorList_t* locators);
86  RTPS_DllAPI static bool parseIP4(info_IP& info);
91  RTPS_DllAPI static bool parseIP6(info_IP& info);
92 
93  RTPS_DllAPI static std::string getIPv4Address(const std::string &name);
94  RTPS_DllAPI static std::string getIPv6Address(const std::string &name);
95 };
96 
97 }
98 }
99 } /* namespace eprosima */
100 
101 #endif /* IPFINDER_H_ */
Class IPFinder, to determine the IP of the NICs.
Definition: IPFinder.h:38
static RTPS_DllAPI bool getIP6Address(LocatorList_t *locators)
Get the IP6Adresses in all interfaces.
static RTPS_DllAPI std::string getIPv6Address(const std::string &name)
static RTPS_DllAPI bool getAllIPAddress(LocatorList_t *locators)
Get all IP Adresses in all interfaces.
static RTPS_DllAPI bool getIPs(std::vector< info_IP > *vec_name, bool return_loopback=false)
struct eprosima::fastrtps::rtps::IPFinder::info_IP info_IP
Structure info_IP with information about a specific IP obtained from a NIC.
IPTYPE
Enum IPTYPE, to define the type of IP obtained from the NICs.
Definition: IPFinder.h:45
@ IP4_LOCAL
IP4_LOCAL.
Definition: IPFinder.h:48
@ IP4
IP4.
Definition: IPFinder.h:46
@ IP6_LOCAL
IP6_LOCAL.
Definition: IPFinder.h:49
@ IP6
IP6.
Definition: IPFinder.h:47
static RTPS_DllAPI bool parseIP4(info_IP &info)
Parses an IP4 string, populating a info_IP with its value.
static RTPS_DllAPI std::string getIPv4Address(const std::string &name)
static RTPS_DllAPI bool getIP4Address(LocatorList_t *locators)
Get the IP4Adresses in all interfaces.
static RTPS_DllAPI bool parseIP6(info_IP &info)
Parses an IP6 string, populating a info_IP with its value.
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
Structure info_IP with information about a specific IP obtained from a NIC.
Definition: IPFinder.h:55
std::string dev
Definition: IPFinder.h:58
std::string name
Definition: IPFinder.h:57
IPTYPE type
Definition: IPFinder.h:56
Locator_t locator
Definition: IPFinder.h:59