NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
udp-factory.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FACE_UDP_FACTORY_HPP
27 #define NFD_DAEMON_FACE_UDP_FACTORY_HPP
28 
29 #include "protocol-factory.hpp"
30 #include "udp-channel.hpp"
31 #include "multicast-udp-face.hpp"
32 
33 namespace nfd {
34 
36 
38 {
39 public:
44  {
45  public:
46  explicit
47  Error(const std::string& what)
48  : ProtocolFactory::Error(what)
49  {
50  }
51  };
52 
53  typedef std::map<udp::Endpoint, shared_ptr<MulticastUdpFace>> MulticastFaceMap;
54 
55  explicit
56  UdpFactory(const std::string& defaultPort = "6363");
57 
82  shared_ptr<UdpChannel>
83  createChannel(const udp::Endpoint& localEndpoint,
84  const time::seconds& timeout = time::seconds(600));
85 
100  shared_ptr<UdpChannel>
101  createChannel(const std::string& localIp,
102  const std::string& localPort,
103  const time::seconds& timeout = time::seconds(600));
104 
134  shared_ptr<MulticastUdpFace>
135  createMulticastFace(const udp::Endpoint& localEndpoint,
136  const udp::Endpoint& multicastEndpoint,
137  const std::string& networkInterfaceName = "");
138 
139  shared_ptr<MulticastUdpFace>
140  createMulticastFace(const std::string& localIp,
141  const std::string& multicastIp,
142  const std::string& multicastPort,
143  const std::string& networkInterfaceName = "");
144 
145  // from ProtocolFactory
146  virtual void
147  createFace(const FaceUri& uri,
148  ndn::nfd::FacePersistency persistency,
149  const FaceCreatedCallback& onCreated,
150  const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
151 
152  virtual std::list<shared_ptr<const Channel>>
153  getChannels() const;
154 
158  const MulticastFaceMap&
159  getMulticastFaces() const;
160 
162  void
163  prohibitEndpoint(const udp::Endpoint& endpoint);
164 
165  void
166  prohibitAllIpv4Endpoints(const uint16_t port);
167 
168  void
169  prohibitAllIpv6Endpoints(const uint16_t port);
170 
171  void
172  afterFaceFailed(udp::Endpoint& endpoint);
173 
182  shared_ptr<UdpChannel>
183  findChannel(const udp::Endpoint& localEndpoint);
184 
193  shared_ptr<MulticastUdpFace>
194  findMulticastFace(const udp::Endpoint& localEndpoint);
195 
197  typedef std::map<udp::Endpoint, shared_ptr<UdpChannel>> ChannelMap;
198 
199  ChannelMap m_channels;
200  MulticastFaceMap m_multicastFaces;
201 
202  std::string m_defaultPort;
203  std::set<udp::Endpoint> m_prohibitedEndpoints;
204 };
205 
206 inline const UdpFactory::MulticastFaceMap&
208 {
209  return m_multicastFaces;
210 }
211 
212 } // namespace nfd
213 
214 #endif // NFD_DAEMON_FACE_UDP_FACTORY_HPP
function< void(const std::string &reason)> FaceConnectFailedCallback
Prototype for the callback that is called when face is failed to get created.
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onCreated, const FaceConnectFailedCallback &onConnectFailed) 1
Try to create Face using the supplied FaceUri.
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
UdpFactory(const std::string &defaultPort="6363")
Definition: udp-factory.cpp:48
std::map< udp::Endpoint, shared_ptr< MulticastUdpFace > > MulticastFaceMap
Definition: udp-factory.hpp:53
#define DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:49
virtual std::list< shared_ptr< const Channel > > getChannels() const
shared_ptr< UdpChannel > createChannel(const udp::Endpoint &localEndpoint, const time::seconds &timeout=time::seconds(600))
Create UDP-based channel using udp::Endpoint.
Exception of UdpFactory.
Definition: udp-factory.hpp:43
Error(const std::string &what)
Definition: udp-factory.hpp:47
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
shared_ptr< MulticastUdpFace > createMulticastFace(const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
Create MulticastUdpFace using udp::Endpoint.
Base class for all exceptions thrown by channel factories.
boost::asio::ip::udp::endpoint Endpoint
Definition: udp-channel.hpp:34
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback called when face is created (as a response to incoming connection or after...
const MulticastFaceMap & getMulticastFaces() const
Get map of configured multicast faces.