HardwareEthernetInterface.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_Ethernet_HardwareEthernetInterface_
18 #define HH_SENF_Ext_NetEmu_Ethernet_HardwareEthernetInterface_ 1
19 
20 // Custom includes
23 #include "EthernetController.hh"
24 #include "EthernetInterface.hh"
25 
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace emu {
31 
41  : private detail::HardwareEthernetInterfaceNet,
42  public EthernetInterface,
43  public HardwareInterface
44  {
45  public:
48 
49  HardwareEthernetInterface(std::string const & name);
50 
52 
53  std::string const & v_device() const override;
54 
55  void setREDFilterCallbackRx(senf::ppi::REDFilterCallback const & cb);
56  void setREDFilterCallbackTx(senf::ppi::REDFilterCallback const & cb);
57 
58  VLanId const & pvid() const;
59  bool pvid(VLanId const & p, bool accessMode);
60  std::uint32_t vlanMismatchRx();
61  std::uint32_t vlanMismatchTx();
62 
63  unsigned sndBuf();
64  void sndBuf(unsigned sndbuf);
65  unsigned rcvBuf();
66  void rcvBuf(unsigned rcvbuf);
67 
68  unsigned qlen() const;
69  void qlen(unsigned qlen);
70 
71  std::pair<unsigned,unsigned> rxDropped();
72  std::tuple<unsigned,unsigned,unsigned> txDropped();
73 
74  void dumpMmapStats(std::ostream & os);
75  bool isDead() const;
76 
77 #ifdef SENF_DEBUG
78  unsigned burstMax();
79 #endif
80 
81  unsigned maxBurst() const;
82  void maxBurst(unsigned maxBurst);
83 
85 
86  protected:
87 
88  virtual void v_enable() override;
89  virtual void v_disable() override;
90 
91  virtual unsigned v_mtu() const override;
92  virtual void v_mtu(unsigned v) override;
93 
94  private:
95  void init_sockets();
96  void close_sockets();
97 
98  // interface
99  virtual bool v_enabled() const override;
100  virtual void v_id(MACAddress const & id) override;
101  virtual bool v_annotationMode() const override;
102  virtual void v_annotationMode(bool a) override;
103  virtual bool v_promisc() const override;
104  virtual void v_promisc(bool v) override;
105  virtual void v_mcAdd(MACAddress const & address) override;
106  virtual void v_mcDrop(MACAddress const & address) override;
107  virtual void v_flushRxQueues() override;
108  virtual void v_flushTxQueues() override;
109 
110  virtual MACAddress v_id() const override;
111 
112  std::string dev_;
113  EthernetController ctrl_;
114 
115  unsigned rcvBufSize_;
116  unsigned sndBufSize_;
117  unsigned qlen_;
118  VLanId pvid_;
119  bool accessMode_;
120  senf::MACAddress initialId_;
121 
122  friend struct detail::HardwareEthernetInterfaceNet;
123  friend class EthernetAnnotator;
124  };
125 
126 }}
127 
128 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 //#include "HardwareEthernetInterface.ct"
131 //#include "HardwareEthernetInterface.cti"
132 #endif
133 
134 
135 // Local Variables:
136 // mode: c++
137 // fill-column: 100
138 // comment-column: 40
139 // c-file-style: "senf"
140 // indent-tabs-mode: nil
141 // ispell-local-dictionary: "american"
142 // compile-command: "scons -u test"
143 // End:
void setREDFilterCallbackTx(senf::ppi::REDFilterCallback const &cb)
WLANController public header.
TypedInterfaceDecorator< HardwareEthernetInterface, Interface::Decorator > Decorator
void setREDFilterCallbackRx(senf::ppi::REDFilterCallback const &cb)
std::tuple< unsigned, unsigned, unsigned > txDropped()
virtual unsigned v_mtu() const override
Called to get interface MTU.
Hardware interface base class.
EthernetController & ethController()
std::string const & v_device() const override
std::pair< unsigned, unsigned > rxDropped()
Specialized Interface decorator base-class.
virtual void v_disable() override
Called to disable interface.
Generic Interface decorator base-class.
Control ethernet interfaces.
EthernetInterface public header.
virtual void v_enable() override
Called to enable interface.