1 diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc
2 --- kismet.old/kis_packsources.cc 2005-08-16 03:22:51.000000000 +0200
3 +++ kismet.dev/kis_packsources.cc 2005-08-23 00:59:04.465379568 +0200
5 chancontrol_wlanng_avs, 1);
6 sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0,
7 pcapsource_wrt54g_registrant,
8 - monitor_wrt54g, NULL, NULL, 0);
9 + monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);
11 REG_EMPTY_CARD(sourcetracker, "wlanng");
12 REG_EMPTY_CARD(sourcetracker, "wlanng_avs");
13 diff -urN kismet.old/packetsourcetracker.cc kismet.dev/packetsourcetracker.cc
14 --- kismet.old/packetsourcetracker.cc 2005-08-16 03:22:51.000000000 +0200
15 +++ kismet.dev/packetsourcetracker.cc 2005-08-23 00:59:39.969982048 +0200
17 (meta_packsources[chanpak.meta_num]->device.c_str(),
18 chanpak.channel, errstr,
19 (void *) (meta_packsources[chanpak.meta_num]->capsource)) < 0) {
22 meta_packsources[chanpak.meta_num]->consec_errors++;
30 // Otherwise reset the error count
31 meta_packsources[chanpak.meta_num]->consec_errors = 0;
32 diff -urN kismet.old/pcapsource.cc kismet.dev/pcapsource.cc
33 --- kismet.old/pcapsource.cc 2005-08-16 03:22:51.000000000 +0200
34 +++ kismet.dev/pcapsource.cc 2005-08-23 01:03:45.652632608 +0200
36 u_char callback_data[MAX_PACKET_LEN];
39 +int PcapSourceWrt54g::OpenSource() {
44 + char *unconst = strdup("prism0");
46 + pd = pcap_open_live(unconst, MAX_PACKET_LEN, 1, 1000, errstr);
48 + #if defined (SYS_OPENBSD) || defined(SYS_NETBSD) && defined(HAVE_RADIOTAP)
49 + /* Request desired DLT on multi-DLT systems that default to EN10MB. We do this
50 + later anyway but doing it here ensures we have the desired DLT from the get go. */
51 + pcap_set_datalink(pd, DLT_IEEE802_11_RADIO);
56 + if (strlen(errstr) > 0)
57 + return -1; // Error is already in errstr
65 + if (DatalinkType() < 0)
68 +#ifdef HAVE_PCAP_NONBLOCK
69 + pcap_setnonblock(pd, 1, errstr);
70 +#elif !defined(SYS_OPENBSD)
71 + // do something clever (Thanks to Guy Harris for suggesting this).
72 + int save_mode = fcntl(pcap_get_selectable_fd(pd), F_GETFL, 0);
73 + if (fcntl(pcap_get_selectable_fd(pd), F_SETFL, save_mode | O_NONBLOCK) < 0) {
74 + snprintf(errstr, 1024, "fcntl failed, errno %d (%s)",
75 + errno, strerror(errno));
79 + if (strlen(errstr) > 0)
86 int PcapSource::OpenSource() {
89 @@ -1928,63 +1975,32 @@
90 int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
96 -#ifdef HAVE_LINUX_WIRELESS
97 - vector<string> devbits = StrTokenize(in_dev, ":");
99 - if (devbits.size() < 2) {
100 - snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
101 + snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 1", in_dev);
102 if (RunSysCmd(cmdline) < 0) {
103 - snprintf(in_err, 1024, "Unable to set mode using 'wl monitor 1'. Some "
104 - "custom firmware images require you to specify the origial "
105 + snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 1'. "
106 + "Some custom firmware images require you to specify the origial "
107 "device and a new dynamic device and use the iwconfig controls. "
108 "see the README for how to configure your capture source.");
112 - // Get the mode ... If this doesn't work, try the old wl method.
113 - if (Iwconfig_Get_Mode(devbits[0].c_str(), in_err, &mode) < 0) {
114 - fprintf(stderr, "WARNING: Getting wireless mode via ioctls failed, "
115 - "defaulting to trying the 'wl' command.\n");
120 - snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
121 - if (RunSysCmd(cmdline) < 0) {
122 - snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
125 - } else if (mode != LINUX_WLEXT_MONITOR) {
127 - if (Iwconfig_Set_Mode(devbits[0].c_str(), in_err,
128 - LINUX_WLEXT_MONITOR) < 0) {
129 - snprintf(in_err, STATUS_MAX, "Unable to set iwconfig monitor "
130 - "mode. If you are using an older wrt54g, try specifying "
131 - "only the ethernet device, not ethX:prismX");
138 +int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
140 + char cmdline[2048];
142 + snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 0", in_dev);
143 + if (RunSysCmd(cmdline) < 0) {
144 + snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 0'. "
145 + "Some custom firmware images require you to specify the origial "
146 + "device and a new dynamic device and use the iwconfig controls. "
147 + "see the README for how to configure your capture source.");
152 - snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");
153 - if (RunSysCmd(cmdline) < 0) {
154 - snprintf(in_err, 1024, "Unable to set mode using 'wl monitor 1'. Some "
155 - "custom firmware images require you to specify the origial "
156 - "device and a new dynamic device and use the iwconfig controls. "
157 - "see the README for how to configure your capture source. "
158 - "Support for wireless extensions was not compiled in, so more "
159 - "advanced modes of setting monitor mode are not available.");
162 - fprintf(stderr, "WARNING: Support for wireless extensions was not compiled "
163 - "into this binary. Using the iw* tools to set monitor mode will not "
164 - "be available. This may cause opening the source to fail on some "
165 - "firmware versions. To fix this, make sure wireless extensions are "
166 - "available and found by the configure script when building Kismet.");
171 diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h
172 --- kismet.old/pcapsource.h 2005-08-16 03:22:51.000000000 +0200
173 +++ kismet.dev/pcapsource.h 2005-08-23 01:04:26.057490136 +0200
175 PcapSourceWrt54g(string in_name, string in_dev) : PcapSource(in_name, in_dev) {
179 int FetchPacket(kis_packet *packet, uint8_t *data, uint8_t *moddata);
181 carrier_type IEEE80211Carrier();
183 int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
184 // linksys wrt54g monitoring
185 int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
186 +int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
189 // This should be expanded to handle BSD...