Fast DDS  Version 3.1.2
Fast DDS
Loading...
Searching...
No Matches
IPFinder.hpp
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 FASTDDS_UTILS__IPFINDER_HPP
21#define FASTDDS_UTILS__IPFINDER_HPP
22
23#include <string>
24#include <vector>
25
26#include <fastdds/rtps/common/Locator.hpp>
27#include <fastdds/rtps/common/LocatorList.hpp>
28#include <fastdds/rtps/common/LocatorWithMask.hpp>
29
30namespace eprosima {
31namespace fastdds {
32namespace rtps {
38{
39public:
40
41#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
63
67 typedef struct info_MAC
68 {
69 unsigned char address[6];
70
72 const info_MAC& other)
73 {
74 return memcmp(address, other.address, 6) == 0;
75 }
76
77 }info_MAC;
78
79#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
81 virtual ~IPFinder();
82
83 FASTDDS_EXPORTED_API static bool getIPs(
84 std::vector<info_IP>* vec_name,
85 bool return_loopback = false);
86
91 FASTDDS_EXPORTED_API static bool getIP4Address(
92 LocatorList_t* locators);
97 FASTDDS_EXPORTED_API static bool getIP6Address(
98 LocatorList_t* locators);
103 FASTDDS_EXPORTED_API static bool getAllIPAddress(
104 LocatorList_t* locators);
109 FASTDDS_EXPORTED_API static bool parseIP4(
110 info_IP& info);
115 FASTDDS_EXPORTED_API static bool parseIP6(
116 info_IP& info);
117
118 FASTDDS_EXPORTED_API static std::string getIPv4Address(
119 const std::string& name);
120 FASTDDS_EXPORTED_API static std::string getIPv6Address(
121 const std::string& name);
122
128 FASTDDS_EXPORTED_API static bool getAllMACAddress(
129 std::vector<info_MAC>* macs);
130};
131
132} // namespace rtps
133} // namespace fastdds
134} // namespace eprosima
135
136#endif // FASTDDS_UTILS__IPFINDER_HPP
Class IPFinder, to determine the IP of the NICs.
Definition IPFinder.hpp:38
static FASTDDS_EXPORTED_API bool getIP4Address(LocatorList_t *locators)
Get the IP4Adresses in all interfaces.
static FASTDDS_EXPORTED_API bool parseIP6(info_IP &info)
Parses an IP6 string, populating a info_IP with its value.
static FASTDDS_EXPORTED_API bool parseIP4(info_IP &info)
Parses an IP4 string, populating a info_IP with its value.
static FASTDDS_EXPORTED_API bool getIP6Address(LocatorList_t *locators)
Get the IP6Adresses in all interfaces.
static FASTDDS_EXPORTED_API std::string getIPv4Address(const std::string &name)
IPTYPE
Enum IPTYPE, to define the type of IP obtained from the NICs.
Definition IPFinder.hpp:46
@ IP4_LOCAL
IP4_LOCAL.
Definition IPFinder.hpp:49
@ IP4
IP4.
Definition IPFinder.hpp:47
@ IP6_LOCAL
IP6_LOCAL.
Definition IPFinder.hpp:50
@ IP6
IP6.
Definition IPFinder.hpp:48
static FASTDDS_EXPORTED_API bool getAllIPAddress(LocatorList_t *locators)
Get all IP Adresses in all interfaces.
static FASTDDS_EXPORTED_API std::string getIPv6Address(const std::string &name)
static FASTDDS_EXPORTED_API bool getIPs(std::vector< info_IP > *vec_name, bool return_loopback=false)
static FASTDDS_EXPORTED_API bool getAllMACAddress(std::vector< info_MAC > *macs)
Get all MAC Adresses of all interfaces.
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
Class LocatorList, a Locator vector that doesn't allow duplicates.
Definition LocatorList.hpp:97
A Locator with a mask that defines the number of significant bits of its address.
Definition LocatorWithMask.hpp:35
eProsima namespace.
Structure info_IP with information about a specific IP obtained from a NIC.
Definition IPFinder.hpp:56
std::string dev
Definition IPFinder.hpp:59
fastdds::rtps::LocatorWithMask masked_locator
Definition IPFinder.hpp:61
std::string name
Definition IPFinder.hpp:58
IPTYPE type
Definition IPFinder.hpp:57
Locator_t locator
Definition IPFinder.hpp:60
Structure info_MAC with information about a specific MAC obtained from a NIC.
Definition IPFinder.hpp:68
bool operator==(const info_MAC &other)
Definition IPFinder.hpp:71
unsigned char address[6]
Definition IPFinder.hpp:69