Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
  • Loading branch information
juanlofer-eprosima committed Mar 8, 2024
1 parent c87c374 commit 19cffc9
Show file tree
Hide file tree
Showing 96 changed files with 1,227 additions and 556 deletions.
2 changes: 1 addition & 1 deletion include/fastdds/dds/core/policy/QosPolicies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <fastdds/rtps/common/Types.h>
#include <fastdds/rtps/flowcontrol/FlowControllerConsts.hpp>
#include <fastdds/rtps/resources/ResourceManagement.h>
#include <fastdds/rtps/transport/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/network/NetmaskFilterKind.hpp>

#include <fastrtps/types/TypeObject.h>
#include <fastrtps/utils/collections/ResourceLimitedVector.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <fastdds/rtps/flowcontrol/FlowControllerDescriptor.hpp>
#include <fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h>
#include <fastdds/rtps/resources/ResourceManagement.h>
#include <fastdds/rtps/transport/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/network/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/TransportInterface.h>
#include <fastrtps/fastrtps_dll.h>
#include <fastrtps/utils/fixed_size_string.hpp>
Expand Down
22 changes: 18 additions & 4 deletions include/fastdds/rtps/common/Guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,22 @@ struct RTPS_DllAPI GUID_t
/**
* Checks whether this guid is from an entity on the same host as another guid.
*
* @note This method assumes the value of \c other_guid was originally assigned by Fast-DDS vendor.
*
* @param other_guid GUID_t to compare to.
*
* @return true when this guid is on the same host, false otherwise.
*/
bool is_on_same_host_as(
const GUID_t& other_guid) const
{
return memcmp(guidPrefix.value, other_guid.guidPrefix.value, 4) == 0;
return guidPrefix.is_on_same_host_as(other_guid.guidPrefix);
}

