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 
32 namespace nfd {
33 
35 
37 {
38 public:
43  {
44  public:
45  explicit
46  Error(const std::string& what)
47  : ProtocolFactory::Error(what)
48  {
49  }
50  };
51 
52  typedef std::map<udp::Endpoint, shared_ptr<Face>> MulticastFaceMap;
53 
78  shared_ptr<UdpChannel>
79  createChannel(const udp::Endpoint& localEndpoint,
80  const time::seconds& timeout = time::seconds(600));
81 
96  shared_ptr<UdpChannel>
97  createChannel(const std::string& localIp, const std::string& localPort,
98  const time::seconds& timeout = time::seconds(600));
99 
131  shared_ptr<Face>
132  createMulticastFace(const udp::Endpoint& localEndpoint,
133  const udp::Endpoint& multicastEndpoint,
134  const std::string& networkInterfaceName = "");
135 
136  shared_ptr<Face>
137  createMulticastFace(const std::string& localIp,
138  const std::string& multicastIp,
139  const std::string& multicastPort,
140  const std::string& networkInterfaceName = "");
141 
145  const MulticastFaceMap&
146  getMulticastFaces() const;
147 
148 public: // from ProtocolFactory
149  virtual void
150  createFace(const FaceUri& uri,
151  ndn::nfd::FacePersistency persistency,
152  const FaceCreatedCallback& onCreated,
153  const FaceCreationFailedCallback& onConnectFailed) DECL_OVERRIDE;
154 
155  virtual std::vector<shared_ptr<const Channel>>
156  getChannels() const DECL_OVERRIDE;
157 
159  void
160  prohibitEndpoint(const udp::Endpoint& endpoint);
161 
162  void
163  prohibitAllIpv4Endpoints(uint16_t port);
164 
165  void
166  prohibitAllIpv6Endpoints(uint16_t port);
167 
168 private:
175  shared_ptr<UdpChannel>
176  findChannel(const udp::Endpoint& localEndpoint) const;
177 
184  shared_ptr<Face>
185  findMulticastFace(const udp::Endpoint& localEndpoint) const;
186 
187 private:
188  std::map<udp::Endpoint, shared_ptr<UdpChannel>> m_channels;
189  MulticastFaceMap m_multicastFaces;
190 
192  std::set<udp::Endpoint> m_prohibitedEndpoints;
193 };
194 
195 inline const UdpFactory::MulticastFaceMap&
197 {
198  return m_multicastFaces;
199 }
200 
201 } // namespace nfd
202 
203 #endif // NFD_DAEMON_FACE_UDP_FACTORY_HPP
const MulticastFaceMap & getMulticastFaces() const
Get map of configured multicast faces.
std::map< udp::Endpoint, shared_ptr< Face > > MulticastFaceMap
Definition: udp-factory.hpp:52
function< void(const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
Definition: channel.hpp:44
Base class for all exceptions thrown by protocol factories.
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
Class implementing UDP-based channel to create faces.
Definition: udp-channel.hpp:40
shared_ptr< Face > createMulticastFace(const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
Create MulticastUdpFace using udp::Endpoint.
STL namespace.
#define DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports &#39;override&#39; specifier, otherwise expands to nothing ...
Definition: common.hpp:50
shared_ptr< UdpChannel > createChannel(const udp::Endpoint &localEndpoint, const time::seconds &timeout=time::seconds(600))
Create UDP-based channel using udp::Endpoint.
Definition: udp-factory.cpp:92
Exception of UdpFactory.
Definition: udp-factory.hpp:42
virtual std::vector< shared_ptr< const Channel > > getChannels() const 1
Error(const std::string &what)
Definition: udp-factory.hpp:46
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onConnectFailed) 1
Try to create Face using the supplied FaceUri.
Abstract base class for all protocol factories.
boost::asio::ip::tcp::endpoint Endpoint
Definition: tcp-channel.hpp:35
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 that is invoked when the face is created (as a response to incoming connec...
Definition: channel.hpp:38