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();
107 proto_init(register_all_protocols_func, register_all_handoffs_func,
111 final_registration_all_protocols();
112 /*host_name_lookup_init();*//* We load the hostname file in cf_open, no need to do it here? */
113 expert_packet_init();
115 wslua_init(cb, client_data);
122 cleanup_dissection();
128 oid_resolv_cleanup();
129 #ifdef HAVE_LIBGNUTLS
130 gnutls_global_deinit();
133 host_name_lookup_cleanup();
138 epan_conversation_init(void)
144 epan_conversation_cleanup(void)
146 conversation_cleanup();
150 epan_circuit_init(void)
156 epan_circuit_cleanup(void)
162 epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible)
166 edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_SIMPLE);
168 if (create_proto_tree) {
169 edt->tree = proto_tree_create_root(&edt->pi);
170 proto_tree_set_visible(edt->tree, proto_tree_visible);
176 edt->pi.dependent_frames = NULL;
182 epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible)
186 edt = g_new0(epan_dissect_t, 1);
188 return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
192 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
195 proto_tree_set_fake_protocols(edt->tree, fake_protocols);
199 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
200 const guint8* data, frame_data *fd, column_info *cinfo)
203 wslua_prime_dfilter(edt); /* done before entering wmem scope */
205 wmem_enter_packet_scope();
206 dissect_packet(edt, phdr, data, fd, cinfo);
208 /* free all memory allocated */
210 wmem_leave_packet_scope();
214 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
215 const guint8* data, frame_data *fd, column_info *cinfo)
217 wmem_enter_packet_scope();
219 dissect_packet(edt, phdr, data, fd, cinfo);
220 tap_push_tapped_queue(edt);
222 /* free all memory allocated */
224 wmem_leave_packet_scope();
228 epan_dissect_cleanup(epan_dissect_t* edt)
232 g_slist_free(edt->pi.dependent_frames);
234 /* Free the data sources list. */
235 free_data_sources(&edt->pi);
237 /* Free all tvb's chained from this tvb */
238 tvb_free_chain(edt->tvb);
241 proto_tree_free(edt->tree);
244 wmem_destroy_allocator(edt->pi.pool);
248 epan_dissect_free(epan_dissect_t* edt)
250 epan_dissect_cleanup(edt);
255 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
257 dfilter_prime_proto_tree(dfcode, edt->tree);
260 /* ----------------------- */
262 epan_custom_set(epan_dissect_t *edt, int field_id,
265 gchar *expr, const int size )
267 return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
271 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
273 col_custom_set_edt(edt, edt->pi.cinfo);
274 col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
278 epan_dissect_packet_contains_field(epan_dissect_t* edt,
279 const char *field_name)
283 gboolean contains_field;
285 if (!edt || !edt->tree)
287 field_id = proto_get_id_by_filter_name(field_name);
290 array = proto_find_finfo(edt->tree, field_id);
291 contains_field = (array->len > 0) ? TRUE : FALSE;
292 g_ptr_array_free(array, TRUE);
293 return contains_field;
297 * Get compile-time information for libraries used by libwireshark.
300 epan_get_compiled_version_info(GString *str)
303 g_string_append(str, ", ");
305 g_string_append(str, "with SMI " SMI_VERSION_STRING);
306 #else /* no SNMP library */
307 g_string_append(str, "without SMI");
311 g_string_append(str, ", ");
313 g_string_append(str, "with c-ares " ARES_VERSION_STR);
315 g_string_append(str, "without c-ares");
317 /* ADNS - only add if no c-ares */
318 g_string_append(str, ", ");
320 g_string_append(str, "with ADNS");
322 g_string_append(str, "without ADNS");
323 #endif /* HAVE_GNU_ADNS */
324 #endif /* HAVE_C_ARES */
327 g_string_append(str, ", ");
329 g_string_append(str, "with ");
330 g_string_append(str, LUA_VERSION);
332 g_string_append(str, "without Lua");
333 #endif /* HAVE_LUA */
335 g_string_append(str, ", ");
337 g_string_append(str, "with Python");
339 g_string_append(str, " " PY_VERSION);
340 #endif /* PY_VERSION */
342 g_string_append(str, "without Python");
343 #endif /* HAVE_PYTHON */
346 g_string_append(str, ", ");
347 #ifdef HAVE_LIBGNUTLS
348 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
350 g_string_append(str, "without GnuTLS");
351 #endif /* HAVE_LIBGNUTLS */
354 g_string_append(str, ", ");
355 #ifdef HAVE_LIBGCRYPT
356 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
358 g_string_append(str, "without Gcrypt");
359 #endif /* HAVE_LIBGCRYPT */
362 /* XXX - I don't see how to get the version number, at least for KfW */
363 g_string_append(str, ", ");
365 #ifdef HAVE_MIT_KERBEROS
366 g_string_append(str, "with MIT Kerberos");
368 /* HAVE_HEIMDAL_KERBEROS */
369 g_string_append(str, "with Heimdal Kerberos");
372 g_string_append(str, "without Kerberos");
373 #endif /* HAVE_KERBEROS */
376 g_string_append(str, ", ");
378 g_string_append(str, "with GeoIP");
380 g_string_append(str, "without GeoIP");
381 #endif /* HAVE_GEOIP */
386 * Get runtime information for libraries used by libwireshark.
389 epan_get_runtime_version_info(GString *str
390 #if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
396 #ifdef HAVE_LIBGNUTLS
397 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
398 #endif /* HAVE_LIBGNUTLS */
401 #ifdef HAVE_LIBGCRYPT
402 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
403 #endif /* HAVE_LIBGCRYPT */
407 * Editor modelines - http://www.wireshark.org/tools/modelines.html
412 * indent-tabs-mode: t
415 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
416 * :indentSize=8:tabSize=8:noTabs=false: