Skip to content

Commit 8abd633

Browse files
Accept v6 interfaces and interface names in whitelist (#128) (#130)
Signed-off-by: Juan Lopez Fernandez <[email protected]> (cherry picked from commit ac61a84) # Conflicts: # ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp Co-authored-by: juanlofer-eprosima <[email protected]>
1 parent 68162ec commit 8abd633

File tree

6 files changed

+30
-71
lines changed

6 files changed

+30
-71
lines changed

ddspipe_participants/include/ddspipe_participants/configuration/SimpleParticipantConfiguration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct SimpleParticipantConfiguration : public ParticipantConfiguration
5151

5252
core::types::DomainId domain {0u};
5353

54-
std::set<participants::types::IpType> whitelist {};
54+
std::set<participants::types::WhitelistType> whitelist {};
5555

5656
core::types::TransportDescriptors transport {core::types::TransportDescriptors::builtin};
5757

ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class CommonParticipant
173173
template<typename T>
174174
DDSPIPE_PARTICIPANTS_DllAPI
175175
static std::shared_ptr<T> create_descriptor(
176-
std::set<types::IpType> whitelist = {});
176+
std::set<types::WhitelistType> whitelist = {});
177177

178178
protected:
179179

ddspipe_participants/include/ddspipe_participants/types/address/Address.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ namespace types {
2929
using LocatorType = uint32_t;
3030
// Data Type for IP
3131
using IpType = std::string;
32+
// Data Type for an interfaces whitelist entry
33+
using WhitelistType = std::string;
3234
// Data Type for Domain name (DNS)
3335
using DomainType = std::string;
3436
// Data Type for Port

ddspipe_participants/src/cpp/configuration/SimpleParticipantConfiguration.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ bool SimpleParticipantConfiguration::is_valid(
3535
return false;
3636
}
3737

38-
// Check whitelist interfaces
39-
for (types::IpType ip : whitelist)
40-
{
41-
if (!types::Address::is_ipv4_correct(ip))
42-
{
43-
error_msg << "Incorrect IPv4 address " << ip << " in whitelist interfaces. ";
44-
return false;
45-
}
46-
}
47-
4838
return true;
4939
}
5040

ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,16 @@ template<>
204204
DDSPIPE_PARTICIPANTS_DllAPI
205205
std::shared_ptr<eprosima::fastdds::rtps::UDPv4TransportDescriptor>
206206
CommonParticipant::create_descriptor(
207-
std::set<types::IpType> whitelist)
207+
std::set<types::WhitelistType> whitelist)
208208
{
209209
std::shared_ptr<eprosima::fastdds::rtps::UDPv4TransportDescriptor> udp_transport =
210210
std::make_shared<eprosima::fastdds::rtps::UDPv4TransportDescriptor>();
211211

212-
for (const types::IpType& ip : whitelist)
212+
for (const types::WhitelistType& iface : whitelist)
213213
{
214-
if (types::Address::is_ipv4_correct(ip))
215-
{
216-
udp_transport->interfaceWhiteList.emplace_back(ip);
217-
logInfo(DDSPIPE_COMMON_PARTICIPANT,
218-
"Adding " << ip << " to UDP whitelist interfaces.");
219-
}
220-
else
221-
{
222-
// Invalid address, continue with next one
223-
logWarning(DDSPIPE_COMMON_PARTICIPANT,
224-
"Not valid IPv4. Discarding UDP whitelist interface " << ip << ".");
225-
}
214+
udp_transport->interfaceWhiteList.emplace_back(iface);
215+
logInfo(DDSPIPE_COMMON_PARTICIPANT,
216+
"Adding " << iface << " to UDP whitelist interfaces.");
226217
}
227218

228219
return udp_transport;
@@ -232,25 +223,16 @@ template<>
232223
DDSPIPE_PARTICIPANTS_DllAPI
233224
std::shared_ptr<eprosima::fastdds::rtps::UDPv6TransportDescriptor>
234225
CommonParticipant::create_descriptor(
235-
std::set<types::IpType> whitelist)
226+
std::set<types::WhitelistType> whitelist)
236227
{
237228
std::shared_ptr<eprosima::fastdds::rtps::UDPv6TransportDescriptor> udp_transport =
238229
std::make_shared<eprosima::fastdds::rtps::UDPv6TransportDescriptor>();
239230

240-
for (const types::IpType& ip : whitelist)
231+
for (const types::WhitelistType& iface : whitelist)
241232
{
242-
if (types::Address::is_ipv6_correct(ip))
243-
{
244-
udp_transport->interfaceWhiteList.emplace_back(ip);
245-
logInfo(DDSPIPE_COMMON_PARTICIPANT,
246-
"Adding " << ip << " to UDP whitelist interfaces.");
247-
}
248-
else
249-
{
250-
// Invalid address, continue with next one
251-
logWarning(DDSPIPE_COMMON_PARTICIPANT,
252-
"Not valid IPv6. Discarding UDP whitelist interface " << ip << ".");
253-
}
233+
udp_transport->interfaceWhiteList.emplace_back(iface);
234+
logInfo(DDSPIPE_COMMON_PARTICIPANT,
235+
"Adding " << iface << " to UDP whitelist interfaces.");
254236
}
255237

256238
return udp_transport;
@@ -260,25 +242,16 @@ template<>
260242
DDSPIPE_PARTICIPANTS_DllAPI
261243
std::shared_ptr<eprosima::fastdds::rtps::TCPv4TransportDescriptor>
262244
CommonParticipant::create_descriptor(
263-
std::set<types::IpType> whitelist)
245+
std::set<types::WhitelistType> whitelist)
264246
{
265247
std::shared_ptr<eprosima::fastdds::rtps::TCPv4TransportDescriptor> tcp_transport =
266248
std::make_shared<eprosima::fastdds::rtps::TCPv4TransportDescriptor>();
267249

268-
for (const types::IpType& ip : whitelist)
250+
for (const types::WhitelistType& iface : whitelist)
269251
{
270-
if (types::Address::is_ipv4_correct(ip))
271-
{
272-
tcp_transport->interfaceWhiteList.emplace_back(ip);
273-
logInfo(DDSPIPE_COMMON_PARTICIPANT,
274-
"Adding " << ip << " to TCP whitelist interfaces.");
275-
}
276-
else
277-
{
278-
// Invalid address, continue with next one
279-
logWarning(DDSPIPE_COMMON_PARTICIPANT,
280-
"Not valid IPv4. Discarding TCP whitelist interface " << ip << ".");
281-
}
252+
tcp_transport->interfaceWhiteList.emplace_back(iface);
253+
logInfo(DDSPIPE_COMMON_PARTICIPANT,
254+
"Adding " << iface << " to TCP whitelist interfaces.");
282255
}
283256

284257
return tcp_transport;
@@ -288,25 +261,16 @@ template<>
288261
DDSPIPE_PARTICIPANTS_DllAPI
289262
std::shared_ptr<eprosima::fastdds::rtps::TCPv6TransportDescriptor>
290263
CommonParticipant::create_descriptor(
291-
std::set<types::IpType> whitelist)
264+
std::set<types::WhitelistType> whitelist)
292265
{
293266
std::shared_ptr<eprosima::fastdds::rtps::TCPv6TransportDescriptor> tcp_transport =
294267
std::make_shared<eprosima::fastdds::rtps::TCPv6TransportDescriptor>();
295268

296-
for (const types::IpType& ip : whitelist)
269+
for (const types::WhitelistType& iface : whitelist)
297270
{
298-
if (types::Address::is_ipv6_correct(ip))
299-
{
300-
tcp_transport->interfaceWhiteList.emplace_back(ip);
301-
logInfo(DDSPIPE_COMMON_PARTICIPANT,
302-
"Adding " << ip << " to TCP whitelist interfaces.");
303-
}
304-
else
305-
{
306-
// Invalid address, continue with next one
307-
logWarning(DDSPIPE_COMMON_PARTICIPANT,
308-
"Not valid IPv6. Discarding TCP whitelist interface " << ip << ".");
309-
}
271+
tcp_transport->interfaceWhiteList.emplace_back(iface);
272+
logInfo(DDSPIPE_COMMON_PARTICIPANT,
273+
"Adding " << iface << " to TCP whitelist interfaces.");
310274
}
311275

312276
return tcp_transport;

ddspipe_yaml/src/cpp/YamlReader_participants.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ void YamlReader::fill(
137137
// Optional whitelist interfaces
138138
if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG))
139139
{
140-
object.whitelist = YamlReader::get_set<participants::types::IpType>(yml, WHITELIST_INTERFACES_TAG, version);
140+
object.whitelist = YamlReader::get_set<participants::types::WhitelistType>(yml, WHITELIST_INTERFACES_TAG,
141+
version);
141142
}
142143

143144
// Optional get Transport descriptors
@@ -194,7 +195,8 @@ void YamlReader::fill(
194195
// Optional whitelist interfaces
195196
if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG))
196197
{
197-
object.whitelist = YamlReader::get_set<participants::types::IpType>(yml, WHITELIST_INTERFACES_TAG, version);
198+
object.whitelist = YamlReader::get_set<participants::types::WhitelistType>(yml, WHITELIST_INTERFACES_TAG,
199+
version);
198200
}
199201

200202
// Optional listening addresses
@@ -262,7 +264,8 @@ void YamlReader::fill(
262264
// Optional whitelist interfaces
263265
if (YamlReader::is_tag_present(yml, WHITELIST_INTERFACES_TAG))
264266
{
265-
object.whitelist = YamlReader::get_set<participants::types::IpType>(yml, WHITELIST_INTERFACES_TAG, version);
267+
object.whitelist = YamlReader::get_set<participants::types::WhitelistType>(yml, WHITELIST_INTERFACES_TAG,
268+
version);
266269
}
267270

268271
// Optional listening addresses

0 commit comments

Comments
 (0)