5 * Wireshark Protocol Analyzer Library
12 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
13 #include <winposixtype.h>
18 #endif /* HAVE_LIBGCRYPT */
21 #include <gnutls/gnutls.h>
22 #endif /* HAVE_LIBGNUTLS */
27 #include "epan_dissect.h"
28 #include "report_err.h"
30 #include "conversation.h"
34 #include "column-utils.h"
36 #include "addr_resolv.h"
37 #include "oid_resolv.h"
41 static void (*report_failure_func)(const char *, va_list);
42 static void (*report_open_failure_func)(const char *, int, gboolean);
43 static void (*report_read_failure_func)(const char *, int);
46 epan_get_version(void) {
51 * XXX - this takes the plugin directory as an argument, because
52 * libwireshark now has its own configure script and "config.h" file,
53 * which is what code in the "epan" directory includes, but we need
54 * to define PLUGIN_DIR in the top-level directory, as it's used by,
55 * for example, the Makefile for the Gryphon plugin, so it knows
56 * where to install the plugin.
58 * Eventually, we should probably have an "epan-configure" script
59 * (or "libwireshark-configure", or whatever), along the lines of what
60 * GTK+ and GLib have, that can print, among other things, the directory
61 * into which plugins should be installed. That way, only libwireshark
62 * need know what directory that is; programs using it won't, *and*
63 * Makefiles for plugins can just use "epan-configure" to figure out
64 * where to install the plugins.
66 * (Would that *more* libraries had configure scripts like that, so
67 * that configure scripts didn't have to go through various contortions
68 * to figure out where the header files and libraries for various
69 * libraries are located.)
72 epan_init(const char *plugin_dir, void (*register_all_protocols)(void),
73 void (*register_all_handoffs)(void),
74 void (*report_failure)(const char *, va_list),
75 void (*report_open_failure)(const char *, int, gboolean),
76 void (*report_read_failure)(const char *, int))
78 report_failure_func = report_failure;
79 report_open_failure_func = report_open_failure;
80 report_read_failure_func = report_read_failure;
84 #elif defined(HAVE_LIBGCRYPT)
85 gcry_check_version(NULL);
90 proto_init(plugin_dir,register_all_protocols,register_all_handoffs);
93 final_registration_all_protocols();
94 host_name_lookup_init();
105 oid_resolv_cleanup();
107 #ifdef HAVE_LIBGNUTLS
108 gnutls_global_deinit();
111 host_name_lookup_cleanup();
115 epan_conversation_init(void)
121 epan_circuit_init(void)
127 * Report a general error.
130 report_failure(const char *msg_format, ...)
134 va_start(ap, msg_format);
135 (*report_failure_func)(msg_format, ap);
140 * Report an error when trying to open or create a file.
141 * "err" is assumed to be an error code from Wiretap; positive values are
142 * UNIX-style errnos, so this can be used for open failures not from
143 * Wiretap as long as the failue code is just an errno.
146 report_open_failure(const char *filename, int err,
147 gboolean for_writing)
149 (*report_open_failure_func)(filename, err, for_writing);
153 * Report an error when trying to read a file.
154 * "err" is assumed to be a UNIX-style errno.
157 report_read_failure(const char *filename, int err)
159 (*report_read_failure_func)(filename, err);
163 epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
167 edt = g_new(epan_dissect_t, 1);
169 if (create_proto_tree) {
170 edt->tree = proto_tree_create_root();
171 proto_tree_set_visible(edt->tree, proto_tree_visible);
181 epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
182 const guint8* data, frame_data *fd, column_info *cinfo)
184 /* free all memory allocated during previous packet */
187 dissect_packet(edt, pseudo_header, data, fd, cinfo);
192 epan_dissect_free(epan_dissect_t* edt)
194 /* Free the data sources list. */
195 free_data_sources(&edt->pi);
197 /* Free all tvb's created from this tvb, unless dissector
198 * wanted to store the pointer (in which case, the dissector
199 * would have incremented the usage count on that tvbuff_t*) */
200 tvb_free_chain(edt->tvb);
203 proto_tree_free(edt->tree);
210 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
212 dfilter_prime_proto_tree(dfcode, edt->tree);
216 epan_dissect_fill_in_columns(epan_dissect_t *edt)
218 col_fill_in(&edt->pi);