| Fast DDS Version 3.3.0 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
19
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
30 namespace eprosima {
31 namespace fastdds {
32 namespace rtps {
37 class IPFinder
38{
39 public:
40
41#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
45 enum IPTYPE
46 {
47 IP4,
48 IP6,
49 IP4_LOCAL,
50 IP6_LOCAL
51 };
52
55 typedef struct info_IP
56 {
57 IPTYPE type;
58 std::string name;
59 std::string dev;
60 Locator_t locator;
61 fastdds::rtps::LocatorWithMask masked_locator;
62 }info_IP;
63
67 typedef struct info_MAC
68 {
69 unsigned char address[6];
70
71 bool operator == (
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
80 IPFinder();
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
eprosima::fastdds::rtps::IPFinder::info_MAC
struct eprosima::fastdds::rtps::IPFinder::info_MAC info_MAC
Structure info_MAC with information about a specific MAC obtained from a NIC.
eprosima::fastdds::rtps::IPFinder::getIP4Address
static FASTDDS_EXPORTED_API bool getIP4Address(LocatorList_t *locators)
Get the IP4Adresses in all interfaces.
eprosima::fastdds::rtps::IPFinder::parseIP6
static FASTDDS_EXPORTED_API bool parseIP6(info_IP &info)
Parses an IP6 string, populating a info_IP with its value.
eprosima::fastdds::rtps::IPFinder::~IPFinder
virtual ~IPFinder()
eprosima::fastdds::rtps::IPFinder::parseIP4
static FASTDDS_EXPORTED_API bool parseIP4(info_IP &info)
Parses an IP4 string, populating a info_IP with its value.
eprosima::fastdds::rtps::IPFinder::getIP6Address
static FASTDDS_EXPORTED_API bool getIP6Address(LocatorList_t *locators)
Get the IP6Adresses in all interfaces.
eprosima::fastdds::rtps::IPFinder::getIPv4Address
static FASTDDS_EXPORTED_API std::string getIPv4Address(const std::string &name)
eprosima::fastdds::rtps::IPFinder::IPFinder
IPFinder()
eprosima::fastdds::rtps::IPFinder::IPTYPE
IPTYPE
Enum IPTYPE, to define the type of IP obtained from the NICs.
Definition IPFinder.hpp:46
eprosima::fastdds::rtps::IPFinder::IP4_LOCAL
@ IP4_LOCAL
IP4_LOCAL.
Definition IPFinder.hpp:49
eprosima::fastdds::rtps::IPFinder::IP4
@ IP4
IP4.
Definition IPFinder.hpp:47
eprosima::fastdds::rtps::IPFinder::IP6_LOCAL
@ IP6_LOCAL
IP6_LOCAL.
Definition IPFinder.hpp:50
eprosima::fastdds::rtps::IPFinder::IP6
@ IP6
IP6.
Definition IPFinder.hpp:48
eprosima::fastdds::rtps::IPFinder::getAllIPAddress
static FASTDDS_EXPORTED_API bool getAllIPAddress(LocatorList_t *locators)
Get all IP Adresses in all interfaces.
eprosima::fastdds::rtps::IPFinder::getIPv6Address
static FASTDDS_EXPORTED_API std::string getIPv6Address(const std::string &name)
eprosima::fastdds::rtps::IPFinder::getIPs
static FASTDDS_EXPORTED_API bool getIPs(std::vector< info_IP > *vec_name, bool return_loopback=false)
eprosima::fastdds::rtps::IPFinder::getAllMACAddress
static FASTDDS_EXPORTED_API bool getAllMACAddress(std::vector< info_MAC > *macs)
Get all MAC Adresses of all interfaces.
eprosima::fastdds::rtps::IPFinder::info_IP
struct eprosima::fastdds::rtps::IPFinder::info_IP info_IP
Structure info_IP with information about a specific IP obtained from a NIC.
eprosima::fastdds::rtps::Locator_t
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
eprosima::fastdds::rtps::LocatorWithMask
A Locator with a mask that defines the number of significant bits of its address.
Definition LocatorWithMask.hpp:35
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::LocatorList_t
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::IPFinder::info_IP
Structure info_IP with information about a specific IP obtained from a NIC.
Definition IPFinder.hpp:56
eprosima::fastdds::rtps::IPFinder::info_IP::dev
std::string dev
Definition IPFinder.hpp:59
eprosima::fastdds::rtps::IPFinder::info_IP::masked_locator
fastdds::rtps::LocatorWithMask masked_locator
Definition IPFinder.hpp:61
eprosima::fastdds::rtps::IPFinder::info_IP::name
std::string name
Definition IPFinder.hpp:58
eprosima::fastdds::rtps::IPFinder::info_IP::type
IPTYPE type
Definition IPFinder.hpp:57
eprosima::fastdds::rtps::IPFinder::info_IP::locator
Locator_t locator
Definition IPFinder.hpp:60
eprosima::fastdds::rtps::IPFinder::info_MAC
Structure info_MAC with information about a specific MAC obtained from a NIC.
Definition IPFinder.hpp:68
eprosima::fastdds::rtps::IPFinder::info_MAC::operator==
bool operator==(const info_MAC &other)
Definition IPFinder.hpp:71
eprosima::fastdds::rtps::IPFinder::info_MAC::address
unsigned char address[6]
Definition IPFinder.hpp:69