InterfaceAPI.cci
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 InterfaceAPI inline non-template implementation */
16 
17 #include <senf/Utils/String.hh>
18 #include "InterfaceAPI.ih"
19 
20 // Custom includes
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::emu::Interface
27 
28 prefix_ senf::emu::Interface::~Interface()
29 {
30  try {
31  // can't call id() anymore, as this would call v_id()
32  console::provideDirectory(interfaceDir(),"by-id").remove(senf::str(id_));
33  } catch (...) {};
34 }
35 
36 prefix_ bool senf::emu::Interface::canTransmit()
37  const
38 {
39  try {
40  return dynamic_cast<Transmitter const *>(this);
41  }
42  SENF_WRAP_EXC(std::bad_cast)
43 }
44 
45 prefix_ bool senf::emu::Interface::canReceive()
46  const
47 {
48  try {
49  return dynamic_cast<Receiver const *>(this);
50  }
51  SENF_WRAP_EXC(std::bad_cast)
52 }
53 
54 prefix_ void senf::emu::Interface::enable()
55 {
56  v_enable();
57 }
58 
59 prefix_ void senf::emu::Interface::disable()
60 {
61  v_disable();
62 }
63 
64 prefix_ bool senf::emu::Interface::enabled()
65  const
66 {
67  return v_enabled();
68 }
69 
70 prefix_ senf::MACAddress const & senf::emu::Interface::id()
71  const
72 {
73  return id_ = v_id();
74 }
75 
76 prefix_ unsigned senf::emu::Interface::index()
77  const
78 {
79  return index_;
80 }
81 
82 prefix_ unsigned senf::emu::Interface::nodeId()
83 {
84  return nodeId_;
85 }
86 
87 prefix_ void senf::emu::Interface::nodeId(unsigned id)
88 {
89  nodeId_ = id;
90 }
91 
92 prefix_ void senf::emu::Interface::deviceId(InterfaceDeviceId id)
93 {
94  deviceId_ = id;
95 }
96 
97 prefix_ senf::emu::InterfaceDeviceId senf::emu::Interface::deviceId()
98  const
99 {
100  return deviceId_;
101 }
102 
103 prefix_ boost::uint8_t senf::emu::Interface::linkTypeId()
104  const
105 {
106  return v_linkTypeId();
107 }
108 
109 prefix_ std::string const & senf::emu::Interface::device()
110  const
111 {
112  return v_device();
113 }
114 
115 prefix_ senf::console::DirectoryNode & senf::emu::Interface::consoleDir()
116  const
117 {
118  return consoleDir_.node();
119 }
120 
121 prefix_ senf::console::DirectoryNode & senf::emu::Interface::statisticsDir()
122  const
123 {
124  return consoleDir()["stats"];
125 }
126 
127 prefix_ senf::emu::Interface::Interface()
128 {}
129 
130 prefix_ std::string senf::emu::Interface::interfaceTypeName()
131  const
132 {
133  return senf::prettyName(typeid(*const_cast<Interface*>(this)));
134 }
135 
136 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 // senf::emu::Receiver
138 
139 prefix_ senf::emu::Receiver::~Receiver()
140 {}
141 
142 prefix_ bool senf::emu::Receiver::annotationMode()
143  const
144 {
145  return v_annotationMode();
146 }
147 
148 prefix_ void senf::emu::Receiver::annotationMode(bool v)
149 {
150  v_annotationMode(v);
151 }
152 
153 prefix_ bool senf::emu::Receiver::promisc()
154  const
155 {
156  return v_promisc();
157 }
158 
159 prefix_ void senf::emu::Receiver::promisc(bool v)
160 {
161  v_promisc(v);
162 }
163 
164 prefix_ void senf::emu::Receiver::flushRxQueues()
165 {
166  v_flushRxQueues();
167 }
168 
169 prefix_ void senf::emu::Receiver::mcAdd(MACAddress const & address)
170 {
171  v_mcAdd(address);
172 }
173 
174 prefix_ void senf::emu::Receiver::mcDrop(MACAddress const & address)
175 {
176  v_mcDrop(address);
177 }
178 
179 prefix_ senf::emu::Receiver::Receiver(ppi::connector::ActiveOutput<> & output)
180  : output (output)
181 {}
182 
183 prefix_ senf::emu::Receiver::
184 Receiver(ppi::connector::ActiveOutput<EthernetPacket> & output)
185  : output (output)
186 {}
187 
188 prefix_ senf::emu::Receiver::Receiver(ppi::connector::ActiveOutputJack<> & output)
189  : output (output)
190 {}
191 
192 prefix_ senf::emu::Receiver::
193 Receiver(ppi::connector::ActiveOutputJack<EthernetPacket> & output)
194  : output (output)
195 {}
196 
197 //-/////////////////////////////////////////////////////////////////////////////////////////////////
198 // senf::emu::Transmitter
199 
200 prefix_ senf::emu::Transmitter::~Transmitter()
201 {}
202 
203 prefix_ unsigned senf::emu::Transmitter::mtu()
204  const
205 {
206  return v_mtu();
207 }
208 
209 prefix_ void senf::emu::Transmitter::mtu(unsigned v)
210 {
211  v_mtu(v);
212 }
213 
214 prefix_ void senf::emu::Transmitter::flushTxQueues()
215 {
216  v_flushTxQueues();
217 }
218 
219 prefix_ senf::emu::Transmitter::Transmitter(ppi::connector::PassiveInput<> & input)
220  : input (input)
221 {}
222 
223 prefix_ senf::emu::Transmitter::
224 Transmitter(ppi::connector::PassiveInput<EthernetPacket> & input)
225  : input (input)
226 {}
227 
228 prefix_ senf::emu::Transmitter::Transmitter(ppi::connector::PassiveInputJack<> & input)
229  : input (input)
230 {}
231 
232 prefix_ senf::emu::Transmitter::
233 Transmitter(ppi::connector::PassiveInputJack<EthernetPacket> & input)
234  : input (input)
235 {}
236 
237 //-/////////////////////////////////////////////////////////////////////////////////////////////////
238 // senf::emu::WiredReceiver
239 
240 prefix_
241 senf::emu::WiredReceiver::WiredReceiver(ppi::connector::ActiveOutput<> & output)
242  : Receiver (output)
243 {}
244 
245 prefix_ senf::emu::WiredReceiver::
246 WiredReceiver(ppi::connector::ActiveOutput<EthernetPacket> & output)
247  : Receiver (output)
248 {}
249 
250 prefix_ senf::emu::WiredReceiver::
251 WiredReceiver(ppi::connector::ActiveOutputJack<> & output)
252  : Receiver (output)
253 {}
254 
255 prefix_ senf::emu::WiredReceiver::
256 WiredReceiver(ppi::connector::ActiveOutputJack<EthernetPacket> & output)
257  : Receiver (output)
258 {}
259 
260 prefix_ void senf::emu::WiredReceiver::init()
261 {
262  Receiver::init();
263 }
264 
265 //-/////////////////////////////////////////////////////////////////////////////////////////////////
266 // senf::emu::WiredInterface
267 
268 prefix_ void senf::emu::WiredInterface::init()
269 {
270  Interface::init();
271 }
272 
273 //-/////////////////////////////////////////////////////////////////////////////////////////////////
274 // senf::emu::WiredTransmitter
275 prefix_ senf::emu::WiredTransmitter::
276 WiredTransmitter(ppi::connector::PassiveInput<> & input)
277  : Transmitter (input)
278 {}
279 
280 prefix_ senf::emu::WiredTransmitter::
281 WiredTransmitter(ppi::connector::PassiveInput<EthernetPacket> & input)
282  : Transmitter (input)
283 {}
284 
285 prefix_ senf::emu::WiredTransmitter::
286 WiredTransmitter(ppi::connector::PassiveInputJack<> & input)
287  : Transmitter (input)
288 {}
289 
290 prefix_ senf::emu::WiredTransmitter::
291 WiredTransmitter(ppi::connector::PassiveInputJack<EthernetPacket> & input)
292  : Transmitter (input)
293 {}
294 
295 prefix_ void senf::emu::WiredTransmitter::init()
296 {
297  Transmitter::init();
298 }
299 
300 //-/////////////////////////////////////////////////////////////////////////////////////////////////
301 // senf::emu::HardwareInterface
302 
303 prefix_ void senf::emu::HardwareInterface::init()
304 {}
305 
306 //-/////////////////////////////////////////////////////////////////////////////////////////////////
307 #undef prefix_
308 
309 
310 // Local Variables:
311 // mode: c++
312 // fill-column: 100
313 // comment-column: 40
314 // c-file-style: "senf"
315 // indent-tabs-mode: nil
316 // ispell-local-dictionary: "american"
317 // compile-command: "scons -u test"
318 // End: