Back to index

natlog  0.91.0
filter.cc
Go to the documentation of this file.
00001 #include "pcap.ih"
00002 
00003 void Pcap::filter(string const &filterExpr, bool optimize)
00004 {
00005     if (pcap_compile(d_pcap, &d_pcapFilter, 
00006                      filterExpr.c_str(), optimize, d_net) == -1) 
00007         throw Errno(1, "[Fatal] ") << "Pcap compilation of `" << filterExpr << 
00008                             "' failed: " << pcap_geterr(d_pcap);
00009     
00010     if (pcap_setfilter(d_pcap, &d_pcapFilter) == -1) 
00011          throw Errno(1, "[Fatal] ") << "Couldn't install filter `" << 
00012                 filterExpr << ": " << pcap_geterr(d_pcap);
00013 }