source: freewrt/package/kismet/patches/100-wrt54g_source.patch@ 6fc4520e

freewrt_1_0 freewrt_2_0
Last change on this file since 6fc4520e was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 7.0 KB
  • kis_packsources.cc

    diff -urN kismet.old/kis_packsources.cc kismet.dev/kis_packsources.cc
    old new  
    192192                                       chancontrol_wlanng_avs, 1);
    193193    sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0,
    194194                                        pcapsource_wrt54g_registrant,
    195                                         monitor_wrt54g, NULL, NULL, 0);
     195                                                                                monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);
    196196#else
    197197    REG_EMPTY_CARD(sourcetracker, "wlanng");
    198198    REG_EMPTY_CARD(sourcetracker, "wlanng_avs");
  • packetsourcetracker.cc

    diff -urN kismet.old/packetsourcetracker.cc kismet.dev/packetsourcetracker.cc
    old new  
    986986                    (meta_packsources[chanpak.meta_num]->device.c_str(),
    987987                     chanpak.channel, errstr,
    988988                     (void *) (meta_packsources[chanpak.meta_num]->capsource)) < 0) {
     989#if 0
    989990
    990991                                        meta_packsources[chanpak.meta_num]->consec_errors++;
    991992
     
    10071008                                                                                                                                         CHANFLAG_FATAL));
    10081009                                                continue;
    10091010                                        }
     1011#endif
    10101012                } else {
    10111013                                        // Otherwise reset the error count
    10121014                                        meta_packsources[chanpak.meta_num]->consec_errors = 0;
  • pcapsource.cc

    diff -urN kismet.old/pcapsource.cc kismet.dev/pcapsource.cc
    old new  
    115115u_char callback_data[MAX_PACKET_LEN];
    116116
    117117// Open a source
     118int 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
    118165int PcapSource::OpenSource() {
    119166    channel = 0;
    120167
     
    19281975int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
    19291976                                   void *in_ext) {
    19301977    char cmdline[2048];
    1931         int mode;
    1932         int wlmode = 0;
    1933 
    1934 #ifdef HAVE_LINUX_WIRELESS
    1935     vector<string> devbits = StrTokenize(in_dev, ":");
    19361978
    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);
    19391980                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 "
    19421983                                         "device and a new dynamic device and use the iwconfig controls. "
    19431984                                         "see the README for how to configure your capture source.");
    19441985                        return -1;
    19451986                }
    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                 }
    19531987
    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
     1992int 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;
    19692003                }
    1970         }
    1971 #else
    1972         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 #endif
    19882004
    19892005        return 1;
    19902006}
  • pcapsource.h

    diff -urN kismet.old/pcapsource.h kismet.dev/pcapsource.h
    old new  
    265265    PcapSourceWrt54g(string in_name, string in_dev) : PcapSource(in_name, in_dev) {
    266266        fcsbytes = 4;
    267267    }
     268        int OpenSource();
    268269    int FetchPacket(kis_packet *packet, uint8_t *data, uint8_t *moddata);
    269270protected:
    270271    carrier_type IEEE80211Carrier();
     
    412413int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
    413414// linksys wrt54g monitoring
    414415int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
     416int unmonitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext);
    415417#endif
    416418
    417419// This should be expanded to handle BSD...
Note: See TracBrowser for help on using the repository browser.