/**
* Checks whether this guid is from an entity created on this host (from where this method is called).
* Checks whether this guid is from a (Fast-DDS) entity created on this host (from where this method is called).
*
* @return true when this guid is from an entity created on this host, false otherwise.
* @return true when this guid is from a (Fast-DDS) entity created on this host, false otherwise.
*/
bool is_from_this_host() const
{
Expand All @@ -101,14 +103,26 @@ struct RTPS_DllAPI GUID_t
/**
* Checks whether this guid is for an entity on the same host and process as another guid.
*
* @note This method assumes the value of \c other_guid was originally assigned by Fast-DDS vendor.
*
* @param other_guid GUID_t to compare to.
*
* @return true when this guid is on the same host and process, false otherwise.
*/
bool is_on_same_process_as(
const GUID_t& other_guid) const
{
return memcmp(guidPrefix.value, other_guid.guidPrefix.value, 8) == 0;
return guidPrefix.is_on_same_process_as(other_guid.guidPrefix);
}

/**
* Checks whether this guid is from a (Fast-DDS) entity created on this process (from where this method is called).
*
* @return true when this guid is from a (Fast-DDS) entity created on this process, false otherwise.
*/
bool is_from_this_process() const
{
return guidPrefix.is_from_this_process();
}

/**
Expand Down
35 changes: 33 additions & 2 deletions include/fastdds/rtps/common/GuidPrefix_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,43 @@ struct RTPS_DllAPI GuidPrefix_t
}

/**
* Checks whether this guid prefix is from an entity created on this host (from where this method is called).
* Checks whether this guid prefix is from an entity on the same host as another guid prefix.
*
* @return true when this guid prefix is from an entity created on this host, false otherwise.
* @note This method assumes the value of \c other_guid_prefix was originally assigned by Fast-DDS vendor.
*
* @param other_guid_prefix GuidPrefix_t to compare to.
*
* @return true when this guid prefix is on the same host, false otherwise.
*/
bool is_on_same_host_as(
const GuidPrefix_t& other_guid_prefix) const;

/**
* Checks whether this guid prefix is from a (Fast-DDS) entity created on this host (from where this method is called).
*
* @return true when this guid prefix is from a (Fast-DDS) entity created on this host, false otherwise.
*/
bool is_from_this_host() const;

/**
* Checks whether this guid prefix is for an entity on the same host and process as another guid prefix.
*
* @note This method assumes the value of \c other_guid_prefix was originally assigned by Fast-DDS vendor.
*
* @param other_guid_prefix GuidPrefix_t to compare to.
*
* @return true when this guid prefix is on the same host and process, false otherwise.
*/
bool is_on_same_process_as(
const GuidPrefix_t& other_guid_prefix) const;

/**
* Checks whether this guid prefix is from a (Fast-DDS) entity created on this host and process (from where this method is called).
*
* @return true when this guid prefix is from a (Fast-DDS) entity created on this host and process, false otherwise.
*/
bool is_from_this_process() const;

static GuidPrefix_t unknown()
{
return GuidPrefix_t();
Expand Down
5 changes: 5 additions & 0 deletions include/fastdds/rtps/participant/RTPSParticipant.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ class RTPS_DllAPI RTPSParticipant
bool ignore_reader(
const GUID_t& reader_guid);

/**
* Returns registered transports' netmask filter information (transport's netmask filter kind and allowlist).
*/
std::vector<fastdds::rtps::TransportNetmaskFilterInfo> netmask_filter_info() const;

#if HAVE_SECURITY

/**
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds/rtps/transport/ChainingTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ChainingTransport : public TransportInterface

/*!
* Call the low-level transport `netmask_filter_info()`.
* Return netmask filter information (transport's netmask filter kind and allowlist)
* Returns netmask filter information (transport's netmask filter kind and allowlist)
*/
RTPS_DllAPI NetmaskFilterInfo netmask_filter_info() const override
{
Expand Down
8 changes: 5 additions & 3 deletions include/fastdds/rtps/transport/SocketTransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <vector>
#include <string>

#include <fastdds/rtps/transport/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/network/AllowedNetworkInterface.hpp>
#include <fastdds/rtps/transport/network/BlockedNetworkInterface.hpp>
#include <fastdds/rtps/transport/network/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/PortBasedTransportDescriptor.hpp>

namespace eprosima {
Expand Down Expand Up @@ -95,9 +97,9 @@ struct SocketTransportDescriptor : public PortBasedTransportDescriptor
//! Transport's netmask filter configuration.
NetmaskFilterKind netmask_filter;
//! Allowed interfaces in an IP or device name string format, each with a specific netmask filter configuration.
std::vector<std::pair<std::string, NetmaskFilterKind>> interface_allowlist;
std::vector<AllowedNetworkInterface> interface_allowlist;
//! Blocked interfaces in an IP or device name string format.
std::vector<std::string> interface_blocklist;
std::vector<BlockedNetworkInterface> interface_blocklist;
//! Specified time to live (8bit - 255 max TTL)
uint8_t TTL;
};
Expand Down
30 changes: 28 additions & 2 deletions include/fastdds/rtps/transport/TransportDescriptorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define _FASTDDS_TRANSPORT_DESCRIPTOR_INTERFACE_H_

#include <cstdint>
#include <mutex>
#include <vector>

#include <fastrtps/fastrtps_dll.h>
Expand Down Expand Up @@ -51,11 +52,20 @@ struct TransportDescriptorInterface

//! Copy constructor
RTPS_DllAPI TransportDescriptorInterface(
const TransportDescriptorInterface& t) = default;
const TransportDescriptorInterface& t)
: maxMessageSize(t.maxMessageSize)
, maxInitialPeersRange(t.maxInitialPeersRange)
{
}

//! Copy assignment
RTPS_DllAPI TransportDescriptorInterface& operator =(
const TransportDescriptorInterface& t) = default;
const TransportDescriptorInterface& t)
{
maxMessageSize = t.maxMessageSize;
maxInitialPeersRange = t.maxInitialPeersRange;
return *this;
}

//! Destructor
virtual RTPS_DllAPI ~TransportDescriptorInterface() = default;
Expand Down Expand Up @@ -92,11 +102,27 @@ struct TransportDescriptorInterface
this->maxInitialPeersRange == t.max_initial_peers_range());
}

//! Lock internal mutex (for Fast-DDS internal use)
RTPS_DllAPI void lock()
{
mtx_.lock();
}

//! Unlock internal mutex (for Fast-DDS internal use)
RTPS_DllAPI void unlock()
{
mtx_.unlock();
}

//! Maximum size of a single message in the transport
uint32_t maxMessageSize;

//! Number of channels opened with each initial remote peer.
uint32_t maxInitialPeersRange;

private:

mutable std::mutex mtx_;
};

} // namespace rtps
Expand Down
14 changes: 8 additions & 6 deletions include/fastdds/rtps/transport/TransportInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include <fastdds/rtps/common/LocatorSelectorEntry.hpp>
#include <fastdds/rtps/common/LocatorWithMask.hpp>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/transport/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/network/AllowedNetworkInterface.hpp>
#include <fastdds/rtps/transport/network/NetmaskFilterKind.hpp>
#include <fastdds/rtps/transport/SenderResource.h>
#include <fastdds/rtps/transport/TransportDescriptorInterface.h>
#include <fastdds/rtps/transport/TransportReceiverInterface.h>
Expand All @@ -45,7 +46,8 @@ static const std::string s_IPv4AddressAny = "0.0.0.0";
static const std::string s_IPv6AddressAny = "::";

