wlanMon2Eth.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 
14 #include <senf/PPI.hh>
18 #include <senf/Ext/NetEmu/WLAN/MmapSocketSourceRadioTap.hh>
19 
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 void handleSignal(siginfo_t const &)
23 {
25 }
26 
28 {
29  std::cerr << "usage: wlanMon2Eth <monitor_iface> <tap_iface> <reorder|no-reorder>" << std::endl;
30  exit(1);
31 }
32 
33 int main(int argc, char const * argv[])
34 {
35  if (argc != 4) {
37  }
38  if (getuid() != 0) {
39  std::cerr << "you must be root!" << std::endl;
41  }
42 
44  senf::scheduler::SignalEvent sigterm (SIGTERM, handleSignal);
45 
46  senf::PacketSocketHandle srcSocket;
47  srcSocket.bind(senf::LLSocketAddress(argv[1]));
48  srcSocket.blocking(false);
49  senf::MmapSocketSourceRadioTap source (srcSocket, 1024);
50 
51  senf::TapSocketHandle dstSocket (argv[2]);
53 
55  filter.promisc(true);
56  if (std::string(argv[3]) == "no-reorder") {
57  filter.reorderPackets(false);
58  } else {
59  if (std::string(argv[3]) == "reorder") {
60  filter.reorderPackets(true);
61  } else {
63  }
64  }
65 
66  senf::ppi::connect(source, filter);
67  senf::ppi::connect(filter, sink);
69 
70  return 0;
71 }
72 
73 //-/////////////////////////////////////////////////////////////////////////////////////////////////
MonitorDataFilter header.
void print_usage_and_exit()
Definition: wlanMon2Eth.cc:27
virtual void terminate() const
int run(int argc, char const *argv[])
Definition: dfstest.cc:83
int main(int argc, char const *argv[])
Definition: wlanMon2Eth.cc:33
ProtocolClientSocketHandle< TapSocketProtocol > TapSocketHandle
ProtocolClientSocketHandle< PacketSocketProtocol > PacketSocketHandle
void handleSignal(siginfo_t const &)
Definition: wlanMon2Eth.cc:22