NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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  bool wantLocalFieldsEnabled,
153  const FaceCreatedCallback& onCreated,
154  const FaceCreationFailedCallback& onFailure) override;
155 
156  virtual std::vector<shared_ptr<const Channel>>
157  getChannels() const override;
158 
160  void
161  prohibitEndpoint(const udp::Endpoint& endpoint);
162 
163  void
164  prohibitAllIpv4Endpoints(uint16_t port);
165 
166  void
167  prohibitAllIpv6Endpoints(uint16_t port);
168 
169 private:
176  shared_ptr<UdpChannel>
177  findChannel(const udp::Endpoint& localEndpoint) const;
178 
185  shared_ptr<Face>
186  findMulticastFace(const udp::Endpoint& localEndpoint) const;
187 
188 private:
189  std::map<udp::Endpoint, shared_ptr<UdpChannel>> m_channels;
190  MulticastFaceMap m_multicastFaces;
191 
193  std::set<udp::Endpoint> m_prohibitedEndpoints;
194 };
195 
196 inline const UdpFactory::MulticastFaceMap&
198 {
199  return m_multicastFaces;
200 }
201 
202 } // namespace nfd
203 
204 #endif // NFD_DAEMON_FACE_UDP_FACTORY_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
const MulticastFaceMap & getMulticastFaces() const
Get map of configured multicast faces.
std::map< udp::Endpoint, shared_ptr< Face > > MulticastFaceMap
Definition: udp-factory.hpp:52
virtual std::vector< shared_ptr< const Channel > > getChannels() const override
Base class for all exceptions thrown by protocol factories.
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
shared_ptr< Face > createMulticastFace(const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
Create MulticastUdpFace using udp::Endpoint.
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
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
Abstract base class for all protocol factories.
boost::asio::ip::udp::endpoint Endpoint
Definition: udp-channel.hpp:34
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
Definition: channel.hpp:44
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
virtual 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.