5 * Wireshark Protocol Analyzer Library
7 * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <Python.h> /* to get the Python version number (PY_VERSION) */
32 #endif /* HAVE_LIBGCRYPT */
35 #include <gnutls/gnutls.h>
36 #endif /* HAVE_LIBGNUTLS */
40 #include "epan_dissect.h"
41 #include "report_err.h"
43 #include "conversation.h"
48 #include "column-utils.h"
50 #include "addr_resolv.h"
53 #include "wmem/wmem.h"
58 #include <wslua/wslua.h>
66 #include <ares_version.h>
70 epan_get_version(void) {
75 epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
76 void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
79 void (*report_failure_fcn_p)(const char *, va_list),
80 void (*report_open_failure_fcn_p)(const char *, int, gboolean),
81 void (*report_read_failure_fcn_p)(const char *, int),
82 void (*report_write_failure_fcn_p)(const char *, int))
84 init_report_err(report_failure_fcn_p, report_open_failure_fcn_p,
85 report_read_failure_fcn_p, report_write_failure_fcn_p);
87 /* initialize memory allocation subsystems */
91 /* initialize the GUID to name mapping table */
96 /* initialize libgcrypt (beware, it won't be thread-safe) */
97 gcry_check_version(NULL);
98 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
99 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
101 #ifdef HAVE_LIBGNUTLS
102 gnutls_global_init();
106 proto_init(register_all_protocols_func, register_all_handoffs_func,
110 final_registration_all_protocols();
111 host_name_lookup_init();
114 wslua_init(cb, client_data);
121 cleanup_dissection();
126 oid_resolv_cleanup();
127 #ifdef HAVE_LIBGNUTLS
128 gnutls_global_deinit();
131 host_name_lookup_cleanup();
136 epan_conversation_init(void)
142 epan_conversation_cleanup(void)
144 conversation_cleanup();
148 epan_circuit_init(void)
154 epan_circuit_cleanup(void)
160 epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible)
164 if (create_proto_tree) {
165 edt->tree = proto_tree_create_root(&edt->pi);
166 proto_tree_set_visible(edt->tree, proto_tree_visible);
172 edt->pi.dependent_frames = NULL;
178 epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible)
182 edt = g_new0(epan_dissect_t, 1);
184 return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
188 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
191 proto_tree_set_fake_protocols(edt->tree, fake_protocols);
195 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
196 const guint8* data, frame_data *fd, column_info *cinfo)
198 dissect_packet(edt, phdr, data, fd, cinfo);
200 /* free all memory allocated */
205 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
206 const guint8* data, frame_data *fd, column_info *cinfo)
209 dissect_packet(edt, phdr, data, fd, cinfo);
210 tap_push_tapped_queue(edt);
212 /* free all memory allocated */
217 epan_dissect_reset(epan_dissect_t *edt)
219 /* epan_dissect_cleanup(edt) without freeing tree */
220 g_slist_free(edt->pi.dependent_frames);
221 free_data_sources(&edt->pi);
222 tvb_free_chain(edt->tvb);
224 /* epan_dissect_init(edt, create_proto, visible_proto) */
225 edt->pi.dependent_frames = NULL;
227 proto_tree_reset(edt->tree);
231 epan_dissect_cleanup(epan_dissect_t* edt)
235 g_slist_free(edt->pi.dependent_frames);
237 /* Free the data sources list. */
238 free_data_sources(&edt->pi);
240 /* Free all tvb's chained from this tvb */
241 tvb_free_chain(edt->tvb);
244 proto_tree_free(edt->tree);
249 epan_dissect_free(epan_dissect_t* edt)
251 epan_dissect_cleanup(edt);
256 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
258 dfilter_prime_proto_tree(dfcode, edt->tree);
261 /* ----------------------- */
263 epan_custom_set(epan_dissect_t *edt, int field_id,
266 gchar *expr, const int size )
268 return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
272 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
274 col_custom_set_edt(edt, edt->pi.cinfo);
275 col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
279 * Get compile-time information for libraries used by libwireshark.
282 epan_get_compiled_version_info(GString *str)
285 g_string_append(str, ", ");
287 g_string_append(str, "with SMI " SMI_VERSION_STRING);
288 #else /* no SNMP library */
289 g_string_append(str, "without SMI");
293 g_string_append(str, ", ");
295 g_string_append(str, "with c-ares " ARES_VERSION_STR);
297 g_string_append(str, "without c-ares");
299 /* ADNS - only add if no c-ares */
300 g_string_append(str, ", ");
302 g_string_append(str, "with ADNS");
304 g_string_append(str, "without ADNS");
305 #endif /* HAVE_GNU_ADNS */
306 #endif /* HAVE_C_ARES */
309 g_string_append(str, ", ");
311 g_string_append(str, "with ");
312 g_string_append(str, LUA_VERSION);
314 g_string_append(str, "without Lua");
315 #endif /* HAVE_LUA */
317 g_string_append(str, ", ");
319 g_string_append(str, "with Python");
321 g_string_append(str, " " PY_VERSION);
322 #endif /* PY_VERSION */
324 g_string_append(str, "without Python");
325 #endif /* HAVE_PYTHON */
328 g_string_append(str, ", ");
329 #ifdef HAVE_LIBGNUTLS
330 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
332 g_string_append(str, "without GnuTLS");
333 #endif /* HAVE_LIBGNUTLS */
336 g_string_append(str, ", ");
337 #ifdef HAVE_LIBGCRYPT
338 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
340 g_string_append(str, "without Gcrypt");
341 #endif /* HAVE_LIBGCRYPT */
344 /* XXX - I don't see how to get the version number, at least for KfW */
345 g_string_append(str, ", ");
347 #ifdef HAVE_MIT_KERBEROS
348 g_string_append(str, "with MIT Kerberos");
350 /* HAVE_HEIMDAL_KERBEROS */
351 g_string_append(str, "with Heimdal Kerberos");
354 g_string_append(str, "without Kerberos");
355 #endif /* HAVE_KERBEROS */
358 g_string_append(str, ", ");
360 g_string_append(str, "with GeoIP");
362 g_string_append(str, "without GeoIP");
363 #endif /* HAVE_GEOIP */
368 * Get runtime information for libraries used by libwireshark.
371 epan_get_runtime_version_info(GString *str
372 #if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
378 #ifdef HAVE_LIBGNUTLS
379 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
380 #endif /* HAVE_LIBGNUTLS */
383 #ifdef HAVE_LIBGCRYPT
384 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
385 #endif /* HAVE_LIBGCRYPT */
389 * Editor modelines - http://www.wireshark.org/tools/modelines.html
394 * indent-tabs-mode: t
397 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
398 * :indentSize=8:tabSize=8:noTabs=false: