5 * Wireshark 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"
24 #include "oid_resolv.h"
28 static void (*report_failure_func)(const char *, va_list);
29 static void (*report_open_failure_func)(const char *, int, gboolean);
30 static void (*report_read_failure_func)(const char *, int);
33 * XXX - this takes the plugin directory as an argument, because
34 * libwireshark now has its own configure script and "config.h" file,
35 * which is what code in the "epan" directory includes, but we need
36 * to define PLUGIN_DIR in the top-level directory, as it's used by,
37 * for example, the Makefile for the Gryphon plugin, so it knows
38 * where to install the plugin.
40 * Eventually, we should probably have an "epan-configure" script
41 * (or "libwireshark-configure", or whatever), along the lines of what
42 * GTK+ and GLib have, that can print, among other things, the directory
43 * into which plugins should be installed. That way, only libwireshark
44 * need know what directory that is; programs using it won't, *and*
45 * Makefiles for plugins can just use "epan-configure" to figure out
46 * where to install the plugins.
48 * (Would that *more* libraries had configure scripts like that, so
49 * that configure scripts didn't have to go through various contortions
50 * to figure out where the header files and libraries for various
51 * libraries are located.)
54 epan_init(const char *plugin_dir, void (*register_all_protocols)(void),
55 void (*register_all_handoffs)(void),
56 void (*report_failure)(const char *, va_list),
57 void (*report_open_failure)(const char *, int, gboolean),
58 void (*report_read_failure)(const char *, int))
60 report_failure_func = report_failure;
61 report_open_failure_func = report_open_failure;
62 report_read_failure_func = report_read_failure;
67 proto_init(plugin_dir,register_all_protocols,register_all_handoffs);
70 final_registration_all_protocols();
71 host_name_lookup_init();
85 host_name_lookup_cleanup();
89 epan_conversation_init(void)
95 epan_circuit_init(void)
101 * Report a general error.
104 report_failure(const char *msg_format, ...)
108 va_start(ap, msg_format);
109 (*report_failure_func)(msg_format, ap);
114 * Report an error when trying to open or create a file.
115 * "err" is assumed to be an error code from Wiretap; positive values are
116 * UNIX-style errnos, so this can be used for open failures not from
117 * Wiretap as long as the failue code is just an errno.
120 report_open_failure(const char *filename, int err,
121 gboolean for_writing)
123 (*report_open_failure_func)(filename, err, for_writing);
127 * Report an error when trying to read a file.
128 * "err" is assumed to be a UNIX-style errno.
131 report_read_failure(const char *filename, int err)
133 (*report_read_failure_func)(filename, err);
137 epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
141 edt = g_new(epan_dissect_t, 1);
143 if (create_proto_tree) {
144 edt->tree = proto_tree_create_root();
145 proto_tree_set_visible(edt->tree, proto_tree_visible);
155 epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
156 const guint8* data, frame_data *fd, column_info *cinfo)
158 /* free all memory allocated during previous packet */
161 dissect_packet(edt, pseudo_header, data, fd, cinfo);
166 epan_dissect_free(epan_dissect_t* edt)
168 /* Free the data sources list. */
169 free_data_sources(&edt->pi);
171 /* Free all tvb's created from this tvb, unless dissector
172 * wanted to store the pointer (in which case, the dissector
173 * would have incremented the usage count on that tvbuff_t*) */
174 tvb_free_chain(edt->tvb);
177 proto_tree_free(edt->tree);
184 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
186 dfilter_prime_proto_tree(dfcode, edt->tree);
190 epan_dissect_fill_in_columns(epan_dissect_t *edt)
192 col_fill_in(&edt->pi);