Subject: Re: struct sockaddr_bt
To: None <tech-net@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-net
Date: 03/10/2006 04:21:00
On Fri, Mar 10, 2006 at 09:26:50AM +0000, Iain Hibbert wrote:
> Hi,
>    As part of my bluetooth stack for NetBSD (please hold your breath a
> while longer :), one of the decisions I made early on was that the
> sockaddr_bt structure that I use is a flat structure and is constant
> throughout the protocol family.
> 
> like so:
> 
> /*
>  * Socket address used by Bluetooth protocols
>  */
> struct sockaddr_bt {
> 	uint8_t		bt_len;		/* sizeof(sockaddr_bt) */
> 	sa_family_t	bt_family;	/* AF_BLUETOOTH */
> 	bdaddr_t	bt_bdaddr;	/* uint8_t[6] */
> 	uint16_t	bt_psm;
> 	uint8_t		bt_channel;
> };
> 
> Now, I've been talking with the FreeBSD folks a little, and they dont do
> this, they (and incidentally, the linux protocol stacks) use a separate
> structure for each sub protocol:
> 
...
> 
> In each of these, they use AF_BLUETOOTH as the family which just seems
> wrong to me.

I agree, it is wrong to use the same address family for three different
sockaddr formats.  (I confess a morbid curiosity about how Linux &
FreeBSD differentiate the types.  Length?  Context?)

Your layout for sockaddr_bt seems sensible to me because you put the
common/shared fields at the "front."  But someone who groks Bluetooth
should comment.

Dave

-- 
David Young             OJC Technologies
dyoung@ojctech.com      Urbana, IL * (217) 278-3933