2006-11-30 21:32:05 +00:00
|
|
|
/* epan.c
|
Give libethereal its own configuration file, and have that configuration
file, rather than the top-level Ethereal configuration file, check for
"inet_aton()", "inet_pton()", and "inet_ntop()". Then make its
Makefile.am include the appropriate object files if necessary.
Otherwise, they don't get built and put into libethereal, and therefore
attempts to link with anything in libethereal that uses them fail on
platforms that lack ethem, causing the build to fail.
That means a bunch of things need to be fixed to cope with libethereal
having its own "config.h" file; this means removing the include of
"config.h" from some libethereal header files. Move the definitions of
the path names used only by "resolv.c" to "resolv.c" from "resolv.h" (so
"resolv.h" doesn't need "config.h", define HAVE_PLUGINS in the configure
script (so we don't have to include it in "plugins.h" to check whether
HAVE_DLFCN_H is defined).
Unfortunately, stuff outside libethereal needs to know PLUGIN_DIR; for
now, define that in the top-level configuration file, and have Ethereal
and Tethereal pass it as an argument to "epan_init()" - that should be
cleaned up at some point.
Remove from the top-level configure script checks for things used only
in libethereal.
svn path=/trunk/; revision=2498
2000-10-16 23:18:05 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
Give libethereal its own configuration file, and have that configuration
file, rather than the top-level Ethereal configuration file, check for
"inet_aton()", "inet_pton()", and "inet_ntop()". Then make its
Makefile.am include the appropriate object files if necessary.
Otherwise, they don't get built and put into libethereal, and therefore
attempts to link with anything in libethereal that uses them fail on
platforms that lack ethem, causing the build to fail.
That means a bunch of things need to be fixed to cope with libethereal
having its own "config.h" file; this means removing the include of
"config.h" from some libethereal header files. Move the definitions of
the path names used only by "resolv.c" to "resolv.c" from "resolv.h" (so
"resolv.h" doesn't need "config.h", define HAVE_PLUGINS in the configure
script (so we don't have to include it in "plugins.h" to check whether
HAVE_DLFCN_H is defined).
Unfortunately, stuff outside libethereal needs to know PLUGIN_DIR; for
now, define that in the top-level configuration file, and have Ethereal
and Tethereal pass it as an argument to "epan_init()" - that should be
cleaned up at some point.
Remove from the top-level configure script checks for things used only
in libethereal.
svn path=/trunk/; revision=2498
2000-10-16 23:18:05 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark Protocol Analyzer Library
|
2006-11-30 21:32:05 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
Give libethereal its own configuration file, and have that configuration
file, rather than the top-level Ethereal configuration file, check for
"inet_aton()", "inet_pton()", and "inet_ntop()". Then make its
Makefile.am include the appropriate object files if necessary.
Otherwise, they don't get built and put into libethereal, and therefore
attempts to link with anything in libethereal that uses them fail on
platforms that lack ethem, causing the build to fail.
That means a bunch of things need to be fixed to cope with libethereal
having its own "config.h" file; this means removing the include of
"config.h" from some libethereal header files. Move the definitions of
the path names used only by "resolv.c" to "resolv.c" from "resolv.h" (so
"resolv.h" doesn't need "config.h", define HAVE_PLUGINS in the configure
script (so we don't have to include it in "plugins.h" to check whether
HAVE_DLFCN_H is defined).
Unfortunately, stuff outside libethereal needs to know PLUGIN_DIR; for
now, define that in the top-level configuration file, and have Ethereal
and Tethereal pass it as an argument to "epan_init()" - that should be
cleaned up at some point.
Remove from the top-level configure script checks for things used only
in libethereal.
svn path=/trunk/; revision=2498
2000-10-16 23:18:05 +00:00
|
|
|
*/
|
2000-09-27 04:55:05 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-06-11 17:20:44 +00:00
|
|
|
#ifdef HAVE_PYTHON
|
|
|
|
#include <Python.h> /* to get the Python version number (PY_VERSION) */
|
|
|
|
#endif
|
|
|
|
|
2006-08-10 06:06:21 +00:00
|
|
|
#ifdef HAVE_LIBGCRYPT
|
2013-02-21 18:23:29 +00:00
|
|
|
#include <wsutil/wsgcrypt.h>
|
2006-08-10 06:06:21 +00:00
|
|
|
#endif /* HAVE_LIBGCRYPT */
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
#include <gnutls/gnutls.h>
|
|
|
|
#endif /* HAVE_LIBGNUTLS */
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
#include <glib.h>
|
2013-12-03 21:31:04 +00:00
|
|
|
|
2013-07-21 19:08:11 +00:00
|
|
|
#include "epan-int.h"
|
2001-12-18 19:09:08 +00:00
|
|
|
#include "epan.h"
|
2013-12-03 21:31:04 +00:00
|
|
|
#include "dfilter/dfilter.h"
|
2001-12-18 19:09:08 +00:00
|
|
|
#include "epan_dissect.h"
|
2000-09-27 04:55:05 +00:00
|
|
|
|
|
|
|
#include "conversation.h"
|
2002-10-22 08:22:07 +00:00
|
|
|
#include "circuit.h"
|
2000-09-27 04:55:05 +00:00
|
|
|
#include "except.h"
|
2000-10-06 10:11:40 +00:00
|
|
|
#include "packet.h"
|
2007-11-30 09:22:01 +00:00
|
|
|
#include "prefs.h"
|
2001-12-18 19:09:08 +00:00
|
|
|
#include "column-utils.h"
|
2004-09-29 00:06:36 +00:00
|
|
|
#include "tap.h"
|
2004-08-06 19:57:49 +00:00
|
|
|
#include "addr_resolv.h"
|
2007-08-25 01:14:24 +00:00
|
|
|
#include "oids.h"
|
2005-07-22 07:46:58 +00:00
|
|
|
#include "emem.h"
|
2012-10-27 02:42:05 +00:00
|
|
|
#include "wmem/wmem.h"
|
2005-09-11 16:55:34 +00:00
|
|
|
#include "expert.h"
|
2000-09-27 04:55:05 +00:00
|
|
|
|
2012-06-25 20:42:07 +00:00
|
|
|
#ifdef HAVE_LUA
|
2010-07-15 02:07:16 +00:00
|
|
|
#include <lua.h>
|
|
|
|
#include <wslua/wslua.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBSMI
|
|
|
|
#include <smi.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_C_ARES
|
|
|
|
#include <ares_version.h>
|
2006-09-25 01:09:00 +00:00
|
|
|
#endif
|
|
|
|
|
2013-11-04 14:12:59 +00:00
|
|
|
static wmem_allocator_t *pinfo_pool_cache = NULL;
|
|
|
|
|
2011-06-16 07:27:48 +00:00
|
|
|
const gchar*
|
2006-06-13 08:18:50 +00:00
|
|
|
epan_get_version(void) {
|
2011-06-16 07:27:48 +00:00
|
|
|
return VERSION;
|
2006-06-13 08:18:50 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 08:30:29 +00:00
|
|
|
/*
|
|
|
|
* Register all the plugin types that are part of libwireshark, namely
|
|
|
|
* dissector and tap plugins.
|
|
|
|
*
|
|
|
|
* Must be called before init_plugins(), which must be called before
|
|
|
|
* any registration routines are called.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
epan_register_plugin_types(void)
|
|
|
|
{
|
2013-12-10 19:13:09 +00:00
|
|
|
#ifdef HAVE_PLUGINS
|
2013-12-02 08:30:29 +00:00
|
|
|
register_dissector_plugin_type();
|
|
|
|
register_tap_plugin_type();
|
2013-12-10 19:13:09 +00:00
|
|
|
#endif
|
2013-12-02 08:30:29 +00:00
|
|
|
}
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
void
|
2008-06-23 20:17:08 +00:00
|
|
|
epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
|
|
|
|
void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
|
2007-05-07 17:55:42 +00:00
|
|
|
register_cb cb,
|
2013-12-05 09:30:22 +00:00
|
|
|
gpointer client_data)
|
2000-09-27 04:55:05 +00:00
|
|
|
{
|
2012-10-27 02:42:05 +00:00
|
|
|
/* initialize memory allocation subsystems */
|
2009-10-20 17:43:05 +00:00
|
|
|
emem_init();
|
2012-10-27 02:42:05 +00:00
|
|
|
wmem_init();
|
2006-11-21 00:30:36 +00:00
|
|
|
|
2006-11-21 00:16:44 +00:00
|
|
|
/* initialize the GUID to name mapping table */
|
|
|
|
guids_init();
|
|
|
|
|
2013-08-07 16:46:08 +00:00
|
|
|
/* initialize name resolution (addr_resolv.c) */
|
|
|
|
addr_resolv_init();
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
except_init();
|
2012-10-11 08:28:57 +00:00
|
|
|
#ifdef HAVE_LIBGCRYPT
|
|
|
|
/* initialize libgcrypt (beware, it won't be thread-safe) */
|
|
|
|
gcry_check_version(NULL);
|
|
|
|
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
|
|
|
|
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
|
|
|
|
#endif
|
2006-08-10 06:06:21 +00:00
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
gnutls_global_init();
|
|
|
|
#endif
|
2002-09-04 09:40:29 +00:00
|
|
|
tap_init();
|
2007-11-30 09:22:01 +00:00
|
|
|
prefs_init();
|
2013-05-24 17:59:36 +00:00
|
|
|
expert_init();
|
2013-08-13 03:11:28 +00:00
|
|
|
packet_init();
|
2008-06-23 20:17:08 +00:00
|
|
|
proto_init(register_all_protocols_func, register_all_handoffs_func,
|
|
|
|
cb, client_data);
|
2013-08-13 03:11:28 +00:00
|
|
|
packet_cache_proto_handles();
|
2000-09-27 04:55:05 +00:00
|
|
|
dfilter_init();
|
2002-05-09 23:50:34 +00:00
|
|
|
final_registration_all_protocols();
|
2013-05-24 17:59:36 +00:00
|
|
|
expert_packet_init();
|
2012-06-25 20:42:07 +00:00
|
|
|
#ifdef HAVE_LUA
|
2011-10-02 13:39:35 +00:00
|
|
|
wslua_init(cb, client_data);
|
2006-09-25 01:09:00 +00:00
|
|
|
#endif
|
2000-09-27 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_cleanup(void)
|
|
|
|
{
|
|
|
|
dfilter_cleanup();
|
|
|
|
proto_cleanup();
|
2007-11-30 09:22:01 +00:00
|
|
|
prefs_cleanup();
|
2000-10-06 10:11:40 +00:00
|
|
|
packet_cleanup();
|
2013-05-24 17:59:36 +00:00
|
|
|
expert_cleanup();
|
2013-10-23 16:47:02 +00:00
|
|
|
#ifdef HAVE_LUA
|
|
|
|
wslua_cleanup();
|
|
|
|
#endif
|
2006-08-10 06:06:21 +00:00
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
gnutls_global_deinit();
|
|
|
|
#endif
|
2000-09-27 04:55:05 +00:00
|
|
|
except_deinit();
|
2013-08-07 16:46:08 +00:00
|
|
|
addr_resolv_cleanup();
|
2012-10-27 02:42:05 +00:00
|
|
|
wmem_cleanup();
|
2000-09-27 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_t *
|
|
|
|
epan_new(void)
|
|
|
|
{
|
|
|
|
epan_t *session = g_slice_new(epan_t);
|
|
|
|
|
|
|
|
/* XXX, it should take session as param */
|
|
|
|
init_dissection();
|
|
|
|
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
|
2013-08-01 20:59:38 +00:00
|
|
|
const char *
|
|
|
|
epan_get_user_comment(const epan_t *session, const frame_data *fd)
|
|
|
|
{
|
|
|
|
if (session->get_user_comment)
|
|
|
|
return session->get_user_comment(session->data, fd);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-22 19:38:38 +00:00
|
|
|
const char *
|
|
|
|
epan_get_interface_name(const epan_t *session, guint32 interface_id)
|
|
|
|
{
|
|
|
|
if (session->get_interface_name)
|
|
|
|
return session->get_interface_name(session->data, interface_id);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-21 20:48:30 +00:00
|
|
|
const nstime_t *
|
|
|
|
epan_get_frame_ts(const epan_t *session, guint32 frame_num)
|
|
|
|
{
|
2013-07-21 21:04:25 +00:00
|
|
|
const nstime_t *abs_ts = NULL;
|
2013-07-21 20:48:30 +00:00
|
|
|
|
|
|
|
if (session->get_frame_ts)
|
|
|
|
abs_ts = session->get_frame_ts(session->data, frame_num);
|
|
|
|
|
|
|
|
if (!abs_ts)
|
|
|
|
g_warning("!!! couldn't get frame ts for %u !!!\n", frame_num);
|
|
|
|
|
|
|
|
return abs_ts;
|
|
|
|
}
|
|
|
|
|
2013-07-21 18:38:03 +00:00
|
|
|
void
|
|
|
|
epan_free(epan_t *session)
|
|
|
|
{
|
2013-08-13 22:41:34 +00:00
|
|
|
if (session) {
|
|
|
|
/* XXX, it should take session as param */
|
|
|
|
cleanup_dissection();
|
2013-07-21 18:38:03 +00:00
|
|
|
|
2013-08-13 22:41:34 +00:00
|
|
|
g_slice_free(epan_t, session);
|
|
|
|
}
|
2013-07-21 18:38:03 +00:00
|
|
|
}
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
void
|
|
|
|
epan_conversation_init(void)
|
|
|
|
{
|
|
|
|
conversation_init();
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2009-09-06 18:25:23 +00:00
|
|
|
void
|
|
|
|
epan_conversation_cleanup(void)
|
|
|
|
{
|
|
|
|
conversation_cleanup();
|
|
|
|
}
|
|
|
|
|
2002-10-22 08:22:07 +00:00
|
|
|
void
|
|
|
|
epan_circuit_init(void)
|
|
|
|
{
|
|
|
|
circuit_init();
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2009-09-06 18:25:23 +00:00
|
|
|
void
|
|
|
|
epan_circuit_cleanup(void)
|
|
|
|
{
|
|
|
|
circuit_cleanup();
|
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
epan_dissect_t*
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
|
2000-10-06 10:11:40 +00:00
|
|
|
{
|
2009-08-13 19:42:46 +00:00
|
|
|
g_assert(edt);
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2013-07-21 18:38:03 +00:00
|
|
|
edt->session = session;
|
2012-12-02 17:01:04 +00:00
|
|
|
|
2013-11-04 14:12:59 +00:00
|
|
|
memset(&edt->pi, 0, sizeof(edt->pi));
|
|
|
|
if (pinfo_pool_cache != NULL) {
|
|
|
|
edt->pi.pool = pinfo_pool_cache;
|
|
|
|
pinfo_pool_cache = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK);
|
|
|
|
}
|
|
|
|
|
2001-12-06 04:25:09 +00:00
|
|
|
if (create_proto_tree) {
|
2012-08-10 20:33:01 +00:00
|
|
|
edt->tree = proto_tree_create_root(&edt->pi);
|
2002-01-04 08:57:09 +00:00
|
|
|
proto_tree_set_visible(edt->tree, proto_tree_visible);
|
2001-12-06 04:25:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
edt->tree = NULL;
|
|
|
|
}
|
2001-02-01 20:21:25 +00:00
|
|
|
|
2013-10-20 19:05:00 +00:00
|
|
|
edt->tvb = NULL;
|
|
|
|
|
2001-12-18 19:09:08 +00:00
|
|
|
return edt;
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2013-10-20 10:21:25 +00:00
|
|
|
void
|
|
|
|
epan_dissect_reset(epan_dissect_t *edt)
|
|
|
|
{
|
|
|
|
/* We have to preserve the pool pointer across the memzeroing */
|
|
|
|
wmem_allocator_t *tmp;
|
|
|
|
|
|
|
|
g_assert(edt);
|
|
|
|
|
2013-11-23 02:20:13 +00:00
|
|
|
g_slist_free(edt->pi.proto_data);
|
2013-10-20 10:21:25 +00:00
|
|
|
g_slist_free(edt->pi.dependent_frames);
|
|
|
|
|
|
|
|
/* Free the data sources list. */
|
|
|
|
free_data_sources(&edt->pi);
|
|
|
|
|
|
|
|
if (edt->tvb) {
|
|
|
|
/* Free all tvb's chained from this tvb */
|
|
|
|
tvb_free_chain(edt->tvb);
|
|
|
|
edt->tvb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edt->tree)
|
|
|
|
proto_tree_reset(edt->tree);
|
|
|
|
|
|
|
|
tmp = edt->pi.pool;
|
|
|
|
wmem_free_all(tmp);
|
|
|
|
|
|
|
|
memset(&edt->pi, 0, sizeof(edt->pi));
|
|
|
|
edt->pi.pool = tmp;
|
|
|
|
}
|
|
|
|
|
2009-08-13 19:42:46 +00:00
|
|
|
epan_dissect_t*
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
|
2009-08-13 19:42:46 +00:00
|
|
|
{
|
2011-09-06 09:09:36 +00:00
|
|
|
epan_dissect_t *edt;
|
2009-08-13 19:42:46 +00:00
|
|
|
|
2010-06-02 19:29:14 +00:00
|
|
|
edt = g_new0(epan_dissect_t, 1);
|
2009-08-13 19:42:46 +00:00
|
|
|
|
2013-07-21 18:38:03 +00:00
|
|
|
return epan_dissect_init(edt, session, create_proto_tree, proto_tree_visible);
|
2009-08-13 19:42:46 +00:00
|
|
|
}
|
|
|
|
|
2009-08-11 18:08:03 +00:00
|
|
|
void
|
2010-04-03 18:18:50 +00:00
|
|
|
epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
|
2009-08-11 18:08:03 +00:00
|
|
|
{
|
|
|
|
if (edt)
|
|
|
|
proto_tree_set_fake_protocols(edt->tree, fake_protocols);
|
|
|
|
}
|
|
|
|
|
2001-12-18 19:09:08 +00:00
|
|
|
void
|
2012-10-16 21:50:57 +00:00
|
|
|
epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
2013-07-11 05:47:02 +00:00
|
|
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
2001-12-18 19:09:08 +00:00
|
|
|
{
|
2013-02-25 17:32:25 +00:00
|
|
|
#ifdef HAVE_LUA
|
|
|
|
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
|
|
|
#endif
|
2012-11-03 15:49:15 +00:00
|
|
|
wmem_enter_packet_scope();
|
2013-07-11 05:47:02 +00:00
|
|
|
dissect_packet(edt, phdr, tvb, fd, cinfo);
|
2012-10-20 20:04:40 +00:00
|
|
|
|
|
|
|
/* free all memory allocated */
|
|
|
|
ep_free_all();
|
2012-11-03 15:49:15 +00:00
|
|
|
wmem_leave_packet_scope();
|
2000-10-06 10:11:40 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 19:27:24 +00:00
|
|
|
void
|
|
|
|
epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
2013-07-11 05:47:02 +00:00
|
|
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
2012-10-20 19:27:24 +00:00
|
|
|
{
|
2012-11-03 15:49:15 +00:00
|
|
|
wmem_enter_packet_scope();
|
2012-10-20 19:27:24 +00:00
|
|
|
tap_queue_init(edt);
|
2013-07-11 05:47:02 +00:00
|
|
|
dissect_packet(edt, phdr, tvb, fd, cinfo);
|
2012-10-20 19:27:24 +00:00
|
|
|
tap_push_tapped_queue(edt);
|
2012-10-20 20:04:40 +00:00
|
|
|
|
|
|
|
/* free all memory allocated */
|
|
|
|
ep_free_all();
|
2012-11-03 15:49:15 +00:00
|
|
|
wmem_leave_packet_scope();
|
2012-10-20 19:27:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-08 04:35:28 +00:00
|
|
|
void
|
|
|
|
epan_dissect_file_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
|
|
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LUA
|
|
|
|
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
|
|
|
#endif
|
|
|
|
wmem_enter_packet_scope();
|
|
|
|
dissect_file(edt, phdr, tvb, fd, cinfo);
|
|
|
|
|
|
|
|
/* free all memory allocated */
|
|
|
|
ep_free_all();
|
|
|
|
wmem_leave_packet_scope();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_dissect_file_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
|
|
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
|
|
|
{
|
|
|
|
wmem_enter_packet_scope();
|
|
|
|
tap_queue_init(edt);
|
|
|
|
dissect_file(edt, phdr, tvb, fd, cinfo);
|
|
|
|
tap_push_tapped_queue(edt);
|
|
|
|
|
|
|
|
/* free all memory allocated */
|
|
|
|
ep_free_all();
|
|
|
|
wmem_leave_packet_scope();
|
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
void
|
2009-08-13 19:42:46 +00:00
|
|
|
epan_dissect_cleanup(epan_dissect_t* edt)
|
2000-10-06 10:11:40 +00:00
|
|
|
{
|
2009-08-13 19:42:46 +00:00
|
|
|
g_assert(edt);
|
|
|
|
|
2013-11-23 02:20:13 +00:00
|
|
|
g_slist_free(edt->pi.proto_data);
|
2012-04-03 09:18:16 +00:00
|
|
|
g_slist_free(edt->pi.dependent_frames);
|
|
|
|
|
2002-06-04 07:03:57 +00:00
|
|
|
/* Free the data sources list. */
|
|
|
|
free_data_sources(&edt->pi);
|
|
|
|
|
2013-10-20 10:21:25 +00:00
|
|
|
if (edt->tvb) {
|
|
|
|
/* Free all tvb's chained from this tvb */
|
|
|
|
tvb_free_chain(edt->tvb);
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2001-12-06 04:25:09 +00:00
|
|
|
if (edt->tree) {
|
|
|
|
proto_tree_free(edt->tree);
|
|
|
|
}
|
2012-12-02 17:01:04 +00:00
|
|
|
|
2013-11-04 14:12:59 +00:00
|
|
|
if (pinfo_pool_cache == NULL) {
|
|
|
|
wmem_free_all(edt->pi.pool);
|
|
|
|
pinfo_pool_cache = edt->pi.pool;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wmem_destroy_allocator(edt->pi.pool);
|
|
|
|
}
|
2009-08-13 19:42:46 +00:00
|
|
|
}
|
2001-12-06 04:25:09 +00:00
|
|
|
|
2009-08-13 19:42:46 +00:00
|
|
|
void
|
|
|
|
epan_dissect_free(epan_dissect_t* edt)
|
|
|
|
{
|
|
|
|
epan_dissect_cleanup(edt);
|
2000-10-06 10:11:40 +00:00
|
|
|
g_free(edt);
|
|
|
|
}
|
2001-12-18 19:09:08 +00:00
|
|
|
|
|
|
|
void
|
2002-09-09 21:04:15 +00:00
|
|
|
epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
|
2001-12-18 19:09:08 +00:00
|
|
|
{
|
2009-08-25 21:10:35 +00:00
|
|
|
dfilter_prime_proto_tree(dfcode, edt->tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------------- */
|
|
|
|
const gchar *
|
2009-09-08 10:33:15 +00:00
|
|
|
epan_custom_set(epan_dissect_t *edt, int field_id,
|
2010-09-23 06:00:22 +00:00
|
|
|
gint occurrence,
|
|
|
|
gchar *result,
|
|
|
|
gchar *expr, const int size )
|
2009-08-25 21:10:35 +00:00
|
|
|
{
|
2010-09-22 20:56:14 +00:00
|
|
|
return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-04-03 18:18:50 +00:00
|
|
|
epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
|
2001-12-18 19:09:08 +00:00
|
|
|
{
|
2009-08-25 21:10:35 +00:00
|
|
|
col_custom_set_edt(edt, edt->pi.cinfo);
|
2009-09-08 19:00:54 +00:00
|
|
|
col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|
2009-08-25 21:10:35 +00:00
|
|
|
|
2013-05-22 23:02:19 +00:00
|
|
|
gboolean
|
|
|
|
epan_dissect_packet_contains_field(epan_dissect_t* edt,
|
|
|
|
const char *field_name)
|
|
|
|
{
|
|
|
|
GPtrArray* array;
|
|
|
|
int field_id;
|
|
|
|
gboolean contains_field;
|
|
|
|
|
|
|
|
if (!edt || !edt->tree)
|
|
|
|
return FALSE;
|
|
|
|
field_id = proto_get_id_by_filter_name(field_name);
|
|
|
|
if (field_id < 0)
|
|
|
|
return FALSE;
|
|
|
|
array = proto_find_finfo(edt->tree, field_id);
|
|
|
|
contains_field = (array->len > 0) ? TRUE : FALSE;
|
|
|
|
g_ptr_array_free(array, TRUE);
|
|
|
|
return contains_field;
|
|
|
|
}
|
|
|
|
|
2010-07-15 02:07:16 +00:00
|
|
|
/*
|
|
|
|
* Get compile-time information for libraries used by libwireshark.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
epan_get_compiled_version_info(GString *str)
|
|
|
|
{
|
|
|
|
/* SNMP */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_LIBSMI
|
|
|
|
g_string_append(str, "with SMI " SMI_VERSION_STRING);
|
|
|
|
#else /* no SNMP library */
|
|
|
|
g_string_append(str, "without SMI");
|
|
|
|
#endif /* _SMI_H */
|
|
|
|
|
|
|
|
/* c-ares */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_C_ARES
|
|
|
|
g_string_append(str, "with c-ares " ARES_VERSION_STR);
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without c-ares");
|
|
|
|
|
|
|
|
/* ADNS - only add if no c-ares */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_GNU_ADNS
|
|
|
|
g_string_append(str, "with ADNS");
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without ADNS");
|
|
|
|
#endif /* HAVE_GNU_ADNS */
|
|
|
|
#endif /* HAVE_C_ARES */
|
|
|
|
|
|
|
|
/* LUA */
|
|
|
|
g_string_append(str, ", ");
|
2012-06-25 20:42:07 +00:00
|
|
|
#ifdef HAVE_LUA
|
2010-07-15 02:07:16 +00:00
|
|
|
g_string_append(str, "with ");
|
|
|
|
g_string_append(str, LUA_VERSION);
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without Lua");
|
2012-06-25 20:42:07 +00:00
|
|
|
#endif /* HAVE_LUA */
|
2010-07-15 02:07:16 +00:00
|
|
|
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_PYTHON
|
|
|
|
g_string_append(str, "with Python");
|
|
|
|
#ifdef PY_VERSION
|
|
|
|
g_string_append(str, " " PY_VERSION);
|
|
|
|
#endif /* PY_VERSION */
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without Python");
|
|
|
|
#endif /* HAVE_PYTHON */
|
|
|
|
|
|
|
|
/* GnuTLS */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without GnuTLS");
|
|
|
|
#endif /* HAVE_LIBGNUTLS */
|
|
|
|
|
|
|
|
/* Gcrypt */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_LIBGCRYPT
|
|
|
|
g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without Gcrypt");
|
|
|
|
#endif /* HAVE_LIBGCRYPT */
|
|
|
|
|
|
|
|
/* Kerberos */
|
|
|
|
/* XXX - I don't see how to get the version number, at least for KfW */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_KERBEROS
|
|
|
|
#ifdef HAVE_MIT_KERBEROS
|
|
|
|
g_string_append(str, "with MIT Kerberos");
|
|
|
|
#else
|
|
|
|
/* HAVE_HEIMDAL_KERBEROS */
|
|
|
|
g_string_append(str, "with Heimdal Kerberos");
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without Kerberos");
|
|
|
|
#endif /* HAVE_KERBEROS */
|
|
|
|
|
|
|
|
/* GeoIP */
|
|
|
|
g_string_append(str, ", ");
|
|
|
|
#ifdef HAVE_GEOIP
|
|
|
|
g_string_append(str, "with GeoIP");
|
|
|
|
#else
|
|
|
|
g_string_append(str, "without GeoIP");
|
|
|
|
#endif /* HAVE_GEOIP */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get runtime information for libraries used by libwireshark.
|
|
|
|
*/
|
|
|
|
void
|
2010-07-15 03:22:49 +00:00
|
|
|
epan_get_runtime_version_info(GString *str
|
|
|
|
#if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
)
|
2010-07-15 02:07:16 +00:00
|
|
|
{
|
|
|
|
/* GnuTLS */
|
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
|
|
|
|
#endif /* HAVE_LIBGNUTLS */
|
|
|
|
|
|
|
|
/* Gcrypt */
|
|
|
|
#ifdef HAVE_LIBGCRYPT
|
|
|
|
g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
|
|
|
|
#endif /* HAVE_LIBGCRYPT */
|
|
|
|
}
|
2012-10-08 15:23:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|