4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.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;
47 senf::scheduler::FdEvent event;
50 MCSniffer(senf::INet4Address addr, std::ostream& s)
51 : stream(s), event("MCSniffer", senf::membind(&MCSniffer::dumpPacket, this),
52 sock, senf::scheduler::FdEvent::EV_READ)
55 sock.protocol().mcLoop(true);
56 sock.protocol().mcAddMembership(addr);
60 void dumpPacket(int 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::INet4Address::from_string("233.132.152.1"), f1);
83 senf::INet4Address::from_string("233.132.152.2"), f2);
85 senf::scheduler::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