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"
|
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"
|
2005-12-06 11:45:55 +00:00
|
|
|
#include "oid_resolv.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
|
|
|
|
|
2004-04-16 23:17:13 +00:00
|
|
|
static void (*report_failure_func)(const char *, va_list);
|
2004-03-23 21:19:58 +00:00
|
|
|
static void (*report_open_failure_func)(const char *, int, gboolean);
|
|
|
|
static void (*report_read_failure_func)(const char *, int);
|
|
|
|
|
2006-06-13 08:18:50 +00:00
|
|
|
gchar*
|
|
|
|
epan_get_version(void) {
|
|
|
|
return VERSION;
|
|
|
|
}
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
void
|
Add a WIRESHARK_RUN_FROM_BUILD_DIRECTORY environment variable on UN*X;
if set, and if the program isn't running with additional privileges,
it'll treat the directory in which the program is found as the data
directory.
If, on Windows, the version-number subdirectory of {data
directory}\plugins doesn't exist (which is assumed to mean that the
program is being run from the build directory), or if, on UN*X,
WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set, the plugin directory is the
"plugins" subdirectory of the data directory, and all subdirectories of
that directory are scanned for plugins, as the "plugins" subdirectory of
the build directory contains subdirectories for the plugins; this means
that if we're running from the build directory, we'll find the plugins
we built in the build tree.
When generating the wireshark-filter man page, run tshark with
WIRESHARK_RUN_FROM_BUILD_DIRECTORY set, so it uses the plugins from the
build to generate the list of filters.
svn path=/trunk/; revision=20261
2007-01-02 06:49:40 +00:00
|
|
|
epan_init(void (*register_all_protocols)(void),
|
2004-03-23 21:19:58 +00:00
|
|
|
void (*register_all_handoffs)(void),
|
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),
|
|
|
|
void (*report_read_failure)(const char *, int))
|
2000-09-27 04:55:05 +00:00
|
|
|
{
|
2004-04-16 23:17:13 +00:00
|
|
|
report_failure_func = report_failure;
|
2004-03-23 21:19:58 +00:00
|
|
|
report_open_failure_func = report_open_failure;
|
|
|
|
report_read_failure_func = report_read_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();
|
2005-12-06 11:45:55 +00:00
|
|
|
oid_resolv_init();
|
2002-09-04 09:40:29 +00:00
|
|
|
tap_init();
|
Add a WIRESHARK_RUN_FROM_BUILD_DIRECTORY environment variable on UN*X;
if set, and if the program isn't running with additional privileges,
it'll treat the directory in which the program is found as the data
directory.
If, on Windows, the version-number subdirectory of {data
directory}\plugins doesn't exist (which is assumed to mean that the
program is being run from the build directory), or if, on UN*X,
WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set, the plugin directory is the
"plugins" subdirectory of the data directory, and all subdirectories of
that directory are scanned for plugins, as the "plugins" subdirectory of
the build directory contains subdirectories for the plugins; this means
that if we're running from the build directory, we'll find the plugins
we built in the build tree.
When generating the wireshark-filter man page, run tshark with
WIRESHARK_RUN_FROM_BUILD_DIRECTORY set, so it uses the plugins from the
build to generate the list of filters.
svn path=/trunk/; revision=20261
2007-01-02 06:49:40 +00:00
|
|
|
proto_init(register_all_protocols, register_all_handoffs);
|
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();
|
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
|
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_cleanup(void)
|
|
|
|
{
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_cleanup();
|
2000-09-27 04:55:05 +00:00
|
|
|
dfilter_cleanup();
|
|
|
|
proto_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
|
|
|
|
2004-03-23 21:19:58 +00:00
|
|
|
/*
|
2004-04-16 23:17:13 +00:00
|
|
|
* Report a general error.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
report_failure(const char *msg_format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, msg_format);
|
|
|
|
(*report_failure_func)(msg_format, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report an error when trying to open or create a file.
|
|
|
|
* "err" is assumed to be an error code from Wiretap; positive values are
|
|
|
|
* UNIX-style errnos, so this can be used for open failures not from
|
|
|
|
* Wiretap as long as the failue code is just an errno.
|
2004-03-23 21:19:58 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
report_open_failure(const char *filename, int err,
|
|
|
|
gboolean for_writing)
|
|
|
|
{
|
|
|
|
(*report_open_failure_func)(filename, err, for_writing);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report an error when trying to read a file.
|
2004-04-16 23:17:13 +00:00
|
|
|
* "err" is assumed to be a UNIX-style errno.
|
2004-03-23 21:19:58 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
report_read_failure(const char *filename, int err)
|
|
|
|
{
|
|
|
|
(*report_read_failure_func)(filename, err);
|
|
|
|
}
|
|
|
|
|
2000-10-06 10:11:40 +00:00
|
|
|
epan_dissect_t*
|
2001-12-18 19:09:08 +00:00
|
|
|
epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
|
2000-10-06 10:11:40 +00:00
|
|
|
{
|
|
|
|
epan_dissect_t *edt;
|
|
|
|
|
|
|
|
edt = g_new(epan_dissect_t, 1);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
epan_dissect_free(epan_dissect_t* 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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-05-09 23:50:34 +00:00
|
|
|
dfilter_prime_proto_tree(dfcode, edt->tree);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
epan_dissect_fill_in_columns(epan_dissect_t *edt)
|
|
|
|
{
|
2005-10-02 14:56:27 +00:00
|
|
|
col_fill_in(&edt->pi);
|
2001-12-18 19:09:08 +00:00
|
|
|
}
|