From Harald Welte:
[obnox/wireshark/wip.git] / epan / epan.c
index ec1211a077c6758c5e65b70abfaa9e9ce4fee8c3..a74ee9538e3da72bb14b8e6a62c22316b96969ee 100644 (file)
 #include "config.h"
 #endif
 
+#ifdef HAVE_PYTHON
+#include <Python.h> /* to get the Python version number (PY_VERSION) */
+#endif
+
 #ifdef HAVE_LIBGCRYPT
 #include <gcrypt.h>
 #endif /* HAVE_LIBGCRYPT */
@@ -33,7 +37,6 @@
 #include <gnutls/gnutls.h>
 #endif /* HAVE_LIBGNUTLS */
 
-
 #include <glib.h>
 #include "epan.h"
 #include "epan_dissect.h"
 #include "expert.h"
 
 #ifdef HAVE_LUA_5_1
-       int wslua_init(void*);
+#include <lua.h>
+#include <wslua/wslua.h>
+#endif
+
+#ifdef HAVE_LIBSMI
+#include <smi.h>
+#endif
+
+#ifdef HAVE_C_ARES
+#include <ares_version.h>
 #endif
 
 #ifdef HAVE_GEOIP
 #include "geoip_db.h"
 #endif
 
-gchar*
+const gchar*
 epan_get_version(void) {
-  return VERSION;
+       return VERSION;
 }
 
 void
@@ -89,7 +101,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
 #elif defined(HAVE_LIBGCRYPT)
        gcry_check_version(NULL);
 #endif
-       tvbuff_init();
        tap_init();
        prefs_init();
        proto_init(register_all_protocols_func, register_all_handoffs_func,
@@ -99,9 +110,8 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
        final_registration_all_protocols();
        host_name_lookup_init();
        expert_init();
-       oids_init();
 #ifdef HAVE_LUA_5_1
-       wslua_init(NULL);
+       wslua_init(cb, client_data);
 #endif
 #ifdef HAVE_GEOIP
        geoip_db_init();
@@ -118,7 +128,6 @@ epan_cleanup(void)
        prefs_cleanup();
        packet_cleanup();
        oid_resolv_cleanup();
-       tvbuff_cleanup();
 #ifdef HAVE_LIBGNUTLS
        gnutls_global_deinit();
 #endif
@@ -151,7 +160,7 @@ epan_circuit_cleanup(void)
 }
 
 epan_dissect_t*
-epan_dissect_init(epan_dissect_t       *edt, gboolean create_proto_tree, gboolean proto_tree_visible)
+epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible)
 {
        g_assert(edt);
 
@@ -167,17 +176,17 @@ epan_dissect_init(epan_dissect_t  *edt, gboolean create_proto_tree, gboolean prot
 }
 
 epan_dissect_t*
-epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
+epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible)
 {
-       epan_dissect_t  *edt;
+       epan_dissect_t *edt;
 
-       edt = g_new(epan_dissect_t, 1);
+       edt = g_new0(epan_dissect_t, 1);
 
        return epan_dissect_init(edt, create_proto_tree, proto_tree_visible);
 }
 
 void
