summaryrefslogtreecommitdiff
path: root/openwrt/package/kismet/patches/120-wrt54g_source.patch
diff options
context:
space:
mode:
Diffstat (limited to 'openwrt/package/kismet/patches/120-wrt54g_source.patch')
-rw-r--r--openwrt/package/kismet/patches/120-wrt54g_source.patch181
1 files changed, 181 insertions, 0 deletions
diff --git a/openwrt/package/kismet/patches/120-wrt54g_source.patch b/openwrt/package/kismet/patches/120-wrt54g_source.patch
new file mode 100644
index 0000000000..2a0eac24a3
--- /dev/null
+++ b/openwrt/package/kismet/patches/120-wrt54g_source.patch
@@ -0,0 +1,181 @@
+diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc
+--- kismet.old/kis_packsources.cc 2005-08-15 00:15:11.107594000 +0200
++++ kismet.dev/kis_packsources.cc 2005-08-15 01:56:36.467769104 +0200
+@@ -215,7 +215,7 @@
+ #endif
+ sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0,
+ pcapsource_wrt54g_registrant,
+- monitor_wrt54g, NULL, NULL, 0);
++ monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);
+ #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-08-15 00:33:14.628874000 +0200
++++ kismet.dev/packetsourcetracker.cc 2005-08-15 01:20:41.284203096 +0200
+@@ -984,6 +984,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++;
+
+@@ -1005,6 +1006,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-08-15 00:40:28.291416000 +0200
++++ kismet.dev/pcapsource.cc 2005-08-15 01:55:53.972229408 +0200
+@@ -115,6 +115,53 @@
+ u_char callback_data[MAX_PACKET_LEN];
+
+ // 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);
++
++ #if defined (SYS_OPENBSD) || defined(SYS_NETBSD) && defined(HAVE_RADIOTAP)
++ /* Request desired DLT on multi-DLT systems that default to EN10MB. We do this
++ later anyway but doing it here ensures we have the desired DLT from the get go. */
++ pcap_set_datalink(pd, DLT_IEEE802_11_RADIO);
++ #endif
++
++ 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;
++}
++
++// Open a source
+ int PcapSource::OpenSource() {
+ channel = 0;
+
+@@ -1561,45 +1608,39 @@
+
+ int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
+ void *in_ext) {
+- char cmdline[2048];
++ char cmdline[2048];
+ int mode;
+ int wlmode = 0;
+
+- vector<string> devbits = StrTokenize(in_dev, ":");
++ vector<string> devbits = StrTokenize(in_dev, ":");
+
+- if (devbits.size() < 2) {
+- snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
+- if (RunSysCmd(cmdline) < 0) {
+- snprintf(in_err, 1024, "Unable to set mode using 'wl monitor 1'. Some "
+- "custom firmware images require you to specify the origial "
+- "device and a new dynamic device and use the iwconfig controls. "
+- "see the README for how to configure your capture source.");
+- return -1;
+- }
+- } else {
+- // Get the mode ... If this doesn't work, try the old wl method.
+- if (Iwconfig_Get_Mode(devbits[0].c_str(), in_err, &mode) < 0) {
+- fprintf(stderr, "WARNING: Getting wireless mode via ioctls failed, "
+- "defaulting to trying the 'wl' command.\n");
+- wlmode = 1;
+- }
++ snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 1", in_dev);
++ if (RunSysCmd(cmdline) < 0) {
++ snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 1'. Some "
++ "custom firmware images require you to specify the origial "
++ "device and a new dynamic device and use the iwconfig controls. "
++ "see the README for how to configure your capture source.", in_dev);
++ return -1;
++ }
+
+- if (wlmode == 1) {
+- snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
+- if (RunSysCmd(cmdline) < 0) {
+- snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
+- return -1;
+- }
+- } else if (mode != LINUX_WLEXT_MONITOR) {
+- // Set it
+- if (Iwconfig_Set_Mode(devbits[0].c_str(), in_err,
+- LINUX_WLEXT_MONITOR) < 0) {
+- snprintf(in_err, STATUS_MAX, "Unable to set iwconfig monitor "
+- "mode. If you are using an older wrt54g, try specifying "
+- "only the ethernet device, not ethX:prismX");
+- return -1;
+- }
+- }
++ return 1;
++}
++
++int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
++ void *in_ext) {
++ char cmdline[2048];
++ int mode;
++ int wlmode = 0;
++
++ vector<string> devbits = StrTokenize(in_dev, ":");
++
++ snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 0", in_dev);
++ if (RunSysCmd(cmdline) < 0) {
++ snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 0'. Some "
++ "custom firmware images require you to specify the origial "
++ "device and a new dynamic device and use the iwconfig controls. "
++ "see the README for how to configure your capture source.", in_dev);
++ return -1;
+ }
+
+ return 1;
+diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h
+--- kismet.old/pcapsource.h 2005-08-15 00:42:50.849744000 +0200
++++ kismet.dev/pcapsource.h 2005-08-15 01:56:07.649150200 +0200
+@@ -265,6 +265,7 @@
+ 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();
+@@ -388,6 +389,7 @@
+ #ifdef SYS_LINUX
+ // linksys wrt54g monitoring
+ int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
++int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
+ #endif
+
+ // This should be expanded to handle BSD...