TunnelInterface.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Ext_NetEmu_P2PTunnel_TunnelInterface_
18 #define HH_SENF_Ext_NetEmu_P2PTunnel_TunnelInterface_ 1
19 
20 // Custom includes
23 #include "TunnelController.hh"
24 
25 #include "TunnelInterface.ih"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 namespace emu {
30 
33  public HardwareInterface
34  {
35  public:
36  virtual ~TunnelInterfaceBase();
37 
38  INet6SocketAddress const & address() const;
39 
42 
43  boost::shared_ptr<InterfaceIdFactoryBase> ifaceIdFactory();
44  void ifaceIdFactory(boost::shared_ptr<InterfaceIdFactoryBase> factory);
45 
48 
49  protected:
50  template <class Output, class Input>
51  TunnelInterfaceBase(Output & output, Input & input, detail::TunnelControllerBase & ctrlBase, INet6SocketAddress const & address);
52 
53  void isUp(bool up);
54 
57 
58  private:
59  // interface API
60  virtual bool v_enabled() const override;
61  virtual void v_id(MACAddress const & id) override;
62  virtual MACAddress v_id() const override;
63  virtual void v_mcAdd(MACAddress const & address) override;
64  virtual void v_mcDrop(MACAddress const & address) override;
65  virtual boost::uint8_t v_linkTypeId() const override;
66  std::string const & v_device() const override;
67 
68  detail::TunnelControllerBase & ctrlBase_;
69  INet6SocketAddress socketAddress_;
70  boost::shared_ptr<InterfaceIdFactoryBase> ifaceIdFactory_;
71  MACAddress id_;
72  bool isUp_;
73  std::string dev_;
74  };
75 
76 
83  : private detail::TunnelServerInterfaceNet,
84  public TunnelInterfaceBase
85  {
86  public:
88 
91 
92  unsigned capacity(MACAddress const & client, tunnel::CapacityDirection direction) const;
93 
94  unsigned sndBuf();
95  void sndBuf(unsigned sndbuf);
96  unsigned rcvBuf();
97  void rcvBuf(unsigned rcvbuf);
98 
99  unsigned fragmentationThreshold(MACAddress const & client) const;
100  void fragmentationThreshold(MACAddress const & client, unsigned mtu);
101 
102  unsigned maxBurst() const;
103  void maxBurst(unsigned v);
104 
105  private:
106  // interface API
107  virtual void v_enable() override;
108  virtual void v_disable() override;
109  virtual unsigned v_mtu() const override;
110  virtual void v_mtu(unsigned v) override;
111  virtual bool v_promisc() const override;
112  virtual void v_promisc(bool v) override;
113  virtual bool v_annotationMode() const override;
114  virtual void v_annotationMode(bool a) override;
115 
116  private:
117  unsigned sndBufSize_;
118  unsigned rcvBufSize_;
119  };
120 
121 
123  : private detail::TunnelClientInterfaceNet,
124  public TunnelInterfaceBase
125  {
126  public:
128 
131 
132  void serverAddress(INet6SocketAddress const & address);
133  void serverAddress(INet4SocketAddress const & address);
134  INet6SocketAddress const & serverAddress() const;
135 
136  bool established() const;
137 
138  unsigned capacity(tunnel::CapacityDirection direction) const;
139  void capacity(tunnel::CapacityDirection direction, unsigned cap);
140 
141  unsigned sndBuf();
142  void sndBuf(unsigned sndbuf);
143  unsigned rcvBuf();
144  void rcvBuf(unsigned rcvbuf);
145 
146  unsigned fragmentationThreshold() const;
147  void fragmentationThreshold(unsigned mtu);
148 
149  unsigned maxBurst() const;
150  void maxBurst(unsigned v);
151 
152  private:
153  // interface API
154  virtual void v_enable() override;
155  virtual void v_disable() override;
156  virtual unsigned v_mtu() const override;
157  virtual void v_mtu(unsigned v) override;
158  virtual bool v_promisc() const override;
159  virtual void v_promisc(bool v) override;
160  virtual bool v_annotationMode() const override;
161  virtual void v_annotationMode(bool a) override;
162 
163  tunnel::Capacity capacity_;
164 
165  unsigned sndBufSize_;
166  unsigned rcvBufSize_;
167 
169  };
170 
171 }}
172 
173 //-/////////////////////////////////////////////////////////////////////////////////////////////////
174 //#include "TunnelInterface.cci"
175 //#include "TunnelInterface.ct"
176 //#include "TunnelInterface.cti"
177 #endif
178 
179 
180 // Local Variables:
181 // mode: c++
182 // fill-column: 100
183 // comment-column: 40
184 // c-file-style: "senf"
185 // indent-tabs-mode: nil
186 // ispell-local-dictionary: "american"
187 // compile-command: "scons -u test"
188 // End:
config::time_type clock_type
senf::ppi::QueueingAlgorithm & qAlgorithm() const
TunnelController internal header.
std::map< CapacityDirection, unsigned > Capacity
virtual void v_enable()=0
Called to enable interface.
unsigned mtu() const
Get interface MTU.
virtual void v_disable()=0
Called to disable interface.
INet6SocketAddress const & address() const
TypedInterfaceDecorator< TunnelServerInterface, Interface::Decorator > Decorator
std::unique_ptr< QueueingAlgorithm > ptr
detail::TunnelControllerBase & tunnelCtrlBase()
InterfaceAPIBase public header.
Tunnel Server Interface.
InterfaceId public header.
TypedInterfaceDecorator< TunnelClientInterface, Interface::Decorator > Decorator
ppi::connector::PassiveInputJack< EthernetPacket > input
Hardware interface base class.
ppi::connector::ActiveOutputJack< EthernetPacket > output
ClockService::clock_type timeout() const
Specialized Interface decorator base-class.
boost::shared_ptr< InterfaceIdFactoryBase > ifaceIdFactory()
TunnelInterfaceBase(Output &output, Input &input, detail::TunnelControllerBase &ctrlBase, INet6SocketAddress const &address)