[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [bluetooth-dev] Re: Porting to ARM

> -----Original Message-----
> From: Bjorn Wesen [mailto:bjornw@xxxxxxx.com]
> Sent: Wednesday, September 27, 2000 01:30
> To: Gordon McNutt
> Cc: So@xxxxxxx.com
> Subject: Re: [bluetooth-dev] Re: Porting to ARM
> On Tue, 26 Sep 2000, Gordon McNutt wrote:
> > 3. For 12, 6 and other length bitfields use an endian-safe 
> > macro to do the shifting?
> Well, what you really need is to look at the protocol header specification
> and figure out what you want to do, and see if those macros can help
> you. I'm not familiar with the bluetooth headers so I cannot say. In
> TCP/IP, this situation seldomly occurs because they were smart enough to
> not align the header bits in weird ways (it's mostly full 8/16/32 bit
> fields, aligned correctly compared to the header start).
> -Bjorn

Well, one way to solve the odd bitfield values is to do something like
what is done in the standard glibc headers for the IP header:

struct iphdr
    unsigned int ihl:4;
    unsigned int version:4;
    unsigned int version:4;
    unsigned int ihl:4;
# error "Please fix <bits/endian.h>"
    u_int8_t tos;
    u_int16_t tot_len;

It is not exactly beautiful code, but I believe it should work.