Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Ethereal: dev

Printing an array of bytes to the tree?

 

 

Ethereal dev RSS feed   Index | Next | Previous | View Threaded


ykaul at checkpoint

Aug 12, 2002, 8:46 AM

Post #1 of 5 (1223 views)
Permalink
Printing an array of bytes to the tree?

Is there an intelligent way to print an array of bytes to the tree?
I'd like to have something like:

"array: 0x0102030405060708090A"

Thanks in advance,
Y.


guy at netapp

Aug 12, 2002, 10:39 AM

Post #2 of 5 (1155 views)
Permalink
Re: Printing an array of bytes to the tree? [In reply to]

On Mon, Aug 12, 2002 at 05:46:12PM +0200, Yaniv Kaul wrote:
> Is there an intelligent way to print an array of bytes to the tree?
> I'd like to have something like:
>
> "array: 0x0102030405060708090A"

If the array of bytes is a named field, just make it a field of type
FT_BYTES.

If it's not a named field, and you're putting it into the protocol tree
with "proto_tree_add_text()", use "tvb_bytes_to_str()".

Doing one of those won't put a leading "0x" in there, and will just put
in a "..." after 16 bytes rather than showing ever single byte (16 is
1/2 the value of the #define MAX_BYTE_STR_LEN in epan/strutil.c -
MAX_BYTE_STR_LEN is the number of characters in the display, and each
byte is shown as 2 hex digits - so it could be increased), but it's the
type of thing you're asking for .


ykaul at netvision

Aug 15, 2002, 12:31 AM

Post #3 of 5 (1148 views)
Permalink
RE: Printing an array of bytes to the tree? [In reply to]

Thanks.

tvb_bytes_to_str() is not documented in doc/README.developer.

> -----Original Message-----
> From: Guy Harris [mailto:guy [at] netapp]
> Sent: Mon, August 12, 2002 7:39 PM
> To: Yaniv Kaul
> Cc: Ethereal-Dev [at] ethereal
> Subject: Re: [Ethereal-dev] Printing an array of bytes to the tree?
>
>
> On Mon, Aug 12, 2002 at 05:46:12PM +0200, Yaniv Kaul wrote:
> > Is there an intelligent way to print an array of bytes to the tree?
> > I'd like to have something like:
> >
> > "array: 0x0102030405060708090A"
>
> If the array of bytes is a named field, just make it a field of type
> FT_BYTES.
>
> If it's not a named field, and you're putting it into the protocol tree
> with "proto_tree_add_text()", use "tvb_bytes_to_str()".
>
> Doing one of those won't put a leading "0x" in there, and will just put
> in a "..." after 16 bytes rather than showing ever single byte (16 is
> 1/2 the value of the #define MAX_BYTE_STR_LEN in epan/strutil.c -
> MAX_BYTE_STR_LEN is the number of characters in the display, and each
> byte is shown as 2 hex digits - so it could be increased), but it's the
> type of thing you're asking for .
>


snader12 at gmail

May 19, 2006, 10:34 AM

Post #4 of 5 (1145 views)
Permalink
Re: Printing an array of bytes to the tree? [In reply to]

I've tried using the following named field:



...

&hf_my_hex_string,

{

"A Hex String",

"myproto.hexstr",

FT_BYTES,

BASE_HEX,

NULL,

0x0,

"",

HFILL

}

...



But printing to the subtree never showed anything when the dissector makes
this call:



if (tree)

{

proto_tree_add_item(myproto_tree, hf_my_hex_string, tvb, offset, 24, FALSE);

}



Is there anything that I'm missing or is it just not possible to print that
many hex characters?



Thanks,
Saad


jaap.keuter at xs4all

Jun 6, 2006, 9:17 AM

Post #5 of 5 (1153 views)
Permalink
Re: Printing an array of bytes to the tree? [In reply to]

Hi,

Sure it can. Did you register the field?
What code is used to create the subtree?

Thanx,
Jaap

On Fri, 19 May 2006, Saad Nader wrote:

> I've tried using the following named field:
>
>
>
> ...
>
> &hf_my_hex_string,
>
> {
>
> "A Hex String",
>
> "myproto.hexstr",
>
> FT_BYTES,
>
> BASE_HEX,
>
> NULL,
>
> 0x0,
>
> "",
>
> HFILL
>
> }
>
> ...
>
>
>
> But printing to the subtree never showed anything when the dissector makes
> this call:
>
>
>
> if (tree)
>
> {
>
> proto_tree_add_item(myproto_tree, hf_my_hex_string, tvb, offset, 24, FALSE);
>
> }
>
>
>
> Is there anything that I'm missing or is it just not possible to print that
> many hex characters?
>
>
>
> Thanks,
> Saad
>

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev [at] ethereal
http://www.ethereal.com/mailman/listinfo/ethereal-dev

Ethereal dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.