1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-29 17:20:38 +02:00

change wrt54g packet source to automatically switch to monitor mode without wl, add channel hopping support

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@1548 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2005-07-25 07:34:42 +00:00
parent e144d98eba
commit 0672b5981e
3 changed files with 115 additions and 2 deletions

View File

@ -18,7 +18,9 @@ suiduser=nobody
# The initial channel is optional, if hopping is not enabled it can be used # The initial channel is optional, if hopping is not enabled it can be used
# to set the channel the interface listens on. # to set the channel the interface listens on.
# YOU MUST CHANGE THIS TO BE THE SOURCE YOU WANT TO USE # YOU MUST CHANGE THIS TO BE THE SOURCE YOU WANT TO USE
source=wrt54g,prism0,wireless source=wrt54g,eth1,wireless
# For v1 hardware uncomment this:
# source=wrt54g,eth2,wireless
# Comma-separated list of sources to enable. This is only needed if you defined # Comma-separated list of sources to enable. This is only needed if you defined
# multiple sources and only want to enable some of them. By default, all defined # multiple sources and only want to enable some of them. By default, all defined

View File

@ -48,7 +48,9 @@ maxclients=5
# enablesources line to enable them. For example: # enablesources line to enable them. For example:
# source=prism2,wlan0,prism # source=prism2,wlan0,prism
# source=cisco,eth0,cisco # source=cisco,eth0,cisco
source=wrt54g,prism0,wireless source=wrt54g,eth1,wireless
# For v1 hardware uncomment this:
# source=wrt54g,eth2,wireless
# Comma-separated list of sources to enable. This is only needed if you wish # Comma-separated list of sources to enable. This is only needed if you wish
# to selectively enable multiple sources. # to selectively enable multiple sources.

View File

@ -0,0 +1,109 @@
diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc
--- kismet.old/kis_packsources.cc 2005-07-25 12:18:47.230369000 +0200
+++ kismet.dev/kis_packsources.cc 2005-07-25 12:54:44.654390736 +0200
@@ -165,7 +165,7 @@
chancontrol_wlanng_avs, 1);
sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0,
pcapsource_wrt54g_registrant,
- monitor_wrt54g, NULL, NULL, 0);
+ monitor_wrt54g, NULL, chancontrol_wext, 1);
#else
REG_EMPTY_CARD(sourcetracker, "wlanng");
REG_EMPTY_CARD(sourcetracker, "wlanng_avs");
diff -urN kismet.old/packetsourcetracker.cc kismet.dev/packetsourcetracker.cc
--- kismet.old/packetsourcetracker.cc 2005-04-03 07:33:42.000000000 +0200
+++ kismet.dev/packetsourcetracker.cc 2005-07-25 13:29:45.698983408 +0200
@@ -978,6 +978,7 @@
(meta_packsources[chanpak.meta_num]->device.c_str(),
chanpak.channel, errstr,
(void *) (meta_packsources[chanpak.meta_num]->capsource)) < 0) {
+#if 0
meta_packsources[chanpak.meta_num]->consec_errors++;
@@ -999,6 +1000,7 @@
CHANFLAG_FATAL));
continue;
}
+#endif
} else {
// Otherwise reset the error count
meta_packsources[chanpak.meta_num]->consec_errors = 0;
diff -urN kismet.old/pcapsource.cc kismet.dev/pcapsource.cc
--- kismet.old/pcapsource.cc 2005-07-25 12:18:47.234368000 +0200
+++ kismet.dev/pcapsource.cc 2005-07-25 12:51:19.426590104 +0200
@@ -140,6 +140,48 @@
return 1;
}
+
+// Open a source
+int PcapSourceWrt54g::OpenSource() {
+ channel = 0;
+
+ errstr[0] = '\0';
+
+ char *unconst = strdup("prism0");
+
+ pd = pcap_open_live(unconst, MAX_PACKET_LEN, 1, 1000, errstr);
+
+ free(unconst);
+
+ if (strlen(errstr) > 0)
+ return -1; // Error is already in errstr
+
+ paused = 0;
+
+ errstr[0] = '\0';
+
+ num_packets = 0;
+
+ if (DatalinkType() < 0)
+ return -1;
+
+#ifdef HAVE_PCAP_NONBLOCK
+ pcap_setnonblock(pd, 1, errstr);
+#elif !defined(SYS_OPENBSD)
+ // do something clever (Thanks to Guy Harris for suggesting this).
+ int save_mode = fcntl(pcap_get_selectable_fd(pd), F_GETFL, 0);
+ if (fcntl(pcap_get_selectable_fd(pd), F_SETFL, save_mode | O_NONBLOCK) < 0) {
+ snprintf(errstr, 1024, "fcntl failed, errno %d (%s)",
+ errno, strerror(errno));
+ }
+#endif
+
+ if (strlen(errstr) > 0)
+ return -1; // Ditto
+
+ return 1;
+}
+
// Datalink, override as appropriate
carrier_type PcapSource::IEEE80211Carrier() {
int ch = FetchChannel();
@@ -1609,7 +1651,7 @@
int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
char cmdline[2048];
- snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
+ snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 1", in_dev);
if (RunSysCmd(cmdline) < 0) {
snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
return -1;
diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h
--- kismet.old/pcapsource.h 2005-04-03 07:33:42.000000000 +0200
+++ kismet.dev/pcapsource.h 2005-07-25 12:49:22.089428064 +0200
@@ -250,11 +250,13 @@
// Override packet fetching logic on this one to discard jumbo corrupt packets
// that it likes to generate
+// Override OpenSource() to use prism0 as pcap device
class PcapSourceWrt54g : public PcapSource {
public:
PcapSourceWrt54g(string in_name, string in_dev) : PcapSource(in_name, in_dev) {
fcsbytes = 4;
}
+ int OpenSource();
int FetchPacket(kis_packet *packet, uint8_t *data, uint8_t *moddata);
protected:
carrier_type IEEE80211Carrier();