using SendResourceList = std::vector<std::unique_ptr<fastrtps::rtps::SenderResource>>;
using NetmaskFilterInfo = std::pair<NetmaskFilterKind, std::vector<std::pair<LocatorWithMask, NetmaskFilterKind>>>;
using NetmaskFilterInfo = std::pair<NetmaskFilterKind, std::vector<AllowedNetworkInterface>>;
using TransportNetmaskFilterInfo = std::pair<int32_t, NetmaskFilterInfo>;

/**
* Interface against which to implement a transport layer, decoupled from FastRTPS internals.
Expand Down Expand Up @@ -168,9 +170,9 @@ class RTPS_DllAPI TransportInterface
* If there is an existing channel it registers the receiver interface.
*/
virtual bool OpenInputChannel(
const Locator&,
TransportReceiverInterface*,
uint32_t) = 0;
const Locator&,
TransportReceiverInterface*,
uint32_t) = 0;

/**
* Must close the channel that maps to/from the given locator.
Expand Down Expand Up @@ -305,7 +307,7 @@ class RTPS_DllAPI TransportInterface
return true;
}

//! Return netmask filter information (transport's netmask filter kind and allowlist)
//! Returns netmask filter information (transport's netmask filter kind and allowlist)
virtual NetmaskFilterInfo netmask_filter_info() const
{
return {NetmaskFilterKind::AUTO, {}};
Expand Down
63 changes: 63 additions & 0 deletions include/fastdds/rtps/transport/network/AllowedNetworkInterface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file AllowedNetworkInterface.hpp
*/

#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_
#define _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_

#include <fastdds/rtps/transport/network/NetworkInterfaceWithFilter.hpp>
#include <fastrtps/fastrtps_dll.h>

namespace eprosima {
namespace fastdds {
namespace rtps {

/**
* Structure extending \c NetworkInterfaceWithFilter with information specific to allowed interfaces.
*
* @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide.
* The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user.
*/
struct RTPS_DllAPI AllowedNetworkInterface : public NetworkInterfaceWithFilter
{
using NetworkInterfaceWithFilter::NetworkInterfaceWithFilter;

//! Destructor
virtual ~AllowedNetworkInterface() = default;

//! Copy constructor
AllowedNetworkInterface(
const AllowedNetworkInterface& iface) = default;

//! Copy assignment
AllowedNetworkInterface& operator =(
const AllowedNetworkInterface& iface) = default;

//! Move constructor
AllowedNetworkInterface(
AllowedNetworkInterface&& iface) = default;

//! Move assignment
AllowedNetworkInterface& operator =(
AllowedNetworkInterface&& iface) = default;
};

} // namespace rtps
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_ALLOWEDNETWORKINTERFACE_HPP_
63 changes: 63 additions & 0 deletions include/fastdds/rtps/transport/network/BlockedNetworkInterface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file BlockedNetworkInterface.hpp
*/

#ifndef _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_
#define _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_

#include <fastdds/rtps/transport/network/NetworkInterface.hpp>
#include <fastrtps/fastrtps_dll.h>

namespace eprosima {
namespace fastdds {
namespace rtps {

/**
* Structure extending \c NetworkInterface with information specific to blocked interfaces.
*
* @note When using this structure to interact with Fast-DDS, \c name is the only attribute the user needs to provide.
* The rest of the attributes are internally filled, and are in fact ignored even if already provided by the user.
*/
struct RTPS_DllAPI BlockedNetworkInterface : public NetworkInterface
{
using NetworkInterface::NetworkInterface;

//! Destructor
virtual ~BlockedNetworkInterface() = default;

//! Copy constructor
BlockedNetworkInterface(
const BlockedNetworkInterface& iface) = default;

//! Copy assignment
BlockedNetworkInterface& operator =(
const BlockedNetworkInterface& iface) = default;

//! Move constructor
BlockedNetworkInterface(
BlockedNetworkInterface&& iface) = default;

//! Move assignment
BlockedNetworkInterface& operator =(
BlockedNetworkInterface&& iface) = default;
};

} // namespace rtps
} // namespace fastdds
} // namespace eprosima

#endif // _FASTDDS_RTPS_TRANSPORT_NETWORK_BLOCKEDNETWORKINTERFACE_HPP_
Loading

0 comments on commit 19cffc9

Please sign in to comment.