Wireshark-dev: Re: [Wireshark-dev] BCD ?
From: Jaap Keuter <[email protected]>
Date: Sat, 7 Apr 2007 11:22:08 +0200 (CEST)
Hi,

I've been interested in BCD presentation as well. For that I've whipped
together some proto_tree_add_bcd() code, but couldn't really get my head
around creating a generic FT_BCD.
For that matter you're talking about PACKED BCD, which is different from
BCD.

PACKED BCD:	0x46 0x10 -> 4610
BCD:		0x04 0x06 0x01 0x00 -> 4610

So if we make FT_BCD we also need to make FT_PACKED_BCD.
Anyone a decent manual for adding FTs?

Thanx,
Jaap

On Fri, 6 Apr 2007, Lars Worsaae wrote:

> Desr sirs
> Are their a smart(er) way to dissect data which are BCD encoded?
> I cant find i tvb_get_* reading BCD.
> I had roled my own, but am i and my experimental first time dissector
> realy the first and only dissection BCD encoded data?
>
> Rgds Lars
>
> BTW My get'er looks like:
> static guint32
> tvb_get_bcd(tvbuff_t *tvb, int offset, int length)
> {
>           int i;
>           guint32 val=0;
>           for(i=0;i<length;i++){
>                      guint8 b = tvb_get_guint8(tvb, offset+i);
>                      val = 100*val + ((b>>4)*10 + (b&0xf));
>           }
>           return val;
> }
>