source:
freewrt/package/kismet/patches/100-wrt54g_source.patch@
6fc4520e
| Last change on this file since 6fc4520e was 475ad56, checked in by , 20 years ago | |
|---|---|
|
|
| File size: 7.0 KB | |
-
kis_packsources.cc
diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc
old new 192 192 chancontrol_wlanng_avs, 1); 193 193 sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0, 194 194 pcapsource_wrt54g_registrant, 195 monitor_wrt54g, NULL, NULL, 0);195 monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0); 196 196 #else 197 197 REG_EMPTY_CARD(sourcetracker, "wlanng"); 198 198 REG_EMPTY_CARD(sourcetracker, "wlanng_avs"); -
packetsourcetracker.cc
diff -urN kismet.old/packetsourcetracker.cc kismet.dev/packetsourcetracker.cc
old new 986 986 (meta_packsources[chanpak.meta_num]->device.c_str(), 987 987 chanpak.channel, errstr, 988 988 (void *) (meta_packsources[chanpak.meta_num]->capsource)) < 0) { 989 #if 0 989 990 990 991 meta_packsources[chanpak.meta_num]->consec_errors++; 991 992 … … 1007 1008 CHANFLAG_FATAL)); 1008 1009 continue; 1009 1010 } 1011 #endif 1010 1012 } else { 1011 1013 // Otherwise reset the error count 1012 1014 meta_packsources[chanpak.meta_num]->consec_errors = 0; -
pcapsource.cc
diff -urN kismet.old/pcapsource.cc kismet.dev/pcapsource.cc
old new 115 115 u_char callback_data[MAX_PACKET_LEN]; 116 116 117 117 // Open a source 118 int PcapSourceWrt54g::OpenSource() { 119 channel = 0; 120 121 errstr[0] = '\0'; 122 123 char *unconst = strdup("prism0"); 124 125 pd = pcap_open_live(unconst, MAX_PACKET_LEN, 1, 1000, errstr); 126 127 #if defined (SYS_OPENBSD) || defined(SYS_NETBSD) && defined(HAVE_RADIOTAP) 128 /* Request desired DLT on multi-DLT systems that default to EN10MB. We do this 129 later anyway but doing it here ensures we have the desired DLT from the get go. */ 130 pcap_set_datalink(pd, DLT_IEEE802_11_RADIO); 131 #endif 132 133 free(unconst); 134 135 if (strlen(errstr) > 0) 136 return -1; // Error is already in errstr 137 138 paused = 0; 139 140 errstr[0] = '\0'; 141 142 num_packets = 0; 143 144 if (DatalinkType() < 0) 145 return -1; 146 147 #ifdef HAVE_PCAP_NONBLOCK 148 pcap_setnonblock(pd, 1, errstr); 149 #elif !defined(SYS_OPENBSD) 150 // do something clever (Thanks to Guy Harris for suggesting this). 151 int save_mode = fcntl(pcap_get_selectable_fd(pd), F_GETFL, 0); 152 if (fcntl(pcap_get_selectable_fd(pd), F_SETFL, save_mode | O_NONBLOCK) < 0) { 153 snprintf(errstr, 1024, "fcntl failed, errno %d (%s)", 154 errno, strerror(errno)); 155 } 156 #endif 157 158 if (strlen(errstr) > 0) 159 return -1; // Ditto 160 161 return 1; 162 } 163 164 // Open a source 118 165 int PcapSource::OpenSource() { 119 166 channel = 0; 120 167 … … 1928 1975 int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, 1929 1976 void *in_ext) { 1930 1977 char cmdline[2048]; 1931 int mode;1932 int wlmode = 0;1933 1934 #ifdef HAVE_LINUX_WIRELESS1935 vector<string> devbits = StrTokenize(in_dev, ":");1936 1978 1937 if (devbits.size() < 2) { 1938 snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1"); 1979 snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 1", in_dev); 1939 1980 if (RunSysCmd(cmdline) < 0) { 1940 snprintf(in_err, 1024, "Unable to set mode using ' wl monitor 1'. Some"1941 " custom firmware images require you to specify the origial "1981 snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 1'. " 1982 "Some custom firmware images require you to specify the origial " 1942 1983 "device and a new dynamic device and use the iwconfig controls. " 1943 1984 "see the README for how to configure your capture source."); 1944 1985 return -1; 1945 1986 } 1946 } else {1947 // Get the mode ... If this doesn't work, try the old wl method.1948 if (Iwconfig_Get_Mode(devbits[0].c_str(), in_err, &mode) < 0) {1949 fprintf(stderr, "WARNING: Getting wireless mode via ioctls failed, "1950 "defaulting to trying the 'wl' command.\n");1951 wlmode = 1;1952 }1953 1987 1954 if (wlmode == 1) {1955 snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1"); 1956 if (RunSysCmd(cmdline) < 0) { 1957 snprintf(in_err, 1024, "Unable to execute '%s'", cmdline); 1958 return -1; 1959 }1960 } else if (mode != LINUX_WLEXT_MONITOR) { 1961 // Set it 1962 if (Iwconfig_Set_Mode(devbits[0].c_str(), in_err,1963 LINUX_WLEXT_MONITOR) < 0) {1964 snprintf(in_err, STATUS_MAX, "Unable to set iwconfig monitor"1965 "mode. If you are using an older wrt54g, try specifying"1966 "only the ethernet device, not ethX:prismX");1967 return -1;1968 }1988 return 1; 1989 } 1990 1991 1992 int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, 1993 void *in_ext) { 1994 char cmdline[2048]; 1995 1996 snprintf(cmdline, 2048, "/usr/sbin/iwpriv %s set_monitor 0", in_dev); 1997 if (RunSysCmd(cmdline) < 0) { 1998 snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 0'. " 1999 "Some custom firmware images require you to specify the origial " 2000 "device and a new dynamic device and use the iwconfig controls. " 2001 "see the README for how to configure your capture source."); 2002 return -1; 1969 2003 } 1970 }1971 #else1972 snprintf(cmdline, 2048, "/usr/sbin/wl monitor 1");1973 if (RunSysCmd(cmdline) < 0) {1974 snprintf(in_err, 1024, "Unable to set mode using 'wl monitor 1'. Some "1975 "custom firmware images require you to specify the origial "1976 "device and a new dynamic device and use the iwconfig controls. "1977 "see the README for how to configure your capture source. "1978 "Support for wireless extensions was not compiled in, so more "1979 "advanced modes of setting monitor mode are not available.");1980 return -1;1981 }1982 fprintf(stderr, "WARNING: Support for wireless extensions was not compiled "1983 "into this binary. Using the iw* tools to set monitor mode will not "1984 "be available. This may cause opening the source to fail on some "1985 "firmware versions. To fix this, make sure wireless extensions are "1986 "available and found by the configure script when building Kismet.");1987 #endif1988 2004 1989 2005 return 1; 1990 2006 } -
pcapsource.h
diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h
old new 265 265 PcapSourceWrt54g(string in_name, string in_dev) : PcapSource(in_name, in_dev) { 266 266 fcsbytes = 4; 267 267 } 268 int OpenSource(); 268 269 int FetchPacket(kis_packet *packet, uint8_t *data, uint8_t *moddata); 269 270 protected: 270 271 carrier_type IEEE80211Carrier(); … … 412 413 int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext); 413 414 // linksys wrt54g monitoring 414 415 int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext); 416 int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext); 415 417 #endif 416 418 417 419 // This should be expanded to handle BSD...
Note:
See TracBrowser
for help on using the repository browser.
