Advertisement
kaspyx

setiiiaa

May 20th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #define HAVE_REMOTE
  3. #include "pcap.h"
  4.  
  5. #pragma comment (lib, "wpcap.lib")  
  6.  
  7.  
  8. void main()
  9. {
  10.     pcap_if_t *alldevs;
  11.     pcap_if_t *d;
  12.     int i=0;
  13.     char errbuf[PCAP_ERRBUF_SIZE];
  14.    
  15.     /* Retrieve the device list from the local machine */
  16.     if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
  17.     {
  18.         fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
  19.         exit(1);
  20.     }
  21.    
  22.     /* Print the list */
  23.     for(d= alldevs; d != NULL; d= d->next)
  24.     {
  25.         printf("%d. %s", ++i, d->name);
  26.         if (d->description)
  27.             printf(" (%s)\n", d->description);
  28.         else
  29.             printf(" (No description available)\n");
  30.     }
  31.    
  32.     if (i == 0)
  33.     {
  34.         printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
  35.         return;
  36.     }
  37.  
  38.     /* We don't need any more the device list. Free it */
  39.     pcap_freealldevs(alldevs);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement