QueueSocketSourceSink.cc
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 #include "QueueSocketSourceSink.hh"
18 #include "QueueSocketSourceSink.ih"
19 
20 // Custom includes
21 
22 #define prefix_
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
26 {
27  route(input, output).autoThrottling(false);
28  input.onRequest(&QueueEthVLanFilter::request);
30 }
31 
32 prefix_ void senf::ppi::module::QueueEthVLanFilter::request()
33 {
34  EthernetPacket eth (input());
35  QueueBufferAnnotation const & buffer (eth.annotation<QueueBufferAnnotation>());
36  boost::optional<unsigned> vlanId (buffer->vlan());
37  unsigned tpid (buffer->tpid());
38  if (vlanId) {
39  if (tpid == EthVLanSPacketType::etherType) {
40  EthVLanSPacket vlan (EthVLanSPacket::createInsertBefore(eth.next()));
41  vlan->vlanId() << *vlanId;
42  vlan->type_length() << eth->type_length();
43  eth.finalizeTo(vlan);
44  vlan.reparse();
45  } else {
46  EthVLanCPacket vlan (EthVLanCPacket::createInsertBefore(eth.next()));
47  vlan->vlanId() << *vlanId;
48  vlan->type_length() << eth->type_length();
49  eth.finalizeTo(vlan);
50  vlan.reparse();
51  }
52  }
53  output(eth);
54 }
55 
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 #undef prefix_
58 
59 
60 // Local Variables:
61 // mode: c++
62 // fill-column: 100
63 // comment-column: 40
64 // c-file-style: "senf"
65 // indent-tabs-mode: nil
66 // ispell-local-dictionary: "american"
67 // compile-command: "scons -u test"
68 // End:
unsigned tpid() const
#define prefix_
Route< connector::InputConnector, connector::OutputConnector > & route(connector::InputConnector &input, connector::OutputConnector &output)
Define flow information.
Definition: Module.cc:39
connector::PassiveInput< EthernetPacket > input
ConcretePacket< EthVLanSPacketType > EthVLanSPacket
static const EtherTypes::key_t etherType
connector::ActiveOutput< EthernetPacket > output
ConcretePacket< EthVLanCPacketType > EthVLanCPacket
void onRequest(Handler handler)
Register I/O event handler.
boost::optional< unsigned > vlan() const
ConcretePacket< EthernetPacketType > EthernetPacket
QueueSocketSourceSink public header.
void throttlingDisc(ThrottlingDisc const &disc)
Change the throttling discipline.