nfd::face::UdpFactory Class Reference

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

#include <udp-factory.hpp>

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

Classes

class  Error
 Exception of UdpFactory. More...
 

Public Member Functions

void processConfig (OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
 process face_system.udp config section More...
 
void createFace (const FaceUri &uri, ndn::nfd::FacePersistency persistency, bool wantLocalFieldsEnabled, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
 Try to create Face using the supplied FaceUri. More...
 
shared_ptr< UdpChannelcreateChannel (const udp::Endpoint &localEndpoint, const time::seconds &timeout=time::seconds(600))
 Create UDP-based channel using udp::Endpoint. More...
 
shared_ptr< UdpChannelcreateChannel (const std::string &localIp, const std::string &localPort, const time::seconds &timeout=time::seconds(600))
 Create UDP-based channel using specified IP address and port number. More...
 
std::vector< shared_ptr< const Channel > > getChannels () const override
 
shared_ptr< FacecreateMulticastFace (const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
 Create MulticastUdpFace using udp::Endpoint. More...
 
shared_ptr< FacecreateMulticastFace (const std::string &localIp, const std::string &multicastIp, const std::string &multicastPort, const std::string &networkInterfaceName="")
 
const std::set< std::string > & getProvidedSchemes ()
 

Static Public Member Functions

static const std::string & getId ()
 
template<typename PF >
static void registerType (const std::string &id=PF::getId())
 register a protocol factory type More...
 
static unique_ptr< ProtocolFactorycreate (const std::string &id)
 
static std::set< std::string > listRegistered ()
 

Static Protected Member Functions

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

Protected Attributes

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 Function Documentation

unique_ptr< ProtocolFactory > nfd::face::ProtocolFactory::create ( const std::string &  id)
staticinherited
Returns
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,
const time::seconds &  timeout = time::seconds(600) 
)

Create UDP-based channel using udp::Endpoint.

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

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

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

Once a face is created, if it doesn't send/receive anything for a period of time equal to timeout, it will be destroyed

Todo:
this funcionality has to be implemented
Returns
always a valid pointer to a UdpChannel object, an exception is thrown if it cannot be created.
Exceptions
UdpFactory::Error
See also
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/ip__udp/endpoint.html for details on ways to create udp::Endpoint

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

shared_ptr< UdpChannel > nfd::face::UdpFactory::createChannel ( const std::string &  localIp,
const std::string &  localPort,
const time::seconds &  timeout = time::seconds(600) 
)

Create UDP-based channel using specified IP address and port number.

This method is just a helper that converts a string representation of localIp and port to udp::Endpoint and calls the other createChannel overload.

If localHost is a IPv6 address of a specific device, it must be in the form: ip addressinterface name Example: fe80::5e96:9dff:fe7d:9c8den1 Otherwise, you can use ::

Exceptions
UdpChannel::Errorif the bind on the socket fails
UdpFactory::Error

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

void nfd::face::UdpFactory::createFace ( const FaceUri &  uri,
ndn::nfd::FacePersistency  persistency,
bool  wantLocalFieldsEnabled,
const FaceCreatedCallback onCreated,
const FaceCreationFailedCallback onFailure 
)
overridevirtual

Try to create Face using the supplied FaceUri.

This method should automatically choose channel, based on supplied FaceUri and create face.

Parameters
uriremote URI of the new face
persistencypersistency of the new face
wantLocalFieldsEnabledwhether local fields should be enabled on the face
onCreatedcallback if face creation succeeds If a face with the same remote URI already exists, its persistency and LocalFieldsEnabled setting will not be modified.
onFailurecallback if face creation fails

Implements nfd::face::ProtocolFactory.

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

shared_ptr< Face > nfd::face::UdpFactory::createMulticastFace ( const udp::Endpoint localEndpoint,
const udp::Endpoint multicastEndpoint,
const std::string &  networkInterfaceName = "" 
)

Create MulticastUdpFace using udp::Endpoint.

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

The face will join the multicast group

If this method called twice with the same endpoint and group, only one face will be created. The second call will just retrieve the existing channel.

If an unicast face is already active on the same local NIC and port, the creation fails and an exception is thrown

Parameters
localEndpointlocal endpoint
multicastEndpointmulticast endpoint
networkInterfaceNamename of the network interface on which the face will be bound (Used only on multihomed linux machine with more than one MulticastUdpFace for the same multicast group. If specified, will requires CAP_NET_RAW capability) An empty string can be provided in other system or in linux machine with only one MulticastUdpFace per multicast group
Returns
always a valid pointer to a MulticastUdpFace object, an exception is thrown if it cannot be created.
Exceptions
UdpFactory::Error
See also
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/ip__udp/endpoint.html for details on ways to create udp::Endpoint

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

shared_ptr< Face > nfd::face::UdpFactory::createMulticastFace ( const std::string &  localIp,
const std::string &  multicastIp,
const std::string &  multicastPort,
const std::string &  networkInterfaceName = "" 
)

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

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

Implements nfd::face::ProtocolFactory.

Definition at line 333 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 147 of file protocol-factory.hpp.

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

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

const std::set<std::string>& nfd::face::ProtocolFactory::getProvidedSchemes ( )
inlineinherited
Returns
FaceUri schemes accepted by this ProtocolFactory

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

std::set< std::string > nfd::face::ProtocolFactory::listRegistered ( )
staticinherited
Returns
registered protocol factory ids

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

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

process face_system.udp config section

Reimplemented from nfd::face::ProtocolFactory.

Definition at line 56 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 54 of file protocol-factory.hpp.

Member Data Documentation

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

FaceUri schemes provided by this ProtocolFactory.

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