Hi guys,
This is code which has been modified from a program which is
floating on the net.
The output says didnt grab packet. I wonder why.
I am giving the command 'a.out <filename>'
The same file is read by 'tcpdump -r <filename>'
Can someone say me why and how I can fix it.
Thanks in advance.
zubin
#include<stdio.h>
#include<stdlib.h>
#include <pcap.h>
#include<errno.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<netinet/if_ether.h>
int main(int argc, char **argv)
{
int i;
char *dev;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t* descr;
const u_char *packet;
struct pcap_pkthdr hdr;
struct ether_header *eptr;
u_char *ptr;
dev = pcap_lookupdev(errbuf);
if(dev == NULL)
{
printf("%s\n",errbuf);
exit(1);
}
printf("DEV: %s\n",dev);
descr = pcap_open_offline(argv[1],errbuf);
if(descr == NULL)
{
printf("%s doesnt exist or is of corrupt format\n",argv[1]);
exit(1);
}
packet = pcap_next(descr, &hdr);
if(packet == NULL);
{
printf("Didnt grab packet %s\n",errbuf);
exit(1);
}
return 0;
}
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-
This is the tcpdump-workers list.
Visit https://lists.sandelman.ca/ to unsubscribe.