[Click] endianness

Bart Braem bart.braem at ua.ac.be
Tue Mar 20 07:41:28 EST 2007


On Tuesday 20 March 2007 13:02, David Biot wrote:
> I'm writing an element to append a sequence number to the packet-data. I
> would like to make sure this is as cross-platform as possible. Is there
> a way to know what the endianness of the current machine is? Normally I
> would use a function where I store a bit-array and cast this to a short,
> but as I discovered, casting is not possible with click.

Use the classical ntohs, ntohl, htons and htonl functions. Those will do the 
right conversions for you!

Bart
-- 
Bart Braem
PATS research group
Dept. of Mathematics and Computer Sciences
University of Antwerp
Campus Middelheim, G3.30
Middelheimlaan 1
B-2020 Antwerpen, Belgium
Phone: +32 (0)3 265.32.91
Fax: +32 (0)3 265.37.77
Web: www.pats.ua.ac.be/bart.braem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: not available
Url : https://pdos.csail.mit.edu/pipermail/click/attachments/20070320/6eaa78ab/attachment.pgp


More information about the click mailing list