-epan_dissect_fake_protocols(epan_dissect_t *edt, gboolean fake_protocols)
+epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
 {
        if (edt)
                proto_tree_set_fake_protocols(edt->tree, fake_protocols);
@@ -201,9 +210,7 @@ epan_dissect_cleanup(epan_dissect_t* edt)
        /* Free the data sources list. */
        free_data_sources(&edt->pi);
 
-       /* Free all tvb's created from this tvb, unless dissector
-        * wanted to store the pointer (in which case, the dissector
-        * would have incremented the usage count on that tvbuff_t*) */
+       /* Free all tvb's chained from this tvb */
        tvb_free_chain(edt->tvb);
 
        if (edt->tree) {
@@ -227,16 +234,126 @@ epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
 /* ----------------------- */
 const gchar *
 epan_custom_set(epan_dissect_t *edt, int field_id,
+                             gint occurrence,
                              gchar *result,
-                             gchar *expr, int size )
+                             gchar *expr, const int size )
 {
-    return proto_custom_set(edt->tree, field_id, result, expr, size);
+    return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
 }
 
 void
-epan_dissect_fill_in_columns(epan_dissect_t *edt, gboolean fill_col_exprs, gboolean fill_fd_colums)
+epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
 {
     col_custom_set_edt(edt, edt->pi.cinfo);
     col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
 }
 
+/*
+ * Get compile-time information for libraries used by libwireshark.
+ */
+void
+epan_get_compiled_version_info(GString *str)
+{
+        /* SNMP */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBSMI
+       g_string_append(str, "with SMI " SMI_VERSION_STRING);
+#else /* no SNMP library */
+       g_string_append(str, "without SMI");
+#endif /* _SMI_H */
+
+       /* c-ares */
+       g_string_append(str, ", ");
+#ifdef HAVE_C_ARES
+       g_string_append(str, "with c-ares " ARES_VERSION_STR);
+#else
+       g_string_append(str, "without c-ares");
+
+       /* ADNS - only add if no c-ares */
+       g_string_append(str, ", ");
+#ifdef HAVE_GNU_ADNS
+       g_string_append(str, "with ADNS");
+#else
+       g_string_append(str, "without ADNS");
+#endif /* HAVE_GNU_ADNS */
+#endif /* HAVE_C_ARES */
+
+        /* LUA */
+       g_string_append(str, ", ");
+#ifdef HAVE_LUA_5_1
+       g_string_append(str, "with ");
+       g_string_append(str, LUA_VERSION);
+#else
+       g_string_append(str, "without Lua");
+#endif /* HAVE_LUA_5_1 */
+
+       g_string_append(str, ", ");
+#ifdef HAVE_PYTHON
+       g_string_append(str, "with Python");
+#ifdef PY_VERSION
+       g_string_append(str, " " PY_VERSION);
+#endif /* PY_VERSION */
+#else
+       g_string_append(str, "without Python");
+#endif /* HAVE_PYTHON */
+
+        /* GnuTLS */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBGNUTLS
+       g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
+#else
+       g_string_append(str, "without GnuTLS");
+#endif /* HAVE_LIBGNUTLS */
+
+        /* Gcrypt */
+       g_string_append(str, ", ");
+#ifdef HAVE_LIBGCRYPT
+       g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
+#else
+       g_string_append(str, "without Gcrypt");
+#endif /* HAVE_LIBGCRYPT */
+
+        /* Kerberos */
+        /* XXX - I don't see how to get the version number, at least for KfW */
+       g_string_append(str, ", ");
+#ifdef HAVE_KERBEROS
+#ifdef HAVE_MIT_KERBEROS
+       g_string_append(str, "with MIT Kerberos");
+#else
+        /* HAVE_HEIMDAL_KERBEROS */
+       g_string_append(str, "with Heimdal Kerberos");
+#endif
+#else
+       g_string_append(str, "without Kerberos");
+#endif /* HAVE_KERBEROS */
+
+       /* GeoIP */
+       g_string_append(str, ", ");
+#ifdef HAVE_GEOIP
+       g_string_append(str, "with GeoIP");
+#else
+       g_string_append(str, "without GeoIP");
+#endif /* HAVE_GEOIP */
+
+}
+
+/*
+ * Get runtime information for libraries used by libwireshark.
+ */
+void
+epan_get_runtime_version_info(GString *str
+#if !defined(HAVE_LIBGNUTLS) && !defined(HAVE_LIBGCRYPT)
+_U_
+#endif
+)
+{
+        /* GnuTLS */
+#ifdef HAVE_LIBGNUTLS
+       g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
+#endif /* HAVE_LIBGNUTLS */
+
+        /* Gcrypt */
+#ifdef HAVE_LIBGCRYPT
+       g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
+#endif /* HAVE_LIBGCRYPT */
+}