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 namespace face {
34 
41 {
42 public:
47  {
48  public:
49  explicit
50  Error(const std::string& what)
51  : ProtocolFactory::Error(what)
52  {
53  }
54  };
55 
56  static const std::string&
57  getId();
58 
61  void
63  FaceSystem::ConfigContext& context) override;
64 
65  void
66  createFace(const FaceUri& uri,
67  ndn::nfd::FacePersistency persistency,
68  bool wantLocalFieldsEnabled,
69  const FaceCreatedCallback& onCreated,
70  const FaceCreationFailedCallback& onFailure) override;
71 
96  shared_ptr<UdpChannel>
97  createChannel(const udp::Endpoint& localEndpoint,
98  const time::seconds& timeout = time::seconds(600));
99 
114  shared_ptr<UdpChannel>
115  createChannel(const std::string& localIp, const std::string& localPort,
116  const time::seconds& timeout = time::seconds(600));
117 
118  std::vector<shared_ptr<const Channel>>
119  getChannels() const override;
120 
152  shared_ptr<Face>
153  createMulticastFace(const udp::Endpoint& localEndpoint,
154  const udp::Endpoint& multicastEndpoint,
155  const std::string& networkInterfaceName = "");
156 
157  shared_ptr<Face>
158  createMulticastFace(const std::string& localIp,
159  const std::string& multicastIp,
160  const std::string& multicastPort,
161  const std::string& networkInterfaceName = "");
162 
164  void
165  prohibitEndpoint(const udp::Endpoint& endpoint);
166 
167  void
168  prohibitAllIpv4Endpoints(uint16_t port);
169 
170  void
171  prohibitAllIpv6Endpoints(uint16_t port);
172 
173 private:
180  shared_ptr<UdpChannel>
181  findChannel(const udp::Endpoint& localEndpoint) const;
182 
189  shared_ptr<Face>
190  findMulticastFace(const udp::Endpoint& localEndpoint) const;
191 
192  void
193  applyMulticastConfig(const FaceSystem::ConfigContext& context);
194 
195 private:
196  std::map<udp::Endpoint, shared_ptr<UdpChannel>> m_channels;
197 
198  struct MulticastConfig
199  {
200  bool isEnabled = false;
202  NetworkInterfacePredicate netifPredicate;
203  };
204 
205  MulticastConfig m_mcastConfig;
206  std::map<udp::Endpoint, shared_ptr<Face>> m_mcastFaces;
207 
209  std::set<udp::Endpoint> m_prohibitedEndpoints;
210 };
211 
212 } // namespace face
213 } // namespace nfd
214 
215 #endif // NFD_DAEMON_FACE_UDP_FACTORY_HPP
shared_ptr< UdpChannel > createChannel(const udp::Endpoint &localEndpoint, const time::seconds &timeout=time::seconds(600))
Create UDP-based channel using udp::Endpoint.
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.
Error(const std::string &what)
Definition: udp-factory.hpp:50
Exception of UdpFactory.
Definition: udp-factory.hpp:46
Endpoint getDefaultMulticastGroup()
context for processing a config section in ProtocolFactory
Definition: face-system.hpp:77
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
Definition: config-file.hpp:41
boost::asio::ip::udp::endpoint Endpoint
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
provide support for an underlying protocol
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.udp config section
Definition: udp-factory.cpp:56
static const std::string & getId()
Definition: udp-factory.cpp:48
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
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
std::vector< shared_ptr< const Channel > > getChannels() const override
Represents a predicate to accept or reject a NetworkInterfaceInfo.
protocol factory for UDP over IPv4 and IPv6
Definition: udp-factory.hpp:40
Base class for all exceptions thrown by protocol factories.
shared_ptr< Face > createMulticastFace(const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
Create MulticastUdpFace using udp::Endpoint.