5 * Ethereal Protocol Analyzer Library
14 #include "epan_dissect.h"
15 #include "report_err.h"
17 #include "conversation.h"
21 #include "column-utils.h"
23 #include "addr_resolv.h"
25 static void (*report_failure_func)(const char *, va_list);
26 static void (*report_open_failure_func)(const char *, int, gboolean);
27 static void (*report_read_failure_func)(const char *, int);
30 * XXX - this takes the plugin directory as an argument, because
31 * libethereal now has its own configure script and "config.h" file,
32 * which is what code in the "epan" directory includes, but we need
33 * to define PLUGIN_DIR in the top-level directory, as it's used by,
34 * for example, the Makefile for the Gryphon plugin, so it knows
35 * where to install the plugin.
37 * Eventually, we should probably have an "epan-configure" script
38 * (or "libethereal-configure", or whatever), along the lines of what
39 * GTK+ and GLib have, that can print, among other things, the directory
40 * into which plugins should be installed. That way, only libethereal
41 * need know what directory that is; programs using it won't, *and*
42 * Makefiles for plugins can just use "epan-configure" to figure out
43 * where to install the plugins.
45 * (Would that *more* libraries had configure scripts like that, so
46 * that configure scripts didn't have to go through various contortions
47 * to figure out where the header files and libraries for various
48 * libraries are located.)
51 epan_init(const char *plugin_dir, void (*register_all_protocols)(void),
52 void (*register_all_handoffs)(void),
53 void (*report_failure)(const char *, va_list),
54 void (*report_open_failure)(const char *, int, gboolean),
55 void (*report_read_failure)(const char *, int))
57 report_failure_func = report_failure;
58 report_open_failure_func = report_open_failure;
59 report_read_failure_func = report_read_failure;
64 proto_init(plugin_dir,register_all_protocols,register_all_handoffs);
67 final_registration_all_protocols();
68 host_name_lookup_init();
80 host_name_lookup_cleanup();
84 epan_conversation_init(void)
90 epan_circuit_init(void)
96 * Report a general error.
99 report_failure(const char *msg_format, ...)
103 va_start(ap, msg_format);
104 (*report_failure_func)(msg_format, ap);
109 * Report an error when trying to open or create a file.
110 * "err" is assumed to be an error code from Wiretap; positive values are
111 * UNIX-style errnos, so this can be used for open failures not from
112 * Wiretap as long as the failue code is just an errno.
115 report_open_failure(const char *filename, int err,
116 gboolean for_writing)
118 (*report_open_failure_func)(filename, err, for_writing);
122 * Report an error when trying to read a file.
123 * "err" is assumed to be a UNIX-style errno.
126 report_read_failure(const char *filename, int err)
128 (*report_read_failure_func)(filename, err);
132 epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
136 edt = g_new(epan_dissect_t, 1);
138 if (create_proto_tree) {
139 edt->tree = proto_tree_create_root();
140 proto_tree_set_visible(edt->tree, proto_tree_visible);
150 epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
151 const guint8* data, frame_data *fd, column_info *cinfo)
153 dissect_packet(edt, pseudo_header, data, fd, cinfo);
158 epan_dissect_free(epan_dissect_t* edt)
160 /* Free the data sources list. */
161 free_data_sources(&edt->pi);
163 /* Free all tvb's created from this tvb, unless dissector
164 * wanted to store the pointer (in which case, the dissector
165 * would have incremented the usage count on that tvbuff_t*) */
166 tvb_free_chain(edt->tvb);
169 proto_tree_free(edt->tree);
176 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
178 dfilter_prime_proto_tree(dfcode, edt->tree);
182 epan_dissect_fill_in_columns(epan_dissect_t *edt)
184 fill_in_columns(&edt->pi);