Ethereal-dev: [ethereal-dev] How to handle compiler padding?

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Stuart Stanley <stuarts@xxxxxxxxxxxxxx>
Date: Mon, 6 Dec 1999 22:27:35 +0000 ( )
Hello,

I am working on adding IS-IS protocol unpacking.  Given that OSI loves to
use lots of packed bytes, I ran into a packing problem pretty much right
off the bat.  The question is, what is the "official" way for doing
structure overlays onto the PDU without having the compiler play with
the alignment.  For example:

typedef struct {
        guint8  isis_hello_circuit_reserved;    /* circuit type & reserved */
        guint8  isis_hello_source_id[6];        /* source id */
        guint16 isis_hello_holding_timer;       /* holding timer */
        guint16 isis_hello_pdu_length;          /* full length, includ. hdr */
        guint8  isis_hello_priority_reserved;   /* priority & reserved */
        guint8  isis_hello_lan_id[7];           /* LAN id */
} isis_hello_t;

Later, I was planning on doing a (in a dissector)

	isis_hello_t	*ihd;

	ihd = (isis_hello_t) *pd;


Now, when I access ihd->isis_hello_holding_timer, I am missing an octet.
After playing around, I found isis_hello_t has an extra octet stuck
between the source_id and the holding timer.  ooops.

I can see a couple of routes to do this, but what is the best "style"
for this.  I guess on a similar note, which dissector would make a good
example of current good dissector coding style?  

Thanks for the great framework on this, BTW!



 Life is something set to music; I can hear it     | Stuart Stanley
 when I'm sad. There's a chord in every muscle,    | stuarts@xxxxxxxxxx
 every kiss you've ever had -- Heather Nova        | Lucent Technologies,
                                                   | Eden Prairie, MN
                                                   | 612.996.6829