diff options
Diffstat (limited to 'openwrt/package/kismet/patches/100-wrt54g_source.patch')
-rw-r--r-- | openwrt/package/kismet/patches/100-wrt54g_source.patch | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/openwrt/package/kismet/patches/100-wrt54g_source.patch b/openwrt/package/kismet/patches/100-wrt54g_source.patch new file mode 100644 index 0000000..3336a8f --- /dev/null +++ b/openwrt/package/kismet/patches/100-wrt54g_source.patch @@ -0,0 +1,189 @@ +diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc +--- kismet.old/kis_packsources.cc 2005-08-16 03:22:51.000000000 +0200 ++++ kismet.dev/kis_packsources.cc 2005-08-23 00:59:04.465379568 +0200 +@@ -192,7 +192,7 @@ + chancontrol_wlanng_avs, 1); + 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-16 03:22:51.000000000 +0200 ++++ kismet.dev/packetsourcetracker.cc 2005-08-23 00:59:39.969982048 +0200 +@@ -986,6 +986,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++; + +@@ -1007,6 +1008,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-16 03:22:51.000000000 +0200 ++++ kismet.dev/pcapsource.cc 2005-08-23 01:03:45.652632608 +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; + +@@ -1928,63 +1975,32 @@ + int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, + void *in_ext) { + char cmdline[2048]; +- int mode; +- int wlmode = 0; +- +-#ifdef HAVE_LINUX_WIRELESS +- vector<string> devbits = StrTokenize(in_dev, ":"); + +- if (devbits.size() < 2) { +- 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 set mode using 'wl monitor 1'. Some " +- "custom firmware images require you to specify the origial " ++ 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."); + 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; +- } + +- 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]; ++ ++ 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."); ++ return -1; + } +- } +-#else +- 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. " +- "Support for wireless extensions was not compiled in, so more " +- "advanced modes of setting monitor mode are not available."); +- return -1; +- } +- fprintf(stderr, "WARNING: Support for wireless extensions was not compiled " +- "into this binary. Using the iw* tools to set monitor mode will not " +- "be available. This may cause opening the source to fail on some " +- "firmware versions. To fix this, make sure wireless extensions are " +- "available and found by the configure script when building Kismet."); +-#endif + + return 1; + } +diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h +--- kismet.old/pcapsource.h 2005-08-16 03:22:51.000000000 +0200 ++++ kismet.dev/pcapsource.h 2005-08-23 01:04:26.057490136 +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(); +@@ -412,6 +413,7 @@ + int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext); + // 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... |