13
0
Fork 1

Enhanced gps support

decttxt logfile support
min/max rssi tracking support
scandect pcap now volatile


git-svn-id: https://dedected.org/svn/trunk@100 8d8ab74c-27aa-4a3d-9bde-523a2bc1f624
This commit is contained in:
dragorn 2009-11-22 11:41:51 +00:00
parent 52364a63b5
commit 772763ccd1
6 changed files with 233 additions and 4 deletions

View File

@ -12,7 +12,7 @@ PLUGINLDFLAGS += -shared -rdynamic
LIBS += -lstdc++
CFLAGS += -I/usr/include -I$(KIS_INC_DIR) -g -fPIC
SRVOBJS = packetsource_dect.o tracker_dect.o kismet_dect.o
SRVOBJS = packetsource_dect.o tracker_dect.o dumpfile_decttxt.o kismet_dect.o
SRVOUT = dedected.so
CLIOBJS = dect_client.o

View File

@ -0,0 +1,137 @@
/*
This file is part of Kismet
Kismet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kismet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Kismet; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
DECT source v2
(c) 2008 by Mike Kershaw <dragorn (at) kismetwireless (dot) net,
Jacob Appelbaum <jacob (at) appelbaum (dot) net,
Christian Fromme <kaner (at) strace (dot) org
*/
#include <config.h>
#include <globalregistry.h>
#include "dumpfile_decttxt.h"
Dumpfile_Decttxt::Dumpfile_Decttxt(GlobalRegistry *in_globalreg,
Tracker_Dect *in_tracker) : Dumpfile(in_globalreg) {
globalreg = in_globalreg;
tracker = in_tracker;
txtfile = NULL;
if ((fname = ProcessConfigOpt("decttxt")) == "" ||
globalreg->fatal_condition) {
return;
}
if ((txtfile = fopen(fname.c_str(), "w")) == NULL) {
_MSG("Failed to open decttxt log file '" + fname + "': " + strerror(errno),
MSGFLAG_FATAL);
globalreg->fatal_condition = 1;
return;
}
globalreg->RegisterDumpFile(this);
_MSG("Opened decttxt log file '" + fname + "'", MSGFLAG_INFO);
}
Dumpfile_Decttxt::~Dumpfile_Decttxt() {
Flush();
}
int Dumpfile_Decttxt::Flush() {
if (txtfile != NULL)
fclose(txtfile);
string tempname = fname + ".temp";
if ((txtfile = fopen(tempname.c_str(), "w")) == NULL) {
_MSG("Failed to open temporary nettxt file for writing: " +
string(strerror(errno)), MSGFLAG_ERROR);
return -1;
}
fprintf(txtfile, "Kismet (http://www.kismetwireless.net)\n"
"Dedected (http://www.dedected.org)\n"
"%.24s - Kismet %s.%s.%s\n"
"-----------------\n\n",
ctime(&(globalreg->start_time)),
globalreg->version_major.c_str(),
globalreg->version_minor.c_str(),
globalreg->version_tiny.c_str());
map<mac_addr, dect_tracked_fp *> m = tracker->tracked_fp;
int count = 1;
for (map<mac_addr, dect_tracked_fp *>::iterator i = m.begin();
i != m.end(); ++i) {
fprintf(txtfile, "Basestation %d: RFPI %s\n", count,
i->second->rfpi.Mac2String().substr(0, 14).c_str());
fprintf(txtfile, " First : %.24s\n", ctime(&(i->second->first_time)));
fprintf(txtfile, " Last : %.24s\n", ctime(&(i->second->last_time)));
fprintf(txtfile, " RFPI : %s\n",
i->second->rfpi.Mac2String().substr(0, 14).c_str());
fprintf(txtfile, " Channel : %u\n", i->second->channel);
fprintf(txtfile, " Count : %u\n", i->second->num_seen);
if (i->second->min_rssi > 0)
fprintf(txtfile, " Min RSSI : %d\n", i->second->min_rssi);
if (i->second->max_rssi > 0)
fprintf(txtfile, " Max RSSI : %d\n", i->second->max_rssi);
if (i->second->gpsdata.gps_valid) {
fprintf(txtfile, " Min Pos : Lat %f Lon %f Alt %f Spd %f\n",
i->second->gpsdata.min_lat, i->second->gpsdata.min_lon,
i->second->gpsdata.min_alt, i->second->gpsdata.min_spd);
fprintf(txtfile, " Max Pos : Lat %f Lon %f Alt %f Spd %f\n",
i->second->gpsdata.max_lat, i->second->gpsdata.max_lon,
i->second->gpsdata.max_alt, i->second->gpsdata.max_spd);
fprintf(txtfile, " Peak Pos : Lat %f Lon %f Alt %f\n",
i->second->peak_lat, i->second->peak_lon,
i->second->peak_alt);
fprintf(txtfile, " Avg Pos : AvgLat %Lf AvgLon %Lf AvgAlt %Lf\n",
i->second->gpsdata.aggregate_lat /
i->second->gpsdata.aggregate_points,
i->second->gpsdata.aggregate_lon /
i->second->gpsdata.aggregate_points,
i->second->gpsdata.aggregate_alt /
i->second->gpsdata.aggregate_points);
}
fprintf(txtfile, "\n");
count++;
}
dumped_frames = count;
fflush(txtfile);
fclose(txtfile);
txtfile = NULL;
if (rename(tempname.c_str(), fname.c_str()) < 0) {
_MSG("Failed to rename decttxt temp file " + tempname + " to " + fname + ":" +
string(strerror(errno)), MSGFLAG_ERROR);
return -1;
}
return 1;
}

