Program Listing for File TransportInterface.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/transport/TransportInterface.h)

// Copyright 2019 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.

#ifndef _FASTDDS_TRANSPORT_INTERFACE_H
#define _FASTDDS_TRANSPORT_INTERFACE_H

#include <memory>
#include <vector>
#include <fastdds/rtps/common/Locator.h>
#include <fastdds/rtps/common/LocatorSelector.hpp>
#include <fastdds/rtps/common/PortParameters.h>
#include <fastdds/rtps/transport/TransportDescriptorInterface.h>
#include <fastdds/rtps/transport/TransportReceiverInterface.h>
#include <fastdds/rtps/network/SenderResource.h>
#include <fastdds/rtps/attributes/PropertyPolicy.h>

namespace eprosima {
namespace fastdds {
namespace rtps {

constexpr uint32_t s_maximumMessageSize = 65500;
constexpr uint32_t s_maximumInitialPeersRange = 4;
constexpr uint32_t s_minimumSocketBuffer = 65536;
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>>;

class RTPS_DllAPI TransportInterface
{
public:

    virtual ~TransportInterface() = default;

    TransportInterface(
            const TransportInterface& t) = delete;

    TransportInterface& operator =(
            const TransportInterface& t) = delete;

    TransportInterface(
            TransportInterface&& t) = delete;

    TransportInterface& operator =(
            TransportInterface&& t) = delete;

    virtual bool init(
            const fastrtps::rtps::PropertyPolicy* properties = nullptr) = 0;

    virtual bool IsInputChannelOpen(
            const Locator&) const = 0;

    virtual bool IsLocatorSupported(
            const Locator&) const = 0;

    virtual bool is_locator_allowed(
            const Locator&) const = 0;

    virtual Locator RemoteToMainLocal(
            const Locator& remote) const = 0;

    virtual bool transform_remote_locator(
            const Locator& remote_locator,
            Locator& result_locator) const
    {
        (void)remote_locator;
        (void)result_locator;
        return false;
    }

    virtual bool OpenOutputChannel(
            SendResourceList& sender_resource_list,
            const Locator&) = 0;

    virtual bool OpenInputChannel(
            const Locator&,
            TransportReceiverInterface*,
            uint32_t) = 0;

    virtual bool CloseInputChannel(
            const Locator&) = 0;

    virtual bool DoInputLocatorsMatch(
            const Locator&,
            const Locator&) const = 0;

    virtual LocatorList NormalizeLocator(
            const Locator& locator) = 0;

    virtual void select_locators(
            fastrtps::rtps::LocatorSelector& selector) const = 0;

    virtual bool is_local_locator(
            const Locator& locator) const = 0;

    virtual TransportDescriptorInterface* get_configuration() = 0;

    virtual void AddDefaultOutputLocator(
            LocatorList& defaultList) = 0;

    virtual bool getDefaultMetatrafficMulticastLocators(
            LocatorList& locators,
            uint32_t metatraffic_multicast_port) const = 0;

    virtual bool getDefaultMetatrafficUnicastLocators(
            LocatorList& locators,
            uint32_t metatraffic_unicast_port) const = 0;

    virtual bool getDefaultUnicastLocators(
            LocatorList& locators,
            uint32_t unicast_port) const = 0;

    virtual bool fillMetatrafficMulticastLocator(
            Locator& locator,
            uint32_t metatraffic_multicast_port) const = 0;

    virtual bool fillMetatrafficUnicastLocator(
            Locator& locator,
            uint32_t metatraffic_unicast_port) const = 0;

    virtual bool configureInitialPeerLocator(
            Locator& locator,
            const fastrtps::rtps::PortParameters& port_params,
            uint32_t domainId,
            LocatorList& list) const = 0;

    virtual bool fillUnicastLocator(
            Locator& locator,
            uint32_t well_known_port) const = 0;

    virtual uint32_t max_recv_buffer_size() const = 0;

    virtual void shutdown()
    {
    }

    virtual void update_network_interfaces()
    {
    }

    int32_t kind() const
    {
        return transport_kind_;
    }

protected:

    TransportInterface(
            int32_t transport_kind)
        : transport_kind_(transport_kind)
    {
    }

    int32_t transport_kind_;
};

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

#endif // _FASTDDS_TRANSPORT_INTERFACE_H