Ethereal-dev: Re: [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: Ashok Narayanan <ashokn@xxxxxxxxx>
Date: Mon, 6 Dec 1999 17:50:58 -0500 (EST)
 > 
 > > If you're lucky enough to have a structure where the multibyte
 > > primitives start on 32-bit boundaries (and you're running on a 32-bit
 > > machine) then you may be in luck.
 > 
 > ...but not if
 > 
 > 	1) the machine on which you're running Ethereal doesn't have the
 > 	   same byte order as the one specified for your protocol;

True

 > 	2) the stuff *before* it in the packet doesn't happen to be of
 > 	   such as size as to cause stuff to be properly aligned.

Also true

There's a third reason - compilers on 64-bit machines may very well
declare alignment errors if multibytes are not 64-bit word aligned. 

I guess after all this, the bottom line is "use pletoh[x] always for
multibytes" 

-Ashok
-- 
--- Asok the Intern ----------------------------------------
IOS Network Protocols, Cisco Systems
250 Apollo Drive, Chelmsford, MA 01824
Ph: 978-244-8387