InterfaceId.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_InterfaceId_
18 #define HH_SENF_Ext_NetEmu_InterfaceId_ 1
19 
20 // Custom includes
21 #include <set>
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
28  struct MACAddress;
29 
30 namespace emu {
31 
33  {
34  public:
35  enum Bus_t { Unknown = 0, PCI = 1, PCIe, USB };
36 
38  InterfaceDeviceId(Bus_t b, boost::uint16_t v, boost::uint16_t d);
39  InterfaceDeviceId(boost::uint8_t b, boost::uint16_t v, boost::uint16_t d);
40 
41  static const InterfaceDeviceId None;
42 
43  static InterfaceDeviceId get(senf::MACAddress const & addr);
44 
45  bool operator<(InterfaceDeviceId const & other) const;
46  bool operator==(InterfaceDeviceId const & other) const;
47 
48  Bus_t bus() const;
49  boost::uint16_t vendor() const;
50  boost::uint16_t device() const;
51 
52  private:
53  Bus_t bus_;
54  boost::uint16_t vendor_;
55  boost::uint16_t device_;
56 
57  SENF_CONSOLE_PARSE_FRIEND( InterfaceDeviceId );
58  };
59 
60  std::ostream & operator<<(std::ostream & os, InterfaceDeviceId const & id);
61 
63 
64 
66  {
67  public:
69 
70  MACAddress getId();
71  void releaseId(MACAddress const & id);
72 
73  private:
74  virtual MACAddress v_getId() = 0;
75  virtual void v_releaseId(MACAddress const & id) = 0;
76  };
77 
78 
80  : public InterfaceIdFactoryBase
81  {
82  private:
83  MACAddress v_getId();
84  void v_releaseId(MACAddress const & id);
85 
86  boost::uint32_t calcFirstFreeId();
87 
88  typedef std::set<boost::uint16_t> IdSet;
89  IdSet idSet_;
90  };
91 
92 }};
93 
95 
96 
97 //-/////////////////////////////////////////////////////////////////////////////////////////////////
98 //#include "InterfaceId.cci"
99 //#include "InterfaceId.ct"
100 //#include "InterfaceId.cti"
101 #endif
102 
103 
104 // Local Variables:
105 // mode: c++
106 // fill-column: 100
107 // comment-column: 40
108 // c-file-style: "senf"
109 // indent-tabs-mode: nil
110 // ispell-local-dictionary: "american"
111 // compile-command: "scons -u test"
112 // End:
boost::uint16_t device() const
Definition: InterfaceId.cc:141
static const InterfaceDeviceId None
Definition: InterfaceId.hh:41
bool operator==(InterfaceDeviceId const &other) const
Definition: InterfaceId.cc:121
SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBModulationParameter, fec_rate_t,(FEC_NONE)(FEC_1_2)(FEC_2_3)(FEC_3_4)(FEC_4_5)(FEC_5_6)(FEC_6_7)(FEC_7_8)(FEC_8_9)(FEC_AUTO)(FEC_3_5)(FEC_9_10))
bool operator<(InterfaceDeviceId const &other) const
Definition: InterfaceId.cc:111
boost::uint16_t vendor() const
Definition: InterfaceId.cc:135
SENF_CONSOLE_PARSE_AND_FORMAT_AS_TUPLE(senf::emu::InterfaceDeviceId,(bus_)(vendor_)(device_))
std::ostream & operator<<(std::ostream &os, InterfaceDeviceId const &id)
Definition: InterfaceId.cc:105