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"
54 #include "wmem/wmem_allocator_glib.h"
59 #include <wslua/wslua.h>
67 #include <ares_version.h>
71 epan_get_version(void) {
76 epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
77 void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
80 void (*report_failure_fcn_p)(const char *, va_list),
81 void (*report_open_failure_fcn_p)(const char *, int, gboolean),
82 void (*report_read_failure_fcn_p)(const char *, int),
83 void (*report_write_failure_fcn_p)(const char *, int))
85 init_report_err(report_failure_fcn_p, report_open_failure_fcn_p,
86 report_read_failure_fcn_p, report_write_failure_fcn_p);
88 /* initialize memory allocation subsystems */
92 /* initialize the GUID to name mapping table */
97 /* initialize libgcrypt (beware, it won't be thread-safe) */
98 gcry_check_version(NULL);
99 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
100 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
102 #ifdef HAVE_LIBGNUTLS
103 gnutls_global_init();
107 proto_init(register_all_protocols_func, register_all_handoffs_func,
111 final_registration_all_protocols();
112 host_name_lookup_init();
115 wslua_init(cb, client_data);
122 cleanup_dissection();
127 oid_resolv_cleanup();
128 #ifdef HAVE_LIBGNUTLS
129 gnutls_global_deinit();
132 host_name_lookup_cleanup();
137 epan_conversation_init(void)
143 epan_conversation_cleanup(void)
145 conversation_cleanup();
149 epan_circuit_init(void)
155 epan_circuit_cleanup(void)
161 epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible)
165 edt->pi.pool = wmem_create_glib_allocator();
167 if (create_proto_tree) {
168 edt->tree = proto_tree_create_root(&edt->pi);
169 proto_tree_set_visible(edt->tree, proto_tree_visible);
175 edt->pi.dependent_frames = NULL;
181 epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible)
185 edt = g_new0(epan_dissect_t, 1);
187 return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
191 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
194 proto_tree_set_fake_protocols(edt->tree, fake_protocols);
198 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
199 const guint8* data, frame_data *fd, column_info *cinfo)
201 wmem_enter_packet_scope();
202 dissect_packet(edt, phdr, data, fd, cinfo);
204 /* free all memory allocated */
206 wmem_leave_packet_scope();
210 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
211 const guint8* data, frame_data *fd, column_info *cinfo)
213 wmem_enter_packet_scope();
215 dissect_packet(edt, phdr, data, fd, cinfo);
216 tap_push_tapped_queue(edt);
218 /* free all memory allocated */
220 wmem_leave_packet_scope();
224 epan_dissect_cleanup(epan_dissect_t* edt)
228 g_slist_free(edt->pi.dependent_frames);
230 /* Free the data sources list. */
231 free_data_sources(&edt->pi);
233 /* Free all tvb's chained from this tvb */
234 tvb_free_chain(edt->tvb);
237 proto_tree_free(edt->tree);
240 wmem_free_all(edt->pi.pool);
244 epan_dissect_free(epan_dissect_t* edt)
246 epan_dissect_cleanup(edt);
247 wmem_destroy_allocator(edt->pi.pool);
252 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
254 dfilter_prime_proto_tree(dfcode, edt->tree);
257 /* ----------------------- */
259 epan_custom_set(epan_dissect_t *edt, int field_id,
262 gchar *expr, const int size )
264 return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
268 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
270 col_custom_set_edt(edt, edt->pi.cinfo);
271 col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
275 * Get compile-time information for libraries used by libwireshark.
278 epan_get_compiled_version_info(GString *str)
281 g_string_append(str, ", ");
283 g_string_append(str, "with SMI " SMI_VERSION_STRING);
284 #else /* no SNMP library */
285 g_string_append(str, "without SMI");
289 g_string_append(str, ", ");
291 g_string_append(str, "with c-ares " ARES_VERSION_STR);
293 g_string_append(str, "without c-ares");
295 /* ADNS - only add if no c-ares */
296 g_string_append(str, ", ");
298 g_string_append(str, "with ADNS");
300 g_string_append(str, "without ADNS");
301 #endif /* HAVE_GNU_ADNS */
302 #endif /* HAVE_C_ARES */
305 g_string_append(str, ", ");
307 g_string_append(str, "with ");
308 g_string_append(str, LUA_VERSION);
310 g_string_append(str, "without Lua");
311 #endif /* HAVE_LUA */
313 g_string_append(str, ", ");
315 g_string_append(str, "with Python");
317 g_string_append(str, " " PY_VERSION);
318 #endif /* PY_VERSION */
320 g_string_append(str, "without Python");
321 #endif /* HAVE_PYTHON */
324 g_string_append(str, ", ");
325 #ifdef HAVE_LIBGNUTLS
326 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
328 g_string_append(str, "without GnuTLS");
329 #endif /* HAVE_LIBGNUTLS */
332 g_string_append(str, ", ");
333 #ifdef HAVE_LIBGCRYPT
334 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
336 g_string_append(str, "without Gcrypt");
337 #endif /* HAVE_LIBGCRYPT */
340 /* XXX - I don't see how to get the version number, at least for KfW */
341 g_string_append(str, ", ");
343 #ifdef HAVE_MIT_KERBEROS
344 g_string_append(str, "with MIT Kerberos");
346 /* HAVE_HEIMDAL_KERBEROS */
347 g_string_append(str, "with Heimdal Kerberos");
350 g_string_append(str, "without Kerberos");
351 #endif /* HAVE_KERBEROS */
354 g_string_append(str, ", ");
356 g_string_append(str, "with GeoIP");
358 g_string_append(str, "without GeoIP");
359 #endif /* HAVE_GEOIP */
364 * Get runtime information for libraries used by libwireshark.
367 epan_get_runtime_version_info(GString *str
368 #if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
374 #ifdef HAVE_LIBGNUTLS
375 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
376 #endif /* HAVE_LIBGNUTLS */
379 #ifdef HAVE_LIBGCRYPT
380 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
381 #endif /* HAVE_LIBGCRYPT */
385 * Editor modelines - http://www.wireshark.org/tools/modelines.html
390 * indent-tabs-mode: t
393 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
394 * :indentSize=8:tabSize=8:noTabs=false: