Ask Your Question
0

Extend the Homeplug AV protocol

asked 2019-09-04 17:21:16 +0000

Avi S gravatar image

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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-04 19:11:46 +0000

Guy Harris gravatar image

What can I do to make both dissector coexist ?

Either 1) not have two dissectors, just modify the existing HomePlug AV dissector to handle Green PHY frames or 2) modify the existing HomePlug AV to register itself with the name "homeplug-av".

I.e., you can't develop a plugin that will work with existing Wireshark.

What you should do is probably modify the existing HomePlug AV dissector to handle Green PHY frames and then submit that as an enhancement to Wireshark.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-09-04 17:21:16 +0000

Seen: 757 times

Last updated: Sep 04 '19