Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. wireless sniffing using pcap, MAC address filter
  2. pcap_lookupnet(dev,&net,&mask,errbuf);
  3.     printf("%sn",errbuf);
  4.     /* Open the session in promiscuous mode */
  5.     handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
  6.     if (handle == NULL) {
  7.         printf("Couldn't open device %s: %sn", dev, errbuf);
  8.         return 2;
  9.     }
  10.     if(pcap_compile(handle,&fp,argv[0],0,net)==-1){
  11.         fprintf(stderr,"Error calling pcap_compilen");exit(1);}
  12.     if(pcap_setfilter(handle,&fp) == -1){
  13.         fprintf(stderr,"Error setting filtern");exit(1);}
  14.     /* The call pcap_loop() and pass our callback function */
  15.     pcap_loop(handle, 10, my_callback, NULL);