summaryrefslogtreecommitdiff
path: root/wsutil/filesystem.c
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2014-02-25 14:05:11 +0100
committerMichael Mann <mmann78@netscape.net>2014-08-21 03:34:02 +0000
commitbed29af46db06f4bce00d8a4dab26317d4563dd3 (patch)
tree3502e7ee703097a9c7c3e067ac9e6c7b5ad9ed8a /wsutil/filesystem.c
parent401469880b8b98a4d42011bdf9af7fbb67c6f057 (diff)
downloadwireshark-bed29af46db06f4bce00d8a4dab26317d4563dd3.tar.gz
Extcap Capture Interface
Extcap is a plugin interface, which allows for the usage of external capture interfaces via pipes using a predefined configuration language which results in a graphical gui. This implementation seeks for a generic implementation, which results in a seamless integration with the current system, and does add all external interfaces as simple interfaces. Windows Note: Due to limitations with GTK and Windows, a gspawn-winXX-helper.exe, respective gspawn-winXX-helper-console.exe is needed, which is part of any GTK windows installation. The default installation directory from the build is an extcap subdirectory underneath the run directory. The folder used by extcap may be viewed in the folders tab of the about dialog. The default installation directory for extcap plugins with a pre-build or installer version of wireshark is the extcap subdirectory underneath the main wireshark directory. For more information see: http://youtu.be/Nn84T506SwU bug #9009 Also take a look in doc/extcap_example.py for a Python-example and in extcap.pod for the arguments grammer. Todo: - Integrate with Qt - currently no GUI is generated, but the interfaces are still usable Change-Id: I4f1239b2f1ebd8b2969f73af137915f5be1ce50f Signed-off-by: Mike Ryan <mikeryan+wireshark@lacklustre.net> Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net> Signed-off-by: Roland Knall <rknall@gmail.com> Reviewed-on: https://code.wireshark.org/review/359 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r--wsutil/filesystem.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 6125236bd7..99b3e5340e 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1062,6 +1062,117 @@ get_plugin_dir(void)
#endif
}
+#if defined(HAVE_EXTCAP)
+/*
+ * Find the directory where the extcap hooks are stored.
+ *
+ * On Windows, we use the "extcap" subdirectory of the datafile directory.
+ *
+ * On UN*X, we use the EXTCAP_DIR value supplied by the configure
+ * script, unless we think we're being run from the build directory,
+ * in which case we use the "extcap" subdirectory of the datafile directory.
+ *
+ * In both cases, we then use the subdirectory of that directory whose
+ * name is the version number.
+ *
+ * XXX - if we think we're being run from the build directory, perhaps we
+ * should have the extcap code not look in the version subdirectory
+ * of the extcap directory, but look in all of the subdirectories
+ * of the extcap directory, so it can just fetch the extcap hooks built
+ * as part of the build process.
+ */
+static const char *extcap_dir = NULL;
+
+static void init_extcap_dir(void) {
+#ifdef _WIN32
+ /*
+ * On Windows, the data file directory is the installation
+ * directory; the extcap hooks are stored under it.
+ *
+ * Assume we're running the installed version of Wireshark;
+ * on Windows, the data file directory is the directory
+ * in which the Wireshark binary resides.
+ */
+ extcap_dir = g_strdup_printf("%s\\extcap\\%s", get_datafile_dir(),
+ VERSION);
+
+ /*
+ * Make sure that pathname refers to a directory.
+ */
+ if (test_for_directory(extcap_dir) != EISDIR) {
+ /*
+ * Either it doesn't refer to a directory or it
+ * refers to something that doesn't exist.
+ *
+ * Assume that means we're running a version of
+ * Wireshark we've built in a build directory,
+ * in which case {datafile dir}\plugins is the
+ * top-level extcap hooks source directory, and use
+ * that directory and set the "we're running in
+ * a build directory" flag, so the plugin
+ * scanner will check all subdirectories of that
+ * directory for extcap hooks.
+ */
+ g_free( (gpointer) extcap_dir);
+ extcap_dir = g_strdup_printf("%s\\extcap", get_datafile_dir());
+ running_in_build_directory_flag = TRUE;
+ }
+#else
+ if (running_in_build_directory_flag) {
+ /*
+ * We're (probably) being run from the build directory and
+ * weren't started with special privileges, so we'll use
+ * the "extcap hooks" subdirectory of the directory where the program
+ * we're running is (that's the build directory).
+ */
+ extcap_dir = g_strdup_printf("%s/extcap", get_progfile_dir());
+ } else {
+ if (getenv("WIRESHARK_EXTCAP_DIR") && !started_with_special_privs()) {
+ /*
+ * The user specified a different directory for extcap hooks
+ * and we aren't running with special privileges.
+ */
+ extcap_dir = g_strdup(getenv("WIRESHARK_EXTCAP_DIR"));
+ }
+#ifdef __APPLE__
+ /*
+ * If we're running from an app bundle and weren't started
+ * with special privileges, use the Contents/Resources/lib/wireshark/extcap
+ * subdirectory of the app bundle.
+ *
+ * (appbundle_dir is not set to a non-null value if we're
+ * started with special privileges, so we need only check
+ * it; we don't need to call started_with_special_privs().)
+ */
+ else if (appbundle_dir != NULL) {
+ extcap_dir = g_strdup_printf("%s/Contents/Resources/lib/wireshark/extcap",
+ appbundle_dir);
+ }
+#endif
+ else {
+ extcap_dir = EXTCAP_DIR;
+ }
+ }
+#endif
+}
+#endif /* HAVE_EXTCAP */
+
+/*
+ * Get the directory in which the extcap hooks are stored.
+ *
+ * XXX - A fix instead of HAVE_EXTCAP must be found
+ */
+const char *
+get_extcap_dir(void) {
+#if defined(HAVE_EXTCAP)
+ if (!extcap_dir)
+ init_extcap_dir();
+ return extcap_dir;
+#else
+ return NULL;
+#endif
+}
+
/*
* Get the flag indicating whether we're running from a build
* directory.