TunnelInterface.ih
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 
14 /** \file
15  \brief TunnelInterface internal header */
16 
17 #ifndef IH_SENF_Ext_NetEmu_P2PTunnel_TunnelInterface_
18 #define IH_SENF_Ext_NetEmu_P2PTunnel_TunnelInterface_ 1
19 
20 // Custom includes
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 namespace senf {
25 namespace emu {
26 
27  class TunnelInterfaceBase;
28 
29 namespace detail {
30 
31  template <class Controller> struct TunnelInterfaceNet;
32 
33  template <class Controller>
34  class TunnelIOHelper
35  {
36  public:
37  TunnelIOHelper(TunnelControllerBase & ctrl, TunnelInterfaceNet<Controller> const & tif);
38 
39  // implement PPI Source-Reader / Sink-Writer API
40  typedef TunnelControllerBase::Handle Handle;
41  typedef TunnelControllerBase::PacketType PacketType;
42 
43  PacketType operator()(Handle & handle);
44  bool operator()(Handle & handle, PacketType const & packet);
45 
46  private:
47  TunnelControllerBase & ctrl_;
48  TunnelInterfaceNet<Controller> const & tunnelIface_;
49  };
50 
51 
52  /** \brief Internal: Tunnel Interface PPI network */
53  template <class Controller>
54  struct TunnelInterfaceNet
55  {
56  UDPv6ClientSocketHandle socket;
57  Controller tunnelCtrl;
58 
59  ppi::module::ActiveSocketSource<TunnelIOHelper<Controller> > source;
60  ppi::module::PassiveSocketSink<TunnelIOHelper<Controller> > sink;
61 
62  ppi::connector::ActiveOutputJack<EthernetPacket> netOutput;
63  ppi::connector::PassiveInputJack<EthernetPacket> netInput;
64 
65  unsigned mtu_;
66  unsigned maxBurst_;
67  bool promisc_;
68  bool annotationMode_;
69 
70  TunnelInterfaceNet(typename Controller::Interface & interface);
71 
72  void assignSocket(UDPv6ClientSocketHandle socket);
73 
74  unsigned mtu() const;
75  void mtu(unsigned v);
76 
77  void _promisc(bool p);
78  bool _promisc() const;
79 
80  void _annotationMode(bool a);
81  bool _annotationMode() const;
82 
83  unsigned maxBurst() const;
84  void maxBurst(unsigned v);
85 
86  unsigned rcvBuf();
87  void rcvBuf(unsigned);
88  unsigned sndBuf();
89  void sndBuf(unsigned);
90  };
91 
92  typedef TunnelInterfaceNet<TunnelServerController> TunnelServerInterfaceNet;
93  typedef TunnelInterfaceNet<TunnelClientController> TunnelClientInterfaceNet;
94 
95 }}}
96 
97 //-/////////////////////////////////////////////////////////////////////////////////////////////////
98 #endif
99 
100 
101 // Local Variables:
102 // mode: c++
103 // fill-column: 100
104 // comment-column: 40
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // compile-command: "scons -u test"
109 // End: