source: freewrt/package/kismet/patches/120-cleanup.patch@ 428f140

freewrt_1_0 freewrt_2_0
Last change on this file since 428f140 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: 113.2 KB
  • cursesfront.cc

    diff -urN kismet.dev/cursesfront.cc kismet.dev2/cursesfront.cc
    old new  
    3030// Enable the protocols we can use
    3131void NCurseFront::AddClient(TcpClient *in_client) {
    3232    client = in_client;
    33     client->EnableProtocol("GPS");
    3433    client->EnableProtocol("INFO");
    3534    client->EnableProtocol("REMOVE");
    3635    client->EnableProtocol("NETWORK");
     
    8887        mvwaddstr(netborder, 1, 2, "  SSID                        T W Ch  Data   LLC  Crypt  Wk Flags");
    8988    }
    9089
    91     char gpsdata[1024];
    92     float lat, lon, alt, spd, heading;
    9390    int mode;
    9491
    95     client->FetchLoc(&lat, &lon, &alt, &spd, &heading, &mode);
    96 
    97     if (!(lat == 0 && lon == 0 && alt == 0 && spd == 0 && mode == 0)) {
    98 
    99         char fix[16];
    100 
    101         if (mode == -1)
    102             snprintf(fix, 16, "No signal");
    103         else if (mode == 2)
    104             snprintf(fix, 5, "2D");
    105         else if (mode == 3)
    106             snprintf(fix, 5, "3D");
    107         else
    108             snprintf(fix, 5, "NONE");
    109 
    110         snprintf(gpsdata, 1024, "Lat %.3f Lon %.3f Alt %.3f Spd %.3f Fix %s",
    111                  lat, lon, alt, spd, fix);
    112 
    113         mvwaddstr(netborder, LINES-statheight-1, 2, gpsdata);
    114 
    115     }
    116 
    11792    box(infoborder, '|', '-');
    11893    mvwaddstr(infoborder, 0, 2, "Info");
    11994
  • dronesource.cc

    diff -urN kismet.dev/dronesource.cc kismet.dev2/dronesource.cc
    old new  
    201201            return -1;
    202202        }
    203203
    204                 // Grab the GPS info
    205                 gps_enabled = vpkt.gps_enabled;
    206 
    207204        stream_recv_bytes = 0;
    208205
    209206        // printf("debug - version packet valid\n\n");
     
    336333    packet->encoding = (encoding_type) phdr.encoding;
    337334    packet->datarate = (uint32_t) ntohl(phdr.datarate);
    338335
    339         if (gps_enabled) {
    340                 // If the drone is sending us GPS data, use it
    341                 packet->gps_lat = Pair2Float((int16_t) ntohs(phdr.gps_lat),
    342                                                                          (int64_t) kis_ntoh64(phdr.gps_lat_mant));
    343                 packet->gps_lon = Pair2Float((int16_t) ntohs(phdr.gps_lon),
    344                                                                          (int64_t) kis_ntoh64(phdr.gps_lon_mant));
    345                 packet->gps_alt = Pair2Float((int16_t) ntohs(phdr.gps_alt),
    346                                                                          (int64_t) kis_ntoh64(phdr.gps_alt_mant));
    347                 packet->gps_spd = Pair2Float((int16_t) ntohs(phdr.gps_spd),
    348                                                                          (int64_t) kis_ntoh64(phdr.gps_spd_mant));
    349                 packet->gps_heading = Pair2Float((int16_t) ntohs(phdr.gps_heading),
    350                                                                                  (int64_t) kis_ntoh64(phdr.gps_heading_mant));
    351                 packet->gps_fix = phdr.gps_fix;
    352         } else if (gpsd != NULL) {
    353                 // Otherwise, no
    354                 gpsd->FetchLoc(&packet->gps_lat, &packet->gps_lon, &packet->gps_alt,
    355                                            &packet->gps_spd, &packet->gps_heading, &packet->gps_fix);
    356         }
    357 
    358336    packet->data = data;
    359337    packet->moddata = moddata;
    360338    packet->modified = 0;
  • dronesource.h

    diff -urN kismet.dev/dronesource.h kismet.dev2/dronesource.h
    old new  
    7979    uint8_t databuf[MAX_PACKET_LEN];
    8080
    8181    unsigned int resyncing;
    82 
    83         // Is the drone pushing GPS data to us?
    84         int gps_enabled;
    8582};
    8683
    8784// Nothing but a registrant for us
  • frontend.cc

    diff -urN kismet.dev/frontend.cc kismet.dev2/frontend.cc
    old new  
    248248
    249249            }
    250250
    251             // Aggregate the GPS data
    252             if (wnet->aggregate_points > 0) {
    253                 dnet->virtnet->aggregate_lat += wnet->aggregate_lat;
    254                 dnet->virtnet->aggregate_lon += wnet->aggregate_lon;
    255                 dnet->virtnet->aggregate_alt += wnet->aggregate_alt;
    256                 dnet->virtnet->aggregate_points += wnet->aggregate_points;
    257             }
    258 
    259             if (wnet->gps_fixed > dnet->virtnet->gps_fixed)
    260                 dnet->virtnet->gps_fixed = wnet->gps_fixed;
    261             if (wnet->min_lat < dnet->virtnet->min_lat || dnet->virtnet->min_lat == 0)
    262                 dnet->virtnet->min_lat = wnet->min_lat;
    263             if (wnet->min_lon < dnet->virtnet->min_lon || dnet->virtnet->min_lon == 0)
    264                 dnet->virtnet->min_lon = wnet->min_lon;
    265             if (wnet->min_alt < dnet->virtnet->min_alt || dnet->virtnet->min_alt == 0)
    266                 dnet->virtnet->min_alt = wnet->min_alt;
    267             if (wnet->min_spd < dnet->virtnet->min_spd || dnet->virtnet->min_spd == 0)
    268                 dnet->virtnet->min_spd = wnet->min_spd;
    269             if (wnet->max_lat > dnet->virtnet->max_lat || dnet->virtnet->max_lat == 0)
    270                 dnet->virtnet->max_lat = wnet->max_lat;
    271             if (wnet->max_lon > dnet->virtnet->max_lon || dnet->virtnet->max_lon == 0)
    272                 dnet->virtnet->max_lon = wnet->max_lon;
    273             if (wnet->max_alt > dnet->virtnet->max_alt || dnet->virtnet->max_alt == 0)
    274                 dnet->virtnet->max_alt = wnet->max_alt;
    275             if (wnet->max_spd > dnet->virtnet->max_spd || dnet->virtnet->max_spd == 0)
    276                 dnet->virtnet->max_spd = wnet->max_spd;
    277 
    278251            // Aggregate the carriers and encodings
    279252            dnet->virtnet->carrier_set |= wnet->carrier_set;
    280253            dnet->virtnet->encoding_set |= wnet->encoding_set;
  • kismet_client.cc

    diff -urN kismet.dev/kismet_client.cc kismet.dev2/kismet_client.cc
    old new  
    2828#include "cursesfront.h"
    2929#include "panelfront.h"
    3030#include "configfile.h"
    31 #include "speech.h"
    3231
    3332#ifndef exec_name
    3433char *exec_name;
     
    4746char *configfile;
    4847char *uiconfigfile;
    4948char *server = NULL;
    50 int sound = -1;
    51 int speech = -1;
    5249int flite = 0;
    53 int speech_encoding = 0;
    54 string speech_sentence_encrypted, speech_sentence_unencrypted;
    5550unsigned int metric = 0;
    5651unsigned int reconnect = 0;
    5752
     
    5954string configdir, groupfile;
    6055FILE *group_file = NULL;
    6156
    62 // Pipe file descriptor pairs and fd's
    63 int soundpair[2];
    64 int speechpair[2];
    65 pid_t soundpid = -1, speechpid = -1;
    66 
    6757// Catch our interrupt
    6858void CatchShutdown(int sig) {
    6959
    70     // Kill our sound players
    71     if (soundpid > 0)
    72         kill(soundpid, 9);
    73     if (speechpid > 0)
    74         kill(speechpid, 9);
    75 
    7660    if (group_track) {
    7761        if ((group_file = fopen(groupfile.c_str(), "w")) == NULL) {
    7862            fprintf(stderr, "WARNING: Unable to open '%s' for writing, groups will not be saved.\n",
     
    116100    exit(0);
    117101}
    118102
    119 // Subprocess sound handler
    120 void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {
    121     int read_sock = fds[0];
    122 
    123     close(fds[1]);
    124 
    125     signal(SIGPIPE, PipeHandler);
    126 
    127     fd_set rset;
    128 
    129     char data[1024];
    130 
    131     pid_t sndpid = -1;
    132     int harvested = 1;
    133 
    134     while (1) {
    135         FD_ZERO(&rset);
    136         FD_SET(read_sock, &rset);
    137         char *end;
    138 
    139         memset(data, 0, 1024);
    140 
    141         if (harvested == 0) {
    142             // We consider a wait error to be a sign that the child pid died
    143             // so we flag it as harvested and keep on going
    144             pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
    145             if (harvestpid == -1 || harvestpid == sndpid)
    146                 harvested = 1;
    147         }
    148 
    149         struct timeval tim;
    150         tim.tv_sec = 1;
    151         tim.tv_usec = 0;
    152 
    153         if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {
    154             if (errno != EINTR) {
    155                 exit(1);
    156             }
    157         }
    158 
    159         if (FD_ISSET(read_sock, &rset)) {
    160             int ret;
    161             ret = read(read_sock, data, 1024);
    162 
    163             // We'll die off if we get a read error, and we'll let kismet on the
    164             // other side detact that it died
    165             if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
    166                 exit(1);
    167 
    168             if ((end = strstr(data, "\n")) == NULL)
    169                 continue;
    170 
    171             end[0] = '\0';
    172         }
    173 
    174         if (data[0] == '\0')
    175             continue;
    176 
    177         // If we've harvested the process, spawn a new one and watch it
    178         // instead.  Otherwise, we just let go of the data we read
    179         if (harvested == 1) {
    180             // Only take the first line
    181             char *nl;
    182             if ((nl = strchr(data, '\n')) != NULL)
    183                 *nl = '\0';
    184 
    185             char snd[1024];
    186 
    187             if (soundmap.size() == 0)
    188                 snprintf(snd, 1024, "%s", data);
    189             if (soundmap.find(data) != soundmap.end())
    190                 snprintf(snd, 1024, "%s", soundmap[data].c_str());
    191             else
    192                 continue;
    193 
    194             char plr[1024];
    195             snprintf(plr, 1024, "%s", player);
    196 
    197             harvested = 0;
    198             if ((sndpid = fork()) == 0) {
    199                 // Suppress errors
    200                 int nulfd = open("/dev/null", O_RDWR);
    201                 dup2(nulfd, 1);
    202                 dup2(nulfd, 2);
    203 
    204                 char * const echoarg[] = { plr, snd, NULL };
    205                 execve(echoarg[0], echoarg, NULL);
    206             }
    207         }
    208 
    209         data[0] = '\0';
    210     }
    211 }
    212 
    213 // Subprocess speech handler
    214 void SpeechHandler(int *fds, const char *player) {
    215     int read_sock = fds[0];
    216     close(fds[1]);
    217 
    218     fd_set rset;
    219 
    220     char data[1024];
    221 
    222     pid_t sndpid = -1;
    223     int harvested = 1;
    224 
    225     while (1) {
    226         FD_ZERO(&rset);
    227         FD_SET(read_sock, &rset);
    228         //char *end;
    229 
    230         memset(data, 0, 1024);
    231 
    232         struct timeval tim;
    233         tim.tv_sec = 1;
    234         tim.tv_usec = 0;
    235 
    236         if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {
    237             if (errno != EINTR) {
    238                 exit(1);
    239             }
    240         }
    241 
    242         if (harvested == 0) {
    243             // We consider a wait error to be a sign that the child pid died
    244             // so we flag it as harvested and keep on going
    245             pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
    246             if (harvestpid == -1 || harvestpid == sndpid)
    247                 harvested = 1;
    248         }
    249 
    250         if (FD_ISSET(read_sock, &rset)) {
    251             int ret;
    252             ret = read(read_sock, data, 1024);
    253 
    254             // We'll die off if we get a read error, and we'll let kismet on the
    255             // other side detact that it died
    256             if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
    257                 exit(1);
    258 
    259             data[ret] = '\0';
    260 
    261         }
    262 
    263         if (data[0] == '\0')
    264             continue;
    265 
    266         // If we've harvested the process, spawn a new one and watch it
    267         // instead.  Otherwise, we just let go of the data we read
    268         if (harvested == 1) {
    269             harvested = 0;
    270             if ((sndpid = fork()) == 0) {
    271                 // Only take the first line
    272                 char *nl;
    273                 if ((nl = strchr(data, '\n')) != NULL)
    274                     *nl = '\0';
    275 
    276                 // Make sure it's shell-clean
    277                 MungeToShell(data, strlen(data));
    278                 char spk_call[1024];
    279                 snprintf(spk_call, 1024, "echo \"(%s\\\"%s\\\")\" | %s "
    280                                                  ">/dev/null 2>/dev/null",
    281                                                  flite ? "": "SayText ", data, player);
    282 
    283                 system(spk_call);
    284 
    285                 exit(0);
    286             }
    287         }
    288 
    289         data[0] = '\0';
    290     }
    291 }
    292 
    293 
    294 int PlaySound(string in_sound) {
    295 
    296     char snd[1024];
    297 
    298     snprintf(snd, 1024, "%s\n", in_sound.c_str());
    299 
    300     if (write(soundpair[1], snd, strlen(snd)) < 0) {
    301         char status[STATUS_MAX];
    302         snprintf(status, STATUS_MAX,
    303                  "ERROR: Could not write to sound pipe.  Stopping sound.");
    304         gui->WriteStatus(status);
    305 
    306         return 0;
    307     }
    308 
    309     return 1;
    310 }
    311 
    312 int SayText(string in_text) {
    313     char snd[1024];
    314 
    315     snprintf(snd, 1024, "%s\n", in_text.c_str());
    316 
    317     if (write(speechpair[1], snd, strlen(snd)) < 0) {
    318         char status[STATUS_MAX];
    319         snprintf(status, STATUS_MAX,
    320                  "ERROR: Could not write to speech pipe.  Stopping speech.");
    321         gui->WriteStatus(status);
    322 
    323         return 0;
    324     }
    325 
    326     return 1;
    327 }
    328103
    329104int main(int argc, char *argv[]) {
    330105    exec_name = argv[0];
     
    345120    char guihost[1024];
    346121    int guiport = -1;
    347122
    348     int gpsmode = -1;
    349 
    350123    configfile = NULL;
    351124    uiconfigfile = NULL;
    352125
     
    391164            fprintf(stderr, "Using alternate UI config file: %s\n", uiconfigfile);
    392165            break;
    393166        case 'q':
    394             sound = 0;
    395167            break;
    396168        case 'g':
    397169            reqgui = strdup(optarg);
     
    515287        server = strdup(gui_conf->FetchOpt("host").c_str());
    516288    }
    517289
    518     if (gui_conf->FetchOpt("sound") == "true" && sound == -1) {
    519         if (gui_conf->FetchOpt("soundplay") != "") {
    520             sndplay = gui_conf->FetchOpt("soundplay");
    521             sound = 1;
    522 
    523             if (gui_conf->FetchOpt("soundopts") != "")
    524                 sndplay += " " + gui_conf->FetchOpt("soundopts");
    525 
    526             if (gui_conf->FetchOpt("sound_new") != "")
    527                 wav_map["new"] = gui_conf->FetchOpt("sound_new");
    528             if (gui_conf->FetchOpt("sound_new_wep") != "")
    529                 wav_map["new_wep"] = gui_conf->FetchOpt("sound_new_wep");
    530             if (gui_conf->FetchOpt("sound_traffic") != "")
    531                 wav_map["traffic"] = gui_conf->FetchOpt("sound_traffic");
    532             if (gui_conf->FetchOpt("sound_junktraffic") != "")
    533                 wav_map["junktraffic"] = gui_conf->FetchOpt("sound_junktraffic");
    534             if (gui_conf->FetchOpt("sound_gpslock") != "")
    535                 wav_map["gpslock"] = gui_conf->FetchOpt("sound_gpslock");
    536             if (gui_conf->FetchOpt("sound_gpslost") != "")
    537                 wav_map["gpslost"] = gui_conf->FetchOpt("sound_gpslost");
    538             if (gui_conf->FetchOpt("sound_alert") != "")
    539                 wav_map["alert"] = gui_conf->FetchOpt("sound_alert");
    540 
    541         } else {
    542             fprintf(stderr, "ERROR:  Sound alerts enabled but no sound playing binary specified.\n");
    543             sound = 0;
    544         }
    545     } else if (sound == -1)
    546         sound = 0;
    547 
    548     /* Added by Shaw Innes 17/2/02 */
    549     if (gui_conf->FetchOpt("speech") == "true" && speech == -1) {
    550         if (gui_conf->FetchOpt("festival") != "") {
    551             festival = strdup(gui_conf->FetchOpt("festival").c_str());
    552             speech = 1;
    553 
    554                         if (gui_conf->FetchOpt("flite") == "true")
    555                                 flite = 1;
    556 
    557             string speechtype = gui_conf->FetchOpt("speech_type");
    558 
    559             if (!strcasecmp(speechtype.c_str(), "nato"))
    560                 speech_encoding = SPEECH_ENCODING_NATO;
    561             else if (!strcasecmp(speechtype.c_str(), "spell"))
    562                 speech_encoding = SPEECH_ENCODING_SPELL;
    563             else
    564                 speech_encoding = SPEECH_ENCODING_NORMAL;
    565 
    566             // Make sure we have encrypted text lines
    567             if (gui_conf->FetchOpt("speech_encrypted") == "" || gui_conf->FetchOpt("speech_unencrypted") == "") {
    568                 fprintf(stderr, "ERROR:  Speech request but speech_encrypted or speech_unencrypted line missing.\n");
    569                 speech = 0;
    570             }
    571 
    572             speech_sentence_encrypted = gui_conf->FetchOpt("speech_encrypted");
    573             speech_sentence_unencrypted = gui_conf->FetchOpt("speech_unencrypted");
    574 
    575         } else {
    576             fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");
    577             speech = 0;
    578         }
    579     } else if (speech == -1)
    580         speech = 0;
    581 
    582290    if (gui_conf->FetchOpt("decay") != "") {
    583291        if (sscanf(gui_conf->FetchOpt("decay").c_str(), "%d", &decay) != 1) {
    584292            fprintf(stderr, "FATAL:  Illegal config file value for decay.\n");
     
    636344        }
    637345    }
    638346
    639     // Fork and find the sound options
    640     if (sound) {
    641         if (pipe(soundpair) == -1) {
    642             fprintf(stderr, "WARNING:  Unable to create pipe for audio.  Disabling sound.\n");
    643             sound = 0;
    644         } else {
    645             soundpid = fork();
    646 
    647             if (soundpid < 0) {
    648                 fprintf(stderr, "WARNING:  Unable to fork for audio.  Disabling sound.\n");
    649                 sound = 0;
    650             } else if (soundpid == 0) {
    651                 SoundHandler(soundpair, sndplay.c_str(), wav_map);
    652                 exit(0);
    653             }
    654 
    655             close(soundpair[0]);
    656         }
    657     }
    658 
    659     if (speech) {
    660         if (pipe(speechpair) == -1) {
    661             fprintf(stderr, "WARNING:  Unable to create pipe for speech.  Disabling speech.\n");
    662             speech = 0;
    663         } else {
    664             speechpid = fork();
    665 
    666             if (speechpid < 0) {
    667                 fprintf(stderr, "WARNING:  Unable to fork for speech.  Disabling speech.\n");
    668                 speech = 0;
    669             } else if (speechpid == 0) {
    670                 SpeechHandler(speechpair, festival);
    671                 exit(0);
    672             }
    673 
    674             close(speechpair[0]);
    675         }
    676     }
    677 
    678347    if (kismet_serv.Connect(guiport, guihost) < 0) {
    679348        fprintf(stderr, "FATAL:  Could not connect to %s:%d.\n", guihost, guiport);
    680349        CatchShutdown(-1);
     
    884553                    }
    885554
    886555                    if (pollret != 0) {
    887                         if (pollret == CLIENT_ALERT)
    888                             if (sound == 1)
    889                                 sound = PlaySound("alert");
    890 
    891556                        if (strlen(tcpcli->FetchStatus()) != 0) {
    892557                            gui->WriteStatus(tcpcli->FetchStatus());
    893558                            // gui->DrawDisplay();
    894559                        }
    895560
    896                         // The GPS only gets updated for the primary client
    897                         if (tcpcli == primary_client) {
    898                             if (tcpcli->FetchMode() == 0 && gpsmode != 0) {
    899                                 if (sound == 1 && gpsmode != -1)
    900                                     sound = PlaySound("gpslost");
    901                                 gpsmode = 0;
    902                             } else if (tcpcli->FetchMode() != 0 && gpsmode == 0) {
    903                                 if (sound == 1 && gpsmode != -1)
    904                                     sound = PlaySound("gpslock");
    905                                 gpsmode = 1;
    906                             }
    907                         }
    908 
    909561                        if (tcpcli->FetchDeltaNumNetworks() > 0) {
    910562                            wireless_network *newnet = tcpcli->FetchLastNewNetwork();
    911 
    912                             if (sound == 1 && newnet != lastspoken) {
    913                                 if (newnet->crypt_set &&
    914                                     wav_map.find("new_wep") != wav_map.end())
    915                                     sound = PlaySound("new_wep");
    916                                 else
    917                                     sound = PlaySound("new");
    918                             }
    919 
    920                             if (speech == 1 && newnet != lastspoken) {
    921                                 string text;
    922 
    923                                 if (newnet != NULL) {
    924                                     if (newnet->crypt_set)
    925                                         text = ExpandSpeechString(speech_sentence_encrypted, newnet, speech_encoding);
    926                                     else
    927                                         text = ExpandSpeechString(speech_sentence_unencrypted, newnet, speech_encoding);
    928 
    929                                     speech = SayText(text.c_str());
    930                                 }
    931                             }
    932 
    933                             lastspoken = newnet;
    934563                        }
    935564
    936565                        num_networks += tcpcli->FetchNumNetworks();
     
    938567                        num_noise += tcpcli->FetchNumNoise();
    939568                        num_dropped += tcpcli->FetchNumDropped();
    940569
    941                         if (tcpcli->FetchDeltaNumPackets() != 0) {
    942                             if (time(0) - last_click >= decay && sound == 1) {
    943                                 if (tcpcli->FetchDeltaNumPackets() > tcpcli->FetchDeltaNumDropped()) {
    944                                     sound = PlaySound("traffic");
    945                                 } else {
    946                                     sound = PlaySound("junktraffic");
    947                                 }
    948 
    949                                 last_click = time(0);
    950                             }
    951                         }
     570                                                tcpcli->FetchDeltaNumPackets();
    952571                    }
    953572                }
    954573            } else {
  • kismet_drone.cc

    diff -urN kismet.dev/kismet_drone.cc kismet.dev2/kismet_drone.cc
    old new  
    3232#include "packet.h"
    3333
    3434#include "packetsource.h"
    35 #include "prism2source.h"
    3635#include "pcapsource.h"
    37 #include "wtapfilesource.h"
    38 #include "wsp100source.h"
    39 #include "vihasource.h"
    4036#include "dronesource.h"
    4137#include "packetsourcetracker.h"
    4238#include "kis_packsources.h"
    4339
    44 #include "gpsd.h"
    4540#include "tcpstreamer.h"
    4641#include "configfile.h"
    4742
     
    5348
    5449const char *config_base = "kismet_drone.conf";
    5550
    56 GPSD *gps = NULL;
    57 int gpsmode = 0;
    58 int gps_enable = 0;
    59 
    6051// Unused, only here to make packetsourcetracker link
    6152int retain_monitor = 0;
    6253
     
    8475    exit(0);
    8576}
    8677
    87 int GpsEvent(Timetracker::timer_event *evt, void *parm) {
    88     // The GPS only provides us a new update once per second we might
    89     // as well only update it here once a second
    90     if (gps_enable) {
    91         int gpsret;
    92         gpsret = gps->Scan();
    93         if (gpsret < 0) {
    94             if (!silent)
    95                 fprintf(stderr, "GPS error fetching data: %s\n",
    96                         gps->FetchError());
    97 
    98             gps_enable = 0;
    99         }
    100 
    101     }
    102 
    103     // We want to be rescheduled
    104     return 1;
    105 }
    106 
    10778// Handle channel hopping... this is actually really simple.
    10879int ChannelHopEvent(Timetracker::timer_event *evt, void *parm) {
    10980    sourcetracker.AdvanceChannel();
     
    151122
    152123    TcpStreamer streamer;
    153124
    154     char gpshost[1024];
    155     int gpsport = -1;
    156 
    157125    int channel_hop = -1;
    158126    int channel_velocity = 1;
    159127    int channel_dwell = 0;
     
    354322        exit(1);
    355323    }
    356324
    357     if (conf->FetchOpt("gps") == "true") {
    358         if (sscanf(conf->FetchOpt("gpshost").c_str(), "%1023[^:]:%d", gpshost, &gpsport) != 2) {
    359             fprintf(stderr, "Invalid GPS host in config (host:port required)\n");
    360             exit(1);
    361         }
    362 
    363         gps_enable = 1;
    364     } else {
    365             gps_enable = 0;
    366     }
    367 
    368     if (gps_enable == 1) {
    369         // Open the GPS
    370         gps = new GPSD(gpshost, gpsport);
    371 
    372         // Lock GPS position
    373         if (conf->FetchOpt("gpsmodelock") == "true") {
    374             fprintf(stderr, "Enabling GPS position lock override (broken GPS unit reports 0 always)\n");
    375             gps->SetOptions(GPSD_OPT_FORCEMODE);
    376         }
    377 
    378         if (gps->OpenGPSD() < 0) {
    379             fprintf(stderr, "%s\n", gps->FetchError());
    380 
    381             gps_enable = 0;
    382         } else {
    383             fprintf(stderr, "Opened GPS connection to %s port %d\n",
    384                     gpshost, gpsport);
    385 
    386         }
    387     }
    388 
    389     // Update GPS coordinates and handle signal loss if defined
    390     timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &GpsEvent, NULL);
    391 
    392         // Add the GPS to the tcpstreamer
    393         streamer.AddGpstracker(gps);
    394 
    395     // Register the gps and timetracker with the sourcetracker
    396     sourcetracker.AddGpstracker(gps);
    397325    sourcetracker.AddTimetracker(&timetracker);
    398326
    399327    // Register the sources
  • kismet_server.cc

    diff -urN kismet.dev/kismet_server.cc kismet.dev2/kismet_server.cc
    old new  
    3737#include "packet.h"
    3838
    3939#include "packetsource.h"
    40 #include "prism2source.h"
    4140#include "pcapsource.h"
    42 #include "wtapfilesource.h"
    43 #include "wsp100source.h"
    44 #include "vihasource.h"
    4541#include "dronesource.h"
    4642#include "packetsourcetracker.h"
    4743#include "kis_packsources.h"
     
    5147#include "wtaplocaldump.h"
    5248#include "airsnortdump.h"
    5349#include "fifodump.h"
    54 #include "gpsdump.h"
    55 
    56 #include "gpsd.h"
    5750
    5851#include "packetracker.h"
    5952#include "timetracker.h"
    6053#include "alertracker.h"
    6154
    62 #include "speech.h"
    6355#include "tcpserver.h"
    6456#include "server_globals.h"
    6557#include "kismet_server.h"
     
    8981Alertracker alertracker;
    9082Timetracker timetracker;
    9183
    92 GPSD *gps = NULL;
    93 int gpsmode = 0;
    94 GPSDump gpsdump;
    95 
    96 // Last time we tried to reconnect to the gps
    97 time_t last_gpsd_reconnect = 0;
    98 int gpsd_reconnect_attempt = 0;
    99 
    10084FifoDumpFile fifodump;
    10185TcpServer ui_server;
    102 int sound = -1;
    10386packet_info last_info;
    10487int decay;
    10588channel_power channel_graph[CHANNEL_MAX];
     
    11295// Wep keys
    11396macmap<wep_key_info *> bssid_wep_map;
    11497
    115 // Pipe file descriptor pairs and fd's
    116 int soundpair[2];
    117 int speechpair[2];
    11898int chanpair[2];
    119 pid_t soundpid = -1, speechpid = -1, chanpid = -1;
     99pid_t chanpid = -1;
    120100
    121101// Past alerts
    122102unsigned int max_alerts = 50;
     
    177157int tcpport = -1;
    178158int tcpmax;
    179159
    180 //const char *sndplay = NULL;
    181 string sndplay;
    182 
    183 const char *festival = NULL;
    184 int speech = -1;
    185 int flite = 0;
    186 int speech_encoding = 0;
    187 string speech_sentence_encrypted, speech_sentence_unencrypted;
    188 
    189 map<string, string> wav_map;
    190 
    191160int beacon_log = 1;
    192161int phy_log = 1;
    193162int mangle_log = 0;
     
    348317        // delete cryptfile;
    349318    }
    350319
    351     if (gps_log == 1) {
    352         if (gpsdump.CloseDump(1) < 0)
    353             fprintf(stderr, "Didn't log any GPS coordinates, unlinking gps file\n");
    354     }
    355 
    356     // Kill our sound players
    357     if (soundpid > 0)
    358         kill(soundpid, 9);
    359     if (speechpid > 0)
    360         kill(speechpid, 9);
    361 
    362320    // Shut down the packet sources
    363321    sourcetracker.CloseSources();
    364322
     
    369327    exit(0);
    370328}
    371329
    372 // Subprocess sound handler
    373 void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {
    374     int read_sock = fds[0];
    375     close(fds[1]);
    376 
    377     fd_set rset;
    378 
    379     char data[1024];
    380 
    381     pid_t sndpid = -1;
    382     int harvested = 1;
    383 
    384     while (1) {
    385         FD_ZERO(&rset);
    386         FD_SET(read_sock, &rset);
    387         char *end;
    388 
    389         memset(data, 0, 1024);
    390 
    391         struct timeval tm;
    392         tm.tv_sec = 1;
    393         tm.tv_usec = 0;
    394 
    395         if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {
    396             if (errno != EINTR) {
    397                 exit(1);
    398             }
    399         }
    400 
    401         if (harvested == 0) {
    402             // We consider a wait error to be a sign that the child pid died
    403             // so we flag it as harvested and keep on going
    404             pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
    405             if (harvestpid == -1 || harvestpid == sndpid)
    406                 harvested = 1;
    407         }
    408 
    409         if (FD_ISSET(read_sock, &rset)) {
    410             int ret;
    411             ret = read(read_sock, data, 1024);
    412 
    413             // We'll die off if we get a read error, and we'll let kismet on the
    414             // other side detact that it died
    415             if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
    416                 exit(1);
    417 
    418             if ((end = strstr(data, "\n")) == NULL)
    419                 continue;
    420 
    421             end[0] = '\0';
    422         }
    423 
    424         if (data[0] == '\0')
    425             continue;
    426 
    427 
    428         // If we've harvested the process, spawn a new one and watch it
    429         // instead.  Otherwise, we just let go of the data we read
    430         if (harvested == 1) {
    431             // Only take the first line
    432             char *nl;
    433             if ((nl = strchr(data, '\n')) != NULL)
    434                 *nl = '\0';
    435 
    436             // Make sure it's shell-clean
    437 
    438             char snd[1024];
    439 
    440             if (soundmap.size() == 0)
    441                 snprintf(snd, 1024, "%s", data);
    442             if (soundmap.find(data) != soundmap.end())
    443                 snprintf(snd, 1024, "%s", soundmap[data].c_str());
    444             else
    445                 continue;
    446 
    447             char plr[1024];
    448             snprintf(plr, 1024, "%s", player);
    449 
    450             harvested = 0;
    451             if ((sndpid = fork()) == 0) {
    452                 // Suppress errors
    453                 if (silent) {
    454                     int nulfd = open("/dev/null", O_RDWR);
    455                     dup2(nulfd, 1);
    456                     dup2(nulfd, 2);
    457                 }
    458 
    459                 char * const echoarg[] = { plr, snd, NULL };
    460                 execve(echoarg[0], echoarg, NULL);
    461             }
    462         }
    463         data[0] = '\0';
    464     }
    465 }
    466 
    467 // Subprocess speech handler
    468 void SpeechHandler(int *fds, const char *player) {
    469     int read_sock = fds[0];
    470     close(fds[1]);
    471 
    472     fd_set rset;
    473 
    474     char data[1024];
    475 
    476     pid_t sndpid = -1;
    477     int harvested = 1;
    478 
    479     while (1) {
    480         FD_ZERO(&rset);
    481         FD_SET(read_sock, &rset);
    482         //char *end;
    483 
    484         memset(data, 0, 1024);
    485 
    486         if (harvested == 0) {
    487             // We consider a wait error to be a sign that the child pid died
    488             // so we flag it as harvested and keep on going
    489             pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
    490             if (harvestpid == -1 || harvestpid == sndpid)
    491                 harvested = 1;
    492         }
    493 
    494         struct timeval tm;
    495         tm.tv_sec = 1;
    496         tm.tv_usec = 0;
    497 
    498         if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {
    499             if (errno != EINTR) {
    500                 exit(1);
    501             }
    502         }
    503 
    504         if (FD_ISSET(read_sock, &rset)) {
    505             int ret;
    506             ret = read(read_sock, data, 1024);
    507 
    508             // We'll die off if we get a read error, and we'll let kismet on the
    509             // other side detact that it died
    510             if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
    511                 exit(1);
    512 
    513             data[ret] = '\0';
    514         }
    515 
    516         if (data[0] == '\0')
    517             continue;
    518 
    519         // If we've harvested the process, spawn a new one and watch it
    520         // instead.  Otherwise, we just let go of the data we read
    521         if (harvested == 1) {
    522             harvested = 0;
    523             if ((sndpid = fork()) == 0) {
    524                 // Only take the first line
    525                 char *nl;
    526                 if ((nl = strchr(data, '\n')) != NULL)
    527                     *nl = '\0';
    528 
    529                 // Make sure it's shell-clean
    530                 MungeToShell(data, strlen(data));
    531                 char spk_call[1024];
    532                 snprintf(spk_call, 1024, "echo \"(%s\\\"%s\\\")\" | %s "
    533                                                  ">/dev/null 2>/dev/null",
    534                                                  flite ? "" : "SayText ", data, player);
    535                 system(spk_call);
    536 
    537                 exit(0);
    538             }
    539         }
    540 
    541         data[0] = '\0';
    542     }
    543 }
    544 
    545 
    546 // Fork and run a system call to play a sound
    547 int PlaySound(string in_sound) {
    548 
    549     char snd[1024];
    550 
    551     snprintf(snd, 1024, "%s\n", in_sound.c_str());
    552 
    553     if (write(soundpair[1], snd, strlen(snd)) < 0) {
    554         char status[STATUS_MAX];
    555         if (!silent)
    556             fprintf(stderr, "ERROR:  Write error, closing sound pipe.\n");
    557         snprintf(status, STATUS_MAX, "ERROR:  Write error on sound pipe, closing sound connection");
    558         NetWriteStatus(status);
    559 
    560         return 0;
    561     }
    562 
    563     return 1;
    564 }
    565 
    566 int SayText(string in_text) {
    567 
    568     char snd[1024];
    569 
    570     snprintf(snd, 1024, "%s\n", in_text.c_str());
    571     MungeToShell(snd, 1024);
    572 
    573     if (write(speechpair[1], snd, strlen(snd)) < 0) {
    574         char status[STATUS_MAX];
    575         if (!silent)
    576             fprintf(stderr, "ERROR:  Write error, closing speech pipe.\n");
    577         snprintf(status, STATUS_MAX, "ERROR:  Write error on speech pipe, closing speech connection");
    578         NetWriteStatus(status);
    579 
    580         return 0;
    581     }
    582 
    583     return 1;
    584 }
    585 
    586330void KisLocalAlert(const char *in_text) {
    587331    time_t now = time(0);
    588332    if (!silent)
    589333        fprintf(stderr, "ALERT %.24s %s\n", ctime(&now), in_text);
    590 
    591     if (sound == 1)
    592         sound = PlaySound("alert");
    593 
    594334}
    595335
    596336void KisLocalStatus(const char *in_status) {
     
    639379
    640380    char tmpstr[32];
    641381
    642     GPS_data gdata;
    643 
    644     if (gps_enable) {
    645         float lat, lon, alt, spd, hed;
    646         int mode;
    647 
    648         gps->FetchLoc(&lat, &lon, &alt, &spd, &hed, &mode);
    649 
    650         snprintf(tmpstr, 32, "%f", lat);
    651         gdata.lat = tmpstr;
    652         snprintf(tmpstr, 32, "%f", lon);
    653         gdata.lon = tmpstr;
    654         snprintf(tmpstr, 32, "%f", alt);
    655         gdata.alt = tmpstr;
    656         snprintf(tmpstr, 32, "%f", spd);
    657         gdata.spd = tmpstr;
    658         snprintf(tmpstr, 32, "%f", hed);
    659         gdata.heading = tmpstr;
    660         snprintf(tmpstr, 32, "%d", mode);
    661         gdata.mode = tmpstr;
    662     } else {
    663         gdata.lat = "0.0";
    664         gdata.lon = "0.0";
    665         gdata.alt = "0.0";
    666         gdata.spd = "0.0";
    667         gdata.heading = "0.0";
    668         gdata.mode = "0";
    669     }
    670 
    671     ui_server.SendToAll(gps_ref, (void *) &gdata);
    672 
    673382    INFO_data idata;
    674383    snprintf(tmpstr, 32, "%d", tracker.FetchNumNetworks());
    675384    idata.networks = tmpstr;
     
    790499    }
    791500}
    792501
    793 int GpsEvent(Timetracker::timer_event *evt, void *parm) {
    794     char status[STATUS_MAX];
    795 
    796     // The GPS only provides us a new update once per second we might
    797     // as well only update it here once a second
    798 
    799     // If we're disconnected, try to reconnect.
    800     if (gpsd_reconnect_attempt > 0) {
    801         // Increment the time between connection attempts
    802         if (last_gpsd_reconnect + ((gpsd_reconnect_attempt - 1) * 2) < time(0)) {
    803             if (gps->OpenGPSD() < 0) {
    804                 last_gpsd_reconnect = time(0);
    805 
    806                 if (gpsd_reconnect_attempt < 20)
    807                     gpsd_reconnect_attempt++;
    808 
    809                 snprintf(status, STATUS_MAX, "Unable to reconnect to GPSD, trying "
    810                          "again in %d seconds.", ((gpsd_reconnect_attempt - 1) * 2));
    811 
    812                 if (!silent || NetWriteStatus(status) == 0)
    813                     fprintf(stderr, "WARNING: %s\n", status);
    814 
    815                 return 1;
    816             } else {
    817                 gpsd_reconnect_attempt = 0;
    818 
    819                 snprintf(status, STATUS_MAX, "Reopened connection to GPSD");
    820                 if (!silent || NetWriteStatus(status) == 0)
    821                     fprintf(stderr, "NOTICE: %s\n", status);
    822             }
    823         } else {
    824             // Don't process more if we haven't woken up yet
    825             return 1;
    826         }
    827 
    828     }
    829    
    830     if (gps_enable) {
    831         int gpsret;
    832         gpsret = gps->Scan();
    833 
    834         if (gpsret < 0) {
    835             snprintf(status, STATUS_MAX, "GPS error requesting data: %s",
    836                      gps->FetchError());
    837 
    838             if (!silent || NetWriteStatus(status) == 0)
    839                 fprintf(stderr, "WARNING: %s\n", status);
    840 
    841             gpsd_reconnect_attempt = 1;
    842         }
    843 
    844         if (gpsret == 0 && gpsmode != 0) {
    845             if (!silent || NetWriteStatus("Lost GPS signal.") == 0)
    846                 fprintf(stderr, "Lost GPS signal.\n");
    847             if (sound == 1)
    848                 sound = PlaySound("gpslost");
    849 
    850             gpsmode = 0;
    851         } else if (gpsret != 0 && gpsmode == 0) {
    852             if (!silent || NetWriteStatus("Acquired GPS signal.") == 0)
    853                 fprintf(stderr, "Acquired GPS signal.\n");
    854             if (sound == 1)
    855                 sound = PlaySound("gpslock");
    856 
    857             gpsmode = 1;
    858         }
    859     }
    860 
    861     if (gps_log == 1 && gpsmode != 0 && gps != NULL) {
    862         gpsdump.DumpTrack(gps);
    863     }
    864 
    865     // We want to be rescheduled
    866     return 1;
    867 }
    868502
    869503// Simple redirect to the network info drawer.  We don't want to change netwriteinfo to a
    870504// timer event since we call it un-timed too
     
    885519    return 1;
    886520}
    887521
    888 // Write the waypoints for gpsdrive
    889 int WaypointSyncEvent(Timetracker::timer_event *evt, void *parm) {
    890     tracker.WriteGpsdriveWaypt(waypoint_file);
    891 
    892     return 1;
    893 }
    894 
    895522// Handle tracker maintenance
    896523int TrackerTickEvent(Timetracker::timer_event *evt, void *parm) {
    897524    tracker.Tick();
     
    1160787           "  -c, --capture-source <src>   Packet capture source line (type,interface,name)\n"
    1161788           "  -C, --enable-capture-sources Comma separated list of named packet sources to use.\n"
    1162789           "  -l, --log-types <types>      Comma separated list of types to log,\n"
    1163            "                                (ie, dump,cisco,weak,network,gps)\n"
     790           "                                (ie, dump,cisco,weak,network)\n"
    1164791           "  -d, --dump-type <type>       Dumpfile type (wiretap)\n"
    1165792           "  -m, --max-packets <num>      Maximum number of packets before starting new dump\n"
    1166            "  -q, --quiet                  Don't play sounds\n"
    1167            "  -g, --gps <host:port>        GPS server (host:port or off)\n"
    1168793           "  -p, --port <port>            TCPIP server port for GUI connections\n"
    1169794           "  -a, --allowed-hosts <hosts>  Comma separated list of hosts allowed to connect\n"
    1170795           "  -b, --bind-address <address>    Bind to this address. Default INADDR_ANY\n."
     
    1289914        ip_track = 1;
    1290915    }
    1291916
    1292 
    1293     if (conf->FetchOpt("waypoints") == "true") {
    1294         if(conf->FetchOpt("waypointdata") == "") {
    1295             fprintf(stderr, "WARNING:  Waypoint logging requested but no waypoint data file given.\n"
    1296                     "Waypoint logging will be disabled.\n");
    1297             waypoint = 0;
    1298         } else {
    1299             waypointfile = conf->ExpandLogPath(conf->FetchOpt("waypointdata"), "", "", 0, 1);
    1300             waypoint = 1;
    1301         }
    1302         if(conf->FetchOpt("waypoint_essid") == "true") {
    1303             waypointformat = 1;
    1304         } else {
    1305             waypointformat = 0;
    1306         }
    1307     }
    1308 
    1309917    if (conf->FetchOpt("metric") == "true") {
    1310918        fprintf(stderr, "Using metric measurements.\n");
    1311919        metric = 1;
     
    14231031            }
    14241032
    14251033        }
    1426 
    1427         if (strstr(logtypes, "gps")) {
    1428             if (gps_log == 0) {
    1429                 fprintf(stderr, "WARNING:  Disabling GPS logging.\n");
    1430             } else {
    1431                 gps_log = 1;
    1432 
    1433                 if (conf->FetchOpt("logtemplate") == "") {
    1434                     fprintf(stderr, "FATAL:  Logging (gps coordinates) enabled but no logtemplate given in config.\n");
    1435                     ErrorShutdown();
    1436                 }
    1437             }
    1438 
    1439         }
    1440 
    1441         if (gps_log == 1 && !net_log) {
    1442             fprintf(stderr, "WARNING:  Logging (gps coordinates) enabled but XML logging (networks) was not.\n"
    1443                     "It will be enabled now.\n");
    1444             xml_log = 1;
    1445         }
    14461034    }
    14471035
    14481036    if (conf->FetchOpt("decay") != "") {
     
    15631151        legal_ipblock_vec.push_back(ipb);
    15641152    }
    15651153
    1566     // Process sound stuff
    1567     if (conf->FetchOpt("sound") == "true" && sound == -1) {
    1568         if (conf->FetchOpt("soundplay") != "") {
    1569             sndplay = conf->FetchOpt("soundplay");
    1570 
    1571             if (conf->FetchOpt("soundopts") != "")
    1572                 sndplay += " " + conf->FetchOpt("soundopts");
    1573 
    1574             sound = 1;
    1575 
    1576             if (conf->FetchOpt("sound_new") != "")
    1577                 wav_map["new"] = conf->FetchOpt("sound_new");
    1578             if (conf->FetchOpt("sound_new_wep") != "")
    1579                 wav_map["new_wep"] = conf->FetchOpt("sound_new_wep");
    1580             if (conf->FetchOpt("sound_traffic") != "")
    1581                 wav_map["traffic"] = conf->FetchOpt("sound_traffic");
    1582             if (conf->FetchOpt("sound_junktraffic") != "")
    1583                 wav_map["junktraffic"] = conf->FetchOpt("sound_traffic");
    1584             if (conf->FetchOpt("sound_gpslock") != "")
    1585                 wav_map["gpslock"] = conf->FetchOpt("sound_gpslock");
    1586             if (conf->FetchOpt("sound_gpslost") != "")
    1587                 wav_map["gpslost"] = conf->FetchOpt("sound_gpslost");
    1588             if (conf->FetchOpt("sound_alert") != "")
    1589                 wav_map["alert"] = conf->FetchOpt("sound_alert");
    1590 
    1591         } else {
    1592             fprintf(stderr, "ERROR:  Sound alerts enabled but no sound playing binary specified.\n");
    1593             sound = 0;
    1594         }
    1595     } else if (sound == -1)
    1596         sound = 0;
    1597 
    1598     /* Added by Shaw Innes 17/2/02 */
    1599     /* Modified by Andrew Etter 15/9/02 */
    1600     if (conf->FetchOpt("speech") == "true" && speech == -1) {
    1601         if (conf->FetchOpt("festival") != "") {
    1602             festival = strdup(conf->FetchOpt("festival").c_str());
    1603             speech = 1;
    1604                
    1605                         if (conf->FetchOpt("flite") == "true")
    1606                                 flite = 1;
    1607 
    1608             string speechtype = conf->FetchOpt("speech_type");
    1609 
    1610             if (!strcasecmp(speechtype.c_str(), "nato"))
    1611                 speech_encoding = SPEECH_ENCODING_NATO;
    1612             else if (!strcasecmp(speechtype.c_str(), "spell"))
    1613                 speech_encoding = SPEECH_ENCODING_SPELL;
    1614             else
    1615                 speech_encoding = SPEECH_ENCODING_NORMAL;
    1616 
    1617             // Make sure we have encrypted text lines
    1618             if (conf->FetchOpt("speech_encrypted") == "" || conf->FetchOpt("speech_unencrypted") == "") {
    1619                 fprintf(stderr, "ERROR:  Speech request but speech_encrypted or speech_unencrypted line missing.\n");
    1620                 speech = 0;
    1621             }
    1622 
    1623             speech_sentence_encrypted = conf->FetchOpt("speech_encrypted");
    1624             speech_sentence_unencrypted = conf->FetchOpt("speech_unencrypted");
    1625         } else {
    1626             fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");
    1627             speech = 0;
    1628         }
    1629     } else if (speech == -1)
    1630         speech = 0;
    1631 
    16321154    if (conf->FetchOpt("writeinterval") != "") {
    16331155        if (sscanf(conf->FetchOpt("writeinterval").c_str(), "%d", &datainterval) != 1) {
    16341156            fprintf(stderr, "FATAL:  Illegal config file value for data interval.\n");
     
    16481170        fprintf(stderr, "WARNING:  No client_manuf file specified.  Client manufacturers will not be detected.\n");
    16491171    }
    16501172
    1651     // Fork and find the sound options
    1652     if (sound) {
    1653         if (pipe(soundpair) == -1) {
    1654             fprintf(stderr, "WARNING:  Unable to create pipe for audio.  Disabling sound.\n");
    1655             sound = 0;
    1656         } else {
    1657             soundpid = fork();
    1658 
    1659             if (soundpid < 0) {
    1660                 fprintf(stderr, "WARNING:  Unable to fork for audio.  Disabling sound.\n");
    1661                 sound = 0;
    1662             } else if (soundpid == 0) {
    1663                 SoundHandler(soundpair, sndplay.c_str(), wav_map);
    1664                 exit(0);
    1665             }
    1666 
    1667             close(soundpair[0]);
    1668         }
    1669     }
    1670 
    1671     if (speech) {
    1672         if (pipe(speechpair) == -1) {
    1673             fprintf(stderr, "WARNING:  Unable to create pipe for speech.  Disabling speech.\n");
    1674             speech = 0;
    1675         } else {
    1676             speechpid = fork();
    1677 
    1678             if (speechpid < 0) {
    1679                 fprintf(stderr, "WARNING:  Unable to fork for speech.  Disabling speech.\n");
    1680                 speech = 0;
    1681             } else if (speechpid == 0) {
    1682                 SpeechHandler(speechpair, festival);
    1683                 exit(0);
    1684             }
    1685 
    1686             close(speechpair[0]);
    1687         }
    1688     }
    1689 
    16901173    // Grab the filtering
    16911174    string filter_bit;
    16921175
     
    17121195    }
    17131196
    17141197    if ((filter_bit = conf->FetchOpt("filter_export")) != "") {
    1715         fprintf(stderr, "Enabling filtering on exported (csv, xml, network, gps) files.\n");
     1198        fprintf(stderr, "Enabling filtering on exported (csv, xml, network) files.\n");
    17161199        filter_export = 1;
    17171200        if (ConfigFile::ParseFilterLine(filter_bit, &filter_export_bssid, &filter_export_source,
    17181201                                        &filter_export_dest, &filter_export_bssid_invert,
     
    18181301
    18191302    }
    18201303
    1821     if (waypoint) {
    1822         if ((waypoint_file = fopen(waypointfile.c_str(), "a")) == NULL) {
    1823             fprintf(stderr, "WARNING:  Could not open waypoint file '%s' for writing: %s\n",
    1824                     waypointfile.c_str(), strerror(errno));
    1825             waypoint = 0;
    1826         }
    1827     }
    1828 
    18291304    // Create all the logs and title/number them appropriately
    18301305    // We need to save this for after we toast the conf record
    18311306    int logfile_matched = 0;
     
    18731348                continue;
    18741349        }
    18751350
    1876         if (gps_log == 1) {
    1877             gpslogfile = conf->ExpandLogPath(conf->FetchOpt("logtemplate"), logname, "gps", run_num);
    1878 
    1879             if (gpslogfile == "")
    1880                 continue;
    1881         }
    1882 
    18831351        // if we made it this far we're cool -- all the logfiles we're writing to matched
    18841352        // this number
    18851353        logfile_matched = 1;
     
    19081376    if (cisco_log)
    19091377        fprintf(stderr, "Logging cisco product information to %s\n", ciscologfile.c_str());
    19101378
    1911     if (gps_log == 1)
    1912         fprintf(stderr, "Logging gps coordinates to %s\n", gpslogfile.c_str());
    1913 
    19141379    if (data_log)
    19151380        fprintf(stderr, "Logging data to %s\n", dumplogfile.c_str());
    19161381
     
    20581523        { "dump-type", required_argument, 0, 'd' },
    20591524        { "max-packets", required_argument, 0, 'm' },
    20601525        { "quiet", no_argument, 0, 'q' },
    2061         { "gps", required_argument, 0, 'g' },
    20621526        { "port", required_argument, 0, 'p' },
    20631527        { "allowed-hosts", required_argument, 0, 'a' },
    20641528        { "bind-address", required_argument, 0, 'b'},
     
    21401604                Usage(argv[0]);
    21411605            }
    21421606            break;
    2143         case 'g':
    2144             // GPS
    2145             if (strcmp(optarg, "off") == 0) {
    2146                 gps_enable = 0;
    2147             }
    2148             else if (sscanf(optarg, "%1023[^:]:%d", gpshost, &gpsport) < 2) {
    2149                 fprintf(stderr, "Invalid GPS host '%s' (host:port or off required)\n",
    2150                        optarg);
    2151                 gps_enable = 1;
    2152                 Usage(argv[0]);
    2153             }
    2154             break;
    21551607        case 'p':
    21561608            // Port
    21571609            if (sscanf(optarg, "%d", &tcpport) != 1) {
     
    21731625            break;
    21741626        case 'q':
    21751627            // Quiet
    2176             sound = 0;
    21771628            break;
    21781629        case 'v':
    21791630            // version
     
    23311782    // And we're done
    23321783    fclose(pid_file);
    23331784           
    2334 
    2335     // Set up the GPS object to give to the children
    2336     if (gpsport == -1 && gps_enable) {
    2337         if (conf->FetchOpt("gps") == "true") {
    2338             if (sscanf(conf->FetchOpt("gpshost").c_str(), "%1023[^:]:%d", gpshost,
    2339                        &gpsport) != 2) {
    2340                 fprintf(stderr, "Invalid GPS host in config (host:port required)\n");
    2341                 exit(1);
    2342             }
    2343 
    2344             gps_enable = 1;
    2345         } else {
    2346             gps_enable = 0;
    2347             gps_log = 0;
    2348         }
    2349     }
    2350 
    2351     if (gps_enable == 1) {
    2352         gps = new GPSD(gpshost, gpsport);
    2353 
    2354         // Lock GPS position
    2355         if (conf->FetchOpt("gpsmodelock") == "true") {
    2356             fprintf(stderr, "Enabling GPS position lock override (broken GPS unit "
    2357                     "reports 0 always)\n");
    2358             gps->SetOptions(GPSD_OPT_FORCEMODE);
    2359         }
    2360 
    2361     } else {
    2362         gps_log = 0;
    2363     }
    2364 
    2365     // Register the gps and timetracker with the sourcetracker
    2366     sourcetracker.AddGpstracker(gps);
    23671785    sourcetracker.AddTimetracker(&timetracker);
    23681786
    23691787    // Handle errors here maybe in the future
     
    25301948        fprintf(stderr, "Dump file format: %s\n", dumpfile->FetchType());
    25311949    }
    25321950
    2533     if (gps_enable && gps_log == 1) {
    2534         if (gpsdump.OpenDump(gpslogfile.c_str(), xmllogfile.c_str()) < 0) {
    2535             fprintf(stderr, "FATAL: GPS dump error: %s\n", gpsdump.FetchError());
    2536             ErrorShutdown();
    2537         }
    2538     }
    2539 
    25401951    // Open our files first to make sure we can, we'll unlink the empties later.
    25411952    FILE *testfile = NULL;
    25421953    if (net_log) {
     
    26082019    */
    26092020
    26102021    if (data_log || net_log || crypt_log) {
    2611         snprintf(status, STATUS_MAX, "Logging%s%s%s%s%s%s%s",
     2022        snprintf(status, STATUS_MAX, "Logging%s%s%s%s%s%s",
    26122023                 data_log ? " data" : "" ,
    26132024                 net_log ? " networks" : "" ,
    26142025                 csv_log ? " CSV" : "" ,
    26152026                 xml_log ? " XML" : "" ,
    26162027                 crypt_log ? " weak" : "",
    2617                  cisco_log ? " cisco" : "",
    2618                  gps_log == 1 ? " gps" : "");
     2028                 cisco_log ? " cisco" : "");
    26192029        fprintf(stderr, "%s\n", status);
    26202030    } else if (no_log) {
    26212031        snprintf(status, STATUS_MAX, "Not logging any data.");
     
    26332043        }
    26342044    }
    26352045
    2636     if (gps_enable) {
    2637         // Open the GPS
    2638         if (gps->OpenGPSD() < 0) {
    2639             fprintf(stderr, "%s\n", gps->FetchError());
    2640 
    2641             gps_enable = 0;
    2642             gps_log = 0;
    2643         } else {
    2644             fprintf(stderr, "Opened GPS connection to %s port %d\n",
    2645                     gpshost, gpsport);
    2646 
    2647             gpsmode = gps->FetchMode();
    2648 
    2649             last_gpsd_reconnect = time(0);
    2650         }
    2651     }
    2652 
    26532046    fprintf(stderr, "Listening on port %d.\n", tcpport);
    26542047    for (unsigned int ipvi = 0; ipvi < legal_ipblock_vec.size(); ipvi++) {
    26552048        char *netaddr = strdup(inet_ntoa(legal_ipblock_vec[ipvi]->network));
     
    26902083                                             &Protocol_NETWORK, &ProtocolNetworkEnable);
    26912084    client_ref = ui_server.RegisterProtocol("CLIENT", 0, CLIENT_fields_text,
    26922085                                            &Protocol_CLIENT, &ProtocolClientEnable);
    2693     gps_ref = ui_server.RegisterProtocol("GPS", 0, GPS_fields_text,
    2694                                          &Protocol_GPS, NULL);
    26952086    info_ref = ui_server.RegisterProtocol("INFO", 0, INFO_fields_text,
    26962087                                          &Protocol_INFO, NULL);
    26972088    remove_ref = ui_server.RegisterProtocol("REMOVE", 0, REMOVE_fields_text,
     
    27462137    // Write network info and tick the tracker once per second
    27472138    timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &NetWriteEvent, NULL);
    27482139    timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &TrackerTickEvent, NULL);
    2749     // Update GPS coordinates and handle signal loss if defined
    2750     timetracker.RegisterTimer(SERVER_TIMESLICES_SEC, NULL, 1, &GpsEvent, NULL);
    27512140    // Sync the data files if requested
    27522141    if (datainterval > 0 && no_log == 0)
    27532142        timetracker.RegisterTimer(datainterval * SERVER_TIMESLICES_SEC, NULL, 1, &ExportSyncEvent, NULL);
    2754     // Write waypoints if requested
    2755     if (waypoint)
    2756         timetracker.RegisterTimer(decay * SERVER_TIMESLICES_SEC, NULL, 1, &WaypointSyncEvent, NULL);
    27572143    // Channel hop if requested
    27582144    if (channel_hop) {
    27592145        if (channel_dwell)
     
    27772163    snprintf(status, 1024, "%s", TIMESTAMP);
    27782164    kdata.timestamp = status;
    27792165
    2780     time_t last_click = 0;
    27812166    int num_networks = 0, num_packets = 0, num_noise = 0, num_dropped = 0;
    27822167
    27832168
     
    29262311
    29272312                    }
    29282313
    2929                     if (gps_log == 1 && info.type != packet_noise &&
    2930                         info.type != packet_unknown && info.type != packet_phy &&
    2931                         info.corrupt == 0) {
    2932                         if (gpsdump.DumpPacket(&info) < 0) {
    2933                             snprintf(status, STATUS_MAX, "%s", gpsdump.FetchError());
    2934                             if (!silent || NetWriteStatus(status) == 0)
    2935                                 fprintf(stderr, "%s\n", status);
    2936                         }
    2937                     }
    2938 
    29392314                    // tracker.ProcessPacket(info);
    29402315                    tracker.ProcessPacket(&packet, &info, &bssid_wep_map,
    29412316                                                                                  wep_identity);
    29422317
    2943                     if (tracker.FetchNumNetworks() > num_networks) {
    2944                         if (sound == 1)
    2945                             if (info.crypt_set &&
    2946                                                                 wav_map.find("new_wep") != wav_map.end())
    2947                                 sound = PlaySound("new_wep");
    2948                             else
    2949                                 sound = PlaySound("new");
    2950                         if (speech == 1) {
    2951                             string text;
    2952 
    2953                             if (info.crypt_set)
    2954                                 text = ExpandSpeechString(speech_sentence_encrypted, &info,
    2955                                                           speech_encoding);
    2956                             else
    2957                                 text = ExpandSpeechString(speech_sentence_unencrypted,
    2958                                                           &info, speech_encoding);
    2959 
    2960                             speech = SayText(MungeToShell(text).c_str());
    2961                         }
    2962                     }
    29632318                    num_networks = tracker.FetchNumNetworks();
    29642319
    29652320                    if (tracker.FetchNumPackets() != num_packets) {
    2966                         if (cur_time - last_click >= decay && sound == 1) {
    2967                             if (tracker.FetchNumPackets() - num_packets >
    2968                                 tracker.FetchNumDropped() + localdropnum - num_dropped) {
    2969                                 sound = PlaySound("traffic");
    2970                             } else {
    2971                                 sound = PlaySound("junktraffic");
    2972                             }
    2973 
    2974                             last_click = cur_time;
    2975                         }
    2976 
    29772321                        num_packets = tracker.FetchNumPackets();
    29782322                        num_noise = tracker.FetchNumNoise();
    29792323                        num_dropped = tracker.FetchNumDropped() + localdropnum;
  • kismet_server.h

    diff -urN kismet.dev/kismet_server.h kismet.dev2/kismet_server.h
    old new  
    3333void handle_command(TcpServer *tcps, client_command *cc);
    3434int NetWriteStatus(const char *in_status);
    3535void NetWriteInfo();
    36 int SayText(string in_text);
    37 int PlaySound(string in_sound);
    38 void SpeechHandler(int *fds, const char *player);
    39 void SoundHandler(int *fds, const char *player, map<string, string> soundmap);
    4036void ProtocolAlertEnable(int in_fd);
    4137void ProtocolNetworkEnable(int in_fd);
    4238void ProtocolClientEnable(int in_fd);
  • kis_packsources.cc

    diff -urN kismet.dev/kis_packsources.cc kismet.dev2/kis_packsources.cc
    old new  
    6464                                        pcapsource_11g_registrant,
    6565                                        monitor_wext, unmonitor_wext,
    6666                                        chancontrol_wext, 1);
    67     sourcetracker->RegisterPacketsource("cisco", 1, "IEEE80211b", 6,
    68                                        pcapsource_wext_registrant,
    69                                        monitor_cisco, unmonitor_cisco,
    70                                        chancontrol_wext, 1);
    71     sourcetracker->RegisterPacketsource("cisco_wifix", 1, "IEEE80211b", 6,
    72                                        pcapsource_ciscowifix_registrant,
    73                                        monitor_cisco_wifix, NULL, NULL, 1);
     67    REG_EMPTY_CARD(sourcetracker, "cisco");
     68    REG_EMPTY_CARD(sourcetracker, "cisco_wifix");
    7469    sourcetracker->RegisterPacketsource("hostap", 1, "IEEE80211b", 6,
    7570                                       pcapsource_wext_registrant,
    7671                                       monitor_hostap, unmonitor_hostap,
     
    8378                                        pcapsource_wext_registrant,
    8479                                        monitor_orinoco, unmonitor_orinoco,
    8580                                        chancontrol_orinoco, 1);
    86     sourcetracker->RegisterPacketsource("acx100", 1, "IEEE80211b", 6,
    87                                        pcapsource_wext_registrant,
    88                                        monitor_acx100, unmonitor_acx100,
    89                                        chancontrol_wext, 1);
    90     sourcetracker->RegisterPacketsource("admtek", 1, "IEEE80211b", 6,
    91                                         pcapsource_wext_registrant,
    92                                         monitor_admtek, unmonitor_admtek,
    93                                         chancontrol_wext, 1);
    94     sourcetracker->RegisterPacketsource("vtar5k", 1, "IEEE80211a", 36,
    95                                        pcapsource_wext_registrant,
    96                                        monitor_vtar5k, NULL, chancontrol_wext, 1);
    97     sourcetracker->RegisterPacketsource("atmel_usb", 1, "IEEE80211b", 6,
    98                                        pcapsource_wext_registrant,
    99                                        monitor_wext, unmonitor_wext,
    100                                        chancontrol_wext, 1);
     81    REG_EMPTY_CARD(sourcetracker, "acx100");
     82    REG_EMPTY_CARD(sourcetracker, "admtek");
     83    REG_EMPTY_CARD(sourcetracker, "vtar5k");
     84    REG_EMPTY_CARD(sourcetracker, "atmel_usb");
    10185
    10286    sourcetracker->RegisterPacketsource("madwifi_a", 1, "IEEE80211a", 36,
    10387                                        pcapsource_wextfcs_registrant,
     
    146130                                        monitor_prism54g, unmonitor_prism54g,
    147131                                        chancontrol_prism54g, 1);
    148132
    149     sourcetracker->RegisterPacketsource("wlanng_wext", 1, "IEEE80211b", 6,
    150                                         pcapsource_wlanng_registrant,
    151                                         monitor_wlanng_avs, NULL,
    152                                         chancontrol_wext, 1);
    153 
    154     sourcetracker->RegisterPacketsource("ipw2100", 1, "IEEE80211b", 6,
    155                                         pcapsource_wext_registrant,
    156                                         monitor_ipw2100, unmonitor_ipw2100,
    157                                         chancontrol_ipw2100, 1);
    158 
    159     sourcetracker->RegisterPacketsource("ipw2200", 1, "IEEE80211g", 6,
    160                                         pcapsource_wext_registrant,
    161                                         monitor_ipw2200, unmonitor_ipw2200,
    162                                         chancontrol_ipw2200, 1);
    163 
    164     sourcetracker->RegisterPacketsource("ipw2915", 1, "IEEE80211ab", 6,
    165                                         pcapsource_wext_registrant,
    166                                         monitor_ipw2200, unmonitor_ipw2200,
    167                                         chancontrol_ipw2200, 1);
    168 
    169     sourcetracker->RegisterPacketsource("ipw3945", 1, "IEEE80211ab", 6,
    170                                         pcapsource_wext_registrant,
    171                                         monitor_ipw3945, unmonitor_ipw3945,
    172                                         chancontrol_ipw2200, 1);
    173 
    174     sourcetracker->RegisterPacketsource("ipwlivetap", 1, "IEEE80211b", 0,
    175                                         pcapsource_wext_registrant,
    176                                         monitor_ipwlivetap,
    177                                                                                 unmonitor_ipwlivetap,
    178                                         NULL, 1);
    179 
    180     sourcetracker->RegisterPacketsource("rt2400", 1, "IEEE80211b", 6,
    181                                         pcapsource_wext_registrant,
    182                                         monitor_wext, unmonitor_wext,
    183                                         chancontrol_wext, 1);
    184     sourcetracker->RegisterPacketsource("rt2500", 1, "IEEE80211g", 6,
    185                                         pcapsource_11g_registrant,
    186                                         monitor_wext, unmonitor_wext,
    187                                         chancontrol_wext, 1);
    188     sourcetracker->RegisterPacketsource("rt8180", 1, "IEEE80211b", 6,
    189                                         pcapsource_wext_registrant,
    190                                         monitor_wext, unmonitor_wext,
    191                                         chancontrol_wext, 1);
     133    REG_EMPTY_CARD(sourcetracker, "wlanng_wext");
     134    REG_EMPTY_CARD(sourcetracker, "ipw2100");
     135    REG_EMPTY_CARD(sourcetracker, "ipw2200");
     136    REG_EMPTY_CARD(sourcetracker, "ipw2915");
     137    REG_EMPTY_CARD(sourcetracker, "ipw3945");
     138    REG_EMPTY_CARD(sourcetracker, "ipwlivetap");
    192139
     140    REG_EMPTY_CARD(sourcetracker, "rt2400");
     141    REG_EMPTY_CARD(sourcetracker, "rt2500");
     142    REG_EMPTY_CARD(sourcetracker, "rt8180");
     143   
    193144    sourcetracker->RegisterPacketsource("zd1211", 1, "IEEE80211g", 6,
    194145                                        pcapsource_wext_registrant,
    195146                                        monitor_wext, unmonitor_wext,
     
    233184    REG_EMPTY_CARD(sourcetracker, "zd1211");
    234185#endif
    235186
    236 #if defined(HAVE_LIBPCAP) && defined(SYS_LINUX)
    237     sourcetracker->RegisterPacketsource("wlanng", 1, "IEEE80211b", 6,
    238                                        pcapsource_wlanng_registrant,
    239                                        monitor_wlanng, NULL, chancontrol_wlanng, 1);
    240     sourcetracker->RegisterPacketsource("wlanng_avs", 1, "IEEE80211b", 6,
    241                                        pcapsource_wlanng_registrant,
    242                                        monitor_wlanng_avs, NULL,
    243                                        chancontrol_wlanng_avs, 1);
    244187    sourcetracker->RegisterPacketsource("wrt54g", 1, "na", 0,
    245188                                        pcapsource_wrt54g_registrant,
    246                                                                                 monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);
    247 #else
     189                                        monitor_wrt54g, unmonitor_wrt54g, chancontrol_wext, 0);
     190
    248191    REG_EMPTY_CARD(sourcetracker, "wlanng");
    249192    REG_EMPTY_CARD(sourcetracker, "wlanng_avs");
    250     REG_EMPTY_CARD(sourcetracker, "wrt54g");
    251 #endif
    252 
    253 #if defined(SYS_LINUX) && defined(HAVE_LINUX_NETLINK)
    254     sourcetracker->RegisterPacketsource("wlanng_legacy", 1, "IEEE80211b", 6,
    255                                         prism2source_registrant,
    256                                         monitor_wlanng_legacy, NULL,
    257                                         chancontrol_wlanng_legacy, 1);
    258 #else
    259193    REG_EMPTY_CARD(sourcetracker, "wlanng_legacy");
    260 #endif
    261194
    262195#if defined(HAVE_LIBPCAP) && defined(SYS_OPENBSD)
    263196    sourcetracker->RegisterPacketsource("cisco_openbsd", 1, "IEEE80211b", 6,
     
    291224    REG_EMPTY_CARD(sourcetracker, "radiotap_bsd_b");
    292225#endif
    293226
    294 #if defined(HAVE_LIBWIRETAP)
    295     sourcetracker->RegisterPacketsource("wtapfile", 0, "na", 0,
    296                                        wtapfilesource_registrant,
    297                                        NULL, NULL, NULL, 0);
    298 #else
    299227    REG_EMPTY_CARD(sourcetracker, "wtapfile");
    300 #endif
    301228
    302 #if defined(HAVE_WSP100)
    303     sourcetracker->RegisterPacketsource("wsp100", 0, "IEEE80211b", 6,
    304                                         wsp100source_registrant,
    305                                         monitor_wsp100, NULL, chancontrol_wsp100, 0);
    306 #else
    307229    REG_EMPTY_CARD(sourcetracker, "wsp100");
    308 #endif
    309230
    310 #if defined(HAVE_VIHAHEADERS)
    311     sourcetracker->RegisterPacketsource("viha", 1, "IEEE80211b", 6,
    312                                         vihasource_registrant,
    313                                         NULL, NULL, chancontrol_viha, 0);
    314 #else
    315231    REG_EMPTY_CARD(sourcetracker, "viha");
    316 #endif
    317232
    318233    return 1;
    319234}
  • kis_packsources.h

    diff -urN kismet.dev/kis_packsources.h kismet.dev2/kis_packsources.h
    old new  
    2222#include "config.h"
    2323
    2424#include "packetsource.h"
    25 #include "prism2source.h"
    2625#include "pcapsource.h"
    27 #include "wtapfilesource.h"
    28 #include "wsp100source.h"
    29 #include "vihasource.h"
    3026#include "dronesource.h"
    3127#include "packetsourcetracker.h"
    3228
  • Makefile.in

    diff -urN kismet.dev/Makefile.in kismet.dev2/Makefile.in
    old new  
    3939DEPEND  = .depend
    4040
    4141# Objects
    42 PSO     = util.o ringbuf.o configfile.o speech.o ifcontrol.o iwcontrol.o packet.o \
    43                 pcapsource.o prism2source.o wtapfilesource.o wsp100source.o \
    44                 dronesource.o vihasource.o packetsourcetracker.o kis_packsources.o \
    45                 wtapdump.o wtaplocaldump.o gpsdump.o airsnortdump.o fifodump.o \
    46                 gpsd.o manuf.o \
     42PSO     = util.o ringbuf.o configfile.o ifcontrol.o iwcontrol.o packet.o \
     43                pcapsource.o manuf.o \
     44                dronesource.o packetsourcetracker.o kis_packsources.o \
     45                wtapdump.o wtaplocaldump.o airsnortdump.o fifodump.o \
    4746                packetracker.o timetracker.o alertracker.o finitestate.o \
    4847                getopt.o \
    4948                tcpserver.o server_protocols.o server_globals.o kismet_server.o
    5049PS      = kismet_server
    5150
    5251DRONEO = util.o ringbuf.o configfile.o getopt.o ifcontrol.o iwcontrol.o packet.o \
    53                 tcpstreamer.o prism2source.o pcapsource.o wtapfilesource.o wsp100source.o \
    54                 dronesource.o vihasource.o packetsourcetracker.o kis_packsources.o \
    55                 timetracker.o gpsd.o server_globals.o kismet_drone.o
     52                tcpstreamer.o pcapsource.o \
     53                dronesource.o packetsourcetracker.o kis_packsources.o \
     54                timetracker.o server_globals.o kismet_drone.o
    5655DRONE = kismet_drone
    5756
    58 NCO     = util.o configfile.o speech.o manuf.o tcpclient.o \
     57NCO     = util.o configfile.o manuf.o tcpclient.o \
    5958                frontend.o cursesfront.o \
    6059                panelfront.o panelfront_display.o panelfront_input.o \
    61                 gpsd.o getopt.o kismet_client.o
     60                getopt.o kismet_client.o
    6261NC      = kismet_client
    6362
    6463GPSLO = getopt.o util.o configfile.o expat.o manuf.o \
  • packetracker.cc

    diff -urN kismet.dev/packetracker.cc kismet.dev2/packetracker.cc
    old new  
    24432443
    24442444}
    24452445
    2446 // Write a gpsdrive compatable waypoint file
    2447 int Packetracker::WriteGpsdriveWaypt(FILE *in_file) {
    2448     fseek(in_file, 0L, SEEK_SET);
    2449     ftruncate(fileno(in_file), 0);
    2450 
    2451     // Convert the map to a vector and sort it
    2452     for (map<mac_addr, wireless_network *>::const_iterator i = bssid_map.begin();
    2453          i != bssid_map.end(); ++i) {
    2454         wireless_network *net = i->second;
    2455 
    2456         float lat, lon;
    2457         lat = (net->min_lat + net->max_lat) / 2;
    2458         lon = (net->min_lon + net->max_lon) / 2;
    2459         fprintf(in_file, "%s\t%f  %f\n", waypointformat == 1 ? net->ssid.c_str() : net->bssid.Mac2String().c_str(), lat, lon);
    2460     }
    2461 
    2462     fflush(in_file);
    2463 
    2464     return 1;
    2465 }
  • packetracker.h

    diff -urN kismet.dev/packetracker.h kismet.dev2/packetracker.h
    old new  
    3030#include <string>
    3131
    3232#include "util.h"
    33 #include "gpsd.h"
    3433#include "packet.h"
    3534#include "tracktypes.h"
    3635#include "manuf.h"
     
    8584    int WriteXMLNetworks(string in_fname);
    8685    int WriteCisco(string in_fname);
    8786
    88     int WriteGpsdriveWaypt(FILE *in_file);
    89 
    9087    void WriteSSIDMap(FILE *in_file);
    9188    void ReadSSIDMap(FILE *in_file);
    9289
  • packetsourcetracker.cc

    diff -urN kismet.dev/packetsourcetracker.cc kismet.dev2/packetsourcetracker.cc
    old new  
    2727Packetsourcetracker::Packetsourcetracker() {
    2828    next_packsource_id = 0;
    2929    next_meta_id = 0;
    30     gpsd = NULL;
    3130    timetracker = NULL;
    3231    chanchild_pid = 0;
    3332    sockpair[0] = sockpair[1] = 0;
     
    694693       
    695694        // Register the trackers with it
    696695        meta->capsource->AddTimetracker(timetracker);
    697         meta->capsource->AddGpstracker(gpsd);
    698696       
    699697        // Open it
    700698        fprintf(stderr, "Source %d (%s): Opening %s source interface %s...\n",
  • packetsourcetracker.h

    diff -urN kismet.dev/packetsourcetracker.h kismet.dev2/packetsourcetracker.h
    old new  
    3030#include <string>
    3131
    3232#include "timetracker.h"
    33 #include "gpsd.h"
    3433#include "packetsource.h"
    3534
    3635// Sentinel for starting a new packet
     
    144143    // Register a timer event handler for us to use
    145144    void AddTimetracker(Timetracker *in_tracker) { timetracker = in_tracker; }
    146145
    147     // Register the GPS server for us to use
    148     void AddGpstracker(GPSD *in_gpsd) { gpsd = in_gpsd; }
    149    
    150146    // Register a packet prototype source...  Card type string, root binding requirement,
    151147    // function to generate an instance of the source, and function to change channel
    152148    // for this card type.  This fills out the prototype. Sources that don't hop
     
    221217        uint16_t channel;
    222218    } chanchild_changepacket;
    223219
    224     GPSD *gpsd;
    225220    Timetracker *timetracker;
    226221   
    227222    char errstr[1024];
  • panelfront.cc

    diff -urN kismet.dev/panelfront.cc kismet.dev2/panelfront.cc
    old new  
    3737    "  Key  Action",
    3838    "   e   List Kismet servers",
    3939    "   z   Toggle fullscreen zoom of network view",
    40     "   m   Toggle muting of sound and speech",
    4140    "   t   Tag (or untag) selected network",
    4241    "   g   Group tagged networks",
    4342    "   u   Ungroup current group",
     
    121120    "Key Action",
    122121    " e  List Kismet servers",
    123122    " z  Toggle fullscreen net list",
    124     " m  Toggle muting",
    125123    " t  Tag (or untag) selected",
    126124    " g  Group tagged networks",
    127125    " u  Ungroup current group",
     
    237235};
    238236
    239237
    240 char *KismetHelpGps[] = {
    241     "KISMET NETWORK FOLLOW",
    242     "This panel estimates the center of a network, the current",
    243     "direction of travel, and the direction of the network center",
    244     "and distance relative to the current direction of movement.",
    245     " Key   Action",
    246     "  s    Follow location of strongest packet",
    247     "  c    Follow location of estimated network center",
    248     "  q    Close popup",
    249     NULL
    250 };
    251 
    252 
    253238char *KismetHelpStats[] = {
    254239    "KISMET NETWORK STATISTICS",
    255240    "This panel displays overall statistics about the wireless",
     
    678663    }
    679664
    680665    // Enable all the protocols we handle
    681     in_client->EnableProtocol("GPS");
    682666    in_client->EnableProtocol("INFO");
    683667    in_client->EnableProtocol("REMOVE");
    684668    in_client->EnableProtocol("NETWORK");
     
    12821266        if (con->client == NULL)
    12831267            continue;
    12841268
    1285         // Update GPS
    1286         float newlat, newlon, newalt, newspd, newheading;
    1287         int newfix;
    1288         con->client->FetchLoc(&newlat, &newlon, &newalt, &newspd, &newheading, &newfix);
    1289 
    1290         if (GPSD::EarthDistance(newlat, newlon, last_lat, last_lon) > 10) {
    1291             con->last_lat = con->lat;
    1292             con->last_lon = con->lon;
    1293             con->last_spd = con->spd;
    1294             con->last_alt = con->alt;
    1295             con->last_fix = con->fix;
    1296             con->last_heading = con->heading;
    1297         }
    1298 
    1299         con->lat = newlat;
    1300         con->lon = newlon;
    1301         con->alt = newalt;
    1302         con->spd = newspd;
    1303         con->heading = newheading;
    1304         con->fix = newfix;
    1305 
    13061269        // Update quality
    13071270        con->quality = con->client->FetchQuality();
    13081271        con->power = con->client->FetchPower();
  • panelfront_display.cc

    diff -urN kismet.dev/panelfront_display.cc kismet.dev2/panelfront_display.cc
    old new  
    727727        mvwaddstr(netwin, netwin->_maxy, netwin->_maxx - 14, ptxt);
    728728    }
    729729
    730 #ifdef HAVE_GPS
     730#if 0
    731731
    732732
    733733    if (!(lat == 0 && lon == 0 && alt == 0 && spd == 0 && fix == 0)) {
     
    14961496        snprintf(output, print_width, "Networks: %d", (int) details_network->networks.size());
    14971497        kwin->text.push_back(output);
    14981498
    1499         if (details_network->virtnet->gps_fixed != -1) {
    1500             if ((details_network->virtnet->min_lat == 90) && (details_network->virtnet->min_lon == 180) &&
    1501                 (details_network->virtnet->max_lat == -90) && (details_network->virtnet->max_lon == -180)) {
    1502                    snprintf(output, print_width, "Min Loc : N/A");
    1503                    kwin->text.push_back(output);
    1504                    snprintf(output, print_width, "Max Loc : N/A");
    1505                    kwin->text.push_back(output);
    1506                    snprintf(output, print_width, "Range   : N/A");
    1507                    kwin->text.push_back(output);
    1508             }
    1509             else {
    1510                 snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",
    1511                          details_network->virtnet->min_lat, details_network->virtnet->min_lon,
    1512                          metric ? details_network->virtnet->min_alt / 3.3 : details_network->virtnet->min_alt,
    1513                          metric ? details_network->virtnet->min_spd * 1.6093 : details_network->virtnet->min_spd);
    1514                 kwin->text.push_back(output);
    1515                 snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",
    1516                          details_network->virtnet->max_lat, details_network->virtnet->max_lon,
    1517                          metric ? details_network->virtnet->max_alt / 3.3 : details_network->virtnet->max_alt,
    1518                          metric ? details_network->virtnet->max_spd * 1.6093 : details_network->virtnet->max_spd);
    1519                 kwin->text.push_back(output);
    1520 
    1521                 double diagdist = GPSD::EarthDistance(details_network->virtnet->min_lat,
    1522                                                       details_network->virtnet->min_lon,
    1523                                                       details_network->virtnet->max_lat,
    1524                                                       details_network->virtnet->max_lon);
    1525 
    1526                 if (finite(diagdist)) {
    1527                     if (metric) {
    1528                         if (diagdist < 1000)
    1529                             snprintf(output, print_width, "Range    : %.3f meters", diagdist);
    1530                         else
    1531                             snprintf(output, print_width, "Range   : %.3f kilometers", diagdist / 1000);
    1532                     } else {
    1533                         diagdist *= 3.3;
    1534                         if (diagdist < 5280)
    1535                             snprintf(output, print_width, "Range   : %.3f feet", diagdist);
    1536                         else
    1537                             snprintf(output, print_width, "Range   : %.3f miles", diagdist / 5280);
    1538                     }
    1539                     kwin->text.push_back(output);
    1540                 }
    1541             }
    1542         }
    1543 
    15441499        if (details_network->virtnet->carrier_set & (1 << (int) carrier_80211b)) {
    15451500            snprintf(output, print_width, "Carrier : IEEE 802.11b");
    15461501            kwin->text.push_back(output);
     
    18531808                     dnet->ipdata.range_ip[2], dnet->ipdata.range_ip[3]);
    18541809            kwin->text.push_back(output);
    18551810        }
    1856    
    1857         if (dnet->gps_fixed != -1) {
    1858             if ((dnet->min_lat == 90) && (dnet->min_lon == 180) &&
    1859                 (dnet->max_lat == -90) && (dnet->max_lon == -180)) {
    1860                    snprintf(output, print_width, "Min Loc : N/A");
    1861                    kwin->text.push_back(output);
    1862                    snprintf(output, print_width, "Max Loc : N/A");
    1863                    kwin->text.push_back(output);
    1864                    snprintf(output, print_width, "Range   : N/A");
    1865                    kwin->text.push_back(output);
    1866             }
    1867             else {
    1868                 snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",
    1869                          dnet->min_lat, dnet->min_lon,
    1870                          metric ? dnet->min_alt / 3.3 : dnet->min_alt,
    1871                          metric ? dnet->min_spd * 1.6093 : dnet->min_spd);
    1872                 kwin->text.push_back(output);
    1873                 snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",
    1874                          dnet->max_lat, dnet->max_lon,
    1875                          metric ? dnet->max_alt / 3.3 : dnet->max_alt,
    1876                          metric ? dnet->max_spd * 1.6093 : dnet->max_spd);
    1877                 kwin->text.push_back(output);
    1878 
    1879                 double diagdist = GPSD::EarthDistance(dnet->min_lat, dnet->min_lon,
    1880                                                   dnet->max_lat, dnet->max_lon);
    1881 
    1882                 if (finite(diagdist)) {
    1883                     if (metric) {
    1884                         if (diagdist < 1000)
    1885                             snprintf(output, print_width, "Range    : %f meters", diagdist);
    1886                         else
    1887                             snprintf(output, print_width, "Range   : %f kilometers", diagdist / 1000);
    1888                     } else {
    1889                         diagdist *= 3.3;
    1890                         if (diagdist < 5280)
    1891                             snprintf(output, print_width, "Range   : %f feet", diagdist);
    1892                         else
    1893                             snprintf(output, print_width, "Range   : %f miles", diagdist / 5280);
    1894                     }
    1895                     kwin->text.push_back(output);
    1896                 }
    1897             }
    1898         }
    18991811    }
    19001812
    19011813    // Now we just use the text printer to handle the rest for us
     
    19031815    return TextPrinter(in_window);
    19041816}
    19051817
    1906 int PanelFront::GpsPrinter(void *in_window) {
    1907     kis_window *kwin = (kis_window *) in_window;
    1908 
    1909     char output[1024];
    1910     kwin->text.clear();
    1911 
    1912         if (details_network == NULL) {
    1913                 kwin->text.push_back("The network or group being displayed");
    1914                 kwin->text.push_back("has been deleted.  Please select a ");
    1915                 kwin->text.push_back("different network.");
    1916                 return TextPrinter(in_window);
    1917         }
    1918 
    1919     wireless_network *dnet = details_network->virtnet;
    1920 
    1921     int print_width = kwin->print_width;
    1922     if (print_width > 1024)
    1923         print_width = 1023;
    1924 
    1925     if (print_width < 32) {
    1926         kwin->text.push_back("Display not wide enough");
    1927         return TextPrinter(in_window);
    1928     }
    1929 
    1930     if (dnet->aggregate_points == 0) {
    1931         kwin->text.push_back("No GPS data.");
    1932         return TextPrinter(in_window);
    1933     }
    1934 
    1935     float center_lat, center_lon;
    1936 
    1937     // We hijack the "selected" field as a toggle
    1938     if (kwin->selected == 1) {
    1939         center_lat = dnet->best_lat;
    1940         center_lon = dnet->best_lon;
    1941     } else {
    1942         center_lat = dnet->aggregate_lat / dnet->aggregate_points;
    1943         center_lon = dnet->aggregate_lon / dnet->aggregate_points;
    1944     }
    1945 
    1946     // Get bearing to the center
    1947     float center_angle = GPSD::CalcHeading(center_lat, center_lon, lat, lon);
    1948 
    1949     float difference_angle = heading - center_angle;
    1950     if (difference_angle < 0)
    1951         difference_angle += 360;
    1952 
    1953     double diagdist = GPSD::EarthDistance(lat, lon, center_lat, center_lon);
    1954 
    1955     // Now we know everything - where we are, where we are headed, where we SHOULD be headed
    1956     // to get to the supposed center of the network, how far it is, and the orientation on our
    1957     // compass to get to it.  Time to start drawing our output.
    1958 
    1959     char compass[5][10];
    1960     memset(compass, 0, sizeof(char) * 5 * 10);
    1961 
    1962     // |  41.12345x-74.12345     .-|-/    |
    1963     // | Bearing:               /  |/ \   |
    1964     // |  123.23 degrees       |   O   |  |
    1965     // |                        \   \ /   |
    1966     // | Estimated center:       '---\    |
    1967 
    1968 
    1969     // Find the orientation on our compass:
    1970     if (difference_angle > 330 || difference_angle <= 22) {
    1971         snprintf(compass[0], 10, "  .-|-.  ");
    1972         snprintf(compass[1], 10, " /  |  \\ ");
    1973         snprintf(compass[2], 10, "|   O   |");
    1974         snprintf(compass[3], 10, " \\     / ");
    1975         snprintf(compass[4], 10, "  '---'  ");
    1976     } else if (difference_angle > 22 && difference_angle <= 66) {
    1977         snprintf(compass[0], 10, "  .---/  ");
    1978         snprintf(compass[1], 10, " /   / \\ ");
    1979         snprintf(compass[2], 10, "|   O   |");
    1980         snprintf(compass[3], 10, " \\     / ");
    1981         snprintf(compass[4], 10, "  '---'  ");
    1982     } else if (difference_angle > 66 && difference_angle <= 110) {
    1983         snprintf(compass[0], 10, "  .---.  ");
    1984         snprintf(compass[1], 10, " /     \\ ");
    1985         snprintf(compass[2], 10, "|   O----");
    1986         snprintf(compass[3], 10, " \\     / ");
    1987         snprintf(compass[4], 10, "  '---'  ");
    1988     } else if (difference_angle > 110 && difference_angle <= 154) {
    1989         snprintf(compass[0], 10, "  .---.  ");
    1990         snprintf(compass[1], 10, " /     \\ ");
    1991         snprintf(compass[2], 10, "|   O   |");
    1992         snprintf(compass[3], 10, " \\   \\ / ");
    1993         snprintf(compass[4], 10, "  '---\\  ");
    1994     } else if (difference_angle > 154 && difference_angle <= 198) {
    1995         snprintf(compass[0], 10, "  .---.  ");
    1996         snprintf(compass[1], 10, " /     \\ ");
    1997         snprintf(compass[2], 10, "|   O   |");
    1998         snprintf(compass[3], 10, " \\  |  / ");
    1999         snprintf(compass[4], 10, "  '-|-'  ");
    2000     } else if (difference_angle > 198 && difference_angle <= 242) {
    2001         snprintf(compass[0], 10, "  .---.  ");
    2002         snprintf(compass[1], 10, " /     \\ ");
    2003         snprintf(compass[2], 10, "|   O   |");
    2004         snprintf(compass[3], 10, " \\ /   / ");
    2005         snprintf(compass[4], 10, "  /---'  ");
    2006     } else if (difference_angle > 242 && difference_angle <= 286) {
    2007         snprintf(compass[0], 10, "  .---.  ");
    2008         snprintf(compass[1], 10, " /     \\ ");
    2009         snprintf(compass[2], 10, "----O   |");
    2010         snprintf(compass[3], 10, " \\     / ");
    2011         snprintf(compass[4], 10, "  '---'  ");
    2012     } else if (difference_angle > 286 && difference_angle <= 330) {
    2013         snprintf(compass[0], 10, "  \\---.  ");
    2014         snprintf(compass[1], 10, " / \\   \\ ");
    2015         snprintf(compass[2], 10, "|   O   |");
    2016         snprintf(compass[3], 10, " \\     / ");
    2017         snprintf(compass[4], 10, "  '---'  ");
    2018     } else {
    2019         snprintf(compass[0], 10, "%f\n", difference_angle);
    2020     }
    2021 
    2022 
    2023     // - Network GPS ---------------------|
    2024     // | Current:                         |
    2025     // |  41.12345x-74.12345     .-|-.    |
    2026     // | Bearing:               /  |  \   |
    2027     // |  123.23 degrees       |   O   |  |
    2028     // |                        \   \ /   |
    2029     // | Estimated center:       '---\    |
    2030     // | -73.12345x43.12345               |
    2031     // |                        120 feet  |
    2032     // ------------------------------------
    2033     char textfrag[23];
    2034 
    2035     snprintf(output, print_width, "Current:");
    2036     kwin->text.push_back(output);
    2037 
    2038     snprintf(textfrag, 23, "%.3f x %.3f", lat, lon);
    2039     snprintf(output, print_width, "%-22s%s", textfrag, compass[0]);
    2040     kwin->text.push_back(output);
    2041 
    2042     snprintf(textfrag, 23, " Bearing:");
    2043     snprintf(output, print_width, "%-22s%s", textfrag, compass[1]);
    2044     kwin->text.push_back(output);
    2045 
    2046     snprintf(textfrag, 23, " %.2f*", heading);
    2047     snprintf(output, print_width, "%-22s%s", textfrag, compass[2]);
    2048     kwin->text.push_back(output);
    2049 
    2050     snprintf(textfrag, 23, " ");
    2051     snprintf(output, print_width, "%-22s%s", textfrag, compass[3]);
    2052     kwin->text.push_back(output);
    2053 
    2054     if (kwin->selected == 1)
    2055         snprintf(textfrag, 23, "Strongest signal:");
    2056     else
    2057         snprintf(textfrag, 23, "Estimated Center:");
    2058     snprintf(output, print_width, "%-22s%s", textfrag, compass[4]);
    2059     kwin->text.push_back(output);
    2060 
    2061     snprintf(textfrag, 23, "%.3f x %.3f", center_lat, center_lon);
    2062     snprintf(output, print_width, "%-22s%.2f*", textfrag, difference_angle);
    2063     kwin->text.push_back(output);
    2064 
    2065     if (metric) {
    2066         if (diagdist < 1000)
    2067             snprintf(textfrag, 23, "%.2f m", diagdist);
    2068         else
    2069             snprintf(textfrag, 23, "%.2f km", diagdist / 1000);
    2070     } else {
    2071         diagdist *= 3.3;
    2072         if (diagdist < 5280)
    2073             snprintf(textfrag, 23, "%.2f ft", diagdist);
    2074         else
    2075             snprintf(textfrag, 23, "%.2f mi", diagdist / 5280);
    2076     }
    2077 
    2078     snprintf(output, print_width, "%-22s%s", "", textfrag);
    2079     kwin->text.push_back(output);
    2080 
    2081     return TextPrinter(in_window);
    2082 }
    2083 
    20841818int PanelFront::PackPrinter(void *in_window) {
    20851819    kis_window *kwin = (kis_window *) in_window;
    20861820
     
    30492783             details_client->ipdata.ip[2], details_client->ipdata.ip[3]);
    30502784    kwin->text.push_back(output);
    30512785
    3052     if (details_client->gps_fixed != -1) {
    3053         kwin->text.push_back("");
    3054 
    3055         if ((details_client->min_lat == 90) && (details_client->min_lon == 180) &&
    3056             (details_client->max_lat == -90) && (details_client->max_lon == -180)) {
    3057                snprintf(output, print_width, "Min Loc : N/A");
    3058                kwin->text.push_back(output);
    3059                snprintf(output, print_width, "Max Loc : N/A");
    3060                kwin->text.push_back(output);
    3061                snprintf(output, print_width, "Range   : N/A");
    3062                kwin->text.push_back(output);
    3063         }
    3064         else {
    3065             snprintf(output, print_width, "Min Loc : Lat %f Lon %f Alt %f Spd %f",
    3066                      details_client->min_lat, details_client->min_lon,
    3067                      metric ? details_client->min_alt / 3.3 : details_client->min_alt,
    3068                      metric ? details_client->min_spd * 1.6093 : details_client->min_spd);
    3069             kwin->text.push_back(output);
    3070             snprintf(output, print_width, "Max Loc : Lat %f Lon %f Alt %f Spd %f",
    3071                      details_client->max_lat, details_client->max_lon,
    3072                      metric ? details_client->max_alt / 3.3 : details_client->max_alt,
    3073                      metric ? details_client->max_spd * 1.6093 : details_client->max_spd);
    3074             kwin->text.push_back(output);
    3075 
    3076             double diagdist = GPSD::EarthDistance(details_client->min_lat,
    3077                                                   details_client->min_lon,
    3078                                                   details_client->max_lat,
    3079                                                   details_client->max_lon);
    3080 
    3081             if (finite(diagdist)) {
    3082                 if (metric) {
    3083                     if (diagdist < 1000)
    3084                         snprintf(output, print_width, "Range    : %f meters", diagdist);
    3085                     else
    3086                         snprintf(output, print_width, "Range    : %f kilometers", diagdist / 1000);
    3087                 } else {
    3088                     diagdist *= 3.3;
    3089                     if (diagdist < 5280)
    3090                         snprintf(output, print_width, "Range   : %f feet", diagdist);
    3091                     else
    3092                         snprintf(output, print_width, "Range   : %f miles", diagdist / 5280);
    3093                 }
    3094                 kwin->text.push_back(output);
    3095             }
    3096         }
    3097         kwin->text.push_back("");
    3098     }
    30992786
    31002787    snprintf(output, print_width, "Packets :");
    31012788    kwin->text.push_back(output);
  • panelfront.h

    diff -urN kismet.dev/panelfront.h kismet.dev2/panelfront.h
    old new  
    6565#define SORT_SIZE 10
    6666extern char *KismetHelpPower[];
    6767extern char *KismetHelpRate[];
    68 extern char *KismetHelpGps[];
    6968extern char *KismetHelpStats[];
    7069extern char *KismetHelpDump[];
    7170extern char *KismetHelpPack[];
     
    269268    int RatePrinter(void *in_window);
    270269    int StatsPrinter(void *in_window);
    271270    int PackPrinter(void *in_window);
    272     int GpsPrinter(void *in_window);
    273271    int AlertPrinter(void *in_window);
    274272
    275273    int MainClientPrinter(void *in_window);
     
    298296    int PackInput(void *in_window, int in_chr);
    299297    // Help has a generic handler
    300298    int TextInput(void *in_window, int in_chr);
    301     int GpsInput(void *in_window, int in_chr);
    302299    int AlertInput(void *in_window, int in_chr);
    303300
    304301    int MainClientInput(void *in_window, int in_chr);
  • panelfront_input.cc

    diff -urN kismet.dev/panelfront_input.cc kismet.dev2/panelfront_input.cc
    old new  
    300300        break;
    301301    case 'f':
    302302    case 'F':
    303         if (sortby != sort_auto && last_displayed.size() > 0) {
    304             details_network = last_displayed[kwin->selected];
    305             SpawnWindow("Network Location", &PanelFront::GpsPrinter, &PanelFront::GpsInput, 8, 34);
    306         } else {
    307             WriteStatus("Cannot view network GPS info in autofit sort mode.  Sort by a different method.");
    308         }
    309303        break;
    310304    case 'm':
    311305    case 'M':
    312         MuteToggle();
    313306        break;
    314307    case 'e':
    315308    case 'E':
     
    447440    switch(in_chr) {
    448441    case 'm':
    449442    case 'M':
    450         MuteToggle();
    451443        break;
    452444    case 'p':
    453445    case 'P':
     
    546538    return 1;
    547539}
    548540
    549 int PanelFront::GpsInput(void *in_window, int in_chr) {
    550     kis_window *kwin = (kis_window *) in_window;
    551 
    552     switch (in_chr) {
    553     case 's':
    554     case 'S':
    555         kwin->selected = 1;
    556         break;
    557     case 'c':
    558     case 'C':
    559         kwin->selected = 0;
    560         break;
    561     case 'h':
    562     case 'H':
    563         SpawnHelp(KismetHelpGps);
    564         break;
    565     case 'x':
    566     case 'X':
    567     case 'q':
    568     case 'Q':
    569         return 0;
    570         break;
    571     }
    572 
    573     return 1;
    574 }
    575 
    576541int PanelFront::RateInput(void *in_window, int in_chr) {
    577542    switch (in_chr) {
    578543    case 'h':
     
    645610    return 1;
    646611}
    647612
    648 void PanelFront::MuteToggle() {
    649     if (muted) {
    650         speech = old_speech;
    651         sound = old_sound;
    652         muted = 0;
    653         WriteStatus("Restoring sound");
    654     } else if (sound != 0 || speech != 0) {
    655         old_speech = speech;
    656         old_sound = sound;
    657         sound = 0;
    658         speech = 0;
    659         muted = 1;
    660         WriteStatus("Muting sound");
    661     } else if (sound == 0 && speech == 0) {
    662         WriteStatus("Sound not enabled.");
    663     }
    664 }
    665 
    666613int PanelFront::AlertInput(void *in_window, int in_chr) {
    667614    kis_window *kwin = (kis_window *) in_window;
    668615
  • pcapsource.cc

    diff -urN kismet.dev/pcapsource.cc kismet.dev2/pcapsource.cc
    old new  
    343343    packet->moddata = moddata;
    344344    packet->modified = 0;
    345345
    346     if (gpsd != NULL) {
    347         gpsd->FetchLoc(&packet->gps_lat, &packet->gps_lon, &packet->gps_alt,
    348                        &packet->gps_spd, &packet->gps_heading, &packet->gps_fix);
    349     }
    350 
    351346    if (datalink_type == DLT_PRISM_HEADER) {
    352347        ret = Prism2KisPack(packet, data, moddata);
    353348    } else if (datalink_type == KDLT_BSD802_11) {
     
    11571152
    11581153// Monitor commands
    11591154#ifdef HAVE_LINUX_WIRELESS
    1160 // Cisco uses its own config file in /proc to control modes
    1161 int monitor_cisco(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1162     FILE *cisco_config;
    1163     char cisco_path[128];
    1164 
    1165     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    1166     (*in_if) = ifparm;
    1167 
    1168     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    1169         return -1;
    1170     }
    1171 
    1172     if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)
    1173         return -1;
    1174 
    1175     if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    1176         return -1;
    1177 
    1178     if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    1179         return -1;
    1180 
    1181     if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    1182         return -1;
    1183 
    1184     // Try the iwpriv
    1185     if (Iwconfig_Set_IntPriv(in_dev, "setRFMonitor", 1, 0, in_err) >= 0) {
    1186         return 0;
    1187     }
    1188 
    1189     // Zero the ssid - nonfatal
    1190     Iwconfig_Set_SSID(in_dev, in_err, NULL);
    1191    
    1192     // Build the proc control path
    1193     snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", in_dev);
    1194 
    1195     if ((cisco_config = fopen(cisco_path, "w")) == NULL) {
    1196         snprintf(in_err, STATUS_MAX, "Unable to open cisco control file '%s' %d:%s",
    1197                  cisco_path, errno, strerror(errno));
    1198         return -1;
    1199     }
    1200 
    1201     fprintf(cisco_config, "Mode: r\n");
    1202     fprintf(cisco_config, "Mode: y\n");
    1203     fprintf(cisco_config, "XmitPower: 1\n");
    1204 
    1205     fclose(cisco_config);
    1206 
    1207     // Channel can't be set on cisco with these drivers.
    1208 
    1209     return 0;
    1210 }
    1211 
    1212 int unmonitor_cisco(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1213     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1214     int ret = -1;
    1215 
    1216     // Try the iwpriv
    1217     if (Iwconfig_Set_IntPriv(in_dev, "setRFMonitor", 0, 0, in_err) >= 0) {
    1218         // If we're the new drivers, unmonitor
    1219         if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {
    1220             return -1;
    1221         }
    1222 
    1223         // Reset the SSID since monitor mode nukes it
    1224         if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)
    1225             return -1;
    1226 
    1227         if (ifparm->channel > 0) {
    1228             if (Iwconfig_Set_Channel(in_dev, ifparm->channel, in_err) < 0)
    1229                 return -1;
    1230         }
    1231 
    1232         ret = 1;
    1233     }
    1234 
    1235     free(ifparm);
    1236 
    1237     return ret;
    1238 }
    1239 
    1240 // Cisco uses its own config file in /proc to control modes
    1241 //
    1242 // I was doing this with ioctls but that seems to cause lockups while
    1243 // this method doesn't.  I don't think I like these drivers.
    1244 int monitor_cisco_wifix(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1245     FILE *cisco_config;
    1246     char cisco_path[128];
    1247     vector<string> devbits = StrTokenize(in_dev, ":");
    1248 
    1249     if (devbits.size() < 2) {
    1250         snprintf(in_err, STATUS_MAX, "Invalid device pair '%s'.  Proper device "
    1251                                  "for cisco_wifix is eth?:wifi?.", in_dev);
    1252         return -1;
    1253     }
    1254 
    1255     // Bring the device up, zero its ip, and set promisc
    1256     if (Ifconfig_Delta_Flags(devbits[0].c_str(), in_err,
    1257                              IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    1258         return -1;
    1259     if (Ifconfig_Delta_Flags(devbits[1].c_str(), in_err,
    1260                              IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    1261         return -1;
    1262 
    1263     // Zero the ssid, nonfatally
    1264     Iwconfig_Set_SSID(devbits[0].c_str(), in_err, NULL);
    1265     Iwconfig_Set_SSID(devbits[1].c_str(), in_err, NULL);
    1266    
    1267     // Build the proc control path
    1268     snprintf(cisco_path, 128, "/proc/driver/aironet/%s/Config", devbits[0].c_str());
    1269 
    1270     if ((cisco_config = fopen(cisco_path, "w")) == NULL) {
    1271         snprintf(in_err, STATUS_MAX, "Unable to open cisco control file '%s' %d:%s",
    1272                  cisco_path, errno, strerror(errno));
    1273         return -1;
    1274     }
    1275 
    1276     fprintf(cisco_config, "Mode: r\n");
    1277     fprintf(cisco_config, "Mode: y\n");
    1278     fprintf(cisco_config, "XmitPower: 1\n");
    1279 
    1280     fclose(cisco_config);
    1281 
    1282     // Channel can't be set on cisco with these drivers.
    1283 
    1284     return 0;
    1285 }
    1286 
    12871155// Hostap uses iwpriv and iwcontrol settings to control monitor mode
    12881156int monitor_hostap(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    12891157    int ret;
     
    14331301
    14341302}
    14351303
    1436 // Acx100 uses the packhdr iwpriv control to set link state, rest is normal
    1437 int monitor_acx100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1438     int ret;
    1439 
    1440     // Allocate a tracking record for the interface settings and remember our
    1441     // setup
    1442     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    1443     (*in_if) = ifparm;
    1444 
    1445     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    1446         return -1;
    1447     }
    1448 
    1449     if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)
    1450         return -1;
    1451 
    1452     if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    1453         return -1;
    1454 
    1455     if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    1456         return -1;
    1457 
    1458     // it looks like an orinoco now, apparently
    1459     if ((ret = Iwconfig_Set_IntPriv(in_dev, "monitor", 1, initch, in_err)) < 0) {
    1460         if (ret == -2)
    1461             snprintf(in_err, 1024, "Could not find 'monitor' private ioctl "
    1462                      "Make sure you have the latest ACX100 development release.");
    1463         return -1;
    1464     }
    1465 
    1466     if (chancontrol_wext(in_dev, initch, in_err, NULL) < 0)
    1467         return -1;
    1468 
    1469     return 0;
    1470 }
    1471 
    1472 int unmonitor_acx100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1473     // Restore the IP settings
    1474     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1475 
    1476     if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {
    1477         return -1;
    1478     }
    1479 
    1480     Iwconfig_Set_IntPriv(in_dev, "monitor", 0, ifparm->channel, in_err);
    1481     Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode);
    1482 
    1483     if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)
    1484         return -1;
    1485    
    1486     free(ifparm);
    1487 
    1488     return 1;
    1489 }
    1490 
    1491 int monitor_admtek(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1492     // Allocate a tracking record for the interface settings and remember our
    1493     // setup
    1494     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    1495     (*in_if) = ifparm;
    1496 
    1497     // Try to figure out the name so we know if we have fcs bytes or not
    1498     char iwname[IFNAMSIZ+1];
    1499     if (Iwconfig_Get_Name(in_dev, in_err, iwname) < 0)
    1500         return -1;
    1501 
    1502     if (strncmp(iwname, "IEEE 802.11b", IFNAMSIZ) == 0) {
    1503         // Looks like the GPL driver, we need to adjust the fcsbytes
    1504         PcapSource *psrc = (PcapSource *) in_ext;
    1505         psrc->fcsbytes = 4;
    1506     }
    1507 
    1508     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    1509         return -1;
    1510     }
    1511 
    1512     if ((ifparm->flags & IFF_UP)) {
    1513         if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    1514             return -1;
    1515 
    1516         if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    1517             return -1;
    1518 
    1519         if (Iwconfig_Get_SSID(in_dev, in_err, ifparm->essid) < 0)
    1520             return -1;
    1521    
    1522     } else {
    1523         ifparm->channel = -1;
    1524         ifparm->mode = -1;
    1525     }
    1526 
    1527     int ret = monitor_wext(in_dev, initch, in_err, in_if, in_ext);
    1528 
    1529     if (ret < 0 && ret != -2)
    1530         return ret;
    1531 
    1532     if (Iwconfig_Set_SSID(in_dev, in_err, "") < 0)
    1533         return -1;
    1534    
    1535     return 0;
    1536 }
    1537 
    1538 int unmonitor_admtek(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1539     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1540 
    1541     if (unmonitor_wext(in_dev, initch, in_err, in_if, in_ext))
    1542         return -1;
    1543 
    1544     if (Iwconfig_Set_SSID(in_dev, in_err, ifparm->essid) < 0)
    1545         return -1;
    1546    
    1547     return 1;
    1548 }
    1549 // vtar5k iwpriv control to set link state, rest is normal
    1550 int monitor_vtar5k(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1551     // Set the prism iwpriv control to 1
    1552     if (Iwconfig_Set_IntPriv(in_dev, "prism", 1, 0, in_err) < 0) {
    1553         return -1;
    1554     }
    1555    
    1556     // The rest is standard wireless extensions
    1557     if (monitor_wext(in_dev, initch, in_err, in_if, in_ext) < 0)
    1558         return -1;
    1559 
    1560     return 0;
    1561 }
    15621304
    15631305/* Madwifi NG ioctls from net80211 */
    15641306#define SIOC80211IFCREATE               (SIOCDEVPRIVATE+7)
     
    19271669    return unmonitor_wext(in_dev, initch, in_err, in_if, in_ext);
    19281670}
    19291671
    1930 int monitor_ipw2100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1931     // Allocate a tracking record for the interface settings and remember our
    1932     // setup
    1933     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    1934     (*in_if) = ifparm;
    1935 
    1936     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    1937         return -1;
    1938     }
    1939 
    1940     if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    1941         return -1;
    1942 
    1943     if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    1944         return -1;
    1945 
    1946     // Call the normal monitor mode
    1947     return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));
    1948 }
    1949 
    1950 int unmonitor_ipw2100(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    1951     // Restore initial monitor header
    1952     // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1953 
    1954     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1955 
    1956     if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {
    1957         return -1;
    1958     }
    1959 
    1960     if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)
    1961         return -1;
    1962 
    1963     free(ifparm);
    1964 
    1965     return 1;
    1966 }
    1967 
    1968 int monitor_ipw2200(const char *in_dev, int initch, char *in_err,
    1969                                         void **in_if, void *in_ext) {
    1970     // Allocate a tracking record for the interface settings and remember our
    1971     // setup
    1972     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    1973     (*in_if) = ifparm;
    1974 
    1975     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    1976         return -1;
    1977     }
    1978 
    1979     if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    1980         return -1;
    1981 
    1982     if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    1983         return -1;
    1984 
    1985     // Call the normal monitor mode
    1986     return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));
    1987 }
    1988 
    1989 int unmonitor_ipw2200(const char *in_dev, int initch, char *in_err,
    1990                                           void **in_if, void *in_ext) {
    1991     // Restore initial monitor header
    1992     // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1993 
    1994     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    1995 
    1996     if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {
    1997         return -1;
    1998     }
    1999 
    2000     if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)
    2001         return -1;
    2002 
    2003         // James says this wants to be set to channel 0 for proper scanning operation
    2004         if (Iwconfig_Set_Channel(in_dev, 0, in_err) < 0)
    2005                 return -1;
    2006 
    2007     free(ifparm);
    2008 
    2009     return 1;
    2010 }
    2011 
    2012 // (Unless we learn different) the 3945 in full rfmon acts the same as
    2013 // an ipw2200, so we'll use the same control mechanisms
    2014 int monitor_ipw3945(const char *in_dev, int initch, char *in_err,
    2015                                         void **in_if, void *in_ext) {
    2016     // Allocate a tracking record for the interface settings and remember our
    2017     // setup
    2018     linux_ifparm *ifparm = (linux_ifparm *) malloc(sizeof(linux_ifparm));
    2019     (*in_if) = ifparm;
    2020 
    2021     if (Ifconfig_Get_Flags(in_dev, in_err, &ifparm->flags) < 0) {
    2022         return -1;
    2023     }
    2024 
    2025     if ((ifparm->channel = Iwconfig_Get_Channel(in_dev, in_err)) < 0)
    2026         return -1;
    2027 
    2028     if (Iwconfig_Get_Mode(in_dev, in_err, &ifparm->mode) < 0)
    2029         return -1;
    2030 
    2031     // Call the normal monitor mode
    2032     return (monitor_wext(in_dev, initch, in_err, in_if, in_ext));
    2033 }
    2034 
    2035 int unmonitor_ipw3945(const char *in_dev, int initch, char *in_err,
    2036                                           void **in_if, void *in_ext) {
    2037     // Restore initial monitor header
    2038     // linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    2039 
    2040     linux_ifparm *ifparm = (linux_ifparm *) (*in_if);
    2041 
    2042     if (Ifconfig_Set_Flags(in_dev, in_err, ifparm->flags) < 0) {
    2043         return -1;
    2044     }
    2045 
    2046     if (Iwconfig_Set_Mode(in_dev, in_err, ifparm->mode) < 0)
    2047         return -1;
    2048 
    2049         // James says this wants to be set to channel 0 for proper scanning operation
    2050         if (Iwconfig_Set_Channel(in_dev, 0, in_err) < 0)
    2051                 return -1;
    2052 
    2053     free(ifparm);
    2054 
    2055     return 1;
    2056 }
    2057 
    2058 // The 3945 in "parasite" mode (until James names it) is a different
    2059 // beast entirely.  It uses a dynamically added tap interface to give us
    2060 // realtime rtap formatted frames off the interface, so we need to
    2061 // turn it on via sysfs and then push the new rtapX interface into the source
    2062 // before the open happens
    2063 int monitor_ipwlivetap(const char *in_dev, int initch, char *in_err,
    2064                                            void **in_if, void *in_ext) {
    2065         // We don't try to remember settings because we aren't going to do
    2066         // anything with them, we're leeching off a dynamic interface made
    2067         // just for us.
    2068         char dynif[32];
    2069         FILE *sysf;
    2070         char path[1024];
    2071         short int ifflags;
    2072 
    2073         // Try to get the flags off the master interface
    2074     if (Ifconfig_Get_Flags(in_dev, in_err, &ifflags) < 0) {
    2075         return -1;
    2076     }
    2077 
    2078         // If the master interface isn't even up, blow up.
    2079         if ((ifflags & IFF_UP) == 0) {
    2080                 snprintf(in_err, 1024, "The ipw control interface (%s) is not "
    2081                                  "configured as 'up'.  The ipwlivetap mode reports "
    2082                                  "traffic from a currently running interface.  For pure "
    2083                                  "rfmon monitor mode, use ipwXXXX instead.", in_dev);
    2084                 return -1;
    2085         }
    2086 
    2087         // Use the .../net/foo/device symlink into the .../bus/pci/drivers/
    2088         // ipw3945/foo/ pci bus interface
    2089         snprintf(path, 1024, "/sys/class/net/%s/device/rtap_iface",
    2090                          in_dev);
    2091 
    2092         // Open it in RO mode first and get the current state.  I'm not sure
    2093         // how well frewind works on a dynamic system file so we'll just
    2094         // close it off and re-open it when we go to set modes, if we need
    2095         // to.
    2096         if ((sysf = fopen(path, "r")) == NULL) {
    2097                 snprintf(in_err, 1024, "Failed to open ipw sysfs tap control file, "
    2098                                  "check that the version of the ipw drivers you are running "
    2099                                  "is recent enough, and that your system has sysfs properly "
    2100                                  "set up.");
    2101                 return -1;
    2102         }
    2103 
    2104         fgets(dynif, 32, sysf);
    2105 
    2106         // We're done with the RO
    2107         fclose(sysf);
    2108 
    2109         // If it's -1, we aren't turned on and we need to.
    2110         if (strncmp(dynif, "-1", 32) == 0) {
    2111                 if ((sysf = fopen(path, "w")) == NULL) {
    2112                         snprintf(in_err, 1024, "Failed to open the ipw sysfs tap control "
    2113                                          "file for writing (%s).  Check that Kismet has the proper "
    2114                                          "privilege levels and that you are running a version of the "
    2115                                          "ipw drivers which supports associated rfmon.", strerror(errno));
    2116                         return -1;
    2117                 }
    2118 
    2119                 fprintf(sysf, "1\n");
    2120                 fclose(sysf);
    2121 
    2122                 // Reopen it again for reading for the last time, and get the
    2123                 // interface we changed to.  Do some minor error checking to make
    2124                 // sure the new interface isn't called -1, 0, or 1, which I'm going
    2125                 // to guess would imply an older driver
    2126                 if ((sysf = fopen(path, "r")) == NULL) {
    2127                         snprintf(in_err, 1024, "Failed to open the ipw sysfs tap "
    2128                                          "control to find the interface allocated.  Something strange "
    2129                                          "has happened, because the control file was available "
    2130                                          "previously for setting.  Check your system messages.");
    2131                         return -1;
    2132                 }
    2133 
    2134                 fgets(dynif, 32, sysf);
    2135 
    2136                 fclose(sysf);
    2137 
    2138                 // Wait for the distro to settle if its going to rename an interface
    2139                 sleep(1);
    2140         }
    2141 
    2142         // Sanity check the interface we were told to use.  A 0, 1, -1 probably
    2143         // means a bad driver version.
    2144         if (strncmp(dynif, "-1", 32) == 0 || strncmp(dynif, "0", 32) == 0 ||
    2145                 strncmp(dynif, "1", 32) == 0) {
    2146                 snprintf(in_err, 1024, "Got a nonsense interface from the ipw "
    2147                                  "sysfs tap control file.  This probably means your ipw "
    2148                                  "drivers are out of date, or that there is something strange "
    2149                                  "happening in the drivers.  Check your system messages.");
    2150                 return -1;
    2151         }
    2152 
    2153         // Now that we've gone through that nonsense, make sure the
    2154         // dynamic rtap interface is up
    2155         if (Ifconfig_Delta_Flags(dynif, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    2156         return -1;
    2157 
    2158         // And push the config into the packetsoure
    2159         ((KisPacketSource *) in_ext)->SetInterface(dynif);
    2160 
    2161         return 1;
    2162 }
    2163 
    2164 int unmonitor_ipwlivetap(const char *in_dev, int initch, char *in_err,
    2165                                                  void **in_if, void *in_ext) {
    2166         // Actually there isn't anything to do here.  Right now, I don't
    2167         // think I care if we leave the parasite rtap interface hanging around.
    2168         // Newcore might do this better, but this isn't newcore.
    2169 
    2170     return 1;
    2171 }
    2172 
    21731672// "standard" wireless extension monitor mode
    21741673int monitor_wext(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    21751674    int mode;
     
    22311730#endif
    22321731
    22331732#ifdef SYS_LINUX
    2234 // wlan-ng modern standard
    2235 int monitor_wlanng(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    2236     // I really didn't want to do this...
    2237     char cmdline[2048];
    2238 
    2239     // Sanitize the device just to be safe.  The ifconfig should fail if
    2240     // the device is invalid, but why take risks
    2241     for (unsigned int x = 0; x < strlen(in_dev); x++) {
    2242         if (!isalnum(in_dev[x])) {
    2243             snprintf(in_err, STATUS_MAX, "Invalid device '%s'", in_dev);
    2244             return -1;
    2245         }
    2246     }
    2247    
    2248     if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    2249         return -1;
    2250 
    2251     // Enable the interface
    2252     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_ifstate ifstate=enable >/dev/null 2>/dev/null", in_dev);
    2253     if (RunSysCmd(cmdline) < 0) {
    2254         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2255         return -1;
    2256     }
    2257 
    2258     // Turn off WEP
    2259     snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "
    2260              "mibattribute=dot11PrivacyInvoked=false >/dev/null 2>/dev/null", in_dev);
    2261     if (RunSysCmd(cmdline) < 0) {
    2262         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2263         return -1;
    2264     }
    2265 
    2266     // Don't exclude packets
    2267     snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "
    2268              "mibattribute=dot11ExcludeUnencrypted=false >/dev/null 2>/dev/null", in_dev);
    2269     if (RunSysCmd(cmdline) < 0) {
    2270         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2271         return -1;
    2272     }
    2273 
    2274     // Turn on rfmon on the initial channel
    2275     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d "
    2276              "enable=true prismheader=true >/dev/null 2>/dev/null", in_dev, initch);
    2277     if (RunSysCmd(cmdline) < 0) {
    2278         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2279         return -1;
    2280     }
    2281    
    2282     return 0;
    2283 }
    2284 
    2285 // wlan-ng avs
    2286 int monitor_wlanng_avs(const char *in_dev, int initch, char *in_err, void **in_if, void *in_ext) {
    2287     // I really didn't want to do this...
    2288     char cmdline[2048];
    2289 
    2290     // Sanitize the device just to be safe.  The ifconfig should fail if
    2291     // the device is invalid, but why take risks
    2292     for (unsigned int x = 0; x < strlen(in_dev); x++) {
    2293         if (!isalnum(in_dev[x])) {
    2294             snprintf(in_err, STATUS_MAX, "Invalid device '%s'", in_dev);
    2295             return -1;
    2296         }
    2297     }
    2298 
    2299     if (Ifconfig_Delta_Flags(in_dev, in_err, IFF_UP | IFF_RUNNING | IFF_PROMISC) < 0)
    2300         return -1;
    2301 
    2302     // Enable the interface
    2303     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_ifstate ifstate=enable >/dev/null 2>/dev/null", in_dev);
    2304     if (RunSysCmd(cmdline) < 0) {
    2305         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2306         return -1;
    2307     }
    2308 
    2309     // Turn off WEP
    2310     snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "
    2311              "mibattribute=dot11PrivacyInvoked=false >/dev/null 2>/dev/null", in_dev);
    2312     if (RunSysCmd(cmdline) < 0) {
    2313         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2314         return -1;
    2315     }
    2316 
    2317     // Don't exclude packets
    2318     snprintf(cmdline, 2048, "wlanctl-ng %s dot11req_mibset "
    2319              "mibattribute=dot11ExcludeUnencrypted=false >/dev/null 2>/dev/null", in_dev);
    2320     if (RunSysCmd(cmdline) < 0) {
    2321         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2322         return -1;
    2323     }
    2324 
    2325     // Turn on rfmon on the initial channel
    2326     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d prismheader=false "
    2327              "wlanheader=true stripfcs=false keepwepflags=false enable=true >/dev/null 2>/dev/null", in_dev, initch);
    2328     if (RunSysCmd(cmdline) < 0) {
    2329         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2330         return -1;
    2331     }
    2332    
    2333     return 0;
    2334 }
    2335 
    23361733int monitor_wrt54g(const char *in_dev, int initch, char *in_err, void **in_if,
    23371734                                   void *in_ext) {
    23381735    char cmdline[2048];
     
    23421739                        snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 1'. "
    23431740                                         "Some custom firmware images require you to specify the origial "
    23441741                                         "device and a new dynamic device and use the iwconfig controls. "
    2345                                          "see the README for how to configure your capture source.");
     1742                                         "see the README for how to configure your capture source.", in_dev);
    23461743                        return -1;
    23471744                }
    23481745
     
    23591756                        snprintf(in_err, 1024, "Unable to set mode using 'iwpriv %s set_monitor 0'. "
    23601757                                         "Some custom firmware images require you to specify the origial "
    23611758                                         "device and a new dynamic device and use the iwconfig controls. "
    2362                                          "see the README for how to configure your capture source.");
     1759                                         "see the README for how to configure your capture source.", in_dev);
    23631760                        return -1;
    23641761                }
    23651762
     
    26072004    return 0;
    26082005}
    26092006
    2610 int chancontrol_ipw2100(const char *in_dev, int in_ch, char *in_err, void *in_ext) {
    2611     // Introduce a slight delay to let the driver settle, a la orinoco.  I don't
    2612     // like doing this at all since it introduces hiccups into the channel control
    2613     // process, but....
    2614 
    2615     int ret = 0;
    2616 
    2617     ret = chancontrol_wext(in_dev, in_ch, in_err, in_ext);
    2618     usleep(5000);
    2619 
    2620     return ret;
    2621 }
    2622 
    2623 int chancontrol_ipw2200(const char *in_dev, int in_ch, char *in_err, void *in_ext) {
    2624         // Lets see if this really needs the channel change delay like the 2100 did
    2625     int ret = 0;
    2626 
    2627     ret = chancontrol_wext(in_dev, in_ch, in_err, in_ext);
    2628         // Drop a tiny sleep in here to let the channel set settle, otherwise we
    2629         // run the risk of the card freaking out
    2630         usleep(7000);
    2631 
    2632     return ret;
    2633 }
    2634 
    2635 #endif
    2636 
    2637 #ifdef SYS_LINUX
    2638 int chancontrol_wlanng(const char *in_dev, int in_ch, char *in_err, void *in_ext) {
    2639     // I really didn't want to do this...
    2640     char cmdline[2048];
    2641 
    2642     // Turn on rfmon on the initial channel
    2643     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d enable=true "
    2644              "prismheader=true >/dev/null 2>&1", in_dev, in_ch);
    2645     if (RunSysCmd(cmdline) < 0) {
    2646         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2647         return -1;
    2648     }
    2649 
    2650     if (in_ext != NULL) {
    2651         PcapSourceWlanng *src = (PcapSourceWlanng *) in_ext;
    2652         src->last_channel = in_ch;
    2653     }
    2654    
    2655     return 0;
    2656 }
    2657 
    2658 int chancontrol_wlanng_avs(const char *in_dev, int in_ch, char *in_err, void *in_ext) {
    2659     // I really didn't want to do this...
    2660     char cmdline[2048];
    2661 
    2662     // Turn on rfmon on the initial channel
    2663     snprintf(cmdline, 2048, "wlanctl-ng %s lnxreq_wlansniff channel=%d "
    2664              "prismheader=false wlanheader=true stripfcs=false keepwepflags=false "
    2665              "enable=true >/dev/null 2>&1", in_dev, in_ch);
    2666 
    2667     if (RunSysCmd(cmdline) < 0) {
    2668         snprintf(in_err, 1024, "Unable to execute '%s'", cmdline);
    2669         return -1;
    2670     }
    2671 
    2672     if (in_ext != NULL) {
    2673         PcapSourceWlanng *src = (PcapSourceWlanng *) in_ext;
    2674         src->last_channel = in_ch;
    2675     }
    2676    
    2677     return 0;
    2678 }
    26792007#endif
    26802008
    26812009#ifdef SYS_OPENBSD
  • tcpstreamer.cc

    diff -urN kismet.dev/tcpstreamer.cc kismet.dev2/tcpstreamer.cc
    old new  
    3030    serv_fd = 0;
    3131
    3232    max_fd = 0;
    33 
    34         gpsd = NULL;
    3533}
    3634
    3735TcpStreamer::~TcpStreamer()
     
    287285    hdr.frame_len = (uint32_t) htonl(sizeof(struct stream_version_packet));
    288286
    289287    vpkt.drone_version = (uint16_t) htons(STREAM_DRONE_VERSION);
    290         if (gpsd != NULL)
    291                 vpkt.gps_enabled = 1;
    292         else
    293                 vpkt.gps_enabled = 0;
    294288
    295289    if (!FD_ISSET(in_fd, &client_fds))
    296290        return -1;
  • tcpstreamer.h

    diff -urN kismet.dev/tcpstreamer.h kismet.dev2/tcpstreamer.h
    old new  
    4242#include "ringbuf.h"
    4343#include "packet.h"
    4444#include "packetstream.h"
    45 #include "gpsd.h"
    4645
    4746// Global in kismet_drone.cc
    4847extern int silent;
     
    7675
    7776    int FetchDescriptor() { return serv_fd; }
    7877
    79     // Register the GPS server for us to use
    80     void AddGpstracker(GPSD *in_gpsd) { gpsd = in_gpsd; }
    81 
    8278    void Kill(int in_fd);
    8379
    8480    int Poll(fd_set& in_rset, fd_set& in_wset);
     
    124120    fd_set client_fds;
    125121
    126122    unsigned int max_fd;
    127 
    128         GPSD *gpsd;
    129123};
    130124
    131125#endif
Note: See TracBrowser for help on using the repository browser.