Wireshark-dev: Re: [Wireshark-dev] get_pdu_len signature change (TCP re-assembly) andSVN versio
From: "Kukosa, Tomas" <tomas.kukosa@xxxxxxxxxxx>
Date: Tue, 21 Nov 2006 15:10:59 +0100
Hello,
 
I use code below for checking if the plugin is running with the same version which it has been compiled with.
 
Regards,
  Tomas
 
 
#include "moduleinfo.h"
...
/*--- version ---------------------------------------------------------------*/
G_MODULE_EXPORT const gchar version[] = PLUGIN_VERSION;
 
/*--- plugin_init -----------------------------------------------------------*/
const gchar *get_epan_version(void) {
  GModule *handle;
  gpointer symbol;
  gchar *ver;
 
  handle = g_module_open("libwireshark.dll", 0);
 
  if (!handle)
    return "0.10.3 or earlier";
 
  if (g_module_symbol(handle, "epan_version", &symbol)) {
    ver = symbol;
  } else if (g_module_symbol(handle, "tvb_get_guid", &symbol)) {
    ver = "0.99.0";
  } else if (g_module_symbol(handle, "dissect_ber_object_identifier_str", &symbol)) {
    ver = "0.10.14";
  } else if (g_module_symbol(handle, "se_alloc", &symbol)) {
    ver = "0.10.13";
  } else if (g_module_symbol(handle, "proto_tree_add_guid", &symbol)) {
    ver = "0.10.12";
  } else if (g_module_symbol(handle, "dissect_per_null", &symbol)) {
    ver = "0.10.11";
  } else if (g_module_symbol(handle, "register_all_plugin_tap_listeners", &symbol)) {
    ver = "0.10.10";
  } else if (g_module_symbol(handle, "hex_str_to_bytes", &symbol)) {
    ver = "0.10.9";
  } else if (g_module_symbol(handle, "prefs_register_range_preference", &symbol)) {
    ver = "0.10.7 or 0.10.8";
  } else if (g_module_symbol(handle, "proto_frame", &symbol)) {
    ver = "0.10.6";
  } else if (g_module_symbol(handle, "dfilter_dump", &symbol)) {
    ver = "0.10.5a";
  } else {
    ver = "0.10.4";
  }
 
  g_module_close(handle);
  return ver;
}
 
/*--- plugin_init -----------------------------------------------------------*/
G_MODULE_EXPORT void plugin_register(void) {
  gboolean ver_ok;
  const gchar *epan_ver;
  const gchar *rep_ok;
 
  epan_ver = epan_get_version();
  /* g_message("get_epan_version() = '%s'", epan_ver); */
 
  ver_ok = !strcmp(epan_ver, VERSION);
 
#ifndef MKLAST
  rep_ok = (ver_ok)?"OK":"ERROR";
#else
  rep_ok = "DEVEL";
#endif  /* MKLAST */
 
  log(1, "Wireshark: %s, My plugin: %s compiled for %s - %s", epan_ver, version, VERSION, rep_ok);
 
#ifndef MKLAST
  if (!ver_ok) {
    g_error("My plugin: %s\n"
            "Plugin is compiled for Ethereal %s but running version is %s",
            version, VERSION, epan_ver);
    return;
  }
#endif  /* MKLAST */
...
 


From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Jacques, Olivier (PD&E IT Test)
Sent: Tuesday, November 21, 2006 1:36 PM
To: Developer support list for Wireshark
Subject: [Wireshark-dev] get_pdu_len signature change (TCP re-assembly) andSVN versions

Hello,
 
with recent Wireshark SVN versions, my TCP plugins which use re-assembly are throwing exceptions.
I found that there is a change that occured in "get_pdu_len" signature that happened in SVN 19751 (http://www.mail-archive.com/wireshark-commits@xxxxxxxxxxxxx/msg01181.html).
 
The corresponding documentation in README.developer should change too to reflect that.
In 2.7.1 Using tcp_dissect_pdus(), the text should read:
-----------------------------------
 a routine that takes as arguments a packet_info pointer, a tvbuff pointer and an offset
 value representing the offset into the tvbuff at which a PDU
 begins and should return - *without* throwing an exception (it
 is guaranteed that the number of bytes specified by the previous
 argument to tcp_dissect_pdus is available, but more data might
 not be available, so don't refer to any data past that) - the
 total length of the PDU, in bytes;
-----------------------------------
I updated my plugins and it seems to be OK.
 
The ideal would be to protect the plugins from being incompatible from one Wireshark version to another (I know binary compatibility is not guaranteed, but I would like to make this as transparent as possible).
The first idea that comes to me is having access to the SVN release at run time (compile time is not enough as we provide plugin binaries) and test against this.
 
But maybe there is something that already exist for that?
 
Thanks,
Olivier.