summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/sniffer.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.cc b/noncore/net/wellenreiter/daemon/source/sniffer.cc
index 65c8579..be64d67 100644
--- a/noncore/net/wellenreiter/daemon/source/sniffer.cc
+++ b/noncore/net/wellenreiter/daemon/source/sniffer.cc
@@ -21,23 +21,34 @@ int main(void)
21 return 1; 21 return 1;
22} 22}
23 23
24int start_sniffing (char * device) 24int start_sniffing (char * device)
25{ 25{
26 26
27 pcap_t *handletopcap; 27 pcap_t *handletopcap; /* The handle to the libpcap */
28 char errbuf[PCAP_ERRBUF_SIZE]; 28 char errbuf[PCAP_ERRBUF_SIZE]; /* The errorbuffer of libpacap */
29 struct pcap_pkthdr header; /* The packet header from pcap*/
30 const u_char *packet; /* The actual packet content*/
29 31
30 /* opening the pcap for sniffing */ 32 /* opening the pcap for sniffing */
31 handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf); 33 handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf);
32 34
33 #ifdef HAVE_PCAP_NONBLOCK 35 #ifdef HAVE_PCAP_NONBLOCK
34 pcap_setnonblock(handletopcap, 1, errstr); 36 pcap_setnonblock(handletopcap, 1, errstr);
35 #endif 37 #endif
36 /*start scanning */ 38 /*start scanning */
37 pcap_loop(handletopcap,-1,process_packets,NULL); 39 //pcap_loop(handletopcap,-1,process_packets,NULL);
40 /* Loope endless */
41 while(1)
42 {
43 /* Grab one single packet */
44 packet = pcap_next(handletopcap, &header);
45
46 /* process the packet */
47 process_packets(NULL,&header,*&packet);
48 }
38 49
39 printf("\nDone processing packets... wheew!\n"); 50 printf("\nDone processing packets... wheew!\n");
40 return 1; 51 return 1;
41} 52}
42 53
43void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet) 54void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet)
@@ -95,13 +106,12 @@ void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_ch
95 case T_MGMT: 106 case T_MGMT:
96 switch (FC_SUBTYPE(fc)) 107 switch (FC_SUBTYPE(fc))
97 { /* Is it a beacon frame? */ 108 { /* Is it a beacon frame? */
98 case ST_BEACON: 109 case ST_BEACON:
99 if (handle_beacon(fc, packet,pinfoptr) ==0) 110 if (handle_beacon(fc, packet,pinfoptr) ==0)
100 { 111 {
101 printf ("\n\tOn network : %s",pinfoptr->ssid);
102 if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) 112 if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0)
103 { 113 {
104 /* Every beacon must have the broadcast as destination 114 /* Every beacon must have the broadcast as destination
105 so it must be a shitti packet */ 115 so it must be a shitti packet */
106 pinfoptr->isvalid = 0; 116 pinfoptr->isvalid = 0;
107 return; 117 return;