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
|
|
|
/* epan.h
|
|
|
|
*
|
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
|
|
|
*
|
|
|
|
* Ethereal Protocol Analyzer Library
|
|
|
|
*/
|
2000-09-27 04:55:05 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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-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
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* XXX - this takes the plugin directory as an argument, because
|
|
|
|
* libethereal now has its own configure script and "config.h" file,
|
|
|
|
* which is what code in the "epan" directory includes, but we need
|
|
|
|
* to define PLUGIN_DIR in the top-level directory, as it's used by,
|
|
|
|
* for example, the Makefile for the Gryphon plugin, so it knows
|
|
|
|
* where to install the plugin.
|
|
|
|
*
|
|
|
|
* Eventually, we should probably have an "epan-configure" script
|
|
|
|
* (or "libethereal-configure", or whatever), along the lines of what
|
|
|
|
* GTK+ and GLib have, that can print, among other things, the directory
|
|
|
|
* into which plugins should be installed. That way, only libethereal
|
|
|
|
* need know what directory that is; programs using it won't, *and*
|
|
|
|
* Makefiles for plugins can just use "epan-configure" to figure out
|
|
|
|
* where to install the plugins.
|
|
|
|
*
|
|
|
|
* (Would that *more* libraries had configure scripts like that, so
|
|
|
|
* that configure scripts didn't have to go through various contortions
|
|
|
|
* to figure out where the header files and libraries for various
|
|
|
|
* libraries are located.)
|
|
|
|
*/
|
2000-09-27 04:55:05 +00:00
|
|
|
void
|
2004-03-23 21:19:58 +00:00
|
|
|
epan_init(const char *plugin_dir, void (*register_all_protocols)(void),
|
|
|
|
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;
|
2000-09-27 04:55:05 +00:00
|
|
|
except_init();
|
|
|
|
tvbuff_init();
|
2002-09-04 09:40:29 +00:00
|
|
|
tap_init();
|
2001-04-02 00:38:36 +00:00
|
|
|
proto_init(plugin_dir,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();
|
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();
|
2000-09-27 04:55:05 +00:00
|
|
|
tvbuff_cleanup();
|
|
|
|
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
|
|
|
}
|