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
@@ -3,28 +3,33 @@
3 * 3 *
4 * $Id$ 4 * $Id$
5 */ 5 */
6 6
7#include "sniff.hh" 7#include "sniff.hh"
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;
17 u_int16_t fc; 18 u_int16_t fc;
18 unsigned int HEADER_LENGTH; 19 unsigned int HEADER_LENGTH;
19 20
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;
26 pinfoptr->pktlen = pkthdr->len; 31 pinfoptr->pktlen = pkthdr->len;
27 32
28 if (caplen < IEEE802_11_FC_LEN) 33 if (caplen < IEEE802_11_FC_LEN)
29 { 34 {
30 /* This is a garbage packet, because is does not long enough 35 /* This is a garbage packet, because is does not long enough
@@ -87,38 +92,44 @@ void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *pack
87 others must be noise packets */ 92 others must be noise packets */
88 pinfoptr->isvalid = 0; 93 pinfoptr->isvalid = 0;
89 return; 94 return;
90 } 95 }
91 96
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:
120 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); 131 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc));
121 break; 132 break;
122 } /* End of switch over different mgt frame types */ 133 } /* End of switch over different mgt frame types */
123 134
124 break; 135 break;
@@ -200,19 +211,19 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
200 { 211 {
201 case E_SSID: 212 case E_SSID:
202 memcpy(&(pbody.ssid),p+offset,2); offset += 2; 213 memcpy(&(pbody.ssid),p+offset,2); offset += 2;
203 if (pbody.ssid.length > 0) 214 if (pbody.ssid.length > 0)
204 { 215 {
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;
214 225
215 case E_CHALLENGE: 226 case E_CHALLENGE:
216 memcpy(&(pbody.challenge),p+offset,2); offset += 2; 227 memcpy(&(pbody.challenge),p+offset,2); offset += 2;
217 if (pbody.challenge.length > 0) 228 if (pbody.challenge.length > 0)
218 { 229 {
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
@@ -22,24 +22,24 @@ struct packetinfo
22 int pktlen; 22 int pktlen;
23 int fctype; 23 int fctype;
24 int fcsubtype; 24 int fcsubtype;
25 int fc_wep; 25 int fc_wep;
26 int cap_WEP; 26 int cap_WEP;
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);
41 41
42int GetHeaderLength(u_int16_t fc); 42int GetHeaderLength(u_int16_t fc);
43 43
44/* 44/*
45 * True if "l" bytes of "var" were captured. 45 * True if "l" bytes of "var" were captured.