
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.64 KB | hits: 21 | expires: Never
wireless sniffing using pcap, MAC address filter
pcap_lookupnet(dev,&net,&mask,errbuf);
printf("%sn",errbuf);
/* Open the session in promiscuous mode */
handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
if (handle == NULL) {
printf("Couldn't open device %s: %sn", dev, errbuf);
return 2;
}
if(pcap_compile(handle,&fp,argv[0],0,net)==-1){
fprintf(stderr,"Error calling pcap_compilen");exit(1);}
if(pcap_setfilter(handle,&fp) == -1){
fprintf(stderr,"Error setting filtern");exit(1);}
/* The call pcap_loop() and pass our callback function */
pcap_loop(handle, 10, my_callback, NULL);