nfd::face::UdpFactory Class Reference

protocol factory for UDP over IPv4 and IPv6 More...

#include <daemon/face/udp-factory.hpp>

+ Inheritance diagram for nfd::face::UdpFactory:
+ Collaboration diagram for nfd::face::UdpFactory:

Classes

class  Error
 Exception of UdpFactory. More...
 

Public Types

using CtorParams = ProtocolFactoryCtorParams
 

Public Member Functions

 UdpFactory (const CtorParams &params)
 
shared_ptr< UdpChannelcreateChannel (const udp::Endpoint &localEndpoint, time::nanoseconds idleTimeout)
 Create UDP-based channel using udp::Endpoint. More...
 
void createFace (const CreateFaceRequest &req, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
 Try to create a unicast face using the supplied parameters. More...
 
shared_ptr< FacecreateMulticastFace (const shared_ptr< const ndn::net::NetworkInterface > &netif, const boost::asio::ip::address &localAddress, const udp::Endpoint &multicastEndpoint)
 Create a multicast UDP face. More...
 
std::vector< shared_ptr< const Channel > > getChannels () const override
 
const std::set< std::string > & getProvidedSchemes ()
 Get FaceUri schemes accepted by this ProtocolFactory. More...
 
void processConfig (OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
 process face_system.udp config section More...
 

Static Public Member Functions

static unique_ptr< ProtocolFactorycreate (const std::string &id, const CtorParams &params)
 Create a protocol factory instance. More...
 
static const std::string & getId ()
 
static std::set< std::string > listRegistered ()
 Get registered protocol factory ids. More...
 
template<typename PF >
static void registerType (const std::string &id=PF::getId())
 Register a protocol factory type. More...
 

Static Protected Member Functions

template<typename ChannelMap >
static std::vector< shared_ptr< const Channel > > getChannelsFromMap (const ChannelMap &channelMap)
 

Protected Attributes

FaceCreatedCallback addFace
 callback when a new face is created More...
 
shared_ptr< ndn::net::NetworkMonitor > netmon
 NetworkMonitor for listing available network interfaces and monitoring their changes. More...
 
std::set< std::string > providedSchemes
 FaceUri schemes provided by this ProtocolFactory. More...
 

Detailed Description

protocol factory for UDP over IPv4 and IPv6

UDP unicast is available over both IPv4 and IPv6. UDP multicast is available over IPv4 only.

Definition at line 40 of file udp-factory.hpp.

Member Typedef Documentation

Constructor & Destructor Documentation

nfd::face::UdpFactory::UdpFactory ( const CtorParams params)
explicit

Definition at line 51 of file udp-factory.cpp.

Member Function Documentation

unique_ptr< ProtocolFactory > nfd::face::ProtocolFactory::create ( const std::string &  id,
const CtorParams params 
)
staticinherited

Create a protocol factory instance.

Return values
nullptrif factory with id is not registered

Definition at line 41 of file protocol-factory.cpp.

shared_ptr< UdpChannel > nfd::face::UdpFactory::createChannel ( const udp::Endpoint localEndpoint,
time::nanoseconds  idleTimeout 
)

Create UDP-based channel using udp::Endpoint.

udp::Endpoint is really an alias for boost::asio::ip::udp::endpoint.

If this method is called twice with the same endpoint, only one channel will be created. The second call will just return the existing channel.

If a multicast face is already active on the same local endpoint, the creation fails and an exception is thrown.

Returns
always a valid pointer to a UdpChannel object, an exception is thrown if it cannot be created.
Exceptions
UdpFactory::Error

Definition at line 286 of file udp-factory.cpp.

void nfd::face::UdpFactory::createFace ( const CreateFaceRequest req,
const FaceCreatedCallback onCreated,
const FaceCreationFailedCallback onFailure 
)
overridevirtual

Try to create a unicast face using the supplied parameters.

Parameters
reqrequest object containing the face creation parameters
onCreatedcallback if face creation succeeds or face already exists; the settings of an existing face are not updated if they differ from the request
onFailurecallback if face creation fails

Implements nfd::face::ProtocolFactory.

Definition at line 238 of file udp-factory.cpp.

shared_ptr< Face > nfd::face::UdpFactory::createMulticastFace ( const shared_ptr< const ndn::net::NetworkInterface > &  netif,
const boost::asio::ip::address &  localAddress,
const udp::Endpoint multicastEndpoint 
)

Create a multicast UDP face.

udp::Endpoint is really an alias for boost::asio::ip::udp::endpoint.

The face will join the specified multicast group.

If this method is called twice with the same set of arguments, only one face will be created. The second call will just return the existing face.

If a UDP channel, unicast face, or multicast face already exists on the same combination of local address and multicast port, the creation fails and an exception is thrown.

Parameters
netifthe network interface to which the face will be bound
localAddressthe local IP address to which the face will be bound
multicastEndpointthe multicast endpoint (multicast group and port number)
Returns
always a valid shared pointer to the created face; an exception is thrown if the face cannot be created.
Exceptions
UdpFactory::Error

Definition at line 313 of file udp-factory.cpp.

std::vector< shared_ptr< const Channel > > nfd::face::UdpFactory::getChannels ( ) const
overridevirtual

Implements nfd::face::ProtocolFactory.

Definition at line 307 of file udp-factory.cpp.

template<typename ChannelMap >
static std::vector<shared_ptr<const Channel> > nfd::face::ProtocolFactory::getChannelsFromMap ( const ChannelMap &  channelMap)
inlinestaticprotectedinherited

Definition at line 165 of file protocol-factory.hpp.

const std::string & nfd::face::UdpFactory::getId ( )
static

Definition at line 45 of file udp-factory.cpp.

const std::set<std::string>& nfd::face::ProtocolFactory::getProvidedSchemes ( )
inlineinherited

Get FaceUri schemes accepted by this ProtocolFactory.

Definition at line 127 of file protocol-factory.hpp.

std::set< std::string > nfd::face::ProtocolFactory::listRegistered ( )
staticinherited

Get registered protocol factory ids.

Definition at line 53 of file protocol-factory.cpp.

void nfd::face::UdpFactory::processConfig ( OptionalConfigSection  configSection,
FaceSystem::ConfigContext context 
)
overridevirtual

process face_system.udp config section

Implements nfd::face::ProtocolFactory.

Definition at line 58 of file udp-factory.cpp.

template<typename PF >
static void nfd::face::ProtocolFactory::registerType ( const std::string &  id = PF::getId())
inlinestaticinherited

Register a protocol factory type.

Template Parameters
Ssubclass of ProtocolFactory
Parameters
idfactory identifier

Definition at line 70 of file protocol-factory.hpp.

Member Data Documentation

FaceCreatedCallback nfd::face::ProtocolFactory::addFace
protectedinherited

callback when a new face is created

Definition at line 181 of file protocol-factory.hpp.

shared_ptr<ndn::net::NetworkMonitor> nfd::face::ProtocolFactory::netmon
protectedinherited

NetworkMonitor for listing available network interfaces and monitoring their changes.

ProtocolFactory subclass should check the NetworkMonitor has sufficient capabilities prior to usage.

Definition at line 188 of file protocol-factory.hpp.

std::set<std::string> nfd::face::ProtocolFactory::providedSchemes
protectedinherited

FaceUri schemes provided by this ProtocolFactory.

Definition at line 180 of file protocol-factory.hpp.