summaryrefslogtreecommitdiff
path: root/openwrt/package/kismet/patches/130-wrt54g_source.patch
blob: 9192224c6e211971927791725beac87272a311db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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();