Only in kismet-2.2.2: .depend diff -u kismet-2.2.2/CHANGELOG kismet-devel/CHANGELOG --- kismet-2.2.2/CHANGELOG Tue May 28 11:26:36 2002 +++ kismet-devel/CHANGELOG Thu Jun 13 22:54:35 2002 @@ -1,9 +1,114 @@ -May 28 2002 2.2.2 !! 2.2.2 released - fixes potentially exploitable remote - hole in Festival saytext. !! - Added Zaurus default configs to Zaurus ipk - -May 27 2002 2.2.1 !! 2.2.1 released - potentially exploitable local root - hole fixed !! +Jun 13 2002 2.3 Hacked at gpsmap more. +Jun 11 2002 2.3 Philly wasn't all that good. + Bugfixes to gpsmap. +Jun 10 2002 2.3 More work on gpsmap supporting xml. + gpsmap now works with XML (woo, that took way too long). + fix for segfault at termination coming soon, as well as + new features available via gpsmap reading the network xml + files too. Zlib support will be re-introduced ASAP. + Fixed majors problems in the new gpsmap code. + Added wep-based coloring of networks +Jun 07 2002 2.3 Fixed display glitch in statistics panel + Fixed writing glitch in gps xml + Stopped trying to extract strings from WEP-encrypted + packets. (Eliminates much of the junk data in the strings + dump) + Fixed bug in adhoc probe req handling (hopefully) + Fixed bug in group IP merging +Jun 06 2002 2.3 XML parser is done, pending integration with gpsmap. + More gpsmap work. + Tracked down another file-related segfault and made it + go away (thanks Dave) +Jun 05 2002 2.3 Fixed XML error in gps-dump xml output + Kismet was on Screensavers on TechTV. Cool. + Tweaked gps DTD. +Jun 04 2002 2.3 Fixed segfault for generic capture, fixed several other + potential bugs in kismet_server regarding signed-ness + (thanks Francois) + Tweaked panel scrolling code, hopefully this will fix some + of the problems with scrolling networks (thanks again + Francois for a point in the right direction). + Worked more on expat parser, no, gpsmap doesn't work again + yet. + Finished network XML expat parser. gpsmap still doesn't + work but it's almost there. gps xml parser is next. + Added expat to configure script + Fixed missing ; in csv output (thanks dave) +Jun 03 2002 2.3 Fixed %/ in default kismet config for gpsdrive waypoints. +Jun 02 2002 2.3 Fixed segfault with waypoint writing + Fixed segfaults with new logfiletypes. + Started expat XML parser to load network and gps files into + gpsmap + Added packtype=unknown to gpsdump ignore list +Jun 01 2002 2.3 Changed to XML-format GPS logging + Merged patch from Faust to optomize convex hull mapping + Rewrote logfile handling to be more efficient + Completely broke gpsmap until XML importer is written + Merged patch from Magnus to write gpsdrive waypoints +May 30 2002 2.3 Fixed bug that caused GPS ranges to be printed when there + was no valid GPS data. +May 29 2002 2.3 Added persistant IP range detection (like cloaked SSIDs, + once an IP range is found it will be remembered). + Added periodic saving of datafiles, controlled by the + writeinterval config file option. Leave this out or set + it to zero if you don't want to write all the data files + until quit time. +May 28 2002 2.3 Added default Zaurus configs to Zaurus ipk build process. +May 27 2002 2.3 Fixed (potentially) exploitable hole (local only). + Fixed remote-exploitable hole (ack!) with specially crafted + SSID's and Festival speech output. + Fixed lack of newline in tcpclient.cc +May 26 2002 2.3 Fixed all sorts of bugs in MAC filtering (they were ignored + but still logged in the dumpfile and in the gpslogs, which + leads to interesting, but bad, drawing patterns.) + Rolled in network-convex-hulling gpsmap patch from Faust + (gpsmap -H) + Added filter and inverse filter BSSID to gpsmap (-F, -I) + Added configfile support to gpsmap (to read MAC filter + lists.) It will continue to work without a configfile + as well. + Added popup window catch for fixed sizes > screen +May 25 2002 2.3 Tweaked gpsdump DTD +May 24 2002 2.3 Merged gpsmap patch from Faust, scatterplot of sample + points (should make a few people happy) +May 23 2002 2.3 Actually fixed association of probe req counting + Merged another gpsmap patch from Faust. Beginnings of + convex hull, numerous fixes to my code. + Fixed minor error in network DTD + Started GPS dtd + Added more manuf fingerprints +May 22 2002 2.3 Fixed association of probe req network & number of total + networks. +May 21 2002 2.3 Some code cleanup in the panels drawing + Added max packet rate to statistics popup + Prettied statistics popup more + Started framework for per-channel signal power + Fixed weirdness with level rate reporting +May 20 2002 2.3 Added statistics popup + Added more manufacturer ID's + Added nice channel allocation graph to statistics popup +May 19 2002 2.3 Fixed packet rate counting dropped packets + Fixed GPS alt reporting + Fixed all-X'd startup rate graph + Added 'q' as cancel key for sort popup + Added total number of networks in group to info window + Added second linksys manufacturer ID + Added Apple manufacturer ID + Un-broke gpsmap tracks +May 17 2002 2.3 Fixed dependencies generation error in the Makefile + Added scoring, manufacturer information, default config + matching. *Modification to client protocol to add + transmission of manuf and score* + Fixed Jason Luthers name in code comments for SSID uncloak + code. (Yikes, that's been wrong for a really long time, + sorry about that.) + Fixed counting bug in network groups. + Fixed offset bug with column headers in panels UI. + Fixed segfault in manufacturer code + Added manufacturer output to network details. + Added flag 'v' (Vulnerable default) +May 16 2002 2.3 Started 2.3 development + Started manufacturer and default-config recognition May 16 2002 2.2 !! 2.2 released (wow, it's been a month, hasn't it.) diff -u kismet-2.2.2/FAQ kismet-devel/FAQ --- kismet-2.2.2/FAQ Tue Apr 30 19:32:11 2002 +++ kismet-devel/FAQ Tue Jun 4 11:05:48 2002 @@ -151,4 +151,9 @@ A: You disabled GPS support. Set GPS to false and turn off the GPS in logtypes. +Q: My Garmin GPS appears to have a lock, and Kismet reports coordinates, but +Kismet still won't record a GPS file and it says it has no lock. +A: Upgrade your GPS firmware to the latest version from Garmin. Most Garmin +GPSs ship with a version that has a bug in the NMEA output. + Only in kismet-2.2.2: Makefile diff -u kismet-2.2.2/Makefile.in kismet-devel/Makefile.in --- kismet-2.2.2/Makefile.in Tue May 28 11:25:36 2002 +++ kismet-devel/Makefile.in Tue Jun 11 22:33:22 2002 @@ -37,15 +37,16 @@ PSO = configfile.o packet.o \ prism2source.o pcapsource.o wtapfilesource.o genericsource.o \ wtapdump.o wtaplocaldump.o gpsdump.o \ - gpsd.o packetracker.o \ + gpsd.o packetracker.o manuf.o \ getopt.o \ - tcpserver.o kismet_server.o $(PCAPLIB) + tcpserver.o kismet_server.o PS = kismet_server -NCO = configfile.o tcpclient.o frontend.o cursesfront.o panelfront.o getopt.o kismet_curses.o +NCO = configfile.o manuf.o tcpclient.o frontend.o cursesfront.o panelfront.o \ + getopt.o kismet_curses.o NC = kismet_curses -GPSLO = getopt.o gpsmap.o +GPSLO = getopt.o configfile.o expat.o manuf.o gpsmap.o GPSL = gpsmap HOPPERO = configfile.o getopt.o prism2hopper.o @@ -58,14 +59,14 @@ all: $(DEPEND) $(PS) $(NC) $(GPSLBUILD) $(HOPPER) $(ZAURUSBUILD) -$(PS): $(PSO) - $(LD) $(LDFLAGS) -o $(PS) $(PSO) $(LIBS) $(PCAPLNK) +$(PS): $(PSO) $(PCAPLIB) + $(LD) $(LDFLAGS) -o $(PS) $(PSO) $(PCAPLIB) $(LIBS) $(PCAPLNK) $(NC): $(NCO) $(LD) $(LDFLAGS) -o $(NC) $(NCO) $(LIBS) $(GPSL): $(GPSLO) - $(LD) $(LDFLAGS) -o $(GPSL) $(GPSLO) $(LIBS) `Magick-config --cflags --cppflags --ldflags` `Magick-config --libs` -lpthread + $(LD) $(LDFLAGS) -o $(GPSL) $(GPSLO) $(LIBS) `Magick-config --cflags --cppflags --ldflags` `Magick-config --libs` -lpthread -lexpat $(HOPPER): $(HOPPERO) $(LD) $(LDFLAGS) -o $(HOPPER) $(HOPPERO) @@ -239,7 +240,7 @@ @echo "Generating dependencies... " @echo > $(DEPEND) @$(CXX) $(CFLAGS) -MM \ - `echo $(PSO) $(HOPPERO) $(GPSLO) $(NCO) | sed -e "s/\.o/\.cc/g" | sed -e "s/.*\.a//g"` >> $(DEPEND) + `echo $(PSO) $(HOPPERO) $(GPSLO) $(NCO) | sed -e "s/\.o/\.cc/g"` >> $(DEPEND) include $(DEPEND) diff -u kismet-2.2.2/README kismet-devel/README --- kismet-2.2.2/README Sat May 11 12:38:48 2002 +++ kismet-devel/README Fri May 17 00:26:17 2002 @@ -1,4 +1,4 @@ -Kismet 2.2 +Kismet 2.3 Mike Kershaw http://www.kismetwireless.net/ Licensed under the GPL Common subdirectories: kismet-2.2.2/conf and kismet-devel/conf Only in kismet-2.2.2: config.h diff -u kismet-2.2.2/config.h.bot kismet-devel/config.h.bot --- kismet-2.2.2/config.h.bot Fri Mar 22 16:56:16 2002 +++ kismet-devel/config.h.bot Tue May 21 22:36:43 2002 @@ -2,6 +2,9 @@ /* Maximum number of characters in the status line */ #define STATUS_MAX 1024 +/* Maximum number of channels - I've only ever heard of 14 being used. */ +#define CHANNEL_MAX 14 + /* Stupid ncurses */ #define NCURSES_NOMACROS diff -u kismet-2.2.2/config.h.in kismet-devel/config.h.in --- kismet-2.2.2/config.h.in Tue May 14 00:58:46 2002 +++ kismet-devel/config.h.in Wed Jun 5 00:42:30 2002 @@ -9,6 +9,9 @@ /* Define if you have the header file. */ #undef HAVE_ERRNO_H +/* Expat XML library */ +#undef HAVE_EXPAT + /* Define if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY @@ -149,6 +152,9 @@ /* Maximum number of characters in the status line */ #define STATUS_MAX 1024 + +/* Maximum number of channels - I've only ever heard of 14 being used. */ +#define CHANNEL_MAX 14 /* Stupid ncurses */ #define NCURSES_NOMACROS diff -u kismet-2.2.2/config.log kismet-devel/config.log --- kismet-2.2.2/config.log Fri Jun 7 12:13:42 2002 +++ kismet-devel/config.log Tue Jun 11 22:36:45 2002 @@ -357,35 +357,41 @@ configure:4341: result: struct wtap *, int *, long * configure:4358: checking for forced local-dumper configure:4360: result: no -configure:4398: checking for Magick-config -configure:4413: found /usr/local/bin/Magick-config -configure:4422: result: yes -configure:4431: checking for wget -configure:4446: found /usr/bin/wget -configure:4455: result: yes -configure:4473: checking for magick/api.h -configure:4483: gcc -E -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -I/usr/X11R6/include/freetype2 -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 conftest.c -configure:4489: $? = 0 -configure:4508: result: yes -configure:4511: checking for WriteImage in -lMagick -configure:4538: gcc -o conftest -g -O2 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -I/usr/X11R6/include/freetype2 -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 -Ilibpcap-2002.05.16 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -g -O2 -Wall -L/usr/X11R6/lib -L/usr/local/lib -L/usr/X11R6/lib conftest.c -lMagick -Ilibpcap-2002.05.16 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -g -O2 -Wall -L/home/dragorn/ImageMagick-5.4.5/magick -lMagick -ltiff -lfreetype -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lz -lpthread -lm >&5 +configure:4394: checking for XML_GetCurrentLineNumber in -lexpat +configure:4421: gcc -o conftest -g -O2 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap conftest.c -lexpat -lpanel -lncurses -lz -L/opt/gnome/lib -lglib -L/usr/src/ethereal-0.9.3/wiretap -lwiretap >&5 +configure:4424: $? = 0 +configure:4427: test -s conftest +configure:4430: $? = 0 +configure:4441: result: yes +configure:4461: checking for Magick-config +configure:4476: found /usr/local/bin/Magick-config +configure:4485: result: yes +configure:4494: checking for wget +configure:4509: found /usr/bin/wget +configure:4518: result: yes +configure:4536: checking for magick/api.h +configure:4546: gcc -E -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -I/usr/X11R6/include/freetype2 -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 conftest.c +configure:4552: $? = 0 +configure:4571: result: yes +configure:4574: checking for WriteImage in -lMagick +configure:4601: gcc -o conftest -g -O2 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -I/usr/X11R6/include/freetype2 -D_REENTRANT -D_FILE_OFFSET_BITS=64 -I/usr/local/include -I/usr/X11R6/include -I/usr/X11R6/include/X11 -Ilibpcap-2002.05.16 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -g -O2 -Wall -L/usr/X11R6/lib -L/usr/local/lib -L/usr/X11R6/lib conftest.c -lMagick -Ilibpcap-2002.05.16 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap -g -O2 -Wall -L/home/dragorn/ImageMagick-5.4.5/magick -lMagick -ltiff -lfreetype -ljpeg -lpng -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lz -lpthread -lm >&5 /usr/local/lib/libMagick.a(utility.o): In function `TemporaryFilename': /home/dragorn/ImageMagick-5.4.5/magick/utility.c:2934: the use of `tempnam' is dangerous, better use `mkstemp' -configure:4541: $? = 0 -configure:4544: test -s conftest -configure:4547: $? = 0 -configure:4558: result: yes -configure:4665: checking for pthread.h -configure:4675: gcc -E -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap conftest.c -configure:4681: $? = 0 -configure:4700: result: yes -configure:4703: checking for pthread_create in -lpthread -configure:4730: gcc -o conftest -g -O2 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap conftest.c -lpthread -lpanel -lncurses -lz -L/opt/gnome/lib -lglib -L/usr/src/ethereal-0.9.3/wiretap -lwiretap >&5 -configure:4733: $? = 0 -configure:4736: test -s conftest -configure:4739: $? = 0 -configure:4750: result: yes -configure:4849: creating ./config.status +configure:4604: $? = 0 +configure:4607: test -s conftest +configure:4610: $? = 0 +configure:4621: result: yes +configure:4736: checking for pthread.h +configure:4746: gcc -E -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap conftest.c +configure:4752: $? = 0 +configure:4771: result: yes +configure:4774: checking for pthread_create in -lpthread +configure:4801: gcc -o conftest -g -O2 -Ilibpcap-2002.05.16 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib/glib/include -I/usr/src/ethereal-0.9.3/wiretap conftest.c -lpthread -lpanel -lncurses -lz -L/opt/gnome/lib -lglib -L/usr/src/ethereal-0.9.3/wiretap -lwiretap >&5 +configure:4804: $? = 0 +configure:4807: test -s conftest +configure:4810: $? = 0 +configure:4821: result: yes +configure:4920: creating ./config.status ## ----------------------- ## ## Running config.status. ## @@ -395,18 +401,19 @@ > ./config.status on gir -config.status:5307: creating Makefile -config.status:5307: creating scripts/kismet -config.status:5307: creating scripts/prism2_monitor -config.status:5307: creating scripts/prism2_unmonitor -config.status:5307: creating scripts/cisco_monitor -config.status:5307: creating scripts/cisco_unmonitor -config.status:5307: creating scripts/bsd_cisco_monitor -config.status:5307: creating extra/buzzme/Makefile -config.status:5307: creating extra/Makefile -config.status:5399: creating config.h -configure:5644: configuring in libpcap-2002.05.16 -configure:5711: running /bin/sh './configure' --cache-file=/dev/null --srcdir=. +config.status:5378: creating Makefile +config.status:5378: creating scripts/kismet +config.status:5378: creating scripts/prism2_monitor +config.status:5378: creating scripts/prism2_unmonitor +config.status:5378: creating scripts/cisco_monitor +config.status:5378: creating scripts/cisco_unmonitor +config.status:5378: creating scripts/bsd_cisco_monitor +config.status:5378: creating extra/buzzme/Makefile +config.status:5378: creating extra/Makefile +config.status:5470: creating config.h +config.status:5611: config.h is unchanged +configure:5715: configuring in libpcap-2002.05.16 +configure:5782: running /bin/sh './configure' --cache-file=/dev/null --srcdir=. ## ----------------- ## ## Cache variables. ## @@ -466,6 +473,7 @@ ac_cv_host=i686-pc-linux-gnu ac_cv_host_alias=i686-pc-linux-gnu ac_cv_lib_Magick_WriteImage=yes +ac_cv_lib_expat_XML_GetCurrentLineNumber=yes ac_cv_lib_ncurses_initscr=yes ac_cv_lib_panel_new_panel=yes ac_cv_lib_pthread_pthread_create=yes @@ -533,6 +541,7 @@ #define HAVE_LIBPCAP 1 #define HAVE_LIBWIRETAP 1 #define HAVE_LIBZ 1 +#define HAVE_EXPAT 1 #define HAVE_IMAGEMAGICK 1 #define HAVE_PTHREAD 1 Only in kismet-2.2.2: config.status diff -u kismet-2.2.2/configfile.cc kismet-devel/configfile.cc --- kismet-2.2.2/configfile.cc Tue May 28 02:11:08 2002 +++ kismet-devel/configfile.cc Tue May 28 02:09:27 2002 @@ -39,7 +39,6 @@ } } - string StrLower(string in_str) { string thestr = in_str; for (unsigned int i = 0; i < thestr.length(); i++) Only in kismet-2.2.2: configfile.o diff -u kismet-2.2.2/configure kismet-devel/configure --- kismet-2.2.2/configure Thu May 16 22:53:58 2002 +++ kismet-devel/configure Wed Jun 5 00:42:27 2002 @@ -4388,6 +4388,69 @@ fi # gpsmap checks + +# Check for expat +expatl=no +echo "$as_me:4394: checking for XML_GetCurrentLineNumber in -lexpat" >&5 +echo $ECHO_N "checking for XML_GetCurrentLineNumber in -lexpat... $ECHO_C" >&6 +if test "${ac_cv_lib_expat_XML_GetCurrentLineNumber+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lexpat $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 4402 "configure" +#include "confdefs.h" + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char XML_GetCurrentLineNumber (); +int +main () +{ +XML_GetCurrentLineNumber (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4421: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4424: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4427: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4430: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_expat_XML_GetCurrentLineNumber=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_expat_XML_GetCurrentLineNumber=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:4441: result: $ac_cv_lib_expat_XML_GetCurrentLineNumber" >&5 +echo "${ECHO_T}$ac_cv_lib_expat_XML_GetCurrentLineNumber" >&6 +if test $ac_cv_lib_expat_XML_GetCurrentLineNumber = yes; then + +cat >>confdefs.h <<\EOF +#define HAVE_EXPAT 1 +EOF + expatl=yes +else + { echo "$as_me:4450: WARNING: *** Missing Expat XML library. gpsmap will not be built. ***" >&5 +echo "$as_me: WARNING: *** Missing Expat XML library. gpsmap will not be built. ***" >&2;} +fi + # Check for imagemagick save_cppflags="$CPPFLAGS" save_cxxflags="$CXXFLAGS" @@ -4395,7 +4458,7 @@ save_ldflags="$LDFLAGS" # Extract the first word of "Magick-config --version", so it can be a program name with args. set dummy Magick-config --version; ac_word=$2 -echo "$as_me:4398: checking for $ac_word" >&5 +echo "$as_me:4461: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_magickconfig+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4410,7 +4473,7 @@ test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_magickconfig="yes" -echo "$as_me:4413: found $ac_dir/$ac_word" >&5 +echo "$as_me:4476: found $ac_dir/$ac_word" >&5 break done @@ -4419,16 +4482,16 @@ fi magickconfig=$ac_cv_prog_magickconfig if test -n "$magickconfig"; then - echo "$as_me:4422: result: $magickconfig" >&5 + echo "$as_me:4485: result: $magickconfig" >&5 echo "${ECHO_T}$magickconfig" >&6 else - echo "$as_me:4425: result: no" >&5 + echo "$as_me:4488: result: no" >&5 echo "${ECHO_T}no" >&6 fi # Extract the first word of "wget --version", so it can be a program name with args. set dummy wget --version; ac_word=$2 -echo "$as_me:4431: checking for $ac_word" >&5 +echo "$as_me:4494: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_wget+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4443,7 +4506,7 @@ test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_wget="yes" -echo "$as_me:4446: found $ac_dir/$ac_word" >&5 +echo "$as_me:4509: found $ac_dir/$ac_word" >&5 break done @@ -4452,41 +4515,41 @@ fi wget=$ac_cv_prog_wget if test -n "$wget"; then - echo "$as_me:4455: result: $wget" >&5 + echo "$as_me:4518: result: $wget" >&5 echo "${ECHO_T}$wget" >&6 else - echo "$as_me:4458: result: no" >&5 + echo "$as_me:4521: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test $magickconfig = "no"; then - { echo "$as_me:4463: WARNING: *** Missing Magick-config (or it is not in the path). gpsmap will not be built. ***" >&5 + { echo "$as_me:4526: WARNING: *** Missing Magick-config (or it is not in the path). gpsmap will not be built. ***" >&5 echo "$as_me: WARNING: *** Missing Magick-config (or it is not in the path). gpsmap will not be built. ***" >&2;} elif test $wget = "no"; then - { echo "$as_me:4466: WARNING: *** Missing wget (or it is not in the path). gpsmap will not be build. ***" >&5 + { echo "$as_me:4529: WARNING: *** Missing wget (or it is not in the path). gpsmap will not be build. ***" >&5 echo "$as_me: WARNING: *** Missing wget (or it is not in the path). gpsmap will not be build. ***" >&2;} else CPPFLAGS="$CPPFLAGS `Magick-config --cppflags`" CXXFLAGS="$CXXFLAGS `Magick-config --cflags`" LDFLAGS="$CXXFLAGS `Magick-config --ldflags`" LIBS="$CXXFLAGS `Magick-config --libs`" - echo "$as_me:4473: checking for magick/api.h" >&5 + echo "$as_me:4536: checking for magick/api.h" >&5 echo $ECHO_N "checking for magick/api.h... $ECHO_C" >&6 if test "${ac_cv_header_magick_api_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4479 "configure" +#line 4542 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4483: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4546: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4489: \$? = $ac_status" >&5 + echo "$as_me:4552: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4505,10 +4568,10 @@ fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4508: result: $ac_cv_header_magick_api_h" >&5 +echo "$as_me:4571: result: $ac_cv_header_magick_api_h" >&5 echo "${ECHO_T}$ac_cv_header_magick_api_h" >&6 if test $ac_cv_header_magick_api_h = yes; then - echo "$as_me:4511: checking for WriteImage in -lMagick" >&5 + echo "$as_me:4574: checking for WriteImage in -lMagick" >&5 echo $ECHO_N "checking for WriteImage in -lMagick... $ECHO_C" >&6 if test "${ac_cv_lib_Magick_WriteImage+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4516,7 +4579,7 @@ ac_check_lib_save_LIBS=$LIBS LIBS="-lMagick $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4519 "configure" +#line 4582 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4535,16 +4598,16 @@ } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4538: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4601: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4541: \$? = $ac_status" >&5 + echo "$as_me:4604: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4544: \"$ac_try\"") >&5 + { (eval echo "$as_me:4607: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4547: \$? = $ac_status" >&5 + echo "$as_me:4610: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_Magick_WriteImage=yes else @@ -4555,7 +4618,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4558: result: $ac_cv_lib_Magick_WriteImage" >&5 +echo "$as_me:4621: result: $ac_cv_lib_Magick_WriteImage" >&5 echo "${ECHO_T}$ac_cv_lib_Magick_WriteImage" >&6 if test $ac_cv_lib_Magick_WriteImage = yes; then @@ -4564,12 +4627,12 @@ EOF gpslc="\$(GPSL)" else - { echo "$as_me:4567: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&5 + { echo "$as_me:4630: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&5 echo "$as_me: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&2;} fi else - { echo "$as_me:4572: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&5 + { echo "$as_me:4635: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&5 echo "$as_me: WARNING: *** Missing Imagemagick (or Imagemagick is not recent enough). gpsmap will not be built. ***" >&2;} fi @@ -4580,7 +4643,7 @@ magicktiny=`echo $magickversion | cut -d '.' -f 3` if test "$magickmajor" -lt 5 -o "$magickminor" -lt 4 -o "$magicktiny" -lt 4; then - { echo "$as_me:4583: WARNING: *** Old version of ImageMagick ($magickversion) found. This may cause problems. Building anyway. ***" >&5 + { echo "$as_me:4646: WARNING: *** Old version of ImageMagick ($magickversion) found. This may cause problems. Building anyway. ***" >&5 echo "$as_me: WARNING: *** Old version of ImageMagick ($magickversion) found. This may cause problems. Building anyway. ***" >&2;} magickold="true" fi @@ -4593,14 +4656,22 @@ if test "$wantgps" = "no"; then if test "$gpslc" != ""; then - { echo "$as_me:4596: WARNING: *** Disabling gpsmap because gps support is turned off. ***" >&5 + { echo "$as_me:4659: WARNING: *** Disabling gpsmap because gps support is turned off. ***" >&5 echo "$as_me: WARNING: *** Disabling gpsmap because gps support is turned off. ***" >&2;} gpslc="" fi fi +if test "$expatl" = "no"; then + if test "$gpslc" != ""; then + { echo "$as_me:4667: WARNING: *** Disabling gpsmap because expat was not found. ***" >&5 +echo "$as_me: WARNING: *** Disabling gpsmap because expat was not found. ***" >&2;} + gpslc="" + fi +fi + if test "$libz" = "no" -a "$gpslc" != ""; then - echo "$as_me:4603: checking for gzopen in -lz" >&5 + echo "$as_me:4674: checking for gzopen in -lz" >&5 echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 if test "${ac_cv_lib_z_gzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4608,7 +4679,7 @@ ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4611 "configure" +#line 4682 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4627,16 +4698,16 @@ } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4630: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4701: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4633: \$? = $ac_status" >&5 + echo "$as_me:4704: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4636: \"$ac_try\"") >&5 + { (eval echo "$as_me:4707: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4639: \$? = $ac_status" >&5 + echo "$as_me:4710: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_z_gzopen=yes else @@ -4647,7 +4718,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4650: result: $ac_cv_lib_z_gzopen" >&5 +echo "$as_me:4721: result: $ac_cv_lib_z_gzopen" >&5 echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 if test $ac_cv_lib_z_gzopen = yes; then @@ -4656,29 +4727,29 @@ EOF LIBS="$LIBS -lz" libz="yes" else - { echo "$as_me:4659: WARNING: Unable to find libz compression" >&5 + { echo "$as_me:4730: WARNING: Unable to find libz compression" >&5 echo "$as_me: WARNING: Unable to find libz compression" >&2;} fi fi -echo "$as_me:4665: checking for pthread.h" >&5 +echo "$as_me:4736: checking for pthread.h" >&5 echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6 if test "${ac_cv_header_pthread_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4671 "configure" +#line 4742 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4675: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4746: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4681: \$? = $ac_status" >&5 + echo "$as_me:4752: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4697,10 +4768,10 @@ fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:4700: result: $ac_cv_header_pthread_h" >&5 +echo "$as_me:4771: result: $ac_cv_header_pthread_h" >&5 echo "${ECHO_T}$ac_cv_header_pthread_h" >&6 if test $ac_cv_header_pthread_h = yes; then - echo "$as_me:4703: checking for pthread_create in -lpthread" >&5 + echo "$as_me:4774: checking for pthread_create in -lpthread" >&5 echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6 if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4708,7 +4779,7 @@ ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 4711 "configure" +#line 4782 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -4727,16 +4798,16 @@ } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:4730: \"$ac_link\"") >&5 +if { (eval echo "$as_me:4801: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:4733: \$? = $ac_status" >&5 + echo "$as_me:4804: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:4736: \"$ac_try\"") >&5 + { (eval echo "$as_me:4807: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4739: \$? = $ac_status" >&5 + echo "$as_me:4810: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthread_pthread_create=yes else @@ -4747,7 +4818,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:4750: result: $ac_cv_lib_pthread_pthread_create" >&5 +echo "$as_me:4821: result: $ac_cv_lib_pthread_pthread_create" >&5 echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6 if test $ac_cv_lib_pthread_pthread_create = yes; then @@ -4756,12 +4827,12 @@ EOF else - { echo "$as_me:4759: WARNING: *** Disabling gpsmap because threads support not present. ***" >&5 + { echo "$as_me:4830: WARNING: *** Disabling gpsmap because threads support not present. ***" >&5 echo "$as_me: WARNING: *** Disabling gpsmap because threads support not present. ***" >&2;} fi else - { echo "$as_me:4764: WARNING: *** Disabling gpsmap because threads support not present. ***" >&5 + { echo "$as_me:4835: WARNING: *** Disabling gpsmap because threads support not present. ***" >&5 echo "$as_me: WARNING: *** Disabling gpsmap because threads support not present. ***" >&2;} fi @@ -4846,7 +4917,7 @@ : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:4849: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:4920: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -5019,7 +5090,7 @@ echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:5022: error: ambiguous option: $1 + { { echo "$as_me:5093: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} @@ -5050,12 +5121,12 @@ 'config.h' ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; # This is an error. - -*) { { echo "$as_me:5053: error: unrecognized option: $1 + -*) { { echo "$as_me:5124: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; - *) { { echo "$as_me:5058: error: invalid argument: $1" >&5 + *) { { echo "$as_me:5129: error: invalid argument: $1" >&5 echo "$as_me: error: invalid argument: $1" >&2;} { (exit 1); exit 1; }; };; esac @@ -5304,7 +5375,7 @@ esac if test x"$ac_file" != x-; then - { echo "$as_me:5307: creating $ac_file" >&5 + { echo "$as_me:5378: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -5322,7 +5393,7 @@ -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:5325: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:5396: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -5335,7 +5406,7 @@ echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5338: error: cannot find input file: $f" >&5 + { { echo "$as_me:5409: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5396,7 +5467,7 @@ * ) ac_file_in=$ac_file.in ;; esac - test x"$ac_file" != x- && { echo "$as_me:5399: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:5470: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -5407,7 +5478,7 @@ -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:5410: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:5481: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -5420,7 +5491,7 @@ echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:5423: error: cannot find input file: $f" >&5 + { { echo "$as_me:5494: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -5537,7 +5608,7 @@ rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:5540: $ac_file is unchanged" >&5 + { echo "$as_me:5611: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ @@ -5641,7 +5712,7 @@ # parts of a large source tree are present. test -d $srcdir/$ac_subdir || continue - { echo "$as_me:5644: configuring in $ac_subdir" >&5 + { echo "$as_me:5715: configuring in $ac_subdir" >&5 echo "$as_me: configuring in $ac_subdir" >&6;} case $srcdir in .) ;; @@ -5663,7 +5734,7 @@ if test -d ./$ac_subdir; then :; else - { { echo "$as_me:5666: error: cannot create \`pwd\`/$ac_subdir" >&5 + { { echo "$as_me:5737: error: cannot create \`pwd\`/$ac_subdir" >&5 echo "$as_me: error: cannot create \`pwd\`/$ac_subdir" >&2;} { (exit 1); exit 1; }; } fi @@ -5694,7 +5765,7 @@ elif test -f $ac_sub_srcdir/configure.in; then ac_sub_configure=$ac_configure else - { echo "$as_me:5697: WARNING: no configuration information is in $ac_subdir" >&5 + { echo "$as_me:5768: WARNING: no configuration information is in $ac_subdir" >&5 echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2;} ac_sub_configure= fi @@ -5708,12 +5779,12 @@ ac_sub_cache_file=$ac_dots$cache_file ;; esac - { echo "$as_me:5711: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" >&5 + { echo "$as_me:5782: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" >&5 echo "$as_me: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" >&6;} # The eval makes quoting arguments work. eval $ac_sub_configure $ac_sub_configure_args \ --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir || - { { echo "$as_me:5716: error: $ac_sub_configure failed for $ac_subdir" >&5 + { { echo "$as_me:5787: error: $ac_sub_configure failed for $ac_subdir" >&5 echo "$as_me: error: $ac_sub_configure failed for $ac_subdir" >&2;} { (exit 1); exit 1; }; } fi @@ -5812,6 +5883,12 @@ echo " WARNING: Old version of ImageMagick." fi fi +echo -n " Expat Library: " +if test "$expatl" = "no"; then + echo "no" +else + echo "yes" +fi echo -n " libz compression: " if test "$libz" = "yes"; then echo "yes" @@ -5837,7 +5914,7 @@ vertiny=`uname -r | cut -d '.' -f 3 | cut -f 1 -d-` if test "$verminor" = "4" -a "$vertiny" -lt 16 ; then - { echo "$as_me:5840: WARNING: There have been a number of major improvements in the linux-wireless extentions and in the aironet drivers in recent versions. It is reccomended that you run at least kernel version 2.4.16" >&5 + { echo "$as_me:5917: WARNING: There have been a number of major improvements in the linux-wireless extentions and in the aironet drivers in recent versions. It is reccomended that you run at least kernel version 2.4.16" >&5 echo "$as_me: WARNING: There have been a number of major improvements in the linux-wireless extentions and in the aironet drivers in recent versions. It is reccomended that you run at least kernel version 2.4.16" >&2;} fi diff -u kismet-2.2.2/configure.in kismet-devel/configure.in --- kismet-2.2.2/configure.in Thu May 16 22:53:53 2002 +++ kismet-devel/configure.in Wed Jun 5 00:41:59 2002 @@ -495,6 +495,13 @@ fi # gpsmap checks + +# Check for expat +expatl=no +AC_CHECK_LIB([expat], [XML_GetCurrentLineNumber], + AC_DEFINE(HAVE_EXPAT, 1, Expat XML library) expatl=yes, + AC_MSG_WARN(*** Missing Expat XML library. gpsmap will not be built. ***)) + # Check for imagemagick save_cppflags="$CPPFLAGS" save_cxxflags="$CXXFLAGS" @@ -540,6 +547,13 @@ fi fi +if test "$expatl" = "no"; then + if test "$gpslc" != ""; then + AC_MSG_WARN(*** Disabling gpsmap because expat was not found. ***) + gpslc="" + fi +fi + if test "$libz" = "no" -a "$gpslc" != ""; then AC_CHECK_LIB([z], [gzopen], AC_DEFINE(HAVE_LIBZ, 1, Libz compression lib) LIBS="$LIBS -lz" libz="yes", @@ -648,6 +662,12 @@ if test "$magickold" = "yes"; then echo " WARNING: Old version of ImageMagick." fi +fi +echo -n " Expat Library: " +if test "$expatl" = "no"; then + echo "no" +else + echo "yes" fi echo -n " libz compression: " if test "$libz" = "yes"; then diff -u kismet-2.2.2/cursesfront.cc kismet-devel/cursesfront.cc --- kismet-2.2.2/cursesfront.cc Tue Apr 2 20:36:53 2002 +++ kismet-devel/cursesfront.cc Mon May 27 14:48:20 2002 @@ -210,18 +210,18 @@ pos += 3; char atype; - if (net->atype == address_dhcp) + if (net->ipdata.atype == address_dhcp) atype = 'D'; - else if (net->atype == address_arp) + else if (net->ipdata.atype == address_arp) atype = 'A'; - else if (net->atype == address_udp) + else if (net->ipdata.atype == address_udp) atype = 'U'; else atype = ' '; snprintf(statstr, 6, "%c%c%c%c%c", atype, - net->octets != 0 ? net->octets + '0' : ' ', + net->ipdata.octets != 0 ? net->ipdata.octets + '0' : ' ', net->cisco_equip.size() > 0 ? 'C' : ' ', ' ', ' '); Only in kismet-2.2.2: cursesfront.o Common subdirectories: kismet-2.2.2/docs and kismet-devel/docs Only in kismet-devel: expat.cc Only in kismet-devel: expat.h Common subdirectories: kismet-2.2.2/extra and kismet-devel/extra diff -u kismet-2.2.2/frontend.cc kismet-devel/frontend.cc --- kismet-2.2.2/frontend.cc Mon Apr 22 23:01:04 2002 +++ kismet-devel/frontend.cc Fri Jun 7 18:32:15 2002 @@ -133,15 +133,15 @@ dnet->virtnet.beacon_info = ""; dnet->virtnet.llc_packets = dnet->virtnet.data_packets = dnet->virtnet.crypt_packets = dnet->virtnet.interesting_packets = dnet->virtnet.channel = - dnet->virtnet.beacon; + dnet->virtnet.beacon = 0; dnet->virtnet.wep = -1; dnet->virtnet.cloaked = -1; - dnet->virtnet.atype = address_none; - memset(dnet->virtnet.range_ip, 0, 4); - memset(dnet->virtnet.mask, 0, 4); - memset(dnet->virtnet.gate_ip, 0, 4); - dnet->virtnet.octets = 4; + dnet->virtnet.ipdata.atype = address_none; + memset(dnet->virtnet.ipdata.range_ip, 0, 4); + memset(dnet->virtnet.ipdata.mask, 0, 4); + memset(dnet->virtnet.ipdata.gate_ip, 0, 4); + dnet->virtnet.ipdata.octets = 4; dnet->virtnet.last_time = dnet->virtnet.first_time = 0; dnet->virtnet.bssid = ""; dnet->virtnet.maxrate = 0; @@ -208,21 +208,23 @@ if (dnet->virtnet.maxrate == 0 || dnet->virtnet.maxrate < wnet->maxrate) dnet->virtnet.maxrate = wnet->maxrate; - if (wnet->atype > address_none) { + if (wnet->ipdata.atype > address_none) { int oct; - for (oct = 0; oct < dnet->virtnet.octets && oct < wnet->octets; oct++) { - - if (dnet->virtnet.range_ip[oct] == 0) - dnet->virtnet.range_ip[oct] = wnet->range_ip[oct]; - else if (dnet->virtnet.range_ip[oct] != wnet->range_ip[oct] || - wnet->range_ip[oct] == 0) { - dnet->virtnet.range_ip[oct] = 0; - oct--; + for (oct = 0; oct < dnet->virtnet.ipdata.octets && oct < wnet->ipdata.octets && oct < 4; oct++) { + if (dnet->virtnet.ipdata.range_ip[oct] == 0 && + wnet->ipdata.range_ip[oct] != 0) + dnet->virtnet.ipdata.range_ip[oct] = wnet->ipdata.range_ip[oct]; + else if (dnet->virtnet.ipdata.range_ip[oct] != wnet->ipdata.range_ip[oct] || + wnet->ipdata.range_ip[oct] == 0) { + dnet->virtnet.ipdata.range_ip[oct] = 0; + if (oct != 0) + oct--; break; } } - dnet->virtnet.octets = oct; - dnet->virtnet.atype = address_group; + + dnet->virtnet.ipdata.octets = oct; + dnet->virtnet.ipdata.atype = address_group; } } @@ -239,6 +241,8 @@ dnet->virtnet.bssid += ":"; } + + MatchBestManuf(&dnet->virtnet); // Update the group name if it's and the ssid is set if (dnet->name == NOSSID && dnet->virtnet.ssid != NOSSID) { diff -u kismet-2.2.2/frontend.h kismet-devel/frontend.h --- kismet-2.2.2/frontend.h Sat May 4 15:46:39 2002 +++ kismet-devel/frontend.h Fri May 17 09:41:36 2002 @@ -16,6 +16,7 @@ #include "packet.h" #include "tcpclient.h" #include "packetracker.h" +#include "manuf.h" enum sort_type { sort_auto, sort_channel, sort_first, sort_first_dec, Only in kismet-2.2.2: frontend.o Only in kismet-2.2.2: genericsource.o Only in kismet-2.2.2: getopt.o diff -u kismet-2.2.2/gpsd.cc kismet-devel/gpsd.cc --- kismet-2.2.2/gpsd.cc Mon May 13 16:35:20 2002 +++ kismet-devel/gpsd.cc Sun May 26 18:03:15 2002 @@ -7,6 +7,7 @@ sock = -1; lat = lon = alt = spd = 0; mode = -1; + sock = -1; errstr[0] = '\0'; data[0] = '\0'; @@ -137,7 +138,7 @@ spd = spd * (6076.12 / 5280); - alt = alt * 3.3; + // alt = alt * 3.3; // Zero the buffer buf[0] = '\0'; Only in kismet-2.2.2: gpsd.o diff -u kismet-2.2.2/gpsdump.cc kismet-devel/gpsdump.cc --- kismet-2.2.2/gpsdump.cc Tue Apr 2 11:35:27 2002 +++ kismet-devel/gpsdump.cc Fri Jun 7 12:38:21 2002 @@ -5,31 +5,10 @@ GPSDump::GPSDump() { num_packets = 0; - num_networks = 0; gpsf = NULL; } -// Fit whatever the system defines 'timeval' as into our file -// struct -time_hdr GPSDump::CurTimeHdr() { - timeval ts; - time_hdr ret; - - gettimeofday(&ts, NULL); - - ret.tv_sec = ts.tv_sec; - ret.tv_usec = ts.tv_usec; - - return ret; -} - -// Convert a float to primary and mantissa for storage in consistent manner -void GPSDump::Float2Pair(float in_float, int16_t *primary, int64_t *mantissa) { - *primary = (int) in_float; - *mantissa = (long) (1000000 * ((in_float) - *primary)); -} - -int GPSDump::OpenDump(const char *in_fname) { +int GPSDump::OpenDump(const char *in_fname, const char *in_netfname) { if ((gpsf = fopen(in_fname, "wb")) == NULL) { snprintf(errstr, 1024, "GPSDump unable to open file: %s", strerror(errno)); @@ -38,32 +17,17 @@ fname = in_fname; - // Write the header data - file_hdr fhdr; - memset(&fhdr, 0, sizeof(file_hdr)); - - fhdr.magic = GPS_MAGIC; - fhdr.version = GPS_VERSION; - fhdr.start = CurTimeHdr(); - - if (fwrite(&fhdr, sizeof(file_hdr), 1, gpsf) < 1) { - snprintf(errstr, 1024, "GPSDump unable to write file header: %s", - strerror(errno)); - return errno; - } - - // Write the network header block - net_hdr nblk[HEADER_NUM]; + // Write the XML headers + fprintf(gpsf, "\n\n\n"); - memset(&nblk, 0, sizeof(net_hdr) * HEADER_NUM); + // Write the start of the run + time_t cur_time = time(0); - for (int x = 0; x < HEADER_NUM; x++) - nblk[x].number = x; + fprintf(gpsf, "\n\n", + GPS_VERSION, ctime(&cur_time)); - if (fwrite(&nblk, sizeof(net_hdr), HEADER_NUM, gpsf) < 1) { - snprintf(errstr, 1024, "GPSDump unable to write network block header: %s", - strerror(errno)); - return errno; + if (in_netfname != NULL) { + fprintf(gpsf, " %s\n\n", in_netfname); } return 1; @@ -72,6 +36,8 @@ int GPSDump::CloseDump(int in_unlink) { int ret = 1; + fprintf(gpsf, "\n"); + if (gpsf) fclose(gpsf); @@ -94,136 +60,42 @@ if (gps->FetchMode() < 2) return 0; - int netnum = HEADER_NUM; - data_pkt dpkt; - memset(&dpkt, 0, sizeof(data_pkt)); + timeval ts; + gettimeofday(&ts, NULL); + + // Split the floats + gps->FetchLoc(&lat, &lon, &alt, &spd, &fix); if (in_packinfo == NULL) { - dpkt.number = (uint16_t) HEADER_NUM; + int sig = 0, qual = 0, noise = 0; if (time(0) - last_info.time < decay && last_info.quality != -1) { - dpkt.quality = last_info.quality; - dpkt.power = last_info.signal; - dpkt.noise = last_info.noise; - } else { - dpkt.quality = 0; - dpkt.power = 0; - dpkt.noise = 0; + sig = last_info.signal; + qual = last_info.quality; + noise = last_info.noise; } + fprintf(gpsf, " \n", + gps_track_bssid, + (long int) ts.tv_sec, (long int) ts.tv_usec, + lat, lon, alt, spd, fix, + sig, qual, noise); } else { - // Are we hashed already? - netnum = FindOrHashNet(in_packinfo); - if (netnum < 0) - return -1; - - dpkt.number = netnum; - dpkt.quality = in_packinfo->quality; - dpkt.power = in_packinfo->signal; - dpkt.noise = in_packinfo->noise; - } - - // Split the floats - gps->FetchLoc(&lat, &lon, &alt, &spd, &fix); - - Float2Pair(lat, &dpkt.lat, &dpkt.lat_mant); - Float2Pair(lon, &dpkt.lon, &dpkt.lon_mant); - Float2Pair(alt, &dpkt.alt, &dpkt.alt_mant); - Float2Pair(spd, &dpkt.spd, &dpkt.spd_mant); - dpkt.fix = fix; - dpkt.ts = CurTimeHdr(); + fprintf(gpsf, " \n", + Packetracker::Mac2String(in_packinfo->bssid_mac, ':').c_str(), + (long int) ts.tv_sec, (long int) ts.tv_usec, + lat, lon, alt, spd, fix, + in_packinfo->signal, in_packinfo->quality, in_packinfo->noise); - num_packets++; - - if (fwrite(&dpkt, sizeof(data_pkt), 1, gpsf) < 1) { - snprintf(errstr, 1024, "GPSDump unable to write network data element: %s", - strerror(errno)); - return errno; } num_packets++; - return netnum; -} - -// Find our map, or insert us into the map and return our new number. -int GPSDump::FindOrHashNet(packet_info *in_packinfo) { - string macaddr = Packetracker::Mac2String(in_packinfo->bssid_mac, ':'); - int ret = 0; - - if (bssid_map.find(macaddr) == bssid_map.end()) { - if (num_networks >= HEADER_NUM) { - snprintf(errstr, 1024, "GPSDump unable to add new network. Too many networks in this file."); - return -1; - } - - ret = num_networks; - num_networks++; - bssid_map[macaddr] = ret; - - // Store the offset, calculate the new one, and jump to it - fpos_t old_pos; - fgetpos(gpsf, &old_pos); - - long new_pos = (long) sizeof(file_hdr) + (sizeof(net_hdr) * ret); - fseek(gpsf, new_pos, SEEK_SET); - - net_hdr nhdr; - memset(&nhdr, 0, sizeof(net_hdr)); - nhdr.number = ret; - memcpy(nhdr.bssid, in_packinfo->bssid_mac, MAC_LEN); - - if (in_packinfo->ssid[0] != '\0') { - memcpy(nhdr.ssid, in_packinfo->ssid, SSID_SIZE); - ssid_map[macaddr] = ret; - } - - if (fwrite(&nhdr, sizeof(net_hdr), 1, gpsf) < 1) { - snprintf(errstr, 1024, "GPSDump unable to write network block header: %s", - strerror(errno)); - return errno; - } - - fsetpos(gpsf, &old_pos); - - return ret; - - } else { - // If we don't know the ssid, fill it in and write it back into the file. - if (ssid_map.find(macaddr) == ssid_map.end() && - in_packinfo->ssid[0] != '\0') { - - ret = bssid_map[macaddr]; - - ssid_map[macaddr] = ret; - - // Store the offset, calculate the new one, and jump to it - fpos_t old_pos; - fgetpos(gpsf, &old_pos); - - long new_pos = (long) sizeof(file_hdr) + (sizeof(net_hdr) * ret); - fseek(gpsf, new_pos, SEEK_SET); - - net_hdr nhdr; - memset(&nhdr, 0, sizeof(net_hdr)); - nhdr.number = ret; - memcpy(nhdr.bssid, in_packinfo->bssid_mac, MAC_LEN); - - memcpy(nhdr.ssid, in_packinfo->ssid, SSID_SIZE); - - if (fwrite(&nhdr, sizeof(net_hdr), 1, gpsf) < 1) { - snprintf(errstr, 1024, "GPSDump unable to write network block header: %s", - strerror(errno)); - return errno; - } - - fsetpos(gpsf, &old_pos); - } - - return bssid_map[macaddr]; - } - - return -1; + return 1; } #endif diff -u kismet-2.2.2/gpsdump.h kismet-devel/gpsdump.h --- kismet-2.2.2/gpsdump.h Tue Apr 2 11:17:18 2002 +++ kismet-devel/gpsdump.h Mon Jun 10 17:08:57 2002 @@ -45,24 +45,29 @@ // Link to decay rate in kismet_server.cc extern int decay; -#define GPS_VERSION 4 +#define GPS_VERSION 5 -// Lets just pretend v3 never existed. +#define gps_track_bssid "GP:SD:TR:AC:KL:OG" -// Sacred cows make the best hamburger. -#ifndef WORDS_BIGENDIAN -// Little endian magic -#define GPS_MAGIC 0xDEADBEEF -#else -// Big endian magic -#define GPS_MAGIC 0xEFEBADDE -#endif - -// Number of networks in the header -#define HEADER_NUM 4096 -// Offset of the data segment -#define DATA_OFFSET (sizeof(GPSDump::file_hdr) + (sizeof(GPSDump::net_hdr) * HEADER_NUM)) +typedef struct { + char bssid[MAC_STR_LEN]; + + long tv_sec; + long tv_usec; + + float lat; + float lon; + float alt; + float spd; + + int fix; + int signal; + int quality; + int noise; +} gps_point; + +/* typedef struct { int32_t tv_sec; int32_t tv_usec; @@ -158,7 +163,8 @@ int64_t spd_mant; int16_t fix; time_hdr ts; -} data_pkt_v1; + } data_pkt_v1; + */ class GPSDump { public: @@ -166,8 +172,7 @@ char *FetchError() { return(errstr); }; - - int OpenDump(const char *in_fname); + int OpenDump(const char *in_fname, const char *in_netfname); int CloseDump(int in_unlink); void AddGPS(GPSD *in_gps) { gps = in_gps; }; @@ -175,19 +180,10 @@ int DumpPacket(packet_info *in_packinfo); protected: - time_hdr CurTimeHdr(); - void Float2Pair(float in_float, int16_t *primary, int64_t *mantissa); - int FindOrHashNet(packet_info *in_packinfo); - int num_packets; - int num_networks; FILE *gpsf; const char *fname; char errstr[1024]; - - map bssid_map; - // Our redundancy to record SSID's as they show up - map ssid_map; GPSD *gps; Only in kismet-2.2.2: gpsdump.o Only in kismet-2.2.2: gpsmap diff -u kismet-2.2.2/gpsmap.cc kismet-devel/gpsmap.cc --- kismet-2.2.2/gpsmap.cc Tue May 14 00:41:20 2002 +++ kismet-devel/gpsmap.cc Thu Jun 13 22:52:47 2002 @@ -26,10 +26,14 @@ #include #include #include +#include #include #include +#include "configfile.h" #include "gpsdump.h" +#include "expat.h" +#include "manuf.h" #define MAJOR 2 #define MINOR 2 @@ -39,6 +43,8 @@ #define OldMagickLib #endif +const char *config_base = "kismet.conf"; + const char url_template[] = "http://www.mapblast.com/gif?&CT=%f:%f:%ld&IC=&W=%d&H=%d&FAM=myblast&LB=%s"; const char download_template[] = "wget \"%s\" -O %s"; @@ -49,6 +55,7 @@ // distance (in feet) before we throttle a network and discard it const unsigned int horiz_throttle = 75000; +//const unsigned int horiz_throttle = 850; // Image scales we use long int scales[] = { 1000, 2000, 5000, 10000, 20000, 30000, 50000, 60000, 70000, 75000, 80000, @@ -102,45 +109,94 @@ unsigned int map_width = 1280; unsigned int map_height = 1024; -int draw_opacity, draw_track, draw_bounds, draw_range, draw_interpolated, +int draw_opacity, draw_track, draw_bounds, draw_range, draw_interpolated, draw_hull, draw_scatter, draw_legend, convert_greyscale, keep_gif, draw_center, center_dot, verbose, interpolation_res; int sample_points; +// points .. replaced by gpspoint +/* +struct point { + double x, y, z; + }; + */ + +// don't ask +struct hullPoint { + int x, y; + double angle; + string xy; + bool operator< (const hullPoint&) const; + bool operator() (const hullPoint&, const hullPoint&) const; +}; + +bool hullPoint::operator< (const hullPoint& op) const { + if (y == op.y) { + return x < op.x; + } + return y < op.y; +} + +bool hullPoint::operator() (const hullPoint& a, const hullPoint& b) const { /*FOLD00*/ + if (a.angle == b.angle) { + if (a.x == b.x) { + return a.y < b.y; + } + return a.x < b.x; + } + return a.angle < b.angle; +} + typedef struct gps_network { - net_hdr header; + // Wireless network w/ full details, loaded from the associated netfile xml + wireless_network *wnet; + + string bssid; - double max_lat; - double min_lat; - double max_lon; - double min_lon; - double max_alt; - double min_alt; + float max_lat; + float min_lat; + float max_lon; + float min_lon; + float max_alt; + float min_alt; int count; - double avg_lat, avg_lon, avg_alt, avg_spd; + float avg_lat, avg_lon, avg_alt, avg_spd; + + float diagonal_distance, altitude_distance; + + vector points; - double diagonal_distance, altitude_distance; + // Points w/in this network + // vector net_point; // Index to the netcolors table - int color_index; + string color_index; }; +// All networks we know about +map bssid_net_map; + +// All the networks we know about for drawing +map bssid_gpsnet_map; + typedef struct { int version; - double lat; - double lon; + + float lat; + float lon; + float alt; + float spd; + int power; unsigned int x, y; } track_data; // Array of network track arrays -unsigned int num_tracks; +unsigned int num_tracks = 0; vector< vector > track_vec; -// bssid map -map net_map; // Global average for map scaling gps_network global_map_avg; // Mapquest map scale @@ -160,16 +216,27 @@ pthread_mutex_t power_pos_lock; int *power_input_map; +// Filtered MAC's +string filter; +int invert_filter = 0; + +// color by wep instead of random +int color_wep = 0; +// Draw titles +int draw_title; + + /*FOLD00*/ // Forward prototypes string Mac2String(uint8_t *mac, char seperator); double rad2deg(double x); double earth_distance(double lat1, double lon1, double lat2, double lon2); double calcR (double lat); -void calcxy (double *posx, double *posy, double lat, double lon, double pixelfact, +void calcxy (double *posx, double *posy, double lat, double lon, double pixelfact, /*FOLD00*/ double zero_lat, double zero_long); long int BestMapScale(double tlat, double tlon, double blat, double blon); int ProcessGPSFile(char *in_fname); void AssignNetColors(); +void MergeNetData(vector in_netdata); void ProcessNetData(int in_printstats); void DrawNetTracks(Image *in_img, DrawInfo *in_di); void DrawNetCircles(Image *in_img, DrawInfo *in_di); @@ -178,8 +245,12 @@ void DrawNetCenterDot(Image *in_img, DrawInfo *in_di, int in_dotsize); int InverseWeight(int in_x, int in_y, int in_fuzz, double in_scale); void DrawNetPower(Image *in_img, DrawInfo *in_di); +void DrawNetHull(Image *in_img, DrawInfo *in_di); +void DrawNetScatterPlot(Image *in_img, DrawInfo *in_di, int in_dotsize); + +//forward here -string Mac2String(uint8_t *mac, char seperator) { +string Mac2String(uint8_t *mac, char seperator) { /*FOLD00*/ char tempstr[MAC_STR_LEN]; // There must be a better way to do this... @@ -195,16 +266,16 @@ string temp = tempstr; return temp; } - + /*FOLD00*/ // Faust Code to convert rad to deg and find the distance between two points // on the globe. Thanks, Faust. //const float M_PI = 3.14159; -double rad2deg(double x) { +double rad2deg(double x) { /*FOLD00*/ return x*M_PI/180.0; } -double earth_distance(double lat1, double lon1, double lat2, double lon2) { +double earth_distance(double lat1, double lon1, double lat2, double lon2) { /*FOLD00*/ /* const double radius = 6378150.0; //meters @@ -238,7 +309,7 @@ // centered on a given lat/lon. // This pulls the "real radius" of a lat, instead of a global guesstimate -double calcR (double lat) +double calcR (double lat) /*FOLD00*/ { double a = 6378.137, r, sc, x, y, z; double e2 = 0.081082 * 0.081082; @@ -271,7 +342,7 @@ /* Mapscale / pixelfact is meter / pixel */ #define PIXELFACT 2817.947378 -void calcxy (double *posx, double *posy, double lat, double lon, double pixelfact, +void calcxy (double *posx, double *posy, double lat, double lon, double pixelfact, /*FOLD00*/ double zero_lat, double zero_long) { double dif; @@ -292,7 +363,7 @@ //#endif // Find the best map scale for the 'rectangle' tlat,tlon blat,blon -long int BestMapScale(double tlat, double tlon, double blat, double blon) { +long int BestMapScale(double tlat, double tlon, double blat, double blon) { /*FOLD00*/ for (int x = 0; scales[x] != 0; x++) { /* if (((double) (scales[x] / PIXELFACT) * map_width > width) && @@ -323,7 +394,7 @@ #define geom_distance(a, b, x, y) sqrt(pow((double) (a) - (double) (x), 2) + pow((double) (b) - (double) (y), 2)) // Frank and Nielson's improved weighting algorithm -double WeightAlgo(int start_x, int start_y, int in_x, int in_y, double in_fuzz, double in_scale) { +double WeightAlgo(int start_x, int start_y, int in_x, int in_y, double in_fuzz, double in_scale) { /*FOLD00*/ // Step 1: Find 'r', the distance to the farthest interpolation point int min_x = 0, min_y = 0; @@ -374,11 +445,11 @@ return weight; } - + /*FOLD00*/ // Inverse weight calculations -- Shepard's with Frank and Nielson's improved weight // algorithm -int InverseWeight(int in_x, int in_y, int in_fuzz, double in_scale) { +int InverseWeight(int in_x, int in_y, int in_fuzz, double in_scale) { /*FOLD00*/ // fprintf(stderr, "Getting power on %d %d\n", in_x, in_y); @@ -422,465 +493,294 @@ } +void MergeNetData(vector in_netdata) { + for (unsigned int x = 0; x < in_netdata.size(); x++) { + wireless_network *inet = in_netdata[x]; + + if (bssid_net_map.find(inet->bssid) != bssid_net_map.end()) { + wireless_network *onet = bssid_net_map[inet->bssid]; + + if (onet->last_time < inet->last_time) { + // Update stuff if it's better in the newer data + onet->last_time = inet->last_time; + + if (onet->type > inet->type) + onet->type = inet->type; + if (inet->ssid != "") + onet->ssid = inet->ssid; + onet->channel = inet->channel; + if (inet->beacon_info != "") + onet->beacon_info = inet->beacon_info; + if (onet->ipdata.atype < inet->ipdata.atype) + memcpy(&onet->ipdata, &inet->ipdata, sizeof(net_ip_data)); + onet->cloaked = inet->cloaked; + onet->wep = inet->wep; + } -int ProcessGPSFile(char *in_fname) { - vector net_vec; -#ifdef HAVE_LIBZ - gzFile gpsfz; -#else - FILE *gpsf; -#endif - -#ifdef HAVE_LIBZ - if ((gpsfz = gzopen(in_fname, "rb")) == NULL) { -#else - if ((gpsf = fopen(in_fname, "rb")) == NULL) { -#endif - fprintf(stderr, "FATAL: Could not open data file.\n"); - return -1; - } - - file_hdr filhdr; + if (onet->first_time < inet->first_time) + onet->first_time = inet->first_time; - /* - if (fread(&filhdr, sizeof(file_hdr), 1, gpsf) < 1) { - fprintf(stderr, "FATAL: Could not read header.\n"); - return -1; + onet->llc_packets += inet->llc_packets; + onet->data_packets += inet->data_packets; + onet->crypt_packets += inet->crypt_packets; + onet->interesting_packets += inet->interesting_packets; + } else { + bssid_net_map[inet->bssid] = inet; } - */ -#ifdef HAVE_LIBZ - if (gzread(gpsfz, &filhdr, sizeof(file_hdr)) < (int) sizeof(file_hdr)) -#else - if (fread(&filhdr, sizeof(file_hdr), 1, gpsf) < 1) -#endif - { - fprintf(stderr, "FATAL: Could not read header.\n"); - return -1; } +} - if (filhdr.magic != GPS_MAGIC) { - fprintf(stderr, "FATAL: Invalid gpsdump magic on %s.\n", in_fname); - return -1; - } +int ProcessGPSFile(char *in_fname) { /*FOLD00*/ + FILE *gpsf; + int file_samples = 0; - printf("%s header version %d\n", in_fname, filhdr.version); - if (filhdr.version > 4) { - fprintf(stderr, "FATAL: Unsupported version %d.\n", filhdr.version); + if ((gpsf = fopen(in_fname, "r")) == NULL) { + fprintf(stderr, "FATAL: Could not open data file.\n"); return -1; } - net_hdr nethdr[HEADER_NUM]; - memset(nethdr, 0, sizeof(net_hdr) * HEADER_NUM); - - // Yes this is a nasty repetition of code. - // No I don't have a better way of doing it. - if (filhdr.version == 1) { - net_hdr_v1 nethdr_v1[254]; -#ifdef HAVE_LIBZ - if (gzread(gpsfz, &nethdr_v1, sizeof(net_hdr_v1) * 254) < (int) sizeof(net_hdr_v1) * 254) -#else - if (fread(&nethdr_v1, sizeof(net_hdr_v1), 254, gpsf) < 254) -#endif - { - fprintf(stderr, "FATAL: Could not read v1 network headers.\n"); - return -1; - } - - // These are easy since they didn't change but we'll read them seperately anyhow - for (int x = 0; x < 254; x++) { - /* - typedef struct { - uint8_t number; - uint8_t bssid[6]; - uint8_t ssid[SSID_SIZE]; - } net_hdr; - */ - - nethdr[x].number = nethdr_v1[x].number; - memcpy(nethdr[x].bssid, nethdr_v1[x].bssid, 6); - memcpy(nethdr[x].ssid, nethdr_v1[x].ssid, SSID_SIZE); - } - - } else if (filhdr.version == 2) { - net_hdr_v2 nethdr_v2[255]; -#ifdef HAVE_LIBZ - if (gzread(gpsfz, &nethdr_v2, sizeof(net_hdr_v2) * 254) < (int) sizeof(net_hdr_v2) * 254) -#else - if (fread(&nethdr_v2, sizeof(net_hdr_v2), 254, gpsf) < 254) -#endif - { - fprintf(stderr, "FATAL: Could not read v2 network headers.\n"); - return -1; - } - - // These are easy since they didn't change but we'll read them seperately anyhow - for (int x = 0; x < 254; x++) { - nethdr[x].number = nethdr_v2[x].number; - memcpy(nethdr[x].bssid, nethdr_v2[x].bssid, 6); - memcpy(nethdr[x].ssid, nethdr_v2[x].ssid, SSID_SIZE); - } - } else if (filhdr.version == 3) { - net_hdr_v3 nethdr_v3[254]; -#ifdef HAVE_LIBZ - if (gzread(gpsfz, &nethdr_v3, sizeof(net_hdr_v3) * 254) < (int) sizeof(net_hdr_v3) * 254) -#else - if (fread(&nethdr_v3, sizeof(net_hdr_v3), 254, gpsf) < 254) -#endif - { - fprintf(stderr, "FATAL: Could not read v3 network headers.\n"); - return -1; - } - - // These are easy since they didn't change but we'll read them seperately anyhow - for (int x = 0; x < 254; x++) { - nethdr[x].number = nethdr_v3[x].number; - memcpy(nethdr[x].bssid, nethdr_v3[x].bssid, 6); - memcpy(nethdr[x].ssid, nethdr_v3[x].ssid, SSID_SIZE); - } + fprintf(stderr, "NOTICE: Processing gps file '%s'\n", in_fname); - } else { -#ifdef HAVE_LIBZ - if (gzread(gpsfz, &nethdr, sizeof(net_hdr) * HEADER_NUM) < (int) sizeof(net_hdr) * HEADER_NUM) -#else - if (fread(&nethdr, sizeof(net_hdr), HEADER_NUM, gpsf) < HEADER_NUM) -#endif - { - fprintf(stderr, "FATAL: Could not read v4 network headers.\n"); - return -1; - } + vector file_points; + file_points = XMLFetchGpsList(gpsf); + if (file_points.size() == 0) { + fprintf(stderr, "WARNING: No sample points found in '%s'.\n", in_fname); } + // We handle the points themselves after we handle the network component - // Fill the network vector with empty networks - for (int x = 0; x < HEADER_NUM; x++) { - gps_network netw; - -// printf("Got header '%s'\n", nethdr[x].ssid); + file_samples = file_points.size(); - memset(&netw, 0, sizeof(gps_network)); + fclose(gpsf); - netw.header = nethdr[x]; - - /* - printf("got network header %d encode number %d '%s'\n", - x, netw.header.number, netw.header.ssid); - */ - - net_vec.push_back(netw); - } - - data_pkt dpkt; - data_pkt_v1 dpkt_v1; - data_pkt_v2 dpkt_v2; - - // Build a new track + // We have the file correctly, so add to our gps track count vector trak; track_vec.push_back(trak); num_tracks++; - int last_power = 0; - int power_count = 0; - - // Read all the data packets - /* - while (fread(&dpkt, sizeof(dpkt), 1, gpsf) > 0) { - */ - - int read_ret = 1; - - int file_samples = 0; - while (read_ret > 0) { - - file_samples++; - - if (filhdr.version == 1) { -#ifdef HAVE_LIBZ - read_ret = gzread(gpsfz, &dpkt_v1, sizeof(dpkt_v1)); - if (read_ret < (int) sizeof(dpkt_v1)) - break; - -#else - read_ret = fread(&dpkt_v1, sizeof(dpkt_v1), 1, gpsf); - if (read_ret < 1) - break; -#endif - - dpkt.number = dpkt_v1.number; - dpkt.lat = dpkt_v1.lat; - dpkt.lat_mant = dpkt_v1.lat_mant; - dpkt.lon = dpkt_v1.lon; - dpkt.lon_mant = dpkt_v1.lon_mant; - dpkt.alt = dpkt_v1.alt; - dpkt.alt_mant = dpkt_v1.alt_mant; - dpkt.spd = dpkt_v1.spd; - dpkt.spd_mant = dpkt_v1.spd_mant; - dpkt.fix = dpkt_v1.fix; - dpkt.power = 0; - memcpy(&dpkt.ts, &dpkt_v1.ts, sizeof(time_hdr)); - } else if (filhdr.version == 2 || filhdr.version == 3) { -#ifdef HAVE_LIBZ - read_ret = gzread(gpsfz, &dpkt_v2, sizeof(dpkt_v2)); - if (read_ret < (int) sizeof(dpkt_v2)) - break; -#else - read_ret = fread(&dpkt_v2, sizeof(dpkt_v2), 1, gpsf); - if (read_ret < 1) - break; -#endif - - dpkt.number = dpkt_v2.number; - dpkt.lat = dpkt_v2.lat; - dpkt.lat_mant = dpkt_v2.lat_mant; - dpkt.lon = dpkt_v2.lon; - dpkt.lon_mant = dpkt_v2.lon_mant; - dpkt.alt = dpkt_v2.alt; - dpkt.alt_mant = dpkt_v2.alt_mant; - dpkt.spd = dpkt_v2.spd; - dpkt.spd_mant = dpkt_v2.spd_mant; - dpkt.fix = dpkt_v2.fix; - dpkt.power = dpkt_v2.power; - memcpy(&dpkt.ts, &dpkt_v1.ts, sizeof(time_hdr)); - + // We have all our gps points loaded into the local struct now, so if they had a + // network file specified, load the networks from that and mesh it with the network + // data we already (may) have from ther files. + + if (XMLFetchGpsNetfile() != "") { + fprintf(stderr, "NOTICE: Reading associated network file, '%s'\n", XMLFetchGpsNetfile().c_str()); + if ((gpsf = fopen(XMLFetchGpsNetfile().c_str(), "r")) == NULL) { + fprintf(stderr, "WARNING: Could not open associated network xml file '%s\n", + XMLFetchGpsNetfile().c_str()); } else { -#ifdef HAVE_LIBZ - read_ret = gzread(gpsfz, &dpkt, sizeof(dpkt)); + vector file_networks; + file_networks = XMLFetchNetworkList(gpsf); + if (file_networks.size() != 0) { + // Do something with the networks + MergeNetData(file_networks); + } else { + fprintf(stderr, "WARNING: No network entries found in '%s'.\n", + XMLFetchGpsNetfile().c_str()); + } - if (read_ret < (int) sizeof(dpkt)) - break; + fclose(gpsf); + } + } -#else - read_ret = fread(&dpkt, sizeof(dpkt), 1, gpsf); + // Now that we have the network data (hopefully) loaded, we'll load the points and + // reference the networks for them. + int last_power = 0; + int power_count = 0; - if (read_ret < 1) - break; -#endif - } + for (unsigned int i = 0; i < file_points.size(); i++) { + // All we have to do here is push the points into the network (and make them + // one if it doesn't exist). We crunch all the data points in ProcessNetData + gps_network *gnet = NULL; + + // Don't process filtered networks at all. + if ((invert_filter == 0 && filter.find(file_points[i]->bssid) != string::npos) || + (invert_filter == 1 && filter.find(file_points[i]->bssid) == string::npos)) + continue; - // We can't trust packets that have no coordinate fix - if (dpkt.fix == 0) + // Don't process unfixed points at all + if (file_points[i]->fix < 2) continue; double lat, lon, alt, spd; + int fix; - // Convert the stored primary+mantissa into a double - lat = (double) dpkt.lat + ((double) dpkt.lat_mant / 1000000); - lon = (double) dpkt.lon + ((double) dpkt.lon_mant / 1000000); - alt = (double) dpkt.alt + ((double) dpkt.alt_mant / 1000000); - spd = (double) dpkt.spd + ((double) dpkt.spd_mant / 1000000); - - if (lat == 0 || lon == 0) - continue; + lat = file_points[i]->lat; + lon = file_points[i]->lon; + alt = file_points[i]->alt; + spd = file_points[i]->spd; + fix = file_points[i]->fix; - /* - if (Mac2String(net_vec[dpkt.number].header.bssid, ':') == "00:04:5A:0E:0E:62") - printf("WEIRD: Got %3.6fx%3.6f fix %d for weirdo network in %s.\n", - lat, lon, dpkt.fix, in_fname); - */ - - // Add to the global average -- NOTE -- This will need to check for what - // SSIDs to use to scale correctly global_map_avg.avg_lat += lat; global_map_avg.avg_lon += lon; global_map_avg.avg_alt += alt; global_map_avg.avg_spd += spd; global_map_avg.count++; - // Don't calculate track data for map size if we're not drawing tracks. - if (!(draw_track == 0 && - ((dpkt.number == 0xFF && filhdr.version <= 3) || - (dpkt.number == HEADER_NUM && filhdr.version > 3)) )) { - if (lat > global_map_avg.max_lat || global_map_avg.max_lat == 0) - global_map_avg.max_lat = lat; - if (lat < global_map_avg.min_lat || global_map_avg.min_lat == 0) - global_map_avg.min_lat = lat; - - if (lon > global_map_avg.max_lon || global_map_avg.max_lon == 0) - global_map_avg.max_lon = lon; - if (lon < global_map_avg.min_lon || global_map_avg.min_lon == 0) - global_map_avg.min_lon = lon; - - if (alt > global_map_avg.max_alt || global_map_avg.max_alt == 0) - global_map_avg.max_alt = alt; - if (alt < global_map_avg.min_alt || global_map_avg.min_alt == 0) - global_map_avg.min_alt = alt; - } - - // Push the path into the current track vector - if ((dpkt.number == 0xFF && filhdr.version <= 3) || - (dpkt.number == HEADER_NUM && filhdr.version > 3)) { - track_data tdat; + if (lat > global_map_avg.max_lat || global_map_avg.max_lat == 0) + global_map_avg.max_lat = lat; + if (lat < global_map_avg.min_lat || global_map_avg.min_lat == 0) + global_map_avg.min_lat = lat; + + if (lon > global_map_avg.max_lon || global_map_avg.max_lon == 0) + global_map_avg.max_lon = lon; + if (lon < global_map_avg.min_lon || global_map_avg.min_lon == 0) + global_map_avg.min_lon = lon; + + if (alt > global_map_avg.max_alt || global_map_avg.max_alt == 0) + global_map_avg.max_alt = alt; + if (alt < global_map_avg.min_alt || global_map_avg.min_alt == 0) + global_map_avg.min_alt = alt; - // Junk unfixed packets - if (dpkt.fix < 2) - continue; + if (strncmp(file_points[i]->bssid, gps_track_bssid, MAC_STR_LEN) == 0) { + track_data tdat; tdat.x = 0; tdat.y = 0; tdat.lat = lat; tdat.lon = lon; + tdat.alt = alt; + tdat.spd = spd; - tdat.version = filhdr.version; + tdat.version = (int) XMLFetchGpsVersion(); - if (dpkt.power == last_power) { + // Filter power ratings + if (file_points[i]->signal == last_power) { if (power_count < 3) - tdat.power = dpkt.power; + tdat.power = file_points[i]->signal; else tdat.power = 0; power_count++; } else { - last_power = dpkt.power; + last_power = file_points[i]->signal; power_count = 0; - tdat.power = dpkt.power; + tdat.power = file_points[i]->signal; } if (tdat.power != 0) power_data = 1; track_vec[num_tracks-1].push_back(tdat); - } + } else if (bssid_gpsnet_map.find(file_points[i]->bssid) == bssid_gpsnet_map.end()) { + //printf("making new netork: %s\n", file_points[i]->bssid); + gnet = new gps_network; + + gnet->max_lat = gnet->min_lat = gnet->max_lon = + gnet->min_lon = gnet->max_alt = gnet->min_alt = 0; - // Enter it into our current vector - net_vec[dpkt.number].avg_lat += lat; - net_vec[dpkt.number].avg_lon += lon; - net_vec[dpkt.number].avg_alt += alt; - net_vec[dpkt.number].avg_spd += spd; - net_vec[dpkt.number].count++; + gnet->count = 0; - // Enter the max/min values - if (lat > net_vec[dpkt.number].max_lat || net_vec[dpkt.number].max_lat == 0) - net_vec[dpkt.number].max_lat = lat; + gnet->avg_lat = gnet->avg_lon = gnet->avg_alt = gnet->avg_spd = 0; - if (lat < net_vec[dpkt.number].min_lat || net_vec[dpkt.number].min_lat == 0) - net_vec[dpkt.number].min_lat = lat; + gnet->color_index = ""; - if (lon > net_vec[dpkt.number].max_lon || net_vec[dpkt.number].max_lon == 0) - net_vec[dpkt.number].max_lon = lon; + gnet->bssid = file_points[i]->bssid; - if (lon < net_vec[dpkt.number].min_lon || net_vec[dpkt.number].min_lon == 0) - net_vec[dpkt.number].min_lon = lon; + if (bssid_net_map.find(file_points[i]->bssid) != bssid_net_map.end()) + gnet->wnet = bssid_net_map[file_points[i]->bssid]; + else + gnet->wnet = NULL; - if (alt > net_vec[dpkt.number].max_alt || net_vec[dpkt.number].max_alt == 0) - net_vec[dpkt.number].max_alt = alt; + gnet->points.push_back(file_points[i]); - if (alt < net_vec[dpkt.number].min_alt || net_vec[dpkt.number].min_alt == 0) - net_vec[dpkt.number].min_alt = alt; + bssid_gpsnet_map[file_points[i]->bssid] = gnet; + + } else { + gnet = bssid_gpsnet_map[file_points[i]->bssid]; + gnet->points.push_back(file_points[i]); + } } - // Now transform our per-file list of 254 networks into the global BSSID records - for (unsigned int x = 0; x < net_vec.size(); x++) { - gps_network vec_iter = net_vec[x]; - string bssid = Mac2String(vec_iter.header.bssid, ':'); + if (verbose) + fprintf(stderr, "%s contains %d samples.\n", in_fname, file_samples); - // Skip data only networks - if (bssid == "00:00:00:00:00:00" || bssid == "FF:FF:FF:FF:FF:FF") - continue; + sample_points += file_samples; - if (vec_iter.count <= 0) - continue; + return 1; +} - // Make a new record or add to the existing one - if (net_map.find(bssid) == net_map.end()) { - net_map[bssid] = vec_iter; - } else { - gps_network map_iter = net_map[bssid]; +// Do all the math +void ProcessNetData(int in_printstats) { /*FOLD00*/ + // Convert the tracks to x,y + if (draw_track != 0) { + for (unsigned int vec = 0; vec < track_vec.size(); vec++) { + for (unsigned int x = 0; x < track_vec[vec].size(); x++) { + double track_tx, track_ty; + calcxy(&track_tx, &track_ty, track_vec[vec][x].lat, track_vec[vec][x].lon, + (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); - // Add the average data - map_iter.count += vec_iter.count; - map_iter.avg_lat += vec_iter.avg_lat; - map_iter.avg_lon += vec_iter.avg_lon; - map_iter.avg_alt += vec_iter.avg_alt; - map_iter.avg_spd += vec_iter.avg_spd; - - // Calc our new min and max - if (vec_iter.max_lat > map_iter.max_lat || map_iter.max_lat == 0) - map_iter.max_lat = vec_iter.max_lat; - if (vec_iter.min_lat < map_iter.min_lat || map_iter.min_lat == 0) - map_iter.min_lat = vec_iter.min_lat; - if (vec_iter.max_lon > map_iter.max_lon || map_iter.max_lon == 0) - map_iter.max_lon = vec_iter.max_lon; - if (vec_iter.min_lon < map_iter.min_lon || map_iter.min_lon == 0) - map_iter.min_lon = vec_iter.min_lon; - if (vec_iter.max_alt > map_iter.max_alt || map_iter.max_alt == 0) - map_iter.max_alt = vec_iter.max_alt; - if (vec_iter.min_alt < map_iter.min_alt || map_iter.min_alt == 0) - map_iter.min_alt = vec_iter.min_alt; + track_vec[vec][x].x = (int) track_tx; + track_vec[vec][x].y = (int) track_ty; + } - // And put it back in - net_map[bssid] = map_iter; + if (in_printstats) + printf("Track %d: %d samples.\n", vec, track_vec[vec].size()); } } - /* - fclose(gpsf); - */ -#ifdef HAVE_LIBZ - gzclose(gpsfz); -#else - fclose(gpsf); -#endif + printf("Processing %d networks.\n", bssid_gpsnet_map.size()); - if (verbose) - fprintf(stderr, "%s contains %d samples.\n", - in_fname, file_samples); + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - sample_points += file_samples; + gps_network *map_iter = x->second; - return 1; -} -// Do all the math -void ProcessNetData(int in_printstats) { + if (map_iter->points.size() <= 1) { + // printf("net %s only had <= 1 point.\n", map_iter->bssid.c_str()); + continue; + } - // Convert the tracks to x,y - for (unsigned int vec = 0; vec < track_vec.size(); vec++) { - for (unsigned int x = 0; x < track_vec[vec].size(); x++) { - double track_tx, track_ty; - calcxy(&track_tx, &track_ty, track_vec[vec][x].lat, track_vec[vec][x].lon, - (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); - - /* - if (draw_track == 1 && (track_ty < 0 || track_ty > map_height || track_tx < 0 || track_tx > map_width)) { - //printf("Out of bounds, %f,%f %f,%f fix\n", track_tx, track_ty, track_vec[vec][x].lat, track_vec[vec][x].lon); - continue; - } - */ + // Calculate the min/max and average sizes of this network + for (unsigned int y = 0; y < map_iter->points.size(); y++) { + float lat = map_iter->points[y]->lat; + float lon = map_iter->points[y]->lon; + float alt = map_iter->points[y]->alt; + float spd = map_iter->points[y]->spd; - track_vec[vec][x].x = (int) track_tx; - track_vec[vec][x].y = (int) track_ty; - } + //printf("Got %f %f %f %f\n", lat, lon, alt, spd); - if (in_printstats) - printf("Track %d: %d samples.\n", vec, track_vec[vec].size()); - } + map_iter->avg_lat += lat; + map_iter->avg_lon += lon; + map_iter->avg_alt += alt; + map_iter->avg_spd += spd; + map_iter->count++; - printf("Graphing %d networks.\n", net_map.size()); + // Enter the max/min values + if (lat > map_iter->max_lat || map_iter->max_lat == 0) + map_iter->max_lat = lat; - for (map::const_iterator x = net_map.begin(); - x != net_map.end(); ++x) { + if (lat < map_iter->min_lat || map_iter->min_lat == 0) + map_iter->min_lat = lat; - gps_network map_iter = x->second; + if (lon > map_iter->max_lon || map_iter->max_lon == 0) + map_iter->max_lon = lon; - if (map_iter.count <= 1) - continue; + if (lon < map_iter->min_lon || map_iter->min_lon == 0) + map_iter->min_lon = lon; - map_iter.diagonal_distance = earth_distance(map_iter.max_lat, map_iter.max_lon, - map_iter.min_lat, map_iter.min_lon); + if (alt > map_iter->max_alt || map_iter->max_alt == 0) + map_iter->max_alt = alt; - map_iter.altitude_distance = map_iter.max_alt - map_iter.min_alt; + if (alt < map_iter->min_alt || map_iter->min_alt == 0) + map_iter->min_alt = alt; + } + + map_iter->diagonal_distance = earth_distance(map_iter->max_lat, map_iter->max_lon, + map_iter->min_lat, map_iter->min_lon); + + map_iter->altitude_distance = map_iter->max_alt - map_iter->min_alt; - double avg_lat = (double) map_iter.avg_lat / map_iter.count; - double avg_lon = (double) map_iter.avg_lon / map_iter.count; - double avg_alt = (double) map_iter.avg_alt / map_iter.count; - double avg_spd = (double) map_iter.avg_spd / map_iter.count; - - map_iter.avg_lat = avg_lat; - map_iter.avg_lon = avg_lon; - map_iter.avg_alt = avg_alt; - map_iter.avg_spd = avg_spd; + double avg_lat = (double) map_iter->avg_lat / map_iter->count; + double avg_lon = (double) map_iter->avg_lon / map_iter->count; + double avg_alt = (double) map_iter->avg_alt / map_iter->count; + double avg_spd = (double) map_iter->avg_spd / map_iter->count; - net_map[Mac2String(map_iter.header.bssid, ':')] = map_iter; + map_iter->avg_lat = avg_lat; + map_iter->avg_lon = avg_lon; + map_iter->avg_alt = avg_alt; + map_iter->avg_spd = avg_spd; if (in_printstats) printf("Net: %s [%s]\n" @@ -897,38 +797,50 @@ " Avg Spd : %f\n" " H. Range: %f ft\n" " V. Range: %f ft\n", - map_iter.header.ssid, - Mac2String(map_iter.header.bssid, ':').c_str(), - map_iter.count, - map_iter.min_lat, map_iter.min_lon, - map_iter.max_lat, map_iter.max_lon, - map_iter.min_alt, map_iter.max_alt, - map_iter.avg_lat, map_iter.avg_lon, - map_iter.avg_alt, map_iter.avg_spd, - map_iter.diagonal_distance * 3.3, map_iter.altitude_distance); + map_iter->wnet == NULL ? "Unknown" : map_iter->wnet->ssid.c_str(), + map_iter->bssid.c_str(), + map_iter->count, + map_iter->min_lat, map_iter->min_lon, + map_iter->max_lat, map_iter->max_lon, + map_iter->min_alt, map_iter->max_alt, + map_iter->avg_lat, map_iter->avg_lon, + map_iter->avg_alt, map_iter->avg_spd, + map_iter->diagonal_distance * 3.3, map_iter->altitude_distance); } } -void AssignNetColors() { +void AssignNetColors() { /*FOLD00*/ int base_color = 1; - for (map::const_iterator x = net_map.begin(); - x != net_map.end(); ++x) { + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - gps_network map_iter = x->second; + gps_network *map_iter = x->second; - if (netcolors[base_color] == NULL) - base_color = 1; - - map_iter.color_index = base_color; + if (color_wep) { + if (map_iter->wnet != NULL) { + if (MatchBestManuf(map_iter->wnet) == manuf_max_score) { + map_iter->color_index = "#0000FF"; + } else if (map_iter->wnet->wep) { + map_iter->color_index = "#FF0000"; + } else { + map_iter->color_index = "#00FF00"; + } + } else { + map_iter->color_index = "#00FF00"; + } + } else { + if (netcolors[base_color] == NULL) + base_color = 1; - net_map[Mac2String(map_iter.header.bssid, ':')] = map_iter; + map_iter->color_index = netcolors[base_color]; - base_color++; + base_color++; + } } } -void DrawNetTracks(Image *in_img, DrawInfo *in_di) { +void DrawNetTracks(Image *in_img, DrawInfo *in_di) { /*FOLD00*/ // Our track color uint8_t track_r = 0x00, track_g = 0x00, track_b = 0xFF; char color_str[8]; @@ -941,7 +853,7 @@ // Generate the color we're drawing with snprintf(color_str, 8, "#%02X%02X%02X", track_r, track_g, track_b); - + #ifdef OldMagickLib QueryColorDatabase(color_str, &track_clr); #else @@ -962,17 +874,6 @@ // Initialize the previous track location vars - /* - double prev_tlat = 0, prev_tlon = 0; - prev_tlat = track_vec[vec][0].lat; - prev_tlon = track_vec[vec][0].lon; - - - double prev_tx, prev_ty; - calcxy(&prev_tx, &prev_ty, prev_tlat, prev_tlon, - (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); - */ - int prev_tx, prev_ty; prev_tx = track_vec[vec][0].x; prev_ty = track_vec[vec][0].y; @@ -1004,7 +905,7 @@ // problem and restart the track at the next position double distance; if ((distance = geom_distance(track_vec[vec][x].x, track_vec[vec][x].y, - prev_tx, prev_ty)) * (scale/PIXELFACT) > 50) { + prev_tx, prev_ty)) > 50) { prev_tx = -1; prev_ty = -1; continue; @@ -1021,86 +922,50 @@ } */ - /* - double track_tx, track_ty; - calcxy(&track_tx, &track_ty, track_vec[vec][x].lat, track_vec[vec][x].lon, - (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); - */ - snprintf(prim, 1024, "stroke-width %d line %d,%d %d,%d", track_width, prev_tx, prev_ty, track_vec[vec][x].x, track_vec[vec][x].y); - /* - (int) prev_tx, (int) prev_ty, - (int) track_tx, (int) track_ty); - */ - in_di->primitive = strdup(prim); DrawImage(in_img, in_di); - /* - prev_tlat = track_vec[vec][x].lat; - prev_tlon = track_vec[vec][x].lon; - - prev_tx = track_tx; - prev_ty = track_ty; - */ - prev_tx = track_vec[vec][x].x; prev_ty = track_vec[vec][x].y; } } } -void DrawNetCircles(Image *in_img, DrawInfo *in_di) { - for (map::const_iterator x = net_map.begin(); - x != net_map.end(); ++x) { +void DrawNetCircles(Image *in_img, DrawInfo *in_di) { /*FOLD00*/ + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - gps_network map_iter = x->second; + gps_network *map_iter = x->second; // Skip networks w/ no determined coordinates - if (map_iter.max_lat == 0) + if (map_iter->max_lat == 0) continue; - if (map_iter.diagonal_distance > horiz_throttle) + if (map_iter->diagonal_distance > horiz_throttle) continue; // Figure x, y of min on our hypothetical map double mapx, mapy; - calcxy (&mapx, &mapy, map_iter.avg_lat, map_iter.avg_lon, + calcxy (&mapx, &mapy, map_iter->avg_lat, map_iter->avg_lon, (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); - /* - printf(" Pixel factoring: %f\n", (double) 25000/PIXELFACT); - printf(" Radius: %f\n", calcR(net_vec[x].min_lat)); - printf(" Coords : %dx%d\n", (int) mapx, (int) mapy); - */ - double end_lat, end_lon; // Find the nearest corner of the bounding rectangle, this will determine // the size of our network circle - if (((map_iter.min_lat + map_iter.max_lat) / 2) < map_iter.avg_lat) - end_lat = map_iter.max_lat; + if (((map_iter->min_lat + map_iter->max_lat) / 2) < map_iter->avg_lat) + end_lat = map_iter->max_lat; else - end_lat = map_iter.min_lat; - if (((map_iter.min_lon + map_iter.max_lon)/ 2) < map_iter.avg_lon) - end_lon = map_iter.max_lon; + end_lat = map_iter->min_lat; + if (((map_iter->min_lon + map_iter->max_lon)/ 2) < map_iter->avg_lon) + end_lon = map_iter->max_lon; else - end_lon = map_iter.min_lon; - - /* - if ((map_iter.min_lat - avg_lat) < (map_iter.max_lat - avg_lat) && - (map_iter.min_lon - avg_lon) < (map_iter.max_lon - avg_lon)) { - end_lat = map_iter.min_lat; - end_lon = map_iter.min_lon; - } else { - end_lat = map_iter.max_lat; - end_lon = map_iter.min_lon; - } - */ + end_lon = map_iter->min_lon; double endx, endy; calcxy(&endx, &endy, end_lat, end_lon, @@ -1111,85 +976,179 @@ PixelPacket netclr; #ifdef OldMagickLib - QueryColorDatabase(netcolors[map_iter.color_index], &netclr); + QueryColorDatabase(map_iter->color_index.c_str(), &netclr); #else { ExceptionInfo excep; - QueryColorDatabase(netcolors[map_iter.color_index], &netclr, &excep); + QueryColorDatabase(map_iter->color_index.c_str(), &netclr, &excep); } #endif in_di->fill = netclr; + in_di->stroke = netclr; char prim[1024]; snprintf(prim, 1024, "fill-opacity %d%% stroke-opacity %d%% circle %d,%d %d,%d", draw_opacity, draw_opacity, (int) mapx, (int) mapy, (int) endx, (int) endy); - /* + in_di->primitive = strdup(prim); + DrawImage(in_img, in_di); + } +} - printf("%s [%s] %s\n", map_iter.header.ssid, Mac2String(map_iter.header.bssid, ':').c_str(), - prim); +double clockwize( int x0, int y0, int x1, int y1, int x2, int y2) { /*FOLD00*/ + return ( x2 - x0 ) * ( y1 - y0 ) - ( x1 - x0 ) * ( y2 - y0 ); +} - if (Mac2String(map_iter.header.bssid, ':') == "00:40:96:23:B1:EB") { - printf("Flukey network:\n"); +void DrawNetHull(Image *in_img, DrawInfo *in_di) { /*FOLD00*/ + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - printf("color: %d\n", map_iter.color_index); + gps_network *map_iter = x->second; - snprintf(prim, 1024, "circle %d,%d %d,%d", - (int) mapx, (int) mapy, (int) endx, (int) endy); + // Skip networks w/ no determined coordinates + if (map_iter->max_lat == 0) + continue; - } + if (map_iter->diagonal_distance > horiz_throttle) + continue; - printf("%s\n", prim); - */ + map dim; + for (unsigned int x = 0; x < map_iter->points.size(); x++) { + gps_point *pt = map_iter->points[x]; + double mapx, mapy; + + calcxy (&mapx, &mapy, pt->lat, pt->lon, + (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); + + char mm1[64]; + snprintf(mm1, 64, "%d,%d", (int) mapx, (int) mapy); + string a = mm1; + hullPoint b; + b.x = (int) mapx; + b.y = (int) mapy; + b.angle = 0.0; + b.xy = a; + dim[a] = b; + } + // need at least 3 points for a hull - in_di->primitive = strdup(prim); - DrawImage(in_img, in_di); + //printf("\nPts: %d\n", dim.size()); + if (dim.size() < 3) + continue; + + // got the unique points, now we need to sort em + deque pts; + for (map::const_iterator i = dim.begin(); i != dim.end(); ++i) { + pts.push_back(i->second); + } + sort(pts.begin(), pts.end()); + + //start point for the hull + hullPoint start = pts[0]; + pts.pop_front(); + + //compute angles for pts + for (deque::iterator j = pts.begin(); j != pts.end(); ++j) { + j->angle = atan2( j->y - start.y, j->x - start.x ); + } + + //sort against angle + sort(pts.begin(), pts.end(), hullPoint() ); + + //build the hull + vector hull; + hull.push_back(start); + hullPoint tmp = pts[0]; + hull.push_back(tmp); + pts.push_front(start); + + for (unsigned int k = 2; k < pts.size() ; k++) { + while (clockwize(hull[hull.size()-2].x, + hull[hull.size()-2].y, + hull[hull.size()-1].x, + hull[hull.size()-1].y, + pts[k].x, + pts[k].y) >= 0 + && hull.size() >= 2) { + hull.pop_back(); + } + hull.push_back(pts[k]); + } + if (hull.size() < 3) + continue; + + //wheh /* - printf("Drew circle.\n"); + printf("Hull:\n"); + for(vector::const_iterator l = hull.begin(); l != hull.end(); ++l) { + printf("x: %d y: %d a: %f\n", l->x, l->y, l->angle); + } + printf("orig:\n"); + for(deque::const_iterator l = pts.begin(); l != pts.end(); ++l) { + printf("x: %d y: %d a: %f\n", l->x, l->y, l->angle); + } */ - /* - di->fill = black; - snprintf(prim, 1024, "text %d,%d \"%s %s\"", - (int) mapx, (int) mapy, - net_vec[x].header.ssid, - Mac2String(net_vec[x].header.bssid, ':').c_str()); - di->primitive = strdup(prim); - DrawImage(img, di); - */ + PixelPacket netclr; - /* - //d = sqrt[(x1-x2)^2 + (y1-y2)^2] - printf(" Px RLen : %d\n", (int) sqrt(pow((int) mapx - endx, 2) + pow((int) mapy - endy, 2))); - */ +#ifdef OldMagickLib + QueryColorDatabase(map_iter->color_index.c_str(), &netclr); +#else + { + ExceptionInfo excep; + QueryColorDatabase(map_iter->color_index.c_str(), &netclr, &excep); + } +#endif + + in_di->fill = netclr; + + string sep = ", "; + string pstr = ""; + for(vector::const_iterator l = hull.begin(); l != hull.end(); ++l) { + pstr = pstr + l->xy + sep; + } + pstr = pstr + start.xy; + char pstr2[2048]; + memset(pstr2, 0, sizeof(char)*2048); + pstr.copy(pstr2, string::npos); + + char prim[2048]; + snprintf(prim, 1024, "fill-opacity %d%% stroke-opacity %d%% polygon %s", + draw_opacity, draw_opacity, pstr2); + + //printf("%s\n", prim); + + in_di->primitive = strdup(prim); + DrawImage(in_img, in_di); } + } -void DrawNetBoundRects(Image *in_img, DrawInfo *in_di, int in_fill) { - for (map::const_iterator x = net_map.begin(); - x != net_map.end(); ++x) { +void DrawNetBoundRects(Image *in_img, DrawInfo *in_di, int in_fill) { /*FOLD00*/ + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - gps_network map_iter = x->second; + gps_network *map_iter = x->second; // Skip networks w/ no determined coordinates - if (map_iter.max_lat == 0) + if (map_iter->max_lat == 0) continue; - if (map_iter.diagonal_distance == 0 || map_iter.diagonal_distance > horiz_throttle) + if (map_iter->diagonal_distance == 0 || map_iter->diagonal_distance > horiz_throttle) continue; // Figure x, y of min on our hypothetical map double mapx, mapy; - calcxy (&mapx, &mapy, map_iter.max_lat, map_iter.max_lon, + calcxy (&mapx, &mapy, map_iter->max_lat, map_iter->max_lon, (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); double endx, endy; - calcxy(&endx, &endy, map_iter.min_lat, map_iter.min_lon, + calcxy(&endx, &endy, map_iter->min_lat, map_iter->min_lon, (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); double tlx, tly, brx, bry; @@ -1212,16 +1171,14 @@ if (in_fill) { PixelPacket netclr; - #ifdef OldMagickLib - QueryColorDatabase(netcolors[map_iter.color_index], &netclr); + QueryColorDatabase(map_iter->color_index.c_str(), &netclr); #else { ExceptionInfo excep; - QueryColorDatabase(netcolors[map_iter.color_index], &netclr, &excep); + QueryColorDatabase(map_iter->color_index.c_str(), &netclr, &excep); } #endif - in_di->fill = netclr; } @@ -1245,7 +1202,7 @@ } } -void DrawLegend(Image *in_img, DrawInfo *in_di) { +void DrawLegend(Image *in_img, DrawInfo *in_di) { /*FOLD00*/ @@ -1260,7 +1217,7 @@ unsigned int threadno; }; -void *PowerLine(void *arg) { +void *PowerLine(void *arg) { /*FOLD00*/ powerline_arg *parg = (powerline_arg *) arg; time_t startline; @@ -1308,7 +1265,7 @@ pthread_exit((void *) 0); } -void DrawNetPower(Image *in_img, DrawInfo *in_di, int in_res) { +void DrawNetPower(Image *in_img, DrawInfo *in_di, int in_res) { /*FOLD00*/ PixelPacket point_clr; pthread_attr_t attr; @@ -1417,23 +1374,23 @@ } void DrawNetCenterDot(Image *in_img, DrawInfo *in_di, int in_dotsize) { - for (map::const_iterator x = net_map.begin(); - x != net_map.end(); ++x) { + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - gps_network map_iter = x->second; + gps_network *map_iter = x->second; // Skip networks w/ no determined coordinates - if (map_iter.max_lat == 0) + if (map_iter->max_lat == 0) continue; - if (map_iter.diagonal_distance > horiz_throttle) + if (map_iter->diagonal_distance > horiz_throttle) continue; // Figure x, y of min on our hypothetical map double mapx, mapy; - calcxy (&mapx, &mapy, map_iter.avg_lat, map_iter.avg_lon, + calcxy (&mapx, &mapy, map_iter->avg_lat, map_iter->avg_lon, (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); double endx, endy; @@ -1444,14 +1401,15 @@ PixelPacket netclr; #ifdef OldMagickLib - QueryColorDatabase(netcolors[map_iter.color_index], &netclr); + QueryColorDatabase(map_iter->color_index.c_str(), &netclr); #else { - ExceptionInfo excep; - QueryColorDatabase(netcolors[map_iter.color_index], &netclr, &excep); + ExceptionInfo excep; + QueryColorDatabase(map_iter->color_index.c_str(), &netclr, &excep); } #endif in_di->fill = netclr; + in_di->stroke = netclr; char prim[1024]; @@ -1459,28 +1417,126 @@ (int) mapx, (int) mapy, (int) endx, (int) endy); in_di->primitive = strdup(prim); DrawImage(in_img, in_di); + } +} - /* - di->fill = black; - snprintf(prim, 1024, "text %d,%d \"%s %s\"", - (int) mapx, (int) mapy, - net_vec[x].heade - r.ssid, - Mac2String(net_vec[x].header.bssid, ':').c_str()); - di->primitive = strdup(prim); - DrawImage(img, di); - */ +void DrawNetCenterText(Image *in_img, DrawInfo *in_di, int in_textmode) { + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { - /* - //d = sqrt[(x1-x2)^2 + (y1-y2)^2] - printf(" Px RLen : %d\n", (int) sqrt(pow((int) mapx - endx, 2) + pow((int) mapy - endy, 2))); - */ + gps_network *map_iter = x->second; + + // Skip networks w/ no determined coordinates + if (map_iter->max_lat == 0) + continue; + + if (map_iter->diagonal_distance > horiz_throttle) + continue; + + // Figure x, y of min on our hypothetical map + double mapx, mapy; + + calcxy (&mapx, &mapy, map_iter->avg_lat, map_iter->avg_lon, + (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); + + PixelPacket netclr; + + char prim[1024]; + +#ifdef OldMagickLib + QueryColorDatabase("#000000", &netclr); +#else + { + ExceptionInfo excep; + QueryColorDatabase("#000000", &netclr, &excep); + } +#endif + + in_di->fill = netclr; + in_di->stroke = netclr; + + snprintf(prim, 1024, "gravity center fill-opacity 100%% stroke-opacity 100%% text %d,%d \"%s%s\"", + (int) mapx, (int) mapy + 8, + in_textmode & 1 ? map_iter->bssid.c_str() : "", + (in_textmode & 2 && map_iter->wnet != NULL) ? map_iter->wnet->ssid.c_str() : ""); + in_di->primitive = strdup(prim); + DrawImage(in_img, in_di); + + } +} + + +void DrawNetScatterPlot(Image *in_img, DrawInfo *in_di, int in_dotsize) { /*FOLD00*/ + for (map::const_iterator x = bssid_gpsnet_map.begin(); + x != bssid_gpsnet_map.end(); ++x) { + + gps_network *map_iter = x->second; + + // Skip networks w/ no determined coordinates + if (map_iter->max_lat == 0) + continue; + + if (map_iter->diagonal_distance > horiz_throttle) + continue; + + // hehe, cheating with a hash + map dim; + for (unsigned int y = 0; y < map_iter->points.size(); y++) { + gps_point *pt = map_iter->points[y]; + + double mapx, mapy; + calcxy (&mapx, &mapy, pt->lat, pt->lon, (double) scale/PIXELFACT, map_avg_lat, map_avg_lon); + + double endx, endy; + endx = mapx + in_dotsize; + endy = mapy + in_dotsize; + + char mm1[64]; + snprintf(mm1, 64, "%d,%d", (int) mapx, (int) mapy); + char mm2[64]; + snprintf(mm2, 64, "%d,%d", (int) endx, (int) endy); + string a = mm1; + string b = mm2; + dim[a] = b; + } + + PixelPacket netclr; + +#ifdef OldMagickLib + QueryColorDatabase(map_iter->color_index.c_str(), &netclr); +#else + { + ExceptionInfo excep; + QueryColorDatabase(map_iter->color_index.c_str(), &netclr, &excep); + } +#endif + + in_di->fill = netclr; + + for (map::const_iterator y = dim.begin(); y != dim.end(); ++y) { + char mm1[64]; + memset(mm1, 0, sizeof(char)*64); + char mm2[64]; + memset(mm2, 0, sizeof(char)*64); + y->first.copy(mm1, string::npos); + y->second.copy(mm2, string::npos); + + char prim[1024]; + + snprintf(prim, 1024, "fill-opacity %d%% stroke-opacity %d%% circle %s %s", + draw_opacity, draw_opacity, mm1, mm2); + + in_di->primitive = strdup(prim); + DrawImage(in_img, in_di); + + } } + } -int Usage(char *argv) { +int Usage(char *argv, int ec = 1) { /*FOLD00*/ printf("Usage: %s [OPTION] \n", argv); printf( " -c, --coords Force map center at x,y of scale s\n" @@ -1489,28 +1545,36 @@ " -t, --disable-draw-track Disable drawing travel track\n" " -b, --draw-bounds Draw bounding rectangles\n" " -r, --disable-draw-range Disable drawing estimated range circles\n" + " -w, --color-wep Color based on WEP instead of progressive\n" + " -H, --draw-hull Draw hull of data points\n" + " -p, --draw-scatter-plot Draw network data points\n" " -i, --draw-interpolated Draw interpolated power (slow!)\n" " -s, --interpolated-size Resolution to interpolate with\n" " -C, --interpolated-color Alternate interpolated power color set\n" " 1 is a gradiant though RGB colorspace (12 colors)\n" " 2 is weathermap radar style (9 colors)\n" - " -d, --draw-center-dot [size] Draw a dot at the center of the network range\n" + " -d, --draw-center-dot Draw a dot at the center of the network range\n" + " -D --dot-size Point size for center dot and scatter plot\n" + " [Default: 3]\n" " -O, --opacity Opacity of drawn elements [Default: 70]\n" " -g, --no-greyscale Don't convert map to greyscale\n" " -k, --keep-gif Keep the downloaded GIF\n" " -T, --threads Number of simultaneous threads used for complex\n" " operations\n" " -M, --metric Fetch metric-titled map\n" + " -F, --filter Comma-seperated ALL CAPS list of MAC's to filter\n" + " -I, --invert-filter Invert filtering (ONLY draw filtered MAC's)\n" " -v, --verbose Verbose output while running\n" " -o, --output Output .png file\n" - " -v, --version GPSMap version\n" + " -f, --config-file Alternate config file\n" + " -V, --version GPSMap version\n" " -h, --help What do you think you're reading?\n"); - exit(1); + exit(ec); } char *exec_name; -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) { /*FOLD00*/ exec_name = argv[0]; char mapname[1024]; @@ -1535,10 +1599,18 @@ { "quiet", no_argument, 0, 'q' }, { "threads", required_argument, 0, 'T' }, { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'v' }, - { "draw-center-dot", optional_argument, 0, 'd' }, + { "verbose", no_argument, 0, 'v' }, + { "version", no_argument, 0, 'V' }, + { "draw-center-dot", no_argument, 0, 'd' }, { "interpolated-color", required_argument, 0, 'C' }, { "metric", no_argument, 0, 'M' }, + { "draw-hull", no_argument, 0, 'H' }, + { "draw-scatter-plot", no_argument, 0, 'p' }, + { "dot-size", required_argument, 0, 'D' }, + { "filter", required_argument, 0, 'F' }, + { "invert-filter", no_argument, 0, 'I' }, + { "config-file", required_argument, 0, 'f' }, + { "color-wep", no_argument, 0, 'w' }, { 0, 0, 0, 0 } }; int option_index; @@ -1555,21 +1627,24 @@ convert_greyscale = 1; keep_gif = 0; draw_center = 0; - center_dot = 0; + center_dot = 3; draw_opacity = 70; verbose = 0; power_data = 0; interpolation_res = 2; power_steps = power_steps_Orig; powercolors = powercolors_Orig; + draw_hull = 0; float user_lat, user_lon; long user_scale = 0; sample_points = 0; + char *configfile = NULL; + while(1) { - int r = getopt_long(argc, argv, "T:tbrils:c:o:m:O:gqu:hvd::kC:M", + int r = getopt_long(argc, argv, "T:tbrils:c:o:m:O:gqu:hvdkC:MHVpD:f:Iw", long_options, &option_index); if (r < 0) break; @@ -1637,14 +1712,13 @@ Usage(argv[0]); } break; - case 'd': - if (optarg == NULL) - center_dot = 3; - else if (sscanf(optarg, "%d", ¢er_dot) != 1) { + case 'D': + if (sscanf(optarg, "%d", ¢er_dot) != 1) { fprintf(stderr, "Invalid center dot size.\n"); Usage(argv[0]); } - + break; + case 'd': draw_center = 1; break; case 'g': @@ -1672,12 +1746,71 @@ } } break; + case 'H': + draw_hull = 1; + break; + case 'F': + filter = optarg; + printf("NOTICE: Filtering MAC addresses: %s\n", optarg); + break; + case 'I': + invert_filter = 1; + printf("NOTICE: Inverting MAC address filter.\n"); + break; + case 'f': + configfile = optarg; + printf("NOTICE: Using alternate config file %s\n", optarg); + break; + case 'p': + draw_scatter = 1; + break; + case 'w': + color_wep = 1; + break; + case 'h': + Usage(argv[0], 0); + break; + case 'V': + printf("GPSMap v%i.%i\n", MAJOR, MINOR); + exit(0); + break; default: Usage(argv[0]); break; } } + ConfigFile conf; + + // If we haven't gotten a command line config option... + if (configfile == NULL) { + configfile = (char *) malloc(1024*sizeof(char)); + snprintf(configfile, 1024, "%s/%s", SYSCONF_LOC, config_base); + } + + // Parse the config and load all the values from it and/or our command + // line options. This is a little soupy but it does the trick. + if (conf.ParseConfig(configfile) < 0) { + fprintf(stderr, "WARNING: Couldn't open config file '%s'. Will continue anyway.\n", + configfile); + configfile = NULL; + } + + if (configfile != NULL) { + if (filter.length() == 0) { + if (conf.FetchOpt("macfilter") != "") { + filter = conf.FetchOpt("macfilter"); + printf("NOTICE: Filtering MAC addresses: %s\n", filter.c_str()); + } + } + } + + // Catch a null-draw condition + if (invert_filter == 1 && filter.length() == 0) { + fprintf(stderr, "FATAL: Inverse filtering requested but no MAC's given to draw.\n"); + exit(1); + } + // Initialize stuff num_tracks = 0; memset(&global_map_avg, 0, sizeof(gps_network)); @@ -1711,7 +1844,7 @@ } } - fprintf(stderr, "Graphing %d sample points.\n", + fprintf(stderr, "Processing %d sample points.\n", sample_points); map_avg_lat = (double) (global_map_avg.min_lat + global_map_avg.max_lat) / 2; @@ -1807,9 +1940,9 @@ DrawNetTracks(img, di); } - if (draw_center) { - fprintf(stderr, "Drawing center dot size %d...\n", center_dot); - DrawNetCenterDot(img, di, center_dot); + if (draw_scatter) { + fprintf(stderr, "Drawing scatter plot, dot size %d...\n", center_dot); + DrawNetScatterPlot(img, di, center_dot); } if (draw_interpolated && power_data == 0) { @@ -1826,11 +1959,23 @@ DrawNetCircles(img, di); } + if (draw_hull) { + fprintf(stderr, "Calculating and drawing network hulls...\n"); + DrawNetHull(img, di); + } + if (draw_bounds) { fprintf(stderr, "Calculating and drawing bounding rectangles...\n"); DrawNetBoundRects(img, di, 0); } + if (draw_center) { + fprintf(stderr, "Drawing center dot, size %d...\n", center_dot); + DrawNetCenterDot(img, di, center_dot); + } + + //DrawNetCenterText(img, di, 1); + WriteImage(img_info, img); DestroyDrawInfo(di); @@ -1848,4 +1993,3 @@ } #endif - Only in kismet-2.2.2: gpsmap.o Only in kismet-2.2.2: kismet_curses diff -u kismet-2.2.2/kismet_curses.cc kismet-devel/kismet_curses.cc --- kismet-2.2.2/kismet_curses.cc Tue May 28 02:13:09 2002 +++ kismet-devel/kismet_curses.cc Tue May 28 02:13:05 2002 @@ -12,7 +12,7 @@ #include "configfile.h" #define MAJOR 2 -#define MINOR 2 +#define MINOR 3 enum gui_type { gui_ncurses, gui_panel @@ -92,6 +92,7 @@ // Fork and run a system call to play a sound void SayText(string player, string text) { char snd_call[1024]; + char textprint[1024]; snprintf(textprint, 1024, "%s", text.c_str()); Only in kismet-2.2.2: kismet_curses.o Only in kismet-2.2.2: kismet_server diff -u kismet-2.2.2/kismet_server.cc kismet-devel/kismet_server.cc --- kismet-2.2.2/kismet_server.cc Tue May 28 02:12:04 2002 +++ kismet-devel/kismet_server.cc Fri Jun 7 14:18:41 2002 @@ -31,15 +31,16 @@ // Some globals for command line options char *configfile = NULL; int no_log = 0, noise_log = 0, data_log = 0, net_log = 0, crypt_log = 0, cisco_log = 0, - gps_log = 0, gps_enable = 1, csv_log = 0, xml_log = 0, ssid_cloak_track = 0; + gps_log = 0, gps_enable = 1, csv_log = 0, xml_log = 0, ssid_cloak_track = 0, ip_track = 0, + waypoint = 0; string logname, dumplogfile, netlogfile, cryptlogfile, ciscologfile, - gpslogfile, csvlogfile, xmllogfile, ssidtrackfile, configdir; + gpslogfile, csvlogfile, xmllogfile, ssidtrackfile, configdir, iptrackfile, waypointfile; FILE *net_file = NULL, *crypt_file = NULL, *cisco_file = NULL, *csv_file = NULL, - *xml_file = NULL, *ssid_file = NULL; + *xml_file = NULL, *ssid_file = NULL, *ip_file = NULL, *waypoint_file = NULL; DumpFile *dumpfile; PacketSource *packsource; -int packnum = 0; +int packnum = 0, localdropnum = 0; //Frontend *gui = NULL; Packetracker tracker; packet_parm pack_parm; @@ -53,81 +54,103 @@ packet_info last_info; int decay; unsigned int metric; +channel_power channel_graph[CHANNEL_MAX]; fd_set read_set, write_set; // This/these have to be globals, unfortunately, so that the interrupt // handler can shut down logging and write out to disk the network list. +// Handle writing all the files out and optionally unlinking the empties +void WriteDatafiles(int in_shutdown) { + if (ssid_cloak_track) { + if (ssid_file) + tracker.WriteSSIDMap(ssid_file); + if (in_shutdown) + fclose(ssid_file); + } -// Catch our interrupt -void CatchShutdown(int sig) { - // If we're sighuping ignore the gui entirely - /* - if (gui != NULL && sig != SIGHUP) - gui->EndDisplay(); - */ - - if (packsource != NULL) - packsource->CloseSource(); - - ui_server.SendToAll("*TERMINATE: Kismet server terminating.\n"); - - ui_server.Shutdown(); + if (ip_track) { + if (ip_file) + tracker.WriteIPMap(ip_file); - if (ssid_cloak_track) { - if ((ssid_file = fopen(ssidtrackfile.c_str(), "w")) == NULL) { - fprintf(stderr, "WARNING: Unable to open '%s' for writing, discovered cloaked SSIDs will\n" - "not be saved.\n", ssidtrackfile.c_str()); - } else { - tracker.WriteSSIDMap(ssid_file); - } + if (in_shutdown) + fclose(ip_file); } if (net_log) { if (tracker.FetchNumNetworks() != 0) { - tracker.WriteNetworks(net_file); + if (net_file) + tracker.WriteNetworks(net_file); + if (in_shutdown) + fclose(net_file); + } else if (in_shutdown) { fclose(net_file); - } else { fprintf(stderr, "NOTICE: Didn't detect any networks, unlinking network dump.\n"); - fclose(net_file); unlink(netlogfile.c_str()); } } if (csv_log) { if (tracker.FetchNumNetworks() != 0) { - tracker.WriteCSVNetworks(csv_file); + if (csv_file) + tracker.WriteCSVNetworks(csv_file); + if (in_shutdown) + fclose(csv_file); + } else if (in_shutdown) { fclose(csv_file); - } else { fprintf(stderr, "NOTICE: Didn't detect any networks, unlinking CSV network list.\n"); - fclose(csv_file); unlink(csvlogfile.c_str()); } } if (xml_log) { if (tracker.FetchNumNetworks() != 0) { - tracker.WriteXMLNetworks(xml_file); + if (xml_file) + tracker.WriteXMLNetworks(xml_file); + if (in_shutdown) + fclose(xml_file); + } else if (in_shutdown) { fclose(xml_file); - } else { fprintf(stderr, "NOTICE: Didn't detect any networks, unlinking XML network list.\n"); - fclose(xml_file); unlink(xmllogfile.c_str()); } } if (cisco_log) { if (tracker.FetchNumCisco() != 0) { - tracker.WriteCisco(cisco_file); + if (cisco_file) + tracker.WriteCisco(cisco_file); + if (in_shutdown) + fclose(cisco_file); + } else if (in_shutdown) { fclose(cisco_file); - } else { fprintf(stderr, "NOTICE: Didn't detect any Cisco Discovery Packets, unlinking cisco dump\n"); unlink(ciscologfile.c_str()); } } +} + +// Catch our interrupt +void CatchShutdown(int sig) { + // If we're sighuping ignore the gui entirely + /* + if (gui != NULL && sig != SIGHUP) + gui->EndDisplay(); + */ + + if (packsource != NULL) + packsource->CloseSource(); + + ui_server.SendToAll("*TERMINATE: Kismet server terminating.\n"); + + ui_server.Shutdown(); + + // Write the data file, closing the files and unlinking them + WriteDatafiles(1); + if (data_log) { dumpfile->CloseDump(); @@ -183,21 +206,33 @@ } #endif + // Build power output and channel power output char power_output[16]; if (time(0) - last_info.time < decay && last_info.quality != -1) - snprintf(power_output, 16, "%d %d %d\n", last_info.quality, + snprintf(power_output, 16, "%d %d %d", last_info.quality, last_info.signal, last_info.noise); else if (last_info.quality == -1) - snprintf(power_output, 16, "-1 -1 -1\n"); + snprintf(power_output, 16, "-1 -1 -1"); else - snprintf(power_output, 16, "0 0 0\n"); + snprintf(power_output, 16, "0 0 0"); - snprintf(output, 2048, "*INFO: %d %d %d %d %d %d %s\n", + snprintf(output, 2048, "*INFO: %d %d %d %d %d %d %s %d", tracker.FetchNumNetworks(), tracker.FetchNumPackets(), tracker.FetchNumCrypt(), tracker.FetchNumInteresting(), - tracker.FetchNumNoise(), tracker.FetchNumDropped(), - power_output); + tracker.FetchNumNoise(), tracker.FetchNumDropped() + localdropnum, + power_output, CHANNEL_MAX); + + char munge[2048]; + for (unsigned int x = 0; x < CHANNEL_MAX; x++) { + snprintf(munge, 2048, "%s %d", + output, + (time(0) - channel_graph[x].last_time) < decay ? channel_graph[x].signal : -1); + strncpy(output, munge, 2048); + } + snprintf(munge, 2048, "%s\n", output); + strncpy(output, munge, 2048); + ui_server.SendToAll(output); tracked = tracker.FetchNetworks(); @@ -351,6 +386,7 @@ int sleepu = 0; time_t last_draw = time(0); + time_t last_write = time(0); int log_packnum = 0; int limit_logs = 0; char status[STATUS_MAX]; @@ -381,6 +417,8 @@ string filter; + int datainterval = 0; + static struct option long_options[] = { /* options table */ { "log-title", required_argument, 0, 't' }, { "no-logging", no_argument, 0, 'n' }, @@ -509,6 +547,8 @@ } } + memset(channel_graph, 0, sizeof(channel_power) * CHANNEL_MAX); + // If we haven't gotten a command line config option... if (configfile == NULL) { configfile = (char *) malloc(1024*sizeof(char)); @@ -536,6 +576,26 @@ ssid_cloak_track = 1; } + if (conf.FetchOpt("ipmap") != "") { + // Explode the IP file path + iptrackfile = conf.ExpandLogPath(configdir + conf.FetchOpt("ipmap"), "", "", 0, 1); + ip_track = 1; + } + +#ifdef HAVE_GPS + if (conf.FetchOpt("waypoints") == "true") { + if(conf.FetchOpt("waypointdata") == "") { + fprintf(stderr, "FATAL: Waypoint logging requested but no waypoint data file given.\n"); + exit(1); + } + + waypointfile = conf.ExpandLogPath(conf.FetchOpt("waypointdata"), "", "", 0, 1); + + waypoint = 1; + + } +#endif + if (conf.FetchOpt("metric") == "true") { fprintf(stderr, "NOTICE: Using metric measurements.\n"); metric = 1; @@ -663,6 +723,11 @@ } + if (gps_log && !net_log) { + fprintf(stderr, "WARNING: Logging (gps coordinates) enabled but XML logging (networks) was not.\n" + "It will be enabled now.\n"); + xml_log = 1; + } } if (conf.FetchOpt("decay") != "") { @@ -753,6 +818,17 @@ } else if (speech == -1) speech = 0; + if (conf.FetchOpt("writeinterval") != "") { + if (sscanf(conf.FetchOpt("writeinterval").c_str(), "%d", &datainterval) != 1) { + fprintf(stderr, "FATAL: Illegal config file value for data interval.\n"); + exit(1); + } + + if (datainterval != 0) + fprintf(stderr, "Writing data files to disk every %d seconds.\n", + datainterval); + } + // Open the captype if (captype == NULL) { if (conf.FetchOpt("captype") == "") { @@ -886,8 +962,50 @@ tracker.ReadSSIDMap(ssid_file); fclose(ssid_file); + + } + + if ((ssid_file = fopen(ssidtrackfile.c_str(), "a")) == NULL) { + fprintf(stderr, "FATAL: Could not open SSID track file '%s' for writing: %s\n", + ssidtrackfile.c_str(), strerror(errno)); + exit(1); + } + + } + + if (ip_track) { + if (stat(iptrackfile.c_str(), &fstat) == -1) { + fprintf(stderr, "NOTICE: IP track file did not exist, it will be created.\n"); + + } else { + if ((ip_file = fopen(iptrackfile.c_str(), "r")) == NULL) { + fprintf(stderr, "FATAL: Could not open IP track file '%s': %s\n", + iptrackfile.c_str(), strerror(errno)); + exit(1); + } + + tracker.ReadIPMap(ip_file); + + fclose(ip_file); + } + + if ((ip_file = fopen(iptrackfile.c_str(), "a")) == NULL) { + fprintf(stderr, "FATAL: Could not open IP track file '%s' for writing: %s\n", + iptrackfile.c_str(), strerror(errno)); + exit(1); + } + + } + +#ifdef HAVE_GPS + if (waypoint) { + if ((waypoint_file = fopen(waypointfile.c_str(), "a")) == NULL) { + fprintf(stderr, "FATAL: Could not open waypoint file '%s' for writing: %s\n", + waypointfile.c_str(), strerror(errno)); + exit(1); } } +#endif // Create all the logs and title/number them appropriately int logfile_matched = 0; @@ -983,7 +1101,7 @@ if (filter != "") { fprintf(stderr, "Filtering MAC addresses: %s\n", filter.c_str()); - tracker.AddFilter(filter); + //tracker.AddFilter(filter); } // Now lets open the GPS host if specified @@ -1021,7 +1139,7 @@ gpsdump.AddGPS(&gps); if (gps_log) { - if (gpsdump.OpenDump(gpslogfile.c_str()) < 0) { + if (gpsdump.OpenDump(gpslogfile.c_str(), xmllogfile.c_str()) < 0) { fprintf(stderr, "FATAL: %s\n", gpsdump.FetchError()); exit(1); } @@ -1048,6 +1166,7 @@ fprintf(stderr, "Dump file format: %s\n", dumpfile->FetchType()); } + // Open our files first to make sure we can, we'll unlink the empties later. if (net_log) { if ((net_file = fopen(netlogfile.c_str(), "w")) == NULL) { perror("Unable to open net file"); @@ -1069,20 +1188,22 @@ } } - if (crypt_log) { - if ((crypt_file = fopen(cryptlogfile.c_str(), "w")) == NULL) { - perror("Unable to open weak log file"); + if (cisco_log) { + if ((cisco_file = fopen(ciscologfile.c_str(), "w")) == NULL) { + perror("Unable to open cisco file"); exit(1); } } - if (cisco_log) { - if ((cisco_file = fopen(ciscologfile.c_str(), "w")) == NULL) { - perror("Unable to open cisco file"); + // Crypt log stays open like the dump log for continual writing + if (crypt_log) { + if ((crypt_file = fopen(cryptlogfile.c_str(), "w")) == NULL) { + perror("Unable to open weak log file"); exit(1); } } + snprintf(status, STATUS_MAX, "Kismet %d.%d", MAJOR, MINOR); fprintf(stderr, "%s\n", status); @@ -1115,6 +1236,7 @@ time_t last_click = 0; + time_t last_waypoint = time(0); int num_networks = 0, num_packets = 0, num_noise = 0, num_dropped = 0; // We're ready to begin the show... Fill in our file descriptors for when @@ -1122,18 +1244,18 @@ FD_ZERO(&read_set); FD_ZERO(&write_set); - unsigned int max_fd = 0; + int max_fd = 0; //FD_SET(fileno(stdin), &read_set); // We want to remember all our FD's so we don't have to keep calling functions which // call functions and so on. Fill in our descriptors while we're at it. - unsigned int ui_descrip = ui_server.FetchDescriptor(); - if (ui_descrip > max_fd) + int ui_descrip = ui_server.FetchDescriptor(); + if (ui_descrip > max_fd && ui_descrip > 0) max_fd = ui_descrip; FD_SET(ui_descrip, &read_set); - unsigned int source_descrip = packsource->FetchDescriptor(); + int source_descrip = packsource->FetchDescriptor(); if (source_descrip > 0) { FD_SET(source_descrip, &read_set); if (source_descrip > max_fd) @@ -1165,7 +1287,7 @@ // We can pass the results of this select to the UI handler without incurring a // a delay since it will bail nicely if there aren't any new connections. - unsigned int accept_fd = 0; + int accept_fd = 0; accept_fd = ui_server.Poll(rset, wset, eset); if (accept_fd < 0) { if (!silent) @@ -1213,39 +1335,33 @@ // Handle a packet if (len > 0) { packnum++; - log_packnum++; - - if (limit_logs && log_packnum > limit_logs) { - dumpfile->CloseDump(); - - dumplogfile = conf.ExpandLogPath(conf.FetchOpt("logtemplate"), logname, "dump", 0); - - if (dumpfile->OpenDump(dumplogfile.c_str()) < 0) { - perror("Unable to open new dump file"); - CatchShutdown(-1); - } - - snprintf(status, STATUS_MAX, "Opened new packet log file %s", - dumplogfile.c_str()); - - if (!silent) - fprintf(stderr, "%s\n", status); - - NetWriteStatus(status); - - log_packnum = 0; - } - + static packet_info info; info = GetPacketInfo(&header, data, &pack_parm); last_info = info; + + // Discard it if we're filtering it + if (filter.find(Packetracker::Mac2String(info.bssid_mac, ':')) != string::npos) { + localdropnum++; + + // don't ever do this. ever. (but it really is the most efficient way + // of getting from here to there, so....) + goto last_draw; + + } + + // Handle the per-channel signal power levels + if (info.channel > 0 && info.channel < CHANNEL_MAX) { + channel_graph[info.channel].last_time = info.time; + channel_graph[info.channel].signal = info.signal; + } int process_ret; #ifdef HAVE_GPS - if (gps_log && info.type != packet_noise) { + if (gps_log && info.type != packet_noise && info.type != packet_unknown) { process_ret = gpsdump.DumpPacket(&info); if (process_ret < 0) { snprintf(status, STATUS_MAX, "%s", gpsdump.FetchError()); @@ -1284,7 +1400,7 @@ if (tracker.FetchNumPackets() != num_packets) { if (time(0) - last_click >= decay && sound == 1) { if (tracker.FetchNumPackets() - num_packets > - tracker.FetchNumDropped() - num_dropped) { + tracker.FetchNumDropped() + localdropnum - num_dropped) { PlaySound(sndplay, "traffic", wav_map); } else { PlaySound(sndplay, "junktraffic", wav_map); @@ -1295,11 +1411,11 @@ num_packets = tracker.FetchNumPackets(); num_noise = tracker.FetchNumNoise(); - num_dropped = tracker.FetchNumDropped(); + num_dropped = tracker.FetchNumDropped() + localdropnum; } // Extract the strings from it - if (info.type == packet_data) { + if (info.type == packet_data && info.wep == 0) { vector strlist; strlist = GetPacketStrings(&info, &header, data); @@ -1318,6 +1434,29 @@ */ if (data_log) { + log_packnum++; + + if (limit_logs && log_packnum > limit_logs) { + dumpfile->CloseDump(); + + dumplogfile = conf.ExpandLogPath(conf.FetchOpt("logtemplate"), logname, "dump", 0); + + if (dumpfile->OpenDump(dumplogfile.c_str()) < 0) { + perror("Unable to open new dump file"); + CatchShutdown(-1); + } + + snprintf(status, STATUS_MAX, "Opened new packet log file %s", + dumplogfile.c_str()); + + if (!silent) + fprintf(stderr, "%s\n", status); + + NetWriteStatus(status); + + log_packnum = 0; + } + if (!(info.type == packet_noise && noise_log == 1)) { dumpfile->DumpPacket(&header, data); } @@ -1357,6 +1496,7 @@ } // End processing new packets // Draw if it's time + last_draw: ; if (time(0) != last_draw) { #ifdef HAVE_GPS // The GPS only provides us a new update once per second we might @@ -1400,6 +1540,23 @@ NetWriteInfo(); last_draw = time(0); + } + + // Write the data files out every x seconds + if (datainterval > 0) { + if (time(0) - last_write > datainterval) { + if (!silent) + fprintf(stderr, "Saving data files.\n"); + NetWriteStatus("Saving data files."); + WriteDatafiles(0); + last_write = time(0); + } + } + + // Write the waypoints every decay seconds + if (time(0) - last_waypoint > decay && waypoint) { + tracker.WriteGpsdriveWaypt(waypoint_file); + last_waypoint = time(0); } // Sleep if we have a custom additional sleep time diff -u kismet-2.2.2/kismet_server.h kismet-devel/kismet_server.h --- kismet-2.2.2/kismet_server.h Sat May 11 12:39:10 2002 +++ kismet-devel/kismet_server.h Fri May 17 00:27:47 2002 @@ -7,7 +7,7 @@ #include #define MAJOR 2 -#define MINOR 2 +#define MINOR 3 string ExpandLogPath(string path, string logname, string type); void CatchShutdown(int sig); Only in kismet-2.2.2: kismet_server.o Common subdirectories: kismet-2.2.2/libpcap-2002.05.16 and kismet-devel/libpcap-2002.05.16 Only in kismet-devel: manuf.cc Only in kismet-devel: manuf.h Common subdirectories: kismet-2.2.2/packaging and kismet-devel/packaging diff -u kismet-2.2.2/packet.cc kismet-devel/packet.cc --- kismet-2.2.2/packet.cc Sat May 4 00:10:17 2002 +++ kismet-devel/packet.cc Fri Jun 7 17:42:50 2002 @@ -215,6 +215,12 @@ memcpy(ret.source_mac, (const char *) &msgbuf[10], MAC_LEN); memcpy(ret.bssid_mac, (const char *) &msgbuf[16], MAC_LEN); + if (ret.ap == 0) { + // Weird adhoc beacon where the BSSID isn't 'right' so we use the source instead. + memcpy(ret.bssid_mac, ret.source_mac, MAC_LEN); + ret.type = packet_adhoc; + } + // First byte of offsets ret.header_offset = 24; Only in kismet-2.2.2: packet.o diff -u kismet-2.2.2/packetracker.cc kismet-devel/packetracker.cc --- kismet-2.2.2/packetracker.cc Mon May 13 16:43:11 2002 +++ kismet-devel/packetracker.cc Wed Jun 5 00:53:47 2002 @@ -47,7 +47,8 @@ char output[2048]; snprintf(output, 2048, "%s %d \001%s\001 \001%s\001 %d %d %d %d %d %d %d %d %d " - "%d.%d.%d.%d %d.%d.%d.%d %d.%d.%d.%d %d %f %f %f %f %f %f %f %f %d %d %d %2.1f", + "%d.%d.%d.%d %d.%d.%d.%d %d.%d.%d.%d %d %f %f %f %f %f %f %f %f %d %d %d %2.1f " + "%d %d", in_net->bssid.size() > 0 ? in_net->bssid.c_str() : "\002", (int) in_net->type, in_net->ssid.size() > 0 ? in_net->ssid.c_str() : "\002", @@ -56,20 +57,22 @@ in_net->crypt_packets, in_net->interesting_packets, in_net->channel, in_net->wep, (int) in_net->first_time, (int) in_net->last_time, - (int) in_net->atype, - in_net->range_ip[0], in_net->range_ip[1], - in_net->range_ip[2], in_net->range_ip[3], - in_net->mask[0], in_net->mask[1], - in_net->mask[2], in_net->mask[3], - in_net->gate_ip[0], in_net->gate_ip[1], - in_net->gate_ip[2], in_net->gate_ip[3], + (int) in_net->ipdata.atype, + in_net->ipdata.range_ip[0], in_net->ipdata.range_ip[1], + in_net->ipdata.range_ip[2], in_net->ipdata.range_ip[3], + in_net->ipdata.mask[0], in_net->ipdata.mask[1], + in_net->ipdata.mask[2], in_net->ipdata.mask[3], + in_net->ipdata.gate_ip[0], in_net->ipdata.gate_ip[1], + in_net->ipdata.gate_ip[2], in_net->ipdata.gate_ip[3], in_net->gps_fixed, in_net->min_lat, in_net->min_lon, in_net->min_alt, in_net->min_spd, in_net->max_lat, in_net->max_lon, in_net->max_alt, in_net->max_spd, - in_net->octets, - in_net->cloaked, in_net->beacon, in_net->maxrate); + in_net->ipdata.octets, + in_net->cloaked, in_net->beacon, in_net->maxrate, + + in_net->manuf_id, in_net->manuf_score); ret = output; @@ -137,10 +140,12 @@ bssid_mac = Mac2String(info.bssid_mac, ':'); // Look to see if we're in the filter list, if we are, discard. + /* Done in the server now, earlier in the processing if (filter.find(bssid_mac) != string::npos) { num_dropped++; return(0); - } + } + */ // If it's a broadcast (From and To DS == 1) try to match it to an existing // network @@ -186,14 +191,15 @@ net->type = network_data; net->llc_packets = net->data_packets = - net->crypt_packets = net->interesting_packets = - net->octets = net->listed = 0; + net->crypt_packets = net->interesting_packets = net->listed = 0; + + net->manuf_id = -1; + net->manuf_score = 0; - net->atype = address_none; + memset(&net->ipdata, 0, sizeof(net_ip_data)); - memset(net->range_ip, 0, 4); - memset(net->mask, 0, 4); - memset(net->gate_ip, 0, 4); + if (bssid_ip_map.find(bssid_mac) != bssid_ip_map.end()) + memcpy(&net->ipdata, &bssid_ip_map[bssid_mac], sizeof(net_ip_data)); if (strlen(info.ssid) == 0 || IsBlank(info.ssid)) { if (bssid_cloak_map.find(bssid_mac) != bssid_cloak_map.end()) { @@ -245,6 +251,8 @@ net->ssid.c_str(), net->bssid.c_str(), net->wep ? 'Y' : 'N', net->channel, net->maxrate); + MatchBestManuf(net); + if (gps != NULL) { float lat, lon, alt, spd; int fix; @@ -252,7 +260,7 @@ gps->FetchLoc(&lat, &lon, &alt, &spd, &fix); if (fix < 2) { - net->gps_fixed = 0; + net->gps_fixed = -1; net->min_lat = net->max_lat = net->min_lon = net->max_lon = net->min_alt = net->max_alt = net->min_spd = net->max_spd = 0; } else { @@ -296,7 +304,7 @@ gps->FetchLoc(&lat, &lon, &alt, &spd, &fix); - if (fix != -1) { + if (fix > 1) { net->gps_fixed = fix; if (lat < net->min_lat) @@ -319,6 +327,8 @@ else if (spd > net->max_spd) net->max_spd = spd; + } else { + net->gps_fixed = 0; } } @@ -337,6 +347,7 @@ if (net->ssid != NOSSID && net->ssid != info.ssid && !IsBlank(info.ssid)) { net->ssid = info.ssid; bssid_cloak_map[net->bssid] = info.ssid; + MatchBestManuf(net); } else if (net->ssid == NOSSID && strlen(info.ssid) > 0 && !IsBlank(info.ssid)) { net->ssid = info.ssid; @@ -351,6 +362,7 @@ net->ssid.c_str(), net->bssid.c_str()); } + MatchBestManuf(net); ret = 2; } @@ -362,7 +374,7 @@ // If this is a probe response and the ssid we have is blank, update it. // With "closed" networks, this is our chance to see the real ssid. - // (Thanks to Jason Luder for this "closed network" detection) + // (Thanks to Jason Luther for this "closed network" detection) if (info.type == packet_probe_response && (strlen(info.ssid) > 0) && !IsBlank(info.ssid)) { if (net->ssid == NOSSID) { @@ -375,11 +387,16 @@ snprintf(in_status, STATUS_MAX, "Found SSID \"%s\" for cloaked network BSSID %s", net->ssid.c_str(), net->bssid.c_str()); + + MatchBestManuf(net); + ret = 2; } else if (info.ssid != bssid_cloak_map[net->bssid]) { bssid_cloak_map[net->bssid] = info.ssid; net->ssid = info.ssid; net->wep = info.wep; + + MatchBestManuf(net); } // If we have a probe request network, absorb it into the main network @@ -403,6 +420,8 @@ snprintf(in_status, STATUS_MAX, "Associated probe network \"%s\".", pnet->bssid.c_str()); + num_networks--; + ret = 3; } } @@ -435,28 +454,35 @@ } // If we're not aware of a dhcp server already, try to find one. - if (info.proto.type == proto_dhcp_server && net->atype < address_dhcp) { + if (info.proto.type == proto_dhcp_server && (net->ipdata.atype < address_dhcp || + net->ipdata.load_from_store == 1)) { // Jackpot, this tells us everything we need to know - net->atype = address_dhcp; + net->ipdata.atype = address_dhcp; - net->range_ip[0] = info.proto.misc_ip[0] & info.proto.mask[0]; - net->range_ip[1] = info.proto.misc_ip[1] & info.proto.mask[1]; - net->range_ip[2] = info.proto.misc_ip[2] & info.proto.mask[2]; - net->range_ip[3] = info.proto.misc_ip[3] & info.proto.mask[3]; + net->ipdata.range_ip[0] = info.proto.misc_ip[0] & info.proto.mask[0]; + net->ipdata.range_ip[1] = info.proto.misc_ip[1] & info.proto.mask[1]; + net->ipdata.range_ip[2] = info.proto.misc_ip[2] & info.proto.mask[2]; + net->ipdata.range_ip[3] = info.proto.misc_ip[3] & info.proto.mask[3]; // memcpy(net->range_ip, info.proto.misc_ip, 4); - memcpy(net->mask, info.proto.mask, 4); - memcpy(net->gate_ip, info.proto.gate_ip, 4); + memcpy(net->ipdata.mask, info.proto.mask, 4); + memcpy(net->ipdata.gate_ip, info.proto.gate_ip, 4); snprintf(in_status, STATUS_MAX, "Found IP range for \"%s\" via DHCP %d.%d.%d.%d mask %d.%d.%d.%d", - net->ssid.c_str(), net->range_ip[0], net->range_ip[1], net->range_ip[2], net->range_ip[3], - net->mask[0], net->mask[1], net->mask[2], net->mask[3]); + net->ssid.c_str(), net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3], + net->ipdata.mask[0], net->ipdata.mask[1], + net->ipdata.mask[2], net->ipdata.mask[3]); + + net->ipdata.octets = 0; - net->octets = 0; + bssid_ip_map[net->bssid] = net->ipdata; + net->ipdata.load_from_store = 0; ret = 2; - } else if (info.proto.type == proto_arp && net->atype < address_arp) { + } else if (info.proto.type == proto_arp && (net->ipdata.atype < address_arp || + net->ipdata.load_from_store == 1)) { uint8_t new_range[4]; memset(new_range, 0, 4); @@ -472,19 +498,24 @@ new_range[oct] = info.proto.source_ip[oct]; } - if (oct < net->octets || net->octets == 0) { - net->octets = oct; - memcpy(net->range_ip, new_range, 4); + if (oct < net->ipdata.octets || net->ipdata.octets == 0) { + net->ipdata.octets = oct; + memcpy(net->ipdata.range_ip, new_range, 4); snprintf(in_status, STATUS_MAX, "Found IP range for \"%s\" via ARP %d.%d.%d.%d", - net->ssid.c_str(), net->range_ip[0], net->range_ip[1], net->range_ip[2], net->range_ip[3]); + net->ssid.c_str(), net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); //gui->WriteStatus(status); - net->atype = address_arp; + net->ipdata.atype = address_arp; + + bssid_ip_map[net->bssid] = net->ipdata; + net->ipdata.load_from_store = 0; ret = 2; } } // valid arp - } else if (info.proto.type == proto_udp && net->atype <= address_udp) { + } else if (info.proto.type == proto_udp && (net->ipdata.atype <= address_udp || + net->ipdata.load_from_store == 1)) { uint8_t new_range[4]; memset(new_range, 0, 4); @@ -504,14 +535,18 @@ new_range[oct] = info.proto.source_ip[oct]; } - if (oct < net->octets || net->octets == 0) { - net->octets = oct; - memcpy(net->range_ip, new_range, 4); + if (oct < net->ipdata.octets || net->ipdata.octets == 0) { + net->ipdata.octets = oct; + memcpy(net->ipdata.range_ip, new_range, 4); snprintf(in_status, STATUS_MAX, "Found IP range for \"%s\" via UDP %d.%d.%d.%d", - net->ssid.c_str(), net->range_ip[0], net->range_ip[1], net->range_ip[2], net->range_ip[3]); + net->ssid.c_str(), net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); // gui->WriteStatus(status); - net->atype = address_udp; + net->ipdata.atype = address_udp; + + bssid_ip_map[net->bssid] = net->ipdata; + net->ipdata.load_from_store = 0; ret = 2; } @@ -524,6 +559,9 @@ } int Packetracker::WriteNetworks(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + int netnum = 1; vector bssid_vec; @@ -591,21 +629,23 @@ metric ? net->max_alt / 3.3 : net->max_alt, metric ? net->max_spd * 1.6093 : net->max_spd); - if (net->atype == address_dhcp) + if (net->ipdata.atype == address_dhcp) fprintf(in_file, " Address found via DHCP %d.%d.%d.%d \n" " netmask %d.%d.%d.%d gw %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3], - net->mask[0], net->mask[1], net->mask[2], net->mask[3], - net->gate_ip[0], net->gate_ip[1], net->gate_ip[2], net->gate_ip[3]); - else if (net->atype == address_arp) + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3], + net->ipdata.mask[0], net->ipdata.mask[1], + net->ipdata.mask[2], net->ipdata.mask[3], + net->ipdata.gate_ip[0], net->ipdata.gate_ip[1], + net->ipdata.gate_ip[2], net->ipdata.gate_ip[3]); + else if (net->ipdata.atype == address_arp) fprintf(in_file, " Address found via ARP %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); - else if (net->atype == address_udp) + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); + else if (net->ipdata.atype == address_udp) fprintf(in_file, " Address found via UDP %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); fprintf(in_file, "\n"); netnum++; } @@ -615,6 +655,9 @@ // Write out the cisco information int Packetracker::WriteCisco(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + vector bssid_vec; // Convert the map to a vector and sort it @@ -667,6 +710,9 @@ * Date: 2002/03/13 */ int Packetracker::WriteCSVNetworks(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + int netnum = 1; vector bssid_vec; @@ -703,7 +749,7 @@ snprintf(type, 15, "data"); - fprintf(in_file, "%d;%s;%s;%s;%s;%02d;%2.1f;%s;%d;%d;%d;%d;%d;%s;%s", + fprintf(in_file, "%d;%s;%s;%s;%s;%02d;%2.1f;%s;%d;%d;%d;%d;%d;%s;%s;", netnum, type, net->ssid.c_str(), net->bssid.c_str(), net->beacon_info == "" ? "None" : net->beacon_info.c_str(), @@ -729,20 +775,22 @@ fprintf(in_file, ";;;;;;;;"); } - if (net->atype == address_dhcp) + if (net->ipdata.atype == address_dhcp) fprintf(in_file, "%d.%d.%d.%d;%d.%d.%d.%d;%d.%d.%d.%d;;;\r\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3], - net->mask[0], net->mask[1], net->mask[2], net->mask[3], - net->gate_ip[0], net->gate_ip[1], net->gate_ip[2], net->gate_ip[3]); - else if (net->atype == address_arp) + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3], + net->ipdata.mask[0], net->ipdata.mask[1], + net->ipdata.mask[2], net->ipdata.mask[3], + net->ipdata.gate_ip[0], net->ipdata.gate_ip[1], + net->ipdata.gate_ip[2], net->ipdata.gate_ip[3]); + else if (net->ipdata.atype == address_arp) fprintf(in_file, ";;;%d.%d.%d.%d;;\r\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); - else if (net->atype == address_udp) + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); + else if (net->ipdata.atype == address_udp) fprintf(in_file, ";;;;%d.%d.%d.%d;\r\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); else fprintf(in_file, ";;;;;\r\n"); netnum++; @@ -754,6 +802,9 @@ // Write an XML-formatted output conforming to our DTD at // http://kismetwireless.net/kismet-1.0.dtd int Packetracker::WriteXMLNetworks(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + int netnum = 1; vector bssid_vec; @@ -833,29 +884,29 @@ fprintf(in_file, " \n"); } - if (net->atype == address_dhcp) { + if (net->ipdata.atype == address_dhcp) { fprintf(in_file, " \n"); fprintf(in_file, " %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); fprintf(in_file, " %d.%d.%d.%d\n", - net->mask[0], net->mask[1], - net->mask[2], net->mask[3]); + net->ipdata.mask[0], net->ipdata.mask[1], + net->ipdata.mask[2], net->ipdata.mask[3]); fprintf(in_file, " %d.%d.%d.%d\n", - net->gate_ip[0], net->gate_ip[1], - net->gate_ip[2], net->gate_ip[3]); + net->ipdata.gate_ip[0], net->ipdata.gate_ip[1], + net->ipdata.gate_ip[2], net->ipdata.gate_ip[3]); fprintf(in_file, " \n"); - } else if (net->atype == address_arp) { + } else if (net->ipdata.atype == address_arp) { fprintf(in_file, " \n"); fprintf(in_file, " %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); fprintf(in_file, " \n"); - } else if (net->atype == address_udp) { + } else if (net->ipdata.atype == address_udp) { fprintf(in_file, " \n"); fprintf(in_file, " %d.%d.%d.%d\n", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); fprintf(in_file, " \n"); } @@ -929,6 +980,8 @@ } void Packetracker::WriteSSIDMap(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); char format[64]; snprintf(format, 64, "%%.%ds %%.%ds\n", MAC_STR_LEN, SSID_SIZE); @@ -940,6 +993,64 @@ return; } +void Packetracker::ReadIPMap(FILE *in_file) { + char dline[8192]; + char bssid[MAC_STR_LEN]; + + char format[64]; + // stupid sscanf not taking dynamic sizes + snprintf(format, 64, "%%%d[^ ] %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d\n", + MAC_STR_LEN); + + net_ip_data dat; + + while (!feof(in_file)) { + fgets(dline, 8192, in_file); + + if (feof(in_file)) break; + + memset(&dat, 0, sizeof(net_ip_data)); + + // Fetch the line and continue if we're invalid... + if (sscanf(dline, format, + bssid, &dat.atype, &dat.octets, + &dat.range_ip[0], &dat.range_ip[1], &dat.range_ip[2], &dat.range_ip[3], + &dat.mask[0], &dat.mask[1], &dat.mask[2], &dat.mask[3], + &dat.gate_ip[0], &dat.gate_ip[1], &dat.gate_ip[2], &dat.gate_ip[3]) < 15) + continue; + + dat.load_from_store = 1; + + memcpy(&bssid_ip_map[bssid], &dat, sizeof(net_ip_data)); + } + + return; + +} + +void Packetracker::WriteIPMap(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + + char format[64]; + snprintf(format, 64, "%%.%ds %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d %%d\n", + MAC_STR_LEN); + + for (map::iterator x = bssid_ip_map.begin(); + x != bssid_ip_map.end(); ++x) + fprintf(in_file, format, + x->first.c_str(), + x->second.atype, x->second.octets, + x->second.range_ip[0], x->second.range_ip[1], + x->second.range_ip[2], x->second.range_ip[3], + x->second.mask[0], x->second.mask[1], + x->second.mask[2], x->second.mask[3], + x->second.gate_ip[0], x->second.gate_ip[1], + x->second.gate_ip[2], x->second.gate_ip[3]); + + return; +} + void Packetracker::RemoveNetwork(string in_bssid) { for (unsigned int x = 0; x < network_list.size(); x++) { if (network_list[x]->bssid == in_bssid) { @@ -948,5 +1059,24 @@ } } +} + +// Write a gpsdrive compatable waypoint file +int Packetracker::WriteGpsdriveWaypt(FILE *in_file) { + fseek(in_file, 0L, SEEK_SET); + ftruncate(fileno(in_file), 0); + + // Convert the map to a vector and sort it + for (map::const_iterator i = bssid_map.begin(); + i != bssid_map.end(); ++i) { + wireless_network *net = i->second; + + float lat, lon; + lat = (net->min_lat + net->max_lat) / 2; + lon = (net->min_lon + net->max_lon) / 2; + fprintf(in_file, "%s\t%f %f\n", net->bssid.c_str(), lat, lon); + } + + return 1; } diff -u kismet-2.2.2/packetracker.h kismet-devel/packetracker.h --- kismet-2.2.2/packetracker.h Mon May 13 16:35:54 2002 +++ kismet-devel/packetracker.h Sat Jun 1 12:50:55 2002 @@ -13,109 +13,14 @@ #include "gpsd.h" #include "packet.h" +#include "tracktypes.h" +#include "manuf.h" // Extern over to kismet_server.cc to get our first time extern time_t start_time; // Extern over to kismet_server.cc to get our metric settings extern unsigned int metric; -#define MAC_STR_LEN (MAC_LEN * 2) + 6 - -const string NOSSID(""); - -enum wireless_network_type { - network_ap, - network_adhoc, - network_probe, - network_data, - network_remove -}; - -enum address_type { - address_none, - address_udp, - address_arp, - address_dhcp, - address_group -}; - -// A network -typedef struct { - wireless_network_type type; - - string ssid; - - string beacon_info; - - // Packet counts - int llc_packets; - int data_packets; - int crypt_packets; - int interesting_packets; - - // info extracted from packets - //uint8_t bssid[MAC_LEN]; - int channel; - int wep; - string bssid; - - uint8_t bssid_raw[MAC_LEN]; - - // Are we a cloaked SSID? - int cloaked; - - // Last time we saw a packet - time_t last_time; - // First packet - time_t first_time; - - // beacon interval - int beacon; - - // Are we in the list? - int listed; - - address_type atype; - - // How many address octets have we matched? - int octets; - - // What IP range are we using? - uint8_t range_ip[4]; - // What netmask are we using? - uint8_t mask[4]; - // What's the gateway? - uint8_t gate_ip[4]; - - map cisco_equip; - - /* - float gps_lat, gps_lon, gps_alt, gps_spd; - int gps_mode; - - float first_lat, first_lon, first_alt, first_spd; - int first_mode; - */ - - int gps_fixed; - float min_lat, min_lon, min_alt, min_spd; - float max_lat, max_lon, max_alt, max_spd; - - // How fast we can go - double maxrate; - -} wireless_network; - -enum host_type { - host_unknown, host_linux, host_windows, host_mac -}; - -typedef struct { - string mac; - - host_type type; - -} wireless_host; class Packetracker { public: @@ -127,8 +32,9 @@ // Set up the gps void AddGPS(GPSD *in_gps); - // Set up filtering - void AddFilter(string in_filter) { filter = in_filter; } + // Set up filtering - removed. we do this in the server now before processing + // anything else. + // void AddFilter(string in_filter) { filter = in_filter; } // Packet tracker stuff int ProcessPacket(packet_info info, char *in_status); @@ -141,15 +47,21 @@ int WriteXMLNetworks(FILE *in_file); int WriteCisco(FILE *in_file); + int WriteGpsdriveWaypt(FILE *in_file); + void WriteSSIDMap(FILE *in_file); void ReadSSIDMap(FILE *in_file); + void WriteIPMap(FILE *in_file); + void ReadIPMap(FILE *in_file); + // Convert the MAC static string Mac2String(uint8_t *mac, char seperator); // Utility to find strings that are empty or contain all spaces static bool IsBlank(const char *s); int FetchNumNetworks() { return num_networks; } + //int FetchNumNetworks() { return bssid_map.size(); } int FetchNumPackets() { return num_packets; } int FetchNumDropped() { return num_dropped; } int FetchNumNoise() { return num_noise; } @@ -170,7 +82,7 @@ num_crypt, num_interesting, num_cisco; // List of MAC's to filter - string filter; + //string filter; // all the networks vector network_list; @@ -183,6 +95,9 @@ // Map BSSID's to SSID for storage and cloaking map bssid_cloak_map; + + // Map BSSID's to IP ranges for storage + map bssid_ip_map; // Map probe responses for clients so we know we need to merge map probe_map; Only in kismet-2.2.2: packetracker.o diff -u kismet-2.2.2/panelfront.cc kismet-devel/panelfront.cc --- kismet-2.2.2/panelfront.cc Tue May 14 15:10:13 2002 +++ kismet-devel/panelfront.cc Tue Jun 11 22:34:46 2002 @@ -24,12 +24,13 @@ " l Show wireless card power levels", " d Dump printable strings", " r Packet rate graph", + " a Statistics", " x Close popup window", "", " q Quit", NULL }; -#define HELP_SIZE 22 +#define HELP_SIZE 24 // Narrow text char *KismetHelpTextNarrow[] = { @@ -49,12 +50,13 @@ " l Show signal levels", " d Dump printable strings", " r Packet rate graph", + " a Statistics", " x Close popup window", "", " q Quit", NULL }; -#define HELP_SIZE_NARROW 20 +#define HELP_SIZE_NARROW 22 char *KismetSortText[] = { "Key Sort Key Sort", @@ -94,7 +96,7 @@ hsize = COLS; vsize = LINES; - cutoff = 0; + //cutoff = 0; muted = 0; @@ -102,6 +104,8 @@ for (unsigned int x = 0; x < (60 * 5); x++) packet_history.push_back(0); + max_packet_rate = 0; + selected = 0; } @@ -362,9 +366,11 @@ break; } - last_displayed.erase(last_displayed.begin(), last_displayed.begin() + last_displayed.size()); +// last_displayed.erase(last_displayed.begin(), last_displayed.begin() + last_displayed.size()); // last_displayed = display_vector; -// last_displayed = network_vector; + // last_displayed = network_vector; + + last_displayed.clear(); int num = 0; int voffset = 2; @@ -436,11 +442,14 @@ } else if (column_vec[col] == "maxrate") { snprintf(title, 1024, "Rate"); len = 5; + } else if (column_vec[col] == "manuf") { + snprintf(title, 1024, "Manuf"); + len = 8; } else { len = -1; } - if (pos + len > print_width+4) + if (pos + len > print_width+3) break; mvwaddstr(netwin, 1, pos, title); @@ -449,19 +458,18 @@ } - cutoff = 0; + //cutoff = 0; for (unsigned int i = display_start; i < display_vector.size(); i++) { if (display_vector[i]->networks.size() == 0) continue; - // if (!paused) last_displayed.push_back(display_vector[i]); wireless_network *net = &display_vector[i]->virtnet; - if (i == (display_start + selected) && sortby != sort_auto) { + if (i == (unsigned) (display_start + selected) && sortby != sort_auto) { wattron(netwin, A_REVERSE); char bar[1024]; memset(bar, ' ', 1024); @@ -485,7 +493,7 @@ mvwaddstr(netwin, num+voffset, 1, netline.c_str()); - if (i == (display_start + selected) && sortby != sort_auto) + if (i == (unsigned) (display_start + selected) && sortby != sort_auto) wattroff(netwin, A_REVERSE); num++; @@ -498,9 +506,7 @@ display_vector[i]->expanded == 0) continue; - // Now we're not hilighted, and we've made sure we'll fit past the end of the screen, - // so if we're not autofitting and we're expanded we want to - + // If we we're a group and we're expanded, show all our subgroups vector sortsub = display_vector[i]->networks; switch (sortby) { case sort_auto: @@ -553,7 +559,7 @@ num++; if (num > max_display) { - cutoff = 1; + //cutoff = 1; break; } } @@ -573,15 +579,6 @@ last_draw_size = group_vec.size(); - /* - if (paused) { - wattron(netwin, A_BLINK); - mvwaddstr(netwin, 0, 12, " PAUSED "); - wattroff(netwin, A_BLINK); - } else { - mvwaddstr(netwin, 0, 12, sortxt); - } - */ mvwaddstr(netwin, 0, 12, sortxt); @@ -589,7 +586,7 @@ mvwaddstr(netwin, 0, netwin->_maxx - 10, "(-) Up"); } - if (display_end < group_vec.size()-1 && sortby != sort_auto) { + if (display_end < (int) (group_vec.size() - 1) && sortby != sort_auto) { mvwaddstr(netwin, netwin->_maxy, netwin->_maxx - 10, "(+) Down"); } @@ -804,54 +801,61 @@ len = 15; } else if (column_vec[col] == "flags") { char atype; - if (net->atype == address_dhcp) + if (net->ipdata.atype == address_dhcp) atype = 'D'; - else if (net->atype == address_arp) + else if (net->ipdata.atype == address_arp) atype = 'A'; - else if (net->atype == address_udp) + else if (net->ipdata.atype == address_udp) atype = 'U'; - else if (net->atype == address_group) + else if (net->ipdata.atype == address_group) atype = 'G'; else atype = ' '; snprintf(element, 6, "%c%c%c%c%c", + net->manuf_score == manuf_max_score ? 'F' : ' ', atype, - (net->octets != 0 && net->octets != 4) ? net->octets + '0' : ' ', + (net->ipdata.octets != 0 && net->ipdata.octets != 4) ? net->ipdata.octets + '0' : ' ', net->cisco_equip.size() > 0 ? 'C' : ' ', - ' ', ' '); len = 5; } else if (column_vec[col] == "ip") { - if (net->atype == address_none) { + if (net->ipdata.atype == address_none) { snprintf(element, 1024, "0.0.0.0"); } else { snprintf(element, 16, "%d.%d.%d.%d", - net->range_ip[0], net->range_ip[1], - net->range_ip[2], net->range_ip[3]); + net->ipdata.range_ip[0], net->ipdata.range_ip[1], + net->ipdata.range_ip[2], net->ipdata.range_ip[3]); } len = 15; } else if (column_vec[col] == "mask") { - if (net->atype == address_none) { + if (net->ipdata.atype == address_none) { snprintf(element, 1024, "0.0.0.0"); } else { snprintf(element, 16, "%d.%d.%d.%d", - net->mask[0], net->mask[1], - net->mask[2], net->mask[3]); + net->ipdata.mask[0], net->ipdata.mask[1], + net->ipdata.mask[2], net->ipdata.mask[3]); } len = 15; } else if (column_vec[col] == "gateway") { - if (net->atype == address_none) { + if (net->ipdata.atype == address_none) { snprintf(element, 1024, "0.0.0.0"); } else { snprintf(element, 16, "%d.%d.%d.%d", - net->gate_ip[0], net->gate_ip[1], - net->gate_ip[2], net->gate_ip[3]); + net->ipdata.gate_ip[0], net->ipdata.gate_ip[1], + net->ipdata.gate_ip[2], net->ipdata.gate_ip[3]); } len = 15; } else if (column_vec[col] == "maxrate") { snprintf(element, 6, "%2.1f", net->maxrate); len = 5; + } else if (column_vec[col] == "manuf") { + if (net->manuf_id >= 0 && net->manuf_id < manuf_num) { + snprintf(element, 9, "%s", manuf_list[net->manuf_id].short_manuf.c_str()); + } else { + snprintf(element, 9, "Unknown"); + } + len = 8; } if (pos + len > print_width) @@ -891,7 +895,7 @@ wresize(netwin, LINES-statheight, COLS-infowidth); replace_panel(network_panel, netwin); - if (selected > (unsigned int) netwin->_maxy - 3) + if (selected > netwin->_maxy - 3) selected = netwin->_maxy - 3; zoomed = 0; @@ -902,9 +906,9 @@ void PanelFront::SpawnPopup(string in_title, panel_printer in_print, int in_x = -1, int in_y = -1) { if (cur_panel == network_panel) { - if (in_x == -1) + if (in_x == -1 || in_x > LINES) in_x = LINES-5; - if (in_y == -1) + if (in_y == -1 || in_y > COLS) in_y = COLS-8; popupwin = newwin(in_x, in_y, 0, 0); @@ -1030,7 +1034,7 @@ werase(panel_window(in_panel)); - const int print_width = panel_window(in_panel)->_maxx - 5; + const int print_width = panel_window(in_panel)->_maxx - 3; if (details_network->name == "") snprintf(output, print_width, "Name : %s", details_network->virtnet.ssid.c_str()); @@ -1038,6 +1042,11 @@ snprintf(output, print_width, "Name : %s", details_network->name.c_str()); details_text.push_back(output); + if (details_network->networks.size() > 1) { + snprintf(output, print_width, "Networks: %d", details_network->networks.size()); + details_text.push_back(output); + } + for (unsigned int x = 0; x < details_network->networks.size(); x++) { wireless_network *dnet = details_network->networks[x]; @@ -1059,7 +1068,17 @@ snprintf(output, print_width, " SSID Cloaking on/Closed Network"); details_text.push_back(output); } - + + snprintf(output, print_width, "Manuf : %s", + dnet->manuf_id >= 0 ? manuf_list[dnet->manuf_id].name.c_str() : + "Unknown"); + details_text.push_back(output); + + if (dnet->manuf_score == manuf_max_score) { + snprintf(output, print_width, " WARNING: DEFAULT CONFIGURATION"); + details_text.push_back(output); + } + snprintf(output, print_width, "BSSID : %s", dnet->bssid.c_str()); details_text.push_back(output); @@ -1118,15 +1137,15 @@ snprintf(output, print_width, " Weak : %d", dnet->interesting_packets); details_text.push_back(output); - switch (dnet->atype) { + switch (dnet->ipdata.atype) { case address_none: snprintf(output, print_width, "IP Type : None detected"); break; case address_udp: - snprintf(output, print_width, "IP Type : UDP (%d octets)", dnet->octets); + snprintf(output, print_width, "IP Type : UDP (%d octets)", dnet->ipdata.octets); break; case address_arp: - snprintf(output, print_width, "IP Type : ARP (%d octets)", dnet->octets); + snprintf(output, print_width, "IP Type : ARP (%d octets)", dnet->ipdata.octets); break; case address_dhcp: snprintf(output, print_width, "IP Type : DHCP"); @@ -1137,21 +1156,21 @@ } details_text.push_back(output); - if (dnet->atype != address_none) { + if (dnet->ipdata.atype != address_none) { snprintf(output, print_width, "IP Range: %d.%d.%d.%d", - dnet->range_ip[0], dnet->range_ip[1], - dnet->range_ip[2], dnet->range_ip[3]); + dnet->ipdata.range_ip[0], dnet->ipdata.range_ip[1], + dnet->ipdata.range_ip[2], dnet->ipdata.range_ip[3]); details_text.push_back(output); - if (dnet->atype == address_dhcp) { + if (dnet->ipdata.atype == address_dhcp) { snprintf(output, print_width, "Netmask : %d.%d.%d.%d", - dnet->mask[0], dnet->mask[1], - dnet->mask[2], dnet->mask[3]); + dnet->ipdata.mask[0], dnet->ipdata.mask[1], + dnet->ipdata.mask[2], dnet->ipdata.mask[3]); details_text.push_back(output); snprintf(output, print_width, "Gateway : %d.%d.%d.%d", - dnet->gate_ip[0], dnet->gate_ip[1], - dnet->gate_ip[2], dnet->gate_ip[3]); + dnet->ipdata.gate_ip[0], dnet->ipdata.gate_ip[1], + dnet->ipdata.gate_ip[2], dnet->ipdata.gate_ip[3]); details_text.push_back(output); } @@ -1266,8 +1285,6 @@ if ((ch = wgetch(panel_window(cur_panel))) == ERR) return 0; - // char foo[100]; - if (cur_panel == network_panel) { switch (ch) { case 'q': @@ -1285,21 +1302,6 @@ WriteStatus("Cannot scroll in autofit sort mode."); } - /* - snprintf(foo, 100, "Selected: %d start: %d end: %d", - selected, display_start, display_end); - WriteStatus(foo); - */ - - /* - if (sortby != sort_auto || paused) { - if (selected == 0 && display_start != 0) { - display_start--; - } else if (selected > 0) { - selected--; - } - */ - break; case KEY_DOWN: if (sortby != sort_auto) { @@ -1311,38 +1313,10 @@ selected++; } - /* - snprintf(foo, 100, "Selected: %d start: %d end: %d", - selected, display_start, display_end); - WriteStatus(foo); - */ - } else { WriteStatus("Cannot scroll in autofit sort mode."); } break; - /* - case KEY_PPAGE: - if (sortby != sort_auto) { - if (display_start > 0) - display_start -= (netwin->_maxy - netwin->_begy - 3) / 2; - - if (display_start < 0) - display_start = 0; - } - break; - case KEY_NPAGE: - if (sortby != sort_auto && !paused) { - if (display_end < client->FetchNumNetworks()) { - display_start += (netwin->_maxy - netwin->_begy - 3) / 2; - - if (display_start > client->FetchNumNetworks() - 1) - display_start = client->FetchNumNetworks() - 1; - - } - } - break; - */ case KEY_RIGHT: case '+': if (sortby != sort_auto) { @@ -1436,6 +1410,10 @@ case 'R': SpawnPopup("Packet Rate", &PanelFront::PrintKismetPackHistory); break; + case 'a': + case 'A': + SpawnPopup("Statistics", &PanelFront::PrintKismetStatistics, 20, 65); + break; case 'm': case 'M': MuteToggle(); @@ -1501,6 +1479,8 @@ break; case 'x': case 'X': + case 'q': + case 'Q': break; default: beep(); @@ -1609,7 +1589,22 @@ // Pull our packet count, store it, and bounce if we're // holding more than 5 minutes worth. - packet_history.push_back(client->FetchNumPackets()); + + int rate = client->FetchNumPackets() - client->FetchNumDropped(); + + // Find the delta change since the last event and push it as the max seen packet + // rate if it's larger. + int adjrate; + if (packet_history[packet_history.size()] != 0) { + adjrate = rate - packet_history[packet_history.size()]; + } else { + adjrate = 0; + } + if (adjrate > max_packet_rate) + max_packet_rate = adjrate; + + + packet_history.push_back(rate); if (packet_history.size() > (60 * 5)) packet_history.erase(packet_history.begin()); @@ -1683,6 +1678,134 @@ } } +void PanelFront::PrintKismetStatistics(PANEL *in_panel) { + vector details_text; + char output[1024]; + + werase(panel_window(in_panel)); + + const int print_width = panel_window(in_panel)->_maxx - 3; + + snprintf(output, print_width, "Start : %s", ctime((const time_t *) &start_time)); + details_text.push_back(output); + + snprintf(output, print_width, "Networks: %d", client->FetchNumNetworks()); + details_text.push_back(output); + + vector netlist = client->FetchNetworkList(); + + int wep_count = 0, vuln_count = 0; + int channelperc[CHANNEL_MAX]; + int maxch = 0; + + memset(channelperc, 0, sizeof(int) * CHANNEL_MAX); + + // Summarize the network data + for (unsigned int x = 0; x < netlist.size(); x++) { + if (netlist[x]->channel > 0 && netlist[x]->channel < CHANNEL_MAX) { + int perc = ++channelperc[netlist[x]->channel - 1]; + if (perc > maxch) + maxch = perc; + } + + if (netlist[x]->wep) + wep_count++; + if (netlist[x]->manuf_score == manuf_max_score) + vuln_count++; + } + + snprintf(output, print_width, " Encrypted: %d (%d%%)", wep_count, + client->FetchNumNetworks() > 0 ? + (int) (((double) wep_count / client->FetchNumNetworks()) * 100) : 0); + details_text.push_back(output); + + snprintf(output, print_width, " Default : %d (%d%%)", vuln_count, + client->FetchNumNetworks() > 0 ? + (int) (((double) vuln_count / client->FetchNumNetworks()) * 100) : 0); + details_text.push_back(output); + + snprintf(output, print_width, "Max. Packet Rate: %d packets/sec", + max_packet_rate); + details_text.push_back(output); + + snprintf(output, print_width, "Channel Usage:"); + details_text.push_back(output); + + unsigned int graph_height = 7; + char line[1024]; + + + // Make a nice graph if we have room + if (print_width >= 48) { + snprintf(output, print_width, " --------------------------- -----------------------------"); + details_text.push_back(output); + + unsigned int vdraw = 1; + for (unsigned int x = 0; x < graph_height; x++) { + memset(line, '\0', print_width); + line[0] = line[1] = ' '; + unsigned int draw = 2; + + for (unsigned int y = 0; y < CHANNEL_MAX; y++) { + if ((((double) channelperc[y] / maxch) * graph_height) >= (graph_height - x)) + line[draw] = 'X'; + else + line[draw] = ' '; + + line[draw+1] = ' '; + draw += 2; + } + + snprintf(output, print_width, "%s %02d: %3d (%02d%%) | %02d: %3d (%02d%%)", + line, vdraw, channelperc[vdraw-1], + client->FetchNumNetworks() > 0 ? + (int) (((double) channelperc[vdraw-1] / client->FetchNumNetworks()) * 100) : 0, + vdraw+1, channelperc[vdraw], + client->FetchNumNetworks() > 0 ? + (int) (((double) channelperc[vdraw] / client->FetchNumNetworks()) * 100) : 0); + vdraw += 2; + details_text.push_back(output); + } + + snprintf(output, print_width, " --------------------------- -----------------------------"); + details_text.push_back(output); + snprintf(output, print_width, " 1 2 3 4 5 6 7 8 9 1 1 1 1 1"); + details_text.push_back(output); + snprintf(output, print_width, " 0 1 2 3 4"); + details_text.push_back(output); + } else { + output[0] = '\0'; + + unsigned int netchunk = (unsigned int) ceil((double) print_width / 13); + if (netchunk > 4) + netchunk = 4; + + for (unsigned int x = 0; x < CHANNEL_MAX; x++) { + snprintf(line, print_width, "%s %02d: %3d (%2d%%)", + output, x+1, channelperc[x], + client->FetchNumNetworks() > 0 ? + (int) (((double) channelperc[x] / client->FetchNumNetworks()) * 100) : 0); + strncpy(output, line, 1024); + + if ((x+1) % netchunk == 0) { + details_text.push_back(output); + output[0] = '\0'; + } + } + if (strlen(output) > 0) + details_text.push_back(output); + } + + for (unsigned int x = 0; x + popup_start < details_text.size() && + x < (unsigned int) panel_window(in_panel)->_maxy - 1; x++) { + mvwaddstr(panel_window(in_panel), 1+x, 2, details_text[x+popup_start].c_str()); + popup_end = x + popup_start; + } + + popup_length = details_text.size(); + +} + void PanelFront::PrintKismetPackHistory(PANEL *in_panel) { // -Packet History---------------| @@ -1751,19 +1874,21 @@ // Scan across each row of the graph and draw the columns where needed char *graphstring = new char[graph_width+1]; - for (unsigned int x = 0; x < graph_height; x++) { - memset(graphstring, '\0', graph_width+1); - for (unsigned int y = 0; y < averaged_history.size() && y < graph_width; y++) { - if (averaged_history[y] >= (graph_height - x)) - graphstring[y] = 'X'; - else - graphstring[y] = ' '; - } + if (avg_max != 0) + for (unsigned int x = 0; x < graph_height; x++) { + memset(graphstring, '\0', graph_width+1); + + for (unsigned int y = 0; y < averaged_history.size() && y < graph_width; y++) { + if (averaged_history[y] >= (graph_height - x)) + graphstring[y] = 'X'; + else + graphstring[y] = ' '; + } - mvwaddstr(panel_window(in_panel), graph_voffset+x, graph_hoffset-1, "|"); - mvwaddstr(panel_window(in_panel), graph_voffset+x, graph_hoffset, graphstring); - } + mvwaddstr(panel_window(in_panel), graph_voffset+x, graph_hoffset-1, "|"); + mvwaddstr(panel_window(in_panel), graph_voffset+x, graph_hoffset, graphstring); + } // Print the framework around the graph mvwaddstr(panel_window(in_panel), 1, 2, "Pkts"); diff -u kismet-2.2.2/panelfront.h kismet-devel/panelfront.h --- kismet-2.2.2/panelfront.h Mon May 13 16:46:47 2002 +++ kismet-devel/panelfront.h Tue Jun 4 13:04:29 2002 @@ -70,6 +70,7 @@ void PrintKismetDump(PANEL *in_panel); void PrintKismetGroupname(PANEL *in_panel); void PrintKismetPackHistory(PANEL *in_panel); + void PrintKismetStatistics(PANEL *in_panel); void Details2Vector(wireless_network *in_net); @@ -84,10 +85,10 @@ int clear_dump; sort_type sortby; - unsigned int display_start; - unsigned int display_end; - unsigned int selected; - unsigned int cutoff; + int display_start; + int display_end; + int selected; + int cutoff; int print_width; int max_display; @@ -132,7 +133,7 @@ vector packet_history; // Size of the group vec the last time we drew it - unsigned int last_draw_size; + int last_draw_size; // Battery monitoring states unsigned int monitor_bat; @@ -141,6 +142,10 @@ unsigned int bat_available; unsigned int bat_ac; unsigned int bat_charging; + + // Statistics + int max_packet_rate; + }; Only in kismet-2.2.2: panelfront.o Only in kismet-2.2.2: pcapsource.o Only in kismet-2.2.2: prism2_hopper Only in kismet-2.2.2: prism2hopper.o Only in kismet-2.2.2: prism2source.o Common subdirectories: kismet-2.2.2/scripts and kismet-devel/scripts diff -u kismet-2.2.2/tcpclient.cc kismet-devel/tcpclient.cc --- kismet-2.2.2/tcpclient.cc Sun Apr 28 22:21:43 2002 +++ kismet-devel/tcpclient.cc Tue May 28 02:30:13 2002 @@ -17,6 +17,8 @@ power = quality = noise = 0; memset(status, 0, STATUS_MAX); + memset(channel_graph, 0, sizeof(channel_power) * CHANNEL_MAX); + } TcpClient::~TcpClient() { @@ -189,11 +191,11 @@ scanned = sscanf(in_data, "%*[^:]: %17s %d \001%255[^\001]\001 \001%255[^\001]\001 " "%d %d %d %d %d %d %d %d %d %hd.%hd.%hd.%hd %hd.%hd.%hd.%hd %hd.%hd.%hd.%hd " - "%d %f %f %f %f %f %f %f %f %d %d %d %f", + "%d %f %f %f %f %f %f %f %f %d %d %d %f %d %d", bssid, (int *) &net.type, ssid, beacon, &net.llc_packets, &net.data_packets, &net.crypt_packets, &net.interesting_packets, &net.channel, &net.wep, (int *) &net.first_time, (int *) &net.last_time, - (int *) &net.atype, &range[0], &range[1], &range[2], &range[3], + (int *) &net.ipdata.atype, &range[0], &range[1], &range[2], &range[3], &mask[0], &mask[1], &mask[2], &mask[3], &gate[0], &gate[1], &gate[2], &gate[3], &net.gps_fixed, &net.min_lat, &net.min_lon, &net.min_alt, &net.min_spd, @@ -203,8 +205,9 @@ &net.first_lat, &net.first_lon, &net.first_alt, &net.first_spd, &net.first_mode, */ - &net.octets, &net.cloaked, &net.beacon, - &maxrate); + &net.ipdata.octets, &net.cloaked, &net.beacon, + &maxrate, + &net.manuf_id, &net.manuf_score); if (scanned < 36) { //fprintf(stderr, "Flubbed network, discarding...\n"); @@ -238,9 +241,9 @@ if (beacon[0] != '\002') net.beacon_info = beacon; for (int x = 0; x < 4; x++) { - net.range_ip[x] = (uint8_t) range[x]; - net.mask[x] = (uint8_t) mask[x]; - net.gate_ip[x] = (uint8_t) gate[x]; + net.ipdata.range_ip[x] = (uint8_t) range[x]; + net.ipdata.mask[x] = (uint8_t) mask[x]; + net.ipdata.gate_ip[x] = (uint8_t) gate[x]; } net.maxrate = maxrate; @@ -269,11 +272,23 @@ return 0; } else if (!strncmp(header, "*INFO", 64)) { - if (sscanf(in_data, "%*[^:]: %d %d %d %d %d %d %d %d %d\n", + char chan_details[1024]; + char chan_details_sec[1024]; + unsigned int numchan; + if (sscanf(in_data, "%*[^:]: %d %d %d %d %d %d %d %d %d %d%1024s\n", &num_networks, &num_packets, &num_crypt, &num_interesting, - &num_noise, &num_dropped, &quality, &power, &noise) < 9) + &num_noise, &num_dropped, &quality, &power, &noise, &numchan, + chan_details) < 11) return 0; + + for (unsigned int x = 0; x < CHANNEL_MAX && x < numchan; x++) { + if (sscanf(chan_details, "%d %1024s\n", + &channel_graph[x].signal, chan_details_sec) < 1) + break; + strncpy(chan_details, chan_details_sec, 1024); + } + } else if (!strncmp(header, "*CISCO", 64)) { cdp_packet cdp; memset(&cdp, 0, sizeof(cdp_packet)); @@ -354,3 +369,9 @@ return vec; } +int TcpClient::FetchChannelPower(int in_channel) { + if (in_channel > 0 && in_channel < CHANNEL_MAX) + return channel_graph[in_channel - 1].signal; + + return -1; +} diff -u kismet-2.2.2/tcpclient.h kismet-devel/tcpclient.h --- kismet-2.2.2/tcpclient.h Fri Apr 26 00:07:32 2002 +++ kismet-devel/tcpclient.h Tue May 21 23:20:59 2002 @@ -78,6 +78,8 @@ int FetchQuality() { return quality; } int FetchNoise() { return noise; } + int FetchChannelPower(int in_channel); + vector FetchStrings() { return strings; } void ClearStrings() { strings.clear(); } @@ -120,6 +122,9 @@ int power, quality, noise; vector strings; + + channel_power channel_graph[CHANNEL_MAX]; + }; #endif Only in kismet-2.2.2: tcpclient.o Only in kismet-2.2.2: tcpserver.o Only in kismet-devel: tracktypes.h Common subdirectories: kismet-2.2.2/wav and kismet-devel/wav Only in kismet-2.2.2: wtapdump.o Only in kismet-2.2.2: wtapfilesource.o Only in kismet-2.2.2: wtaplocaldump.o