From 1b95518ce19602f5e0f88c55829f9d64ccb245b5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 9 May 2013 17:29:03 -0700 Subject: [PATCH] remove kismet plugin - closes #1833 --- SConstruct | 1 - bindings/python/mapnik/__init__.py | 20 -- plugins/input/kismet/build.py | 51 ---- plugins/input/kismet/kismet_datasource.cpp | 291 --------------------- plugins/input/kismet/kismet_datasource.hpp | 73 ------ plugins/input/kismet/kismet_featureset.cpp | 97 ------- plugins/input/kismet/kismet_featureset.hpp | 61 ----- plugins/input/kismet/kismet_types.hpp | 111 -------- 8 files changed, 705 deletions(-) delete mode 100644 plugins/input/kismet/build.py delete mode 100644 plugins/input/kismet/kismet_datasource.cpp delete mode 100644 plugins/input/kismet/kismet_datasource.hpp delete mode 100644 plugins/input/kismet/kismet_featureset.cpp delete mode 100644 plugins/input/kismet/kismet_featureset.hpp delete mode 100644 plugins/input/kismet/kismet_types.hpp diff --git a/SConstruct b/SConstruct index 4d99c9b36..717013f32 100644 --- a/SConstruct +++ b/SConstruct @@ -101,7 +101,6 @@ PLUGINS = { # plugins with external dependencies 'csv': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'}, 'raster': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'}, 'geojson': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'}, - 'kismet': {'default':False,'path':None,'inc':None,'lib':None,'lang':'C++'}, 'python': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'}, } diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index eca8c89b8..acb7dfe0b 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -558,26 +558,6 @@ def Osm(**keywords): keywords['type'] = 'osm' return CreateDatasource(keywords) -def Kismet(**keywords): - """Create a Kismet Datasource. - - Required keyword arguments: - host -- kismet hostname - port -- kismet port - - Optional keyword arguments: - encoding -- file encoding (default 'utf-8') - extent -- manually specified data extent (comma delimited string, default None) - - >>> from mapnik import Kismet, Layer - >>> datasource = Kismet(host='localhost',port=2501,extent='-179,-85,179,85') - >>> lyr = Layer('Kismet Server Layer') - >>> lyr.datasource = datasource - - """ - keywords['type'] = 'kismet' - return CreateDatasource(keywords) - def Geos(**keywords): """Create a GEOS Vector Datasource. diff --git a/plugins/input/kismet/build.py b/plugins/input/kismet/build.py deleted file mode 100644 index d85ced8e1..000000000 --- a/plugins/input/kismet/build.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# This file is part of Mapnik (c++ mapping toolkit) -# -# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon -# -# Mapnik is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# - -Import ('plugin_base') -Import ('env') - -prefix = env['PREFIX'] - -plugin_env = plugin_base.Clone() - -kismet_src = Split( - """ - kismet_datasource.cpp - kismet_featureset.cpp - """ - ) - -libraries = [] -# Link Library to Dependencies -libraries.append('mapnik') -libraries.append(env['ICU_LIB_NAME']) -libraries.append('boost_system%s' % env['BOOST_APPEND']) -if env['THREADING'] == 'multi': - libraries.append('boost_thread%s' % env['BOOST_APPEND']) - -input_plugin = plugin_env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) - -# if the plugin links to libmapnik ensure it is built first -Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) - -if 'uninstall' not in COMMAND_LINE_TARGETS: - env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) - env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) diff --git a/plugins/input/kismet/kismet_datasource.cpp b/plugins/input/kismet/kismet_datasource.cpp deleted file mode 100644 index 96348e151..000000000 --- a/plugins/input/kismet/kismet_datasource.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -// network -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// mapnik -#include -#include - -// boost -#include -#include -#include -#include - -#include "kismet_datasource.hpp" -#include "kismet_featureset.hpp" - -#define MAX_TCP_BUFFER 4096 // maximum accepted TCP data block size - -// If you change this also change the according kismet command length ! -#define MAX_KISMET_LINE 1024 // maximum length of a kismet command (assumed) -#define KISMET_COMMAND "*NETWORK: \001%1024[^\001]\001 %1024s %d %lf %lf" - -using mapnik::datasource; -using mapnik::parameters; - -DATASOURCE_PLUGIN(kismet_datasource) - -using mapnik::box2d; -using mapnik::coord2d; -using mapnik::query; -using mapnik::featureset_ptr; -using mapnik::layer_descriptor; -using mapnik::attribute_descriptor; -using mapnik::datasource_exception; - -boost::mutex knd_list_mutex; -std::list knd_list; -const unsigned int queue_size = 20; - -kismet_datasource::kismet_datasource(parameters const& params) - : datasource(params), - extent_(), - extent_initialized_(false), - type_(datasource::Vector), - srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), - desc_(*params.get("type"), *params.get("encoding","utf-8")) -{ - boost::optional host = params.get("host"); - if (host) - { - host_ = *host; - } - else - { - throw datasource_exception("Kismet Plugin: missing parameter"); - } - - boost::optional port = params.get("port", 2501); - if (port) - { - port_ = static_cast(*port); - } - - boost::optional srs = params.get("srs"); - if (srs) - { - srs_ = *srs; - } - - boost::optional ext = params.get("extent"); - if (ext) - { - extent_initialized_ = extent_.from_string(*ext); - } - - kismet_thread.reset(new boost::thread(boost::bind(&kismet_datasource::run, this, host_, port_))); -} - -kismet_datasource::~kismet_datasource() -{ -} - -const char * kismet_datasource::name() -{ - return "kismet"; -} - -mapnik::datasource::datasource_t kismet_datasource::type() const -{ - return type_; -} - -box2d kismet_datasource::envelope() const -{ - return extent_; -} - -boost::optional kismet_datasource::get_geometry_type() const -{ - return boost::optional(mapnik::datasource::Point); -} - -layer_descriptor kismet_datasource::get_descriptor() const -{ - return desc_; -} - -featureset_ptr kismet_datasource::features(query const& q) const -{ - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()"; - - // TODO: use box2d to filter bbox before adding to featureset_ptr - // mapnik::box2d const& e = q.get_bbox(); - - boost::mutex::scoped_lock lock(knd_list_mutex); - return boost::make_shared(knd_list, - srs_, - desc_.get_encoding()); - - // TODO: if illegal: - // return featureset_ptr(); -} - -featureset_ptr kismet_datasource::features_at_point(coord2d const& pt, double tol) const -{ - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()"; - - return featureset_ptr(); -} - -void kismet_datasource::run(std::string const& ip_host, const unsigned int port) -{ - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource: Enter run"; - - int sockfd, n; - struct sockaddr_in sock_addr; - struct in_addr inadr; - struct hostent* host; - char buffer[MAX_TCP_BUFFER]; // TCP data send from kismet_server - std::string command; - - if (inet_aton(ip_host.c_str(), &inadr)) - { - host = gethostbyaddr((char*)&inadr, sizeof(inadr), AF_INET); - } - else - { - host = gethostbyname(ip_host.c_str()); - } - - if (host == NULL) - { - MAPNIK_LOG_ERROR(kismet) << "Kismet Plugin: error while searching host"; - return; - } - - sock_addr.sin_family = AF_INET; - sock_addr.sin_port = htons(port); - memcpy(&sock_addr.sin_addr, host->h_addr_list[0], sizeof(sock_addr.sin_addr)); - - if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) < 0) - { - MAPNIK_LOG_ERROR(kismet) << "Kismet Plugin: error while creating socket"; - return; - } - - if (connect(sockfd, (struct sockaddr*) &sock_addr, sizeof(sock_addr))) - { - MAPNIK_LOG_ERROR(kismet) << "Kismet Plugin: Error while connecting"; - return; - } - - command = "!1 ENABLE NETWORK ssid,bssid,wep,bestlat,bestlon\n"; - - if (write(sockfd, command.c_str(), command.length()) != (signed)command.length()) - { - MAPNIK_LOG_ERROR(kismet) << "Kismet Plugin: Error sending command to " << ip_host; - - close(sockfd); - return; - } - - char ssid[MAX_KISMET_LINE] = {}; - char bssid[MAX_KISMET_LINE] = {}; - double bestlat = 0; - double bestlon = 0; - int crypt = crypt_none; - - // BUG: if kismet_server is active sending after mapnik was killed and then restarted the - // assert is called. Needs to be analyzed! - while ((n = read(sockfd, buffer, sizeof(buffer))) > 0) - { - assert(n < MAX_TCP_BUFFER); - - buffer[n] = '\0'; - std::string bufferObj(buffer); // TCP data send from kismet_server as STL string - - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource: buffer_obj=" << bufferObj; - - std::string::size_type found = 0; - std::string::size_type search_start = 0; - std::string kismet_line; // contains a line from kismet_server - do - { - found = bufferObj.find('\n', search_start); - if (found != std::string::npos) - { - kismet_line.assign(bufferObj, search_start, found - search_start); - - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource: line=" << kismet_line; - - int param_number = 5; // the number of parameters to parse - - // Attention: string length specified to the constant! - if (sscanf (kismet_line.c_str(), - KISMET_COMMAND, - ssid, - bssid, - &crypt, - &bestlat, - &bestlon) == param_number) - { - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource: ssid=" << ssid - << ", bssid=" << bssid - << ", crypt=" << crypt - << ", bestlat=" << bestlat - << ", bestlon=" << bestlon; - - kismet_network_data knd(ssid, bssid, bestlat, bestlon, crypt); - - boost::mutex::scoped_lock lock(knd_list_mutex); - - // the queue only grows to a max size - if (knd_list.size () >= queue_size) - { - knd_list.pop_front(); - } - - knd_list.push_back(knd); - } - else - { - // do nothing if not matched! - } - - search_start = found + 1; - } - } - while (found != std::string::npos); - } - - if (n < 0) - { - MAPNIK_LOG_ERROR(kismet) << "Kismet Plugin: error while reading from socket"; - } - - close(sockfd); - - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource: Exit run"; -} - diff --git a/plugins/input/kismet/kismet_datasource.hpp b/plugins/input/kismet/kismet_datasource.hpp deleted file mode 100644 index 272a15ddd..000000000 --- a/plugins/input/kismet/kismet_datasource.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef KISMET_DATASOURCE_HPP -#define KISMET_DATASOURCE_HPP - -// mapnik -#include -#include -#include -#include -#include -#include -#include - -// boost -#include -#include -#include - -// stl -#include -#include -#include - -#include "kismet_types.hpp" - -class kismet_datasource : public mapnik::datasource -{ -public: - kismet_datasource(mapnik::parameters const& params); - virtual ~kismet_datasource (); - datasource::datasource_t type() const; - static const char * name(); - mapnik::featureset_ptr features(mapnik::query const& q) const; - mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const; - mapnik::box2d envelope() const; - boost::optional get_geometry_type() const; - mapnik::layer_descriptor get_descriptor() const; - -private: - void run (std::string const& host, const unsigned int port); - - mapnik::box2d extent_; - bool extent_initialized_; - std::string host_; - unsigned int port_; - mapnik::datasource::datasource_t type_; - std::string srs_; - mapnik::layer_descriptor desc_; - boost::shared_ptr kismet_thread; -}; - -#endif // KISMET_DATASOURCE_HPP diff --git a/plugins/input/kismet/kismet_featureset.cpp b/plugins/input/kismet/kismet_featureset.cpp deleted file mode 100644 index edd4ec95c..000000000 --- a/plugins/input/kismet/kismet_featureset.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -// mapnik -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kismet_featureset.hpp" - -// boost -#include - -using mapnik::feature_ptr; -using mapnik::geometry_type; -using mapnik::geometry_utils; -using mapnik::transcoder; -using mapnik::feature_factory; - -kismet_featureset::kismet_featureset(std::list const& knd_list, - std::string const& srs, - std::string const& encoding) - : knd_list_(knd_list), - tr_(new transcoder(encoding)), - feature_id_(1), - knd_list_it(knd_list_.begin()), - source_(srs), - ctx_(boost::make_shared()) -{ - ctx_->push("internet_access"); -} - -kismet_featureset::~kismet_featureset() -{ -} - -feature_ptr kismet_featureset::next() -{ - if (knd_list_it != knd_list_.end ()) - { - const kismet_network_data& knd = *knd_list_it; - const std::string key = "internet_access"; - - std::string value; - if (knd.crypt() == crypt_none) - { - value = "wlan_uncrypted"; - } - else if (knd.crypt() == crypt_wep) - { - value = "wlan_wep"; - } - else - { - value = "wlan_crypted"; - } - - feature_ptr feature(feature_factory::create(ctx_,feature_id_)); - ++feature_id_; - - geometry_type* pt = new geometry_type(mapnik::Point); - pt->move_to(knd.bestlon(), knd.bestlat()); - feature->add_geometry(pt); - - feature->put(key, tr_->transcode(value.c_str())); - - ++knd_list_it; - - return feature; - } - - return feature_ptr(); -} diff --git a/plugins/input/kismet/kismet_featureset.hpp b/plugins/input/kismet/kismet_featureset.hpp deleted file mode 100644 index 91e6afef7..000000000 --- a/plugins/input/kismet/kismet_featureset.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef KISMET_FEATURESET_HPP -#define KISMET_FEATURESET_HPP - -// mapnik -#include -#include -#include -#include -#include -#include - -// boost -#include -#include - -//STL -#include - -#include "kismet_types.hpp" - -class kismet_featureset : public mapnik::Featureset -{ -public: - kismet_featureset(std::list const& knd_list, - std::string const& srs, - std::string const& encoding); - virtual ~kismet_featureset(); - mapnik::feature_ptr next(); - -private: - std::list const& knd_list_; - boost::scoped_ptr tr_; - mapnik::value_integer feature_id_; - std::list::const_iterator knd_list_it; - mapnik::projection source_; - mapnik::context_ptr ctx_; -}; - -#endif // KISMET_FEATURESET_HPP diff --git a/plugins/input/kismet/kismet_types.hpp b/plugins/input/kismet/kismet_types.hpp deleted file mode 100644 index ea9ff856a..000000000 --- a/plugins/input/kismet/kismet_types.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2011 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef KISMET_TYPES_HPP -#define KISMET_TYPES_HPP - -// mapnik -#include - -// boost -#include - -// this is a copy from packet.h from kismet 2007.10.R1 -enum crypt_type -{ - crypt_none = 0, - crypt_unknown = 1, - crypt_wep = 2, - crypt_layer3 = 4, - // Derived from WPA headers - crypt_wep40 = 8, - crypt_wep104 = 16, - crypt_tkip = 32, - crypt_wpa = 64, - crypt_psk = 128, - crypt_aes_ocb = 256, - crypt_aes_ccm = 512, - // Derived from data traffic - crypt_leap = 1024, - crypt_ttls = 2048, - crypt_tls = 4096, - crypt_peap = 8192, - crypt_isakmp = 16384, - crypt_pptp = 32768, - crypt_ccmp = 65536 -}; - -class kismet_network_data -{ -public: - kismet_network_data() - : bestlat_(0), bestlon_(0), crypt_(crypt_none) - { - } - - kismet_network_data(std::string ssid, - std::string bssid, - double bestlat, - double bestlon, - int crypt) - : ssid_(ssid), - bssid_(bssid), - bestlat_(bestlat), - bestlon_(bestlon), - crypt_(crypt) - { - } - - std::string const& ssid() const - { - return ssid_; - } - - std::string const& bssid() const - { - return bssid_; - } - - double bestlat() const - { - return bestlat_; - } - - double bestlon() const - { - return bestlon_; - } - - int crypt() const - { - return crypt_; - } - -protected: - std::string ssid_; - std::string bssid_; - double bestlat_; - double bestlon_; - int crypt_; -}; - -#endif // KISMET_TYPES_HPP