Hello,
I want to achieve the following :
1) I have a raw packet buffer, i want to search if they match a certain BPF filter (i dont care about the device or how i received this packet buffer) just want
to know it match or doesn't match.
The code i tried :
pkt = pointer to packet data
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t* pc = pcap_create("any",&errbuf);
int active = pcap_activate(pc);
struct bpf_program fp;
int res = pcap_compile(pc,&fp,"ip",0,0);
struct pcap_pkthdr hdr;
memset(&hdr,0,sizeof(hdr));
hdr.caplen = pkt->pkt_len;
hdr.len = pkt->pkt_len;
u_char* data = "" char *)pkt->data
int match = pcap_offline_filter(&fp, &hdr ,data);
printf("Packet Match = %d\r\n",match);
That doesn't work.... (it doesn't fail but return "0" on match every time even that the packet is IP packet as i debugged it)
Any ideas ? what am i doing wrong? or how else can i achieve the same results?
Thanks in advance!
Gal.