Wireshark-dev: Re: [Wireshark-dev] BCD ?
From: "Michael Lum" <[email protected]>
Date: Wed, 11 Apr 2007 03:45:12 +0800
It's probably even worse than that!

In both GSM and CDMA protocols packed BCD can be represented as:

digit2 digit1
digit4 digit3

such that two octets:

0x01 0x23

would be:

1032

An example is the Called Party BCD Number element.

--
Michael Lum                   Principal Software Engineer
4600 Jacombs Road             +1.604.276.0055
Richmond, B.C.
Canada V6V 3B1
UTStarcom Canada, Inc.
CDMA Division
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Lars Worsaae
> Sent: April 7, 2007 12:31 PM
> To: Developer support list for Wireshark
> Subject: Re: [Wireshark-dev] BCD ?
> 
> Yes
> And we might even need two different variants of PACKED BCD 
> The problem is how to handle odd number of digits in an 
> integer number of bytes
> 
> I have two variants
> leading 0: 0x01 0x23 = 123
> and
> trailing F: 0x12 0x3F = 123
> 
> /Lars
> 
> On 4/7/07, Jaap Keuter <[email protected]> wrote:
> > 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;
> > > }
> > >
> >
> > _______________________________________________
> > Wireshark-dev mailing list
> > [email protected]
> > http://www.wireshark.org/mailman/listinfo/wireshark-dev
> >
> _______________________________________________
> Wireshark-dev mailing list
> [email protected]
> http://www.wireshark.org/mailman/listinfo/wireshark-dev
>