Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Public Types | Public Member Functions | Friends | List of all members
transport::core::Portal Class Reference

#include <portal.h>

Public Types

using ConsumerCallback = interface::Portal::ConsumerCallback
 
using ProducerCallback = interface::Portal::ProducerCallback
 

Public Member Functions

 Portal (asio::io_service &io_service)
 
void setConsumerCallback (ConsumerCallback *consumer_callback)
 
void setProducerCallback (ProducerCallback *producer_callback)
 
TRANSPORT_ALWAYS_INLINE void setOutputInterface (const std::string &output_interface)
 
TRANSPORT_ALWAYS_INLINE void connect (bool is_consumer=true)
 
 ~Portal ()
 
TRANSPORT_ALWAYS_INLINE uint32_t getHash (const Name &name)
 
TRANSPORT_ALWAYS_INLINE bool interestIsPending (const Name &name)
 
TRANSPORT_ALWAYS_INLINE void sendInterest (Interest::Ptr &&interest, OnContentObjectCallback &&on_content_object_callback=UNSET_CALLBACK, OnInterestTimeoutCallback &&on_interest_timeout_callback=UNSET_CALLBACK)
 
TRANSPORT_ALWAYS_INLINE void timerHandler (const std::error_code &ec, uint32_t hash, uint32_t seq)
 
TRANSPORT_ALWAYS_INLINE void bind (const BindConfig &config)
 
TRANSPORT_ALWAYS_INLINE void runEventsLoop ()
 
TRANSPORT_ALWAYS_INLINE void runOneEvent ()
 
TRANSPORT_ALWAYS_INLINE void sendContentObject (ContentObject &content_object)
 
TRANSPORT_ALWAYS_INLINE void stopEventsLoop ()
 
TRANSPORT_ALWAYS_INLINE void killConnection ()
 
TRANSPORT_ALWAYS_INLINE void clear ()
 
TRANSPORT_ALWAYS_INLINE void clearOne (const Name &name)
 
TRANSPORT_ALWAYS_INLINE asio::io_service & getIoService ()
 
TRANSPORT_ALWAYS_INLINE void registerRoute (Prefix &prefix)
 
TRANSPORT_ALWAYS_INLINE bool isConnectedToFwd ()
 

Friends

class PortalConfiguration
 

Detailed Description

Portal is a opaque class which is used for sending/receiving interest/data packets over multiple kind of connector. The connector itself is defined by the template ForwarderInt, which is resolved at compile time. It is then not possible to decide at runtime what the connector will be.

The tasks performed by portal are the following:

The way of working of portal is event-based, which means that data and interests are sent/received in a asynchronous manner, and the notifications are performed through callbacks.

The portal class is not thread safe, appropriate locking is required by the users of this class.

Constructor & Destructor Documentation

◆ Portal()

transport::core::Portal::Portal ( asio::io_service &  io_service)
inline

This workaroung allows to initialize memory for packet buffers before any static variables that may be initialized in the io_modules. In this way static variables in modules will be destroyed before the packet memory.

◆ ~Portal()

transport::core::Portal::~Portal ( )
inline

Destructor.

Member Function Documentation

◆ bind()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::bind ( const BindConfig &  config)
inline

Register a producer name to the local forwarder and optionally set the content store size in a per-face manner.

Parameters
config- The configuration for the local forwarder binding.

◆ clear()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::clear ( )
inline

Clear the pending interest hash table.

◆ clearOne()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::clearOne ( const Name name)
inline

Remove one pending interest.

◆ connect()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::connect ( bool  is_consumer = true)
inline

Connect the transport to the local hicn forwarder.

Parameters
is_consumer- Boolean specifying if the application on top of portal is a consumer or a producer.

◆ getHash()

TRANSPORT_ALWAYS_INLINE uint32_t transport::core::Portal::getHash ( const Name name)
inline

Compute name hash

◆ getIoService()

TRANSPORT_ALWAYS_INLINE asio::io_service& transport::core::Portal::getIoService ( )
inline

Get a reference to the io_service object.

◆ interestIsPending()

TRANSPORT_ALWAYS_INLINE bool transport::core::Portal::interestIsPending ( const Name name)
inline

Check if there is already a pending interest for a given name.

Parameters
name- The interest name.

◆ isConnectedToFwd()

TRANSPORT_ALWAYS_INLINE bool transport::core::Portal::isConnectedToFwd ( )
inline

Check if the transport is connected to a forwarder or not

◆ killConnection()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::killConnection ( )
inline

Disconnect the transport from the local forwarder.

◆ registerRoute()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::registerRoute ( Prefix prefix)
inline

Register a route to the local forwarder.

◆ runEventsLoop()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::runEventsLoop ( )
inline

Start the event loop. This function blocks here and calls the callback set by the application upon interest/data received or timeout.

◆ runOneEvent()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::runOneEvent ( )
inline

Run one event and return.

◆ sendContentObject()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::sendContentObject ( ContentObject content_object)
inline

Send a data packet to the local forwarder. As opposite to sendInterest, the ownership of the content object is not transferred to the portal.

Parameters
content_object- The data packet.

◆ sendInterest()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::sendInterest ( Interest::Ptr &&  interest,
OnContentObjectCallback &&  on_content_object_callback = UNSET_CALLBACK,
OnInterestTimeoutCallback &&  on_interest_timeout_callback = UNSET_CALLBACK 
)
inline

Send an interest through to the local forwarder.

Parameters
interest- The pointer to the interest. The ownership of the interest is transferred by the caller to portal.
on_content_object_callback- If the caller wishes to use a different callback to be called for this interest, it can set this parameter. Otherwise ConsumerCallback::onContentObject will be used.
on_interest_timeout_callback- If the caller wishes to use a different callback to be called for this interest, it can set this parameter. Otherwise ConsumerCallback::onTimeout will be used.

◆ setConsumerCallback()

void transport::core::Portal::setConsumerCallback ( ConsumerCallback consumer_callback)
inline

Set the consumer callback.

Parameters
consumer_callback- The pointer to the ConsumerCallback object.

◆ setOutputInterface()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::setOutputInterface ( const std::string &  output_interface)
inline

Specify the output interface to use. This method will be useful in a future scenario where the library will be able to forward packets without connecting to a local forwarder. Now it is not used.

Parameters
output_interface- The output interface to use for forwarding/receiving packets.

◆ setProducerCallback()

void transport::core::Portal::setProducerCallback ( ProducerCallback producer_callback)
inline

Set the producer callback.

Parameters
producer_callback- The pointer to the ProducerCallback object.

◆ stopEventsLoop()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::stopEventsLoop ( )
inline

Stop the event loop, canceling all the pending events in the event queue.

Beware that stopping the event loop DOES NOT disconnect the transport from the local forwarder, the connector underneath will stay connected.

◆ timerHandler()

TRANSPORT_ALWAYS_INLINE void transport::core::Portal::timerHandler ( const std::error_code &  ec,
uint32_t  hash,
uint32_t  seq 
)
inline

Handler fot the timer set when the interest is sent.

Parameters
ec- Error code which says whether the timer expired or has been canceled upon data packet reception.
hash- The index of the interest in the pending interest hash table.

The documentation for this class was generated from the following file: