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
28 #include <sys/ioctl.h>
29 #include <linux/sockios.h>
30 #include <linux/dvb/dmx.h>
32 #include <senf/Scheduler/Scheduler.hh>
33 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
34 #include <senf/Packets/MPEGDVBBundle/MPESection.hh>
35 #include <senf/Utils/membind.hh>
36 #include <senf/Utils/hexdump.hh>
37 #include <senf/Socket/Protocols/DVB.hh>
38 #include <senf/Packets.hh>
43 ///////////////////////////////cc.p////////////////////////////////////////
47 senf::DVBDemuxSectionHandle handle;
50 MySniffer(unsigned short adapter=0, unsigned short device=0)
51 : handle( adapter, device )
53 struct dmx_sct_filter_params sec_filter;
54 memset(&sec_filter, 0, sizeof (struct dmx_sct_filter_params));
56 sec_filter.filter.filter[0] = 62;
57 sec_filter.filter.mask[0] = 0xff;
58 sec_filter.flags = DMX_IMMEDIATE_START;
59 sec_filter.flags |= DMX_CHECK_CRC;
61 handle.protocol().setSectionFilter( &sec_filter );
63 senf::Scheduler::instance().add(
64 handle, senf::membind(&MySniffer::dumpSection, this));
68 void dumpSection(senf::Scheduler::EventId event)
70 std::string data (handle.read());
71 senf::MPESection section (senf::MPESection::create(data));
72 section.dump(std::cout);
73 senf::PacketData & datagramData (section.next().data());
74 senf::hexdump(datagramData.begin(), datagramData.end(), std::cout);
78 int main(int argc, char const * argv[])
82 senf::Scheduler::instance().process();
84 catch (std::exception const & ex) {
85 std::cerr << senf::prettyName(typeid(ex)) << ": " << ex.what() << "\n";
91 ///////////////////////////////cc.e////////////////////////////////////////
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u"
102 // comment-column: 40