summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc41
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.hh10
2 files changed, 31 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
index fedd8fc..66299d1 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
@@ -8,9 +8,10 @@
8#include "ieee802_11.hh" 8#include "ieee802_11.hh"
9#include "extract.hh" 9#include "extract.hh"
10#include "log.hh" 10#include "log.hh"
11#include "proto.hh"
11 12
12/* Main function, checks packets */ 13/* Main function, checks packets */
13void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet) 14void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet, char *guihost, int guiport)
14{ 15{
15 unsigned int caplen = pkthdr->caplen; 16 unsigned int caplen = pkthdr->caplen;
16 unsigned int length = pkthdr->len; 17 unsigned int length = pkthdr->len;
@@ -20,6 +21,10 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
20 /* pinfo holds all interresting information for us */ 21 /* pinfo holds all interresting information for us */
21 struct packetinfo pinfo; 22 struct packetinfo pinfo;
22 struct packetinfo *pinfoptr; 23 struct packetinfo *pinfoptr;
24
25 /* wl_network_t will finally be set and send to the ui */
26 wl_network_t wl_net;
27
23 pinfoptr=&pinfo; 28 pinfoptr=&pinfo;
24 29
25 pinfoptr->isvalid = 0; 30 pinfoptr->isvalid = 0;
@@ -92,28 +97,34 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
92 97
93 /* Here should be the infos to the gui issued */ 98 /* Here should be the infos to the gui issued */
94 if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0) 99 if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0)
95 { 100 {
96 printf ("\nHave found an accesspoint:"); 101 wl_loginfo("Found an access point");
102 wl_net.net_type=1;
97 } 103 }
98 else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 1) 104 else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 1)
99 { 105 {
100 printf ("\nHave found an AD-HOC station:"); 106 wl_loginfo("Found an ad-hoc network");
101 107 wl_net.net_type=2;
102 } 108 }
103 if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) 109 if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0)
104 { 110 {
105 printf ("\n\tOn a non-broadcasting network"); 111 wl_loginfo("Net is a non-broadcasting network");
106 } 112 }
107 else 113 else
108 { 114 {
109 printf ("\n\tOn network : %s",pinfoptr->ssid); 115 wl_loginfo("SSID is: %s", pinfoptr->ssid);
116 // wl_net.bssid=pinfoptr->ssid;
110 } 117 }
111 printf ("\n\tLen SSID : %d",pinfoptr->ssid_len); 118
112 printf ("\n\tOn Channel : %d",pinfoptr->channel); 119 wl_net.ssid_len=pinfoptr->ssid_len;
113 printf ("\n\tEncryption : %s", pinfoptr->cap_WEP ? "ON" : "OFF"); 120 wl_net.channel=pinfoptr->channel;
114 printf ("\n\tMacaddress : %s",pinfoptr->sndhwaddr); 121 wl_net.wep=pinfoptr->cap_WEP;
115 printf ("\n\tBssid : %s",pinfoptr->bssid); 122 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac));;
116 printf ("\n\tDest : %s\n",pinfoptr->desthwaddr); 123 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid));
124
125 // printf ("\n\tDest : %s\n",pinfoptr->desthwaddr);
126 send_network_found((char *)guihost, guiport, &wl_net);
127 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport);
117 } 128 }
118 break; 129 break;
119 default: 130 default:
@@ -205,9 +216,9 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
205 memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length; 216 memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length;
206 pbody.ssid.ssid[pbody.ssid.length]='\0'; 217 pbody.ssid.ssid[pbody.ssid.length]='\0';
207 if (strcmp((char *)pbody.ssid.ssid,"")==0) 218 if (strcmp((char *)pbody.ssid.ssid,"")==0)
208 ppinfo->ssid = NONBROADCASTING; 219 memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid));
209 else 220 else
210 ppinfo->ssid = (char *)pbody.ssid.ssid; 221 memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid));
211 ppinfo->ssid_len = pbody.ssid.length; 222 ppinfo->ssid_len = pbody.ssid.length;
212 } 223 }
213 break; 224 break;
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh
index fa8519b..60cdc43 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh
@@ -27,14 +27,14 @@ struct packetinfo
27 int cap_IBSS; 27 int cap_IBSS;
28 int cap_ESS; 28 int cap_ESS;
29 int channel; 29 int channel;
30 char bssid[sizeof("00:00:00:00:00:00")]; 30 char bssid[sizeof("00:00:00:00:00:00") + 1];
31 char desthwaddr[sizeof("00:00:00:00:00:00")]; 31 char desthwaddr[sizeof("00:00:00:00:00:00") + 1];
32 char sndhwaddr[sizeof("00:00:00:00:00:00")]; 32 char sndhwaddr[sizeof("00:00:00:00:00:00") + 1];
33 char *ssid; 33 char ssid[128];
34 int ssid_len; 34 int ssid_len;
35}; 35};
36 36
37void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet); 37void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int);
38int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); 38int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo);
39void etheraddr_string(register const u_char *ep,char * text); 39void etheraddr_string(register const u_char *ep,char * text);
40int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); 40int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo);