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