endian dilemma

Nathan Meyers nmeyers at javalinux.net
Thu Sep 5 14:06:32 EDT 2002


On Thu, Sep 05, 2002 at 01:54:23PM -0400, Gregory Gimler wrote:
> Hello all,
> 
> 	I have an interesting problem concerning endian conversion.  I'm 
> 	helping to port some software over from an O2 to linux.  The software that 
> transmits messages, I have no control over and it can't be modified.  There 
> are several different formats to the messages being transmitted.  Does 
> anyone know of a solution already on the internet somewhere or have any 
> suggestions on how I might approach this problem so I can still read the 
> messages, even though I'm on a little endian machine?  Thanks.

Reversing the endian-ness of a 16-, 32-, or 64-bit word is easy enough,
but any solution to your problem is going to be very application-specific.
You need to know the structure of the messages so you can identify what
fields need to have their endianness reversed. There's no magic way
around this.

If you can get your hands on a description of the protocol, preferably
with ready-to-use C structures describing the messages, you're on the
way to a solution.

Nathan Meyers
nmeyers at javalinux.net



More information about the Discuss mailing list