Commit 944d1d19 authored by 's avatar
Browse files

changed pcap_next to pcap_loop at mapinicdrv.c in order to support mmap-pcap.


git-svn-id: file:///home/svn/mapi/trunk@1289 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 99eb3a5a
......@@ -306,12 +306,24 @@ mapidrv_offline_proc_loop(int devid)
DEBUG_CMD(printf("Finished reading file, pkts %lld [%s:%d]\n",i->hwinfo.pkts,__FILE__,__LINE__));
}
void
callback(u_char *user, const struct pcap_pkthdr *phdr,
const u_char *bytes) {
nic_instance_t *i = (nic_instance_t*)user;
mapid_pkthdr_t mhdr;
mhdr.caplen = phdr->caplen;
mhdr.wlen = phdr->len;
mhdr.ts = (((unsigned long long)phdr->ts.tv_sec)<<32)+((((phdr->ts.tv_usec << 12) + (phdr->ts.tv_usec<<8) - ((phdr->ts.tv_usec*1825)>>5))) & 0xffffffff);
i->hwinfo.pkts++;
mapid_process_pkt(&i->mapidlib,(unsigned char*)bytes,(unsigned char*)bytes,&mhdr);
}
static void
mapidrv_proc_loop (int devid)
{
u_char *packet;
struct pcap_pkthdr phdr;
mapid_pkthdr_t mhdr;
nic_instance_t *i=flist_get(devlist,devid);
int err;
......@@ -325,23 +337,7 @@ mapidrv_proc_loop (int devid)
return;
}
while (1)
{
while( (packet = (u_char *)pcap_next(i->pcap,&phdr)) == NULL );
// Transform header
// This is only for backward compatibility
mhdr.caplen = phdr.caplen;
mhdr.wlen = phdr.len;
// mhdr.ts = (((unsigned long long)phdr.ts.tv_sec)<<32)+((phdr.ts.tv_usec*4295) & 0xffffffff);
mhdr.ts = (((unsigned long long)phdr.ts.tv_sec)<<32)+((((phdr.ts.tv_usec << 12) + (phdr.ts.tv_usec<<8) - ((phdr.ts.tv_usec*1825)>>5))) & 0xffffffff);
// increase counter for packets seen so far
i->hwinfo.pkts++;
// Process packet
mapid_process_pkt(&i->mapidlib,packet,packet,&mhdr);
}
pcap_loop(i->pcap, -1, callback, (void*)i);
}
int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment