Back to index

natlog  0.91.0
pcap1.cc
Go to the documentation of this file.
00001 #include "pcap.ih"
00002 
00003 Pcap::Pcap(char const *device, bool promisc, size_t snapLen, size_t timeOutMs)
00004 {
00005     computeShift(device);
00006 
00007     char errBuf[PCAP_ERRBUF_SIZE];
00008 
00009     d_pcap = pcap_open_live(device, snapLen, promisc, timeOutMs, errBuf);
00010 
00011     if (d_pcap == 0)
00012         throw Errno(1, "[Fatal] ") << errBuf;
00013 
00014     bpf_u_int32 netMask;        // The netmask of our sniffing device
00015 
00016     if (pcap_lookupnet(device, &d_net, &netMask, errBuf) == -1) 
00017         throw Errno(1, "[Fatal] ") << 
00018                         "Can't get network address of device " << device;
00019 }