Wireshark-dev: [Wireshark-dev] new plug-in dissector - no packets displayed when dissector spec
From: Stuart Marsden <stuart@xxxxxxxxxxxx>
Date: Fri, 17 Apr 2009 08:20:23 +0100
Hi,

I am new to WS development, I now have a plugin which works well.

however if I select "sslbp.frametype"   in the display filter , I can select "Status" in the predefined values

however:

my printfs appear on the console, for both frametypes but no packets are displayed

I know I must be doing something stupid, but I cant get this to work

thanks in advance

Stuart
---------------------------------------------------------------------
#include <glib.h>
#include <epan/packet.h>
#include "packet-sslbp.h"
#include <epan/prefs.h>


static int proto_sslbp = -1;
static int hf_sslbp_type = -1;

static gint ett_sslbp = -1;
static gint ett_sslbp_header = -1;
static gint ett_sslbp_status = -1;
static gint ett_sslbp_announce = -1;

static const value_string frame_type[] = {
   {MYFT_ANNOUNCE,    "Announce"},
   {MYFT_STATUS,         "Status"},
   {0,            NULL}
};

static void
dissect_sslbp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
   int            offset = 0;
   proto_tree        *sslbp_tree;
   proto_item        *ti;
   proto_tree        *header_tree;
   proto_item        *header_item;

   guint16        magic;              guint8        protocol_ver;
   int            start_offset;
   int            msglen;
   unsigned int    frmtyp;
  // add stuff to columns in main window

   if (check_col(pinfo->cinfo, COL_PROTOCOL))                // set the protcol column
       col_set_str(pinfo->cinfo, COL_PROTOCOL, "sslbp");
   if (check_col(pinfo->cinfo, COL_INFO))                // clear the info column
       col_clear(pinfo->cinfo, COL_INFO);

// basic data

   magic = tvb_get_ntohs(tvb, offset + 0);
   protocol_ver  = tvb_get_guint8(tvb, offset + 2);
   frmtyp = tvb_get_guint8(tvb, offset + 3);
   msglen = tvb_reported_length_remaining(tvb, offset);

   printf("disect_sslbp: magic [%x] ver [%x] typ [%x] length[%d]\n",magic,protocol_ver,frmtyp,msglen);

 

   if (check_col(pinfo->cinfo, COL_INFO)) {
       /*
        * Indicate what kind of message this is.
        */
       if ((frmtyp != MYFT_ANNOUNCE) && (frmtyp != MYFT_STATUS))
       col_set_str(pinfo->cinfo, COL_INFO, "- Invalid -");
       else
       col_set_str(pinfo->cinfo, COL_INFO,val_to_str(frmtyp,frame_type,"Unknown (0x%02x)"));
           col_append_fstr(pinfo->cinfo, COL_INFO," len=%u", msglen );
   }
       if (tree == NULL) {
   printf("disect_sslbp: No tree");
   return;
   }
   DETAILED CODE REMOVED
}
void
proto_register_sslbp(void)
{
   static hf_register_info hf[] = {
   { &hf_sslbp_type, { "Frame type", "sslbp.type", FT_UINT8, BASE_DEC,VALS(frame_type), 0x0, NULL, HFILL }},
   };

   static gint *ett[] = {
   &ett_sslbp,
   &ett_sslbp_header,
   &ett_sslbp_status,
   &ett_sslbp_announce,
   };
   module_t *sslbp_module;

   proto_sslbp = proto_register_protocol("xxxxxx xxxxxxxxxxxxx",
                       "sslbp",
                       "sslbp");
   proto_register_field_array(proto_sslbp, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));

   sslbp_module = prefs_register_protocol(proto_sslbp, NULL);
}

void
proto_reg_handoff_sslbp(void)
{
   dissector_handle_t sslbp_handle;
   sslbp_handle = create_dissector_handle(dissect_sslbp, proto_sslbp);
   dissector_add("udp.port", 10000, sslbp_handle);
}

-

--
_________________________________

Dr Stuart Marsden

MyPhones.com -  Extreme Digital Voice
Meade House
Chesham Rd
Wigginton
Tring
Herts
HP23 6JE

Myphones Voice: +44 (0)1494 414100

Legacy Voice: +44 (0)1494 758204
Fax: +44 (0)1494 757000

Mob: +44 (0)7788 107013

mail to: stuart@xxxxxxxxxxxx

_________________________________