[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v3 15/31] Teach wireshark plugin about VIR_NET_STREAM_HOLE




On 05/16/2017 10:03 AM, Michal Privoznik wrote:
> Ideally, this would be generated, but to achieve that
> corresponding XDR definitions needed to go into a different .x
> file. But they belong just to the one that they are right now.
> 
> Signed-off-by: Michal Privoznik <mprivozn redhat com>
> ---
>  tools/wireshark/src/packet-libvirt.c | 52 ++++++++++++++++++++++++++++++++++++
>  tools/wireshark/src/packet-libvirt.h |  2 ++
>  2 files changed, 54 insertions(+)
> 
> diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
> index 260161e98..a1f5a34f4 100644
> --- a/tools/wireshark/src/packet-libvirt.c
> +++ b/tools/wireshark/src/packet-libvirt.c
> @@ -50,8 +50,12 @@ static int hf_libvirt_serial = -1;
>  static int hf_libvirt_status = -1;
>  static int hf_libvirt_stream = -1;
>  static int hf_libvirt_num_of_fds = -1;
> +static int hf_libvirt_stream_hole_length = -1;

How will this work with a LL (hyper) stream hole size? [1]

> +static int hf_libvirt_stream_hole_flags = -1;
> +static int hf_libvirt_stream_hole = -1;
>  int hf_libvirt_unknown = -1;
>  static gint ett_libvirt = -1;
> +static gint ett_libvirt_stream_hole = -1;
>  
>  #define XDR_PRIMITIVE_DISSECTOR(xtype, ctype, ftype)                    \
>      static gboolean                                                     \
> @@ -326,6 +330,33 @@ dissect_libvirt_payload_xdr_data(tvbuff_t *tvb, proto_tree *tree, gint payload_l
>          dissect_libvirt_fds(tvb, start + payload_length, nfds);
>  }
>  
> +static gboolean
> +dissect_xdr_stream_hole(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf)
int hf? [1]

Of course this does match the prototype I see:

 static gboolean dissect_xdr_hyper(tvbuff_t *tvb, proto_tree *tree, XDR
*xdrs, int hf);

but seems strange.  Then again, I know next to nothing about wireshark.

Call this a "weak" (at best)

Reviewed-by: John Ferlan <jferlan redhat com>


John

> +{
> +    goffset start;
> +    proto_item *ti;
> +
> +    start = xdr_getpos(xdrs);
> +    if (hf == -1) {
> +        ti = proto_tree_add_item(tree, hf_libvirt_stream_hole, tvb, start, -1, ENC_NA);
> +    } else {
> +        header_field_info *hfinfo;
> +        hfinfo = proto_registrar_get_nth(hf_libvirt_stream_hole);
> +        ti = proto_tree_add_item(tree, hf, tvb, start, -1, ENC_NA);
> +        proto_item_append_text(ti, " :: %s", hfinfo->name);
> +    }
> +    tree = proto_item_add_subtree(ti, ett_libvirt_stream_hole);
> +
> +    hf = hf_libvirt_stream_hole_length;
> +    if (!dissect_xdr_hyper(tvb, tree, xdrs, hf)) return FALSE;
> +
> +    hf = hf_libvirt_stream_hole_flags;
> +    if (!dissect_xdr_u_int(tvb, tree, xdrs, hf)) return FALSE;
> +
> +    proto_item_set_len(ti, xdr_getpos(xdrs) - start);
> +    return TRUE;
> +}
> +
>  static void
>  dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
>                          guint32 prog, guint32 proc, guint32 type, guint32 status)
> @@ -346,6 +377,8 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
>          dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, VIR_ERROR_MESSAGE_DISSECTOR);
>      } else if (type == VIR_NET_STREAM) { /* implicitly, status == VIR_NET_CONTINUE */
>          dissect_libvirt_stream(tvb, tree, payload_length);
> +    } else if (type == VIR_NET_STREAM_HOLE) {
> +        dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, dissect_xdr_stream_hole);
>      } else {
>          goto unknown;
>      }
> @@ -525,6 +558,24 @@ proto_register_libvirt(void)
>              NULL, 0x0,
>              NULL, HFILL}
>          },
> +        { &hf_libvirt_stream_hole,
> +          { "stream_hole", "libvirt.stream_hole",
> +            FT_NONE, BASE_NONE,
> +            NULL, 0x0,
> +            NULL, HFILL}
> +        },
> +        { &hf_libvirt_stream_hole_length,
> +          { "length", "libvirt.stream_hole.length",
> +            FT_INT64, BASE_DEC,
> +            NULL, 0x0,
> +            NULL, HFILL}
> +        },
> +        { &hf_libvirt_stream_hole_flags,
> +          { "flags", "libvirt.stream_hole.flags",
> +            FT_UINT32, BASE_DEC,
> +            NULL, 0x0,
> +            NULL, HFILL}
> +        },
>          { &hf_libvirt_unknown,
>            { "unknown", "libvirt.unknown",
>              FT_BYTES, BASE_NONE,
> @@ -535,6 +586,7 @@ proto_register_libvirt(void)
>  
>      static gint *ett[] = {
>          VIR_DYNAMIC_ETTSET
> +        &ett_libvirt_stream_hole,
>          &ett_libvirt
>      };
>  
> diff --git a/tools/wireshark/src/packet-libvirt.h b/tools/wireshark/src/packet-libvirt.h
> index 5f99fdfae..9874a8cbf 100644
> --- a/tools/wireshark/src/packet-libvirt.h
> +++ b/tools/wireshark/src/packet-libvirt.h
> @@ -53,6 +53,7 @@ enum vir_net_message_type {
>      VIR_NET_STREAM         = 3,
>      VIR_NET_CALL_WITH_FDS  = 4,
>      VIR_NET_REPLY_WITH_FDS = 5,
> +    VIR_NET_STREAM_HOLE    = 6,
>  };
>  
>  enum vir_net_message_status {
> @@ -76,6 +77,7 @@ static const value_string type_strings[] = {
>      { VIR_NET_STREAM,         "STREAM"         },
>      { VIR_NET_CALL_WITH_FDS,  "CALL_WITH_FDS"  },
>      { VIR_NET_REPLY_WITH_FDS, "REPLY_WITH_FDS" },
> +    { VIR_NET_STREAM_HOLE,    "STREAM_HOLE"    },
>      { -1, NULL }
>  };
>  
> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]