Advertisement
LocutusOfBorg

gcc filename.c -lpcap && sudo ./a.out

Dec 3rd, 2013
3,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <pcap.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <stdint.h>
  5.  
  6. int main()
  7. {
  8.    char pcap_errbuf[PCAP_ERRBUF_SIZE];
  9.    char perrbuf[PCAP_ERRBUF_SIZE];
  10.    pcap_t *pcap = NULL;
  11.    // pcap_lookupdev(perrbuf) // finds the first suitable interface
  12.    pcap = pcap_open_live(/*pcap_lookupdev(perrbuf)*/"eth0", UINT16_MAX, 1, 0, pcap_errbuf);
  13.    if(pcap==NULL)
  14.       printf("\n\nPCAP NULL, error buffer value is: %s\n\n", pcap_errbuf);
  15.  
  16.    return EXIT_SUCCESS;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement