InterfaceAPIBase.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_InterfaceAPIBase_
18 #define HH_SENF_Ext_NetEmu_InterfaceAPIBase_ 1
19 
20 // Custom includes
21 #include "WirelessInterfaceAPI.hh"
22 #include "EmulatedInterface.hh"
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 namespace senf {
28 namespace emu {
29 namespace interface {
30 
31  // Transport
32  struct Hardware {};
33  struct Emulated {};
34 
35  // Medium
36  struct Wired {};
37  struct Wireless {};
38 
39  // Direction
40  struct Bidirectional {};
41  struct ReceiveOnly {};
42  struct TransmitOnly {};
43 
44 }
45 
160  template <class Medium, class Direction, class Transport=void, class Base=void>
162  {};
163 
164  //-/////////////////////////////////////////////////////////////////////////////////////////////
165  // senf::emu::InterfaceAPIBase< Wired,Bidirectional,void >
166 
167  template <>
169  : public WiredInterface, public WiredReceiver, public WiredTransmitter
170  {
171  public:
172  template <class Output, class Input>
173  InterfaceAPIBase(Output & output, Input & input);
174 
175  protected:
176  void init();
177  };
178 
180 
181  //-/////////////////////////////////////////////////////////////////////////////////////////////
182  // senf::emu::InterfaceAPIBase< Wired,Bidirectional,Hardware >
183 
184  template <>
186  : public BidirectionalWiredInterface,
187  public HardwareInterface
188  {
189  public:
190  template <class Output, class Input>
191  InterfaceAPIBase(Output & output, Input & input);
192 
193  protected:
194  void init();
195  };
196 
197  //-/////////////////////////////////////////////////////////////////////////////////////////////
198  // senf::emu::InterfaceAPIBase< Wired,ReceiveOnly,Hardware >
199 
200  template <>
202  : public WiredInterface, public WiredReceiver,
203  public HardwareInterface
204  {
205  public:
206  template <class Output>
207  explicit InterfaceAPIBase(Output & output);
208 
209  protected:
210  void init();
211  };
212 
213  //-/////////////////////////////////////////////////////////////////////////////////////////////
214  // senf::emu::InterfaceAPIBase< Wired,TransmitOnly,Hardware >
215 
216  template <>
218  : public WiredInterface, public WiredTransmitter,
219  public HardwareInterface
220  {
221  public:
222  template <class Input>
223  explicit InterfaceAPIBase(Input & input);
224 
225  protected:
226  void init();
227  };
228 
229  //-/////////////////////////////////////////////////////////////////////////////////////////////
230  // senf::emu::InterfaceAPIBase< Wireless,Bidirectional,void >
231 
232  template <>
233  class InterfaceAPIBase<interface::Wireless, interface::Bidirectional>
235  {
236  public:
237  template <class Output, class Input>
238  InterfaceAPIBase(Output & output, Input & input);
239 
240  protected:
241  void init();
242  };
243 
245 
246  //-/////////////////////////////////////////////////////////////////////////////////////////////
247  // senf::emu::InterfaceAPIBase< Wireless,Bidirectional,Hardware >
248 
249  template <>
251  : public BidirectionalWirelessInterface,
252  public HardwareInterface
253  {
254  public:
255  template <class Output, class Input>
256  InterfaceAPIBase(Output & output, Input & input);
257 
258  protected:
259  void init();
260  };
261 
262  //-/////////////////////////////////////////////////////////////////////////////////////////////
263  // senf::emu::InterfaceAPIBase< Wireless,ReceiveOnly,Hardware >
264 
265  template <>
267  : public WirelessInterface, public WirelessReceiver,
268  public HardwareInterface
269  {
270  public:
271  template <class Output>
272  explicit InterfaceAPIBase(Output & output);
273 
274  protected:
275  void init();
276  };
277 
278  //-/////////////////////////////////////////////////////////////////////////////////////////////
279  // senf::emu::InterfaceAPIBase< Wireless,TransmitOnly,Hardware >
280 
281  template <>
283  : public WirelessInterface, public WirelessTransmitter,
284  public HardwareInterface
285  {
286  public:
287  template <class Input>
288  explicit InterfaceAPIBase(Input & input);
289 
290  protected:
291  void init();
292  };
293 
294  //-/////////////////////////////////////////////////////////////////////////////////////////////
295  // senf::emu::InterfaceAPIBase< Wired,Bidirectional,Emulated >
296 
297  template < class Base>
299  : public Base,
301  {
302  public:
303  template <class Output, class Input>
304  InterfaceAPIBase(Output & output, Input & input);
305 
306  protected:
307  void init();
308 
309  private:
310  void v_enable();
311  void v_disable();
312  bool v_enabled() const;
313  void v_initEmulationInterface();
314  void v_deinitEmulationInterface();
315  bool v_promisc() const;
316  void v_promisc(bool v);
317  bool v_annotationMode() const;
318  void v_annotationMode(bool a);
319  void v_mcAdd(senf::MACAddress const & address);
320  void v_mcDrop(senf::MACAddress const & address);
321  unsigned v_mtu() const;
322  void v_mtu(unsigned v);
323  };
324 
325  template <>
327  : InterfaceAPIBase<interface::Wired, interface::Bidirectional, interface::Emulated, BidirectionalWiredInterface>
328  { };
329 
330  //-/////////////////////////////////////////////////////////////////////////////////////////////
331  // senf::emu::InterfaceAPIBase< Wired,ReceiveOnly,Emulated >
332 
333  template <>
335  : public WiredInterface, public WiredReceiver,
337  {
338  public:
339  template <class Output>
340  explicit InterfaceAPIBase(Output & output);
341 
342  protected:
343  void init();
344 
345  private:
346  void v_enable();
347  void v_disable();
348  bool v_enabled() const;
349  void v_initEmulationInterface();
350  void v_deinitEmulationInterface();
351  bool v_promisc() const;
352  void v_promisc(bool v);
353  bool v_annotationMode() const;
354  void v_annotationMode(bool a);
355  void v_mcAdd(senf::MACAddress const & address);
356  void v_mcDrop(senf::MACAddress const & address);
357  };
358 
359  //-/////////////////////////////////////////////////////////////////////////////////////////////
360  // senf::emu::InterfaceAPIBase< Wired,TransmitOnly,Emulated >
361 
362  template <>
364  : public WiredInterface, public WiredTransmitter,
366  {
367  public:
368  template <class Input>
369  explicit InterfaceAPIBase(Input & input);
370 
371  protected:
372  void init();
373 
374  private:
375  void v_enable();
376  void v_disable();
377  bool v_enabled() const;
378  void v_initEmulationInterface();
379  void v_deinitEmulationInterface();
380  unsigned v_mtu() const;
381  void v_mtu(unsigned v);
382  };
383 
384  //-/////////////////////////////////////////////////////////////////////////////////////////////
385  // senf::emu::InterfaceAPIBase< Wireless,Bidirectional,Emulated >
386 
387  template <class Base>
389  : public Base,
391  {
392  public:
393  template <class Output, class Input>
394  InterfaceAPIBase(Output & output, Input & input);
395 
396  protected:
397  void init();
398  // why the heck ??
401 
402  private:
403  void v_enable();
404  void v_disable();
405  bool v_enabled() const;
406  void v_initEmulationInterface();
407  void v_deinitEmulationInterface();
408  bool v_promisc() const;
409  void v_promisc(bool v);
410  bool v_annotationMode() const;
411  void v_annotationMode(bool a);
412  void v_mcAdd(senf::MACAddress const & address);
413  void v_mcDrop(senf::MACAddress const & address);
414  unsigned v_mtu() const;
415  void v_mtu(unsigned v);
416  unsigned v_frequency() const;
417  unsigned v_bandwidth() const;
418  void v_frequency(unsigned frequency, unsigned bandwidth);
419  void v_coverageRange(unsigned distance);
420  };
421 
422  template <>
424  : InterfaceAPIBase<interface::Wireless, interface::Bidirectional, interface::Emulated, BidirectionalWirelessInterface>
425  { };
426 
427  //-/////////////////////////////////////////////////////////////////////////////////////////////
428  // senf::emu::InterfaceAPIBase< Wireless,ReceiveOnly,Emulated >
429 
430  template <class Base>
432  : public Base, public WirelessReceiver,
434  {
435  public:
436  template <class Output>
437  explicit InterfaceAPIBase(Output & output);
438 
439  protected:
440  void init();
441  // why the heck ??
443 
444  private:
445  void v_enable();
446  void v_disable();
447  bool v_enabled() const;
448  void v_initEmulationInterface();
449  void v_deinitEmulationInterface();
450  bool v_promisc() const;
451  void v_promisc(bool v);
452  bool v_annotationMode() const;
453  void v_annotationMode(bool a);
454  void v_mcAdd(senf::MACAddress const & address);
455  void v_mcDrop(senf::MACAddress const & address);
456  unsigned v_frequency() const;
457  unsigned v_bandwidth() const;
458  void v_frequency(unsigned frequency, unsigned bandwidth);
459  void v_coverageRange(unsigned distance);
460  };
461 
462  template <>
464  : InterfaceAPIBase<interface::Wireless, interface::ReceiveOnly, interface::Emulated, WirelessInterface>
465  { };
466 
467  //-/////////////////////////////////////////////////////////////////////////////////////////////
468  // senf::emu::InterfaceAPIBase< Wireless,TransmitOnly,Emulated >
469 
470  template <class Base>
472  : public Base, public WirelessTransmitter,
474  {
475  public:
476  template <class Input>
477  explicit InterfaceAPIBase(Input & input);
478 
479  protected:
480  void init();
481  // why the heck ??
483 
484  private:
485  void v_enable();
486  void v_disable();
487  bool v_enabled() const;
488  void v_initEmulationInterface();
489  void v_deinitEmulationInterface();
490  unsigned v_mtu() const;
491  void v_mtu(unsigned v);
492  unsigned v_frequency() const;
493  unsigned v_bandwidth() const;
494  void v_frequency(unsigned frequency, unsigned bandwidth);
495  void v_coverageRange(unsigned distance);
496  };
497 
498  template <>
500  : InterfaceAPIBase<interface::Wireless, interface::TransmitOnly, interface::Emulated, WirelessInterface>
501  { };
502 
503 }}
504 
505 //-/////////////////////////////////////////////////////////////////////////////////////////////////
506 //#include "InterfaceAPIBase.cci"
507 //#include "InterfaceAPIBase.ct"
508 #include "InterfaceAPIBase.cti"
509 #endif
510 
511 
512 // Local Variables:
513 // mode: c++
514 // fill-column: 100
515 // comment-column: 40
516 // c-file-style: "senf"
517 // indent-tabs-mode: nil
518 // ispell-local-dictionary: "american"
519 // compile-command: "scons -u test"
520 // End:
WirelessInterfaceAPI public header.
void init()
Emulated interface base-class for receive capable wired interfaces.
Emulated wireless receiver base-class.
Emulated wireless transmitter base-class.
Wired interface base class.
EmulatedInterface public header.
InterfaceAPIBase< interface::Wired, interface::Bidirectional > BidirectionalWiredInterface
Wired receiver base class.
Interface API base class specialization for wireless interfaces.
ppi::connector::ActiveOutputJack receiverJack
Receive capable wireless interface base class.
InterfaceAPIBase< interface::Wireless, interface::Bidirectional > BidirectionalWirelessInterface
Interface implementation base-class.
Emulated wireless interface base-class.
ppi::connector::PassiveInputJack transmitterJack
Hardware interface base class.
Emulated interface base-class for wired interfaces.
Transmit capable wireless interface base class.
Wired transmitter base class.
EmulatedWirelessInterface public header.
Emulated interface base-class for transmit capable wired interfaces.