4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the
19 // Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // Definition of non-inline non-template functions
24 //#include "MCSniffer.hh"
25 //#include "MCSniffer.ih"
31 #include "Socket/Protocols/INet/UDPSocketHandle.hh"
32 #include "Scheduler/Scheduler.hh"
33 #include "Packets/DefaultBundle/EthernetPacket.hh"
34 #include "Utils/membind.hh"
35 #include "Utils/hexdump.hh"
38 //#include "MCSniffer.mpp"
40 ///////////////////////////////cc.p////////////////////////////////////////
44 senf::UDPv4ClientSocketHandle sock;
48 MCSniffer(senf::INet4SocketAddress addr, std::ostream& s)
51 sock.protocol().bind(addr);
52 sock.protocol().mcLoop(true);
53 sock.protocol().mcAddMembership(addr);
54 senf::Scheduler::instance().add(
55 sock, senf::membind(&MCSniffer::dumpPacket, this));
59 void dumpPacket(senf::FileHandle /* ignored */, senf::Scheduler::EventId event)
61 std::string data (sock.read());
62 senf::EthernetPacket packet (
63 senf::EthernetPacket::create(data));
65 senf::hexdump(packet.last().data().begin(),
66 packet.last().data().end(),
73 int main(int argc, char const * argv[])
76 std::ofstream f1 ("233.132.152.1.txt");
77 std::ofstream f2 ("233.132.152.2.txt");
80 senf::INet4SocketAddress("233.132.152.1:22344"), f1);
82 senf::INet4SocketAddress("233.132.152.2:22344"), f2);
84 senf::Scheduler::instance().process();
86 catch (std::exception const & ex) {
87 std::cerr << senf::prettyName(typeid(ex)) << ": " << ex.what() << "\n";
93 ///////////////////////////////cc.e////////////////////////////////////////
95 //#include "MCSniffer.mpp"
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // compile-command: "scons -u"
105 // comment-column: 40