* [Bluez-devel] endianess question
@ 2006-04-07 10:18 Martin Röhricht
2006-04-07 15:11 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Martin Röhricht @ 2006-04-07 10:18 UTC (permalink / raw)
To: bluez-devel
Hello together,
whenever I take data out of a socket buffer using the get_unaligned()
function like this:
u16 control = get_unaligned((u16 *) skb->data);
do I have to worry about endianess correctness if I need to do some bit
fiddling stuff?
For example:
The specification states that all packet formats shall use little-endian
byte order, so an iframe is denoted like the following:
| 16 | 15 | 14 | 13 | 12 | 11 | 10 | 09 | 08 | 07 06 05 04 03 02 01
|---SAR---|------------ReqSeq-----------|-R--| ...
if I need to pull the ReqSeq value out of the 16 Bits, do I need to make
use of a function like __btoh(control):
u16 reqseq = (__btoh16(control) & 0x3F00) >> 8;
or is it enough to say:
u16 reqseq = (control & 0x3F00) >> 8;
when I took the get_unaligned() function?
Martin
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Bluez-devel] endianess question
2006-04-07 10:18 [Bluez-devel] endianess question Martin Röhricht
@ 2006-04-07 15:11 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2006-04-07 15:11 UTC (permalink / raw)
To: bluez-devel
Hi Martin,
> whenever I take data out of a socket buffer using the get_unaligned()
> function like this:
> u16 control = get_unaligned((u16 *) skb->data);
> do I have to worry about endianess correctness if I need to do some bit
> fiddling stuff?
> For example:
> The specification states that all packet formats shall use little-endian
> byte order, so an iframe is denoted like the following:
> | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 09 | 08 | 07 06 05 04 03 02 01
> |---SAR---|------------ReqSeq-----------|-R--| ...
>
> if I need to pull the ReqSeq value out of the 16 Bits, do I need to make
> use of a function like __btoh(control):
> u16 reqseq = (__btoh16(control) & 0x3F00) >> 8;
> or is it enough to say:
> u16 reqseq = (control & 0x3F00) >> 8;
> when I took the get_unaligned() function?
the get_unaligned() macro has nothing to do with the endian thing. So
you still need to convert from little endian into machine byte order.
Regards
Marcel
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-04-07 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-07 10:18 [Bluez-devel] endianess question Martin Röhricht
2006-04-07 15:11 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox