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) */
31 #include <wsutil/wsgcrypt.h>
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 edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_SIMPLE);
166 if (create_proto_tree) {
167 edt->tree = proto_tree_create_root(&edt->pi);
168 proto_tree_set_visible(edt->tree, proto_tree_visible);
174 edt->pi.dependent_frames = NULL;
180 epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible)
184 edt = g_new0(epan_dissect_t, 1);
186 return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
190 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
193 proto_tree_set_fake_protocols(edt->tree, fake_protocols);
197 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
198 const guint8* data, frame_data *fd, column_info *cinfo)
200 wmem_enter_packet_scope();
201 dissect_packet(edt, phdr, data, fd, cinfo);
203 /* free all memory allocated */
205 wmem_leave_packet_scope();
209 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
210 const guint8* data, frame_data *fd, column_info *cinfo)
212 wmem_enter_packet_scope();
214 dissect_packet(edt, phdr, data, fd, cinfo);
215 tap_push_tapped_queue(edt);
217 /* free all memory allocated */
219 wmem_leave_packet_scope();
223 epan_dissect_cleanup(epan_dissect_t* edt)
227 g_slist_free(edt->pi.dependent_frames);
229 /* Free the data sources list. */
230 free_data_sources(&edt->pi);
232 /* Free all tvb's chained from this tvb */
233 tvb_free_chain(edt->tvb);
236 proto_tree_free(edt->tree);
239 wmem_destroy_allocator(edt->pi.pool);
243 epan_dissect_free(epan_dissect_t* edt)
245 epan_dissect_cleanup(edt);
250 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
252 dfilter_prime_proto_tree(dfcode, edt->tree);
255 /* ----------------------- */
257 epan_custom_set(epan_dissect_t *edt, int field_id,
260 gchar *expr, const int size )
262 return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
266 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
268 col_custom_set_edt(edt, edt->pi.cinfo);
269 col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
273 * Get compile-time information for libraries used by libwireshark.
276 epan_get_compiled_version_info(GString *str)
279 g_string_append(str, ", ");
281 g_string_append(str, "with SMI " SMI_VERSION_STRING);
282 #else /* no SNMP library */
283 g_string_append(str, "without SMI");
287 g_string_append(str, ", ");
289 g_string_append(str, "with c-ares " ARES_VERSION_STR);
291 g_string_append(str, "without c-ares");
293 /* ADNS - only add if no c-ares */
294 g_string_append(str, ", ");
296 g_string_append(str, "with ADNS");
298 g_string_append(str, "without ADNS");
299 #endif /* HAVE_GNU_ADNS */
300 #endif /* HAVE_C_ARES */
303 g_string_append(str, ", ");
305 g_string_append(str, "with ");
306 g_string_append(str, LUA_VERSION);
308 g_string_append(str, "without Lua");
309 #endif /* HAVE_LUA */
311 g_string_append(str, ", ");
313 g_string_append(str, "with Python");
315 g_string_append(str, " " PY_VERSION);
316 #endif /* PY_VERSION */
318 g_string_append(str, "without Python");
319 #endif /* HAVE_PYTHON */
322 g_string_append(str, ", ");
323 #ifdef HAVE_LIBGNUTLS
324 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
326 g_string_append(str, "without GnuTLS");
327 #endif /* HAVE_LIBGNUTLS */
330 g_string_append(str, ", ");
331 #ifdef HAVE_LIBGCRYPT
332 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
334 g_string_append(str, "without Gcrypt");
335 #endif /* HAVE_LIBGCRYPT */
338 /* XXX - I don't see how to get the version number, at least for KfW */
339 g_string_append(str, ", ");
341 #ifdef HAVE_MIT_KERBEROS
342 g_string_append(str, "with MIT Kerberos");
344 /* HAVE_HEIMDAL_KERBEROS */
345 g_string_append(str, "with Heimdal Kerberos");
348 g_string_append(str, "without Kerberos");
349 #endif /* HAVE_KERBEROS */
352 g_string_append(str, ", ");
354 g_string_append(str, "with GeoIP");
356 g_string_append(str, "without GeoIP");
357 #endif /* HAVE_GEOIP */
362 * Get runtime information for libraries used by libwireshark.
365 epan_get_runtime_version_info(GString *str
366 #if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
372 #ifdef HAVE_LIBGNUTLS
373 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
374 #endif /* HAVE_LIBGNUTLS */
377 #ifdef HAVE_LIBGCRYPT
378 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
379 #endif /* HAVE_LIBGCRYPT */
383 * Editor modelines - http://www.wireshark.org/tools/modelines.html
388 * indent-tabs-mode: t
391 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
392 * :indentSize=8:tabSize=8:noTabs=false: