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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-08-10 06:06:21 +00:00
|
|
|
#if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
|
|
|
|
#include <winposixtype.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBGCRYPT
|
|
|
|
#include <gcrypt.h>
|
|
|
|
#endif /* HAVE_LIBGCRYPT */
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
#include <gnutls/gnutls.h>
|
|
|
|
#endif /* HAVE_LIBGNUTLS */
|
|
|
|
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
#include <glib.h>
|
2001-12-18 19:09:08 +00:00
|
|
|
#include "epan.h"
|
|
|
|
#include "epan_dissect.h"
|
2004-03-23 21:19:58 +00:00
|
|
|
#include "report_err.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"
|
2005-09-11 16:55:34 +00:00
|
|
|
#include "expert.h"
|
2000-09-27 04:55:05 +00:00
|
|
|
|
2006-09-25 01:09:00 +00:00
|
|
|
#ifdef HAVE_LUA_5_1
|
2006-09-26 01:12:14 +00:00
|
|
|
int wslua_init(void*);
|
2006-09-25 01:09:00 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-27 04:50:57 +00:00
|
|
|
#ifdef HAVE_GEOIP
|
2008-12-19 23:49:03 +00:00
|
|
|
#include "geoip_db.h"
|
2008-10-27 04:50:57 +00:00
|
|
|
#endif
|
|
|
|
|
2006-06-13 08:18:50 +00:00
|
|
|
gchar*
|
|
|
|
epan_get_version(void) {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
gpointer client_data,
|
2004-04-16 23:17:13 +00:00
|
|
|
void (*report_failure)(const char *, va_list),
|
2004-03-23 21:19:58 +00:00
|
|
|
void (*report_open_failure)(const char *, int, gboolean),
|
2009-02-15 21:47:57 +00:00
|
|
|
void (*report_read_failure)(const char *, int),
|
|
|
|
void (*report_write_failure)(const char *, int))
|
2000-09-27 04:55:05 +00:00
|
|
|
{
|
2009-02-15 21:47:57 +00:00
|
|
|
init_report_err(report_failure, report_open_failure,
|
|
|
|
report_read_failure, report_write_failure);
|
2006-11-21 00:16:44 +00:00
|
|
|
|
2006-11-21 00:30:36 +00:00
|
|
|
/* initialize memory allocation subsystem */
|
|
|
|
ep_init_chunk();
|
|
|
|
se_init_chunk();
|
|
|
|
|
2006-11-21 00:16:44 +00:00
|
|
|
/* initialize the GUID to name mapping table */
|
|
|
|
guids_init();
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
except_init();
|
2006-08-10 06:06:21 +00:00
|
|
|
#ifdef HAVE_LIBGNUTLS
|
|
|
|
gnutls_global_init();
|
|
|
|
#elif defined(HAVE_LIBGCRYPT)
|
|
|
|
gcry_check_version(NULL);
|
|
|
|
#endif
|
2000-09-27 04:55:05 +00:00
|
|
|
tvbuff_init();
|
2002-09-04 09:40:29 +00:00
|
|
|
tap_init();
|
2007-11-30 09:22:01 +00:00
|
|
|
prefs_init();
|
2008-06-23 20:17:08 +00:00
|
|
|
proto_init(register_all_protocols_func, register_all_handoffs_func,
|
|
|
|
cb, client_data);
|
2001-04-01 22:01:34 +00:00
|
|
|
packet_init();
|
2000-09-27 04:55:05 +00:00
|
|
|
dfilter_init();
|
2002-05-09 23:50:34 +00:00
|
|
|
final_registration_all_protocols();
|
2003-05-04 18:50:56 +00:00
|
|
|
host_name_lookup_init();
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_init();
|
2007-08-25 01:14:24 +00:00
|
|
|
oids_init();
|
2006-09-26 10:22:20 +00:00
|
|
|
#ifdef HAVE_LUA_5_1
|
2006-09-25 01:09:00 +00:00
|
|
|
wslua_init(NULL);
|
|
|
|
#endif
|
2008-10-27 04:50:57 +00:00
|
|
|
#ifdef HAVE_GEOIP
|
2008-12-19 23:49:03 +00:00
|
|
|
geoip_db_init();
|
2008-10-27 04:50:57 +00:00
|
|
|
#endif
|
2006-09-25 01:09:00 +00:00
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_cleanup(void)
|
|
|
|
{
|
2008-04-29 15:29:02 +00:00
|
|
|
se_free_all();
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_cleanup();
|
2000-09-27 04:55:05 +00:00
|
|
|
dfilter_cleanup();
|
|
|
|
proto_cleanup();
|
2007-11-30 09:22:01 +00:00
|
|
|
prefs_cleanup();
|
2000-10-06 10:11:40 +00:00
|
|
|
packet_cleanup();
|
2005-12-06 11:45:55 +00:00
|
|
|
oid_resolv_cleanup();
|
2000-09-27 04:55:05 +00:00
|
|
|
tvbuff_cleanup();
|
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();
|
2003-05-04 18:50:56 +00:00
|
|
|
host_name_lookup_cleanup();
|
2000-09-27 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_conversation_init(void)
|
|
|
|
{
|
|
|
|
conversation_init();
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2002-10-22 08:22:07 +00:00
|
|
|
void
|
|
|
|
epan_circuit_init(void)
|
|
|
|
{
|
|
|
|
circuit_init();
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
|
|
|
epan_dissect_t*
|
2009-08-13 19:42:46 +00:00
|
|
|
epan_dissect_init(epan_dissect_t *edt, gboolean create_proto_tree, 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
|
|
|
|
2001-12-06 04:25:09 +00:00
|
|
|
if (create_proto_tree) {
|
|
|
|
edt->tree = proto_tree_create_root();
|
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
|
|
|
|
2001-12-18 19:09:08 +00:00
|
|
|
return edt;
|
|
|
|
}
|
2000-10-06 10:11:40 +00:00
|
|
|
|
2009-08-13 19:42:46 +00:00
|
|
|
epan_dissect_t*
|
|
|
|
epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
|
|
|
|
{
|
|
|
|
epan_dissect_t *edt;
|
|
|
|
|
|
|
|
edt = g_new(epan_dissect_t, 1);
|
|
|
|
|
|
|
|
return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
|
|
|
|
}
|
|
|
|
|
2009-08-11 18:08:03 +00:00
|
|
|
void
|
|
|
|
epan_dissect_fake_protocols(epan_dissect_t *edt, gboolean fake_protocols)
|
|
|
|
{
|
|
|
|
if (edt)
|
|
|
|
proto_tree_set_fake_protocols(edt->tree, fake_protocols);
|
|
|
|
}
|
|
|
|
|
2001-12-18 19:09:08 +00:00
|
|
|
void
|
|
|
|
epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
|
|
|
|
const guint8* data, frame_data *fd, column_info *cinfo)
|
|
|
|
{
|
2005-07-22 07:46:58 +00:00
|
|
|
/* free all memory allocated during previous packet */
|
|
|
|
ep_free_all();
|
|
|
|
|
2001-12-18 19:09:08 +00:00
|
|
|
dissect_packet(edt, pseudo_header, data, fd, cinfo);
|
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);
|
|
|
|
|
2002-06-04 07:03:57 +00:00
|
|
|
/* Free the data sources list. */
|
|
|
|
free_data_sources(&edt->pi);
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
/* Free all tvb's created from this tvb, unless dissector
|
|
|
|
* wanted to store the pointer (in which case, the dissector
|
|
|
|
* would have incremented the usage count on that tvbuff_t*) */
|
|
|
|
tvb_free_chain(edt->tvb);
|
|
|
|
|
2001-12-06 04:25:09 +00:00
|
|
|
if (edt->tree) {
|
|
|
|
proto_tree_free(edt->tree);
|
|
|
|
}
|
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 *
|
|
|
|
epan_custom_set(epan_dissect_t *edt, const gchar *field,
|
|
|
|
gchar *result,
|
|
|
|
gchar *expr, int size )
|
|
|
|
{
|
|
|
|
return proto_custom_set(edt->tree, field, result, expr, size);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-27 08:33:26 +00:00
|
|
|
epan_dissect_fill_in_columns(epan_dissect_t *edt, 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-07-27 08:33:26 +00:00
|
|
|
col_fill_in(&edt->pi, fill_fd_colums);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|
2009-08-25 21:10:35 +00:00
|
|
|
|