Wireshark-dev: Re: [Wireshark-dev] BCD ?
From: "Lars Worsaae" <[email protected]>
Date: Wed, 11 Apr 2007 13:38:02 +0200
Sorry for vasting your time. The API works nicely as is.

After reading the  README.developper (and not just the developer-guide.pdf)
I understodd how to do the BCD I wan't. Define the field as FT_UINT32 and
use it by:
proto_tree_add_uint(tree, hf_apacs_stan_type, tvb,
    offset, length, tvb_get_bcd(tvb, offset, length));

How elegantly simple
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;
> > > > }
> > > >
> > >