Ask Your Question

Revision history [back]

Extend the Homeplug AV protocol

I am currently developing a plugin dissector to decode HomePlug Green PHY frames. Because the protocol is a superset of HomePlug AV, i would like to use the preexisting dissector (packet-homeplug-av.c) for all the frames that my dissector can't decode.

Inspired by the HomeplugAV dissector, I started with the following code :

static int green_phy_proto = -1;
static dissector_handle_t green_phy_handle;

static int
dissect_green_phy(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)  {
    // Stuff ...
}

void proto_register_greenphy(void) {
    green_phy_proto = proto_register_protocol("Homeplug Green Phy", "HomeplugGP", "green-phy");
}

void proto_reg_handoff_greenphy(void) {
    green_phy_handle = create_dissector_handle(dissect_green_phy, green_phy_proto);
    dissector_add_uint("ethertype", ETHERTYPE_HOMEPLUG_AV, green_phy_handle);
}

But when I do this, frames that are not handled by my protocol are ignore by the HomeplugAV dissector. So i tried :

static int
dissect_green_phy(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)  {
  static dissector_handle_t homeplug_av_handle;
  static gboolean homeplug_handle_initialized = FALSE;

  if(!homeplug_handle_initialized) {
    homeplug_av_handle = find_dissector("homeplug-av");

    if(!homeplug_av_handle) {
      g_print("Could not find the HomePlugAV dissector\n");
    }
    homeplug_handle_initialized = TRUE;
  }

  if(homeplug_av_handle) {
      call_dissector(homeplug_av_handle, tvb, pinfo, tree);
  }

  return tvb_reported_length(tvb);
}

But then, it logs Could not find the HomePlugAV dissector. What can I do to make both dissector coexist ?