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"
42 int wslua_init(void*);
45 static void (*report_failure_func)(const char *, va_list);
46 static void (*report_open_failure_func)(const char *, int, gboolean);
47 static void (*report_read_failure_func)(const char *, int);
50 epan_get_version(void) {
55 * XXX - this takes the plugin directory as an argument, because
56 * libwireshark now has its own configure script and "config.h" file,
57 * which is what code in the "epan" directory includes, but we need
58 * to define PLUGIN_DIR in the top-level directory, as it's used by,
59 * for example, the Makefile for the Gryphon plugin, so it knows
60 * where to install the plugin.
62 * Eventually, we should probably have an "epan-configure" script
63 * (or "libwireshark-configure", or whatever), along the lines of what
64 * GTK+ and GLib have, that can print, among other things, the directory
65 * into which plugins should be installed. That way, only libwireshark
66 * need know what directory that is; programs using it won't, *and*
67 * Makefiles for plugins can just use "epan-configure" to figure out
68 * where to install the plugins.
70 * (Would that *more* libraries had configure scripts like that, so
71 * that configure scripts didn't have to go through various contortions
72 * to figure out where the header files and libraries for various
73 * libraries are located.)
76 epan_init(const char *plugin_dir, void (*register_all_protocols)(void),
77 void (*register_all_handoffs)(void),
78 void (*report_failure)(const char *, va_list),
79 void (*report_open_failure)(const char *, int, gboolean),
80 void (*report_read_failure)(const char *, int))
82 report_failure_func = report_failure;
83 report_open_failure_func = report_open_failure;
84 report_read_failure_func = report_read_failure;
88 #elif defined(HAVE_LIBGCRYPT)
89 gcry_check_version(NULL);
94 proto_init(plugin_dir,register_all_protocols,register_all_handoffs);
97 final_registration_all_protocols();
98 host_name_lookup_init();
113 oid_resolv_cleanup();
115 #ifdef HAVE_LIBGNUTLS
116 gnutls_global_deinit();
119 host_name_lookup_cleanup();
123 epan_conversation_init(void)
129 epan_circuit_init(void)
135 * Report a general error.
138 report_failure(const char *msg_format, ...)
142 va_start(ap, msg_format);
143 (*report_failure_func)(msg_format, ap);
148 * Report an error when trying to open or create a file.
149 * "err" is assumed to be an error code from Wiretap; positive values are
150 * UNIX-style errnos, so this can be used for open failures not from
151 * Wiretap as long as the failue code is just an errno.
154 report_open_failure(const char *filename, int err,
155 gboolean for_writing)
157 (*report_open_failure_func)(filename, err, for_writing);
161 * Report an error when trying to read a file.
162 * "err" is assumed to be a UNIX-style errno.
165 report_read_failure(const char *filename, int err)
167 (*report_read_failure_func)(filename, err);
171 epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
175 edt = g_new(epan_dissect_t, 1);
177 if (create_proto_tree) {
178 edt->tree = proto_tree_create_root();
179 proto_tree_set_visible(edt->tree, proto_tree_visible);
189 epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
190 const guint8* data, frame_data *fd, column_info *cinfo)
192 /* free all memory allocated during previous packet */
195 dissect_packet(edt, pseudo_header, data, fd, cinfo);
200 epan_dissect_free(epan_dissect_t* edt)
202 /* Free the data sources list. */
203 free_data_sources(&edt->pi);
205 /* Free all tvb's created from this tvb, unless dissector
206 * wanted to store the pointer (in which case, the dissector
207 * would have incremented the usage count on that tvbuff_t*) */
208 tvb_free_chain(edt->tvb);
211 proto_tree_free(edt->tree);
218 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
220 dfilter_prime_proto_tree(dfcode, edt->tree);
224 epan_dissect_fill_in_columns(epan_dissect_t *edt)
226 col_fill_in(&edt->pi);