View File

@ -0,0 +1,51 @@
/*
This file is part of Kismet
Kismet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kismet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Kismet; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
DECT source v2
(c) 2008 by Mike Kershaw <dragorn (at) kismetwireless (dot) net,
Jacob Appelbaum <jacob (at) appelbaum (dot) net,
Christian Fromme <kaner (at) strace (dot) org
*/
#ifndef __DUMPFILE_DECTTXT_H__
#define __DUMPFILE_DECTTXT_H__
#include "config.h"
#include <packet.h>
#include <gpscore.h>
#include <configfile.h>
#include <dumpfile.h>
#include "packet_dect.h"
#include "tracker_dect.h"
class Dumpfile_Decttxt : public Dumpfile {
public:
Dumpfile_Decttxt() { fprintf(stderr, "FATAL OOPS: Dumpfile_Decttxt()\n"); exit(1); }
Dumpfile_Decttxt(GlobalRegistry *in_globalreg, Tracker_Dect *in_tracker);
virtual ~Dumpfile_Decttxt();
virtual int Flush();
protected:
FILE *txtfile;
Tracker_Dect *tracker;
};
#endif

View File

@ -49,6 +49,7 @@
#include "packetsource_dect.h"
#include "tracker_dect.h"
#include "dumpfile_decttxt.h"
GlobalRegistry *globalreg = NULL;
@ -193,10 +194,14 @@ int dect_register(GlobalRegistry *in_globalreg) {
Dumpfile_Pcap *dectscandump =
new Dumpfile_Pcap(globalreg, "scandect", DLT_EN10MB,
globalreg->pcapdump, dumpfile_dect_scanfilter, NULL);
dectscandump->SetVolatile(1);
Tracker_Dect *trackdect;
trackdect = new Tracker_Dect(globalreg);
Dumpfile_Decttxt *dumptxt = new Dumpfile_Decttxt(globalreg, trackdect);
dumptxt->SetVolatile(1);
return 1;
}

View File

@ -37,6 +37,7 @@ enum DECTFP_fields {
DECTFP_gpsfixed, DECTFP_minlat, DECTFP_maxlat, DECTFP_minlon, DECTFP_maxlon,
DECTFP_minalt, DECTFP_maxalt, DECTFP_minspd, DECTFP_maxspd, DECTFP_agglat,
DECTFP_agglon, DECTFP_aggalt, DECTFP_aggpoints,
DECTFP_minrssi, DECTFP_maxrssi, DECTFP_peaklat, DECTFP_peaklon, DECTFP_peakalt,
DECTFP_maxfield
};
@ -46,6 +47,7 @@ const char *DECTFP_fields_text[] = {
"gpsfixed", "minlat", "maxlat", "minlon", "maxlon",
"minalt", "maxalt", "minspd", "maxspd", "agglat",
"agglon", "aggalt", "aggpoints",
"minrssi", "maxrssi", "peaklat", "peaklon", "peakalt",
NULL
};
@ -128,6 +130,21 @@ int Protocol_DECTFP(PROTO_PARMS) {
case DECTFP_aggpoints:
osstr << fp->gpsdata.aggregate_points;
break;
case DECTFP_minrssi:
osstr << fp->min_rssi;
break;
case DECTFP_maxrssi:
osstr << fp->max_rssi;
break;
case DECTFP_peaklat:
osstr << fp->peak_lat;
break;
case DECTFP_peaklon:
osstr << fp->peak_lon;
break;
case DECTFP_peakalt:
osstr << fp->peak_alt;
break;
}
out_string += osstr.str() + " ";
@ -221,10 +238,21 @@ int Tracker_Dect::chain_handler(kis_packet *in_pack) {
fp->num_seen++;
fp->last_rssi = di->sdata.RSSI;
if (gpsinfo != NULL) {
if (gpsinfo != NULL && gpsinfo->gps_fix) {
fp->gpsdata += gpsinfo;
if (fp->last_rssi > fp->max_rssi) {
fp->peak_lat = gpsinfo->lat;
fp->peak_lon = gpsinfo->lon;
fp->peak_alt = gpsinfo->alt;
}
}
if (fp->last_rssi < fp->min_rssi)
fp->min_rssi = fp->last_rssi;
if (fp->last_rssi > fp->max_rssi)
fp->max_rssi = fp->last_rssi;
fp->dirty = 1;
return 0;

View File

@ -36,20 +36,27 @@ class dect_tracked_fp {
public:
dect_tracked_fp() {
first_time = last_time = 0;
last_rssi = 0;
num_seen = 0;
channel = 0;
dirty = 0;
min_rssi = 999;
max_rssi = -999;
last_rssi = 0;
peak_lat = peak_lon = peak_alt = 0;
}
mac_addr rfpi;
time_t first_time, last_time;
unsigned int last_rssi;
unsigned int num_seen;
unsigned int channel;
unsigned int dirty;
kis_gps_data gpsdata;
int min_rssi, max_rssi, last_rssi;
double peak_lat, peak_lon, peak_alt;
};
class Tracker_Dect {
@ -69,6 +76,7 @@ protected:
int DECTFP_ref;
int timer_ref;
friend class Dumpfile_Decttxt;
};
#endif