Added class to handle IP+Port connections
[sniffer.git] / main.cpp
blob59415ed165637416a1ccfc6fb9c6945b9ea68a0b
1 #include "sniffer.h"
3 #include<pcap.h>
4 #include<stdio.h>
5 #include<stdlib.h>
6 #include<string.h>
8 int main()
10 pcap_if_t* alldevsp;
11 pcap_if_t* device;
12 char errbuf[100];
13 char* devname;
14 char devs[100][100];
15 int count = 1;
16 int n;
18 // Get the list of available devices
19 printf("Finding available devices ... ");
20 if( pcap_findalldevs( &alldevsp , errbuf) )
22 printf("Error finding devices : %s" , errbuf);
23 exit(1);
25 printf("Done");
27 // Print available devices
28 printf("\nAvailable Devices are :\n");
29 for(device = alldevsp ; device != NULL ; device = device->next)
31 printf("%d. %s - %s\n" , count , device->name , device->description);
32 if(device->name != NULL)
34 strcpy(devs[count] , device->name);
36 count++;
39 // Ask user which device to sniff
40 printf("Enter the number of the device you want to sniff : ");
41 scanf("%d", &n);
42 devname = devs[n];
44 filter::Sniffer sniffer;
45 sniffer.loop(devname);
47 return 0;