Subject: Re: Bluetooth update
To: None <tech-kern@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 12/17/2005 20:54:33
> Iain, it would be nice if you could update your patch following Rui's
> suggestions and let us (and tech-net) know.
Ok, I have followed through most of the Rui's style tips (in the kernel
source, still working on the tools) plus a couple of other changes (see
CHANGES file) and a slight change in distribution format to make it easier
to apply.
http://homepages.rya-online.net/plunky/netbt.html
as before, comments gratefully received - I think that generally I'm going
in the right direction but networking/socket code seems a bit counter
intuitive sometimes. anyway some of the things I wasnt sure about:
1. for kernel config files I used
device bt3c: bluetooth
device ubt: bluetooth
which means that you dont actually need to specify
option BLUETOOTH
as it gets pulled in automatically. I dont think any extra complexity is
called for just yet and it would be difficult to make a device compile
without the protocol code in any case as L2CAP/HCI is central.
2. I removed the libbt code that I had, and substituted libbluetooth from
FreeBSD more or less directly (just fixed few linty complaints) which
brings the need (?) for an /etc/bluetooth directory - etc/Makefile looked
very complex, and I didnt want to burn my fingers there.. how to add that
(if its desireable)?
3. reading the style guide, it says use getopt (and presumably
getopt_long) - I didnt in btconfig, because I had it in mind to use
btconfig <device> pscan (enable pscan)
btconfig <device> -pscan (disable pscan)
but I am wavering on that...
btconfig --device <device> --pscan (enable pscan)
btconfig -d <device> --pscan=off (disable pscan)
might be preferable and is not difficult though not as easy to type (using
--pscan to enable seems counter intuitive to me :)
4. Initially I used 134/135/136 for protocol numbers for bluetooth
protocol family because they were the next available ones in
/etc/protocols and also were the numbers that FreeBSD used. I think this
was misapplied now though after importing libbt and snooping about, seems
that /etc/protocols is merely for IP protocols and there is no real
intersection, so I've reverted to 1/2/3 - I dont think we have a generic
file anywhere containing a list of protocol family/numbers ?
5. I changed the l2cap output method (this is fairly recent code in any
case) - a client protocol (the basic case of L2CAP socket is a minimal
client protocol) stores data in the socket buffer and sends a copy to be
output, then gets notified when the data is output and can clear the
socket buffer to allow more data to fall down from above. This seems
rather inefficient, in that you must always double up on output data, but
I think thats the way its supposed to work with socket buffers? There
appears to be no other way to indicate to the socket code if they should
be blocking or not..
6. libbt lint warnings:
/home/plunky/src/sys/netbt/hci.h(1562): warning: bitwise operation on signed value possibly nonportable [117]
/home/plunky/src/sys/netbt/hci.h(1568): warning: bitwise operation on signed value possibly nonportable [117]
/home/plunky/src/sys/netbt/hci.h(1574): warning: bitwise operation on signed value possibly nonportable [117]
all three of those deal with lines like these:
static __inline void
hci_filter_set(uint8_t bit, struct hci_filter *filter)
{
filter->mask[(bit - 1) >> 5] |= (1 << ((bit - 1) & 0x1f));
}
and I cant get rid of it, any clue? (maybe lint is not complex enough?)
7. libbt mdoc warning
nroff -mandoc bluetooth.3 > bluetooth.cat3.tmp && mv bluetooth.cat3.tmp bluetooth.cat3
mdoc warning: .Lb: no description for library `libbt' available (#48)
where should I put the description for libbt? It used to be that there
were a bunch of .Lb descriptions in src/gnu/usr.bin/groff/tmac/mdoc.local
but they have disappeared and I cant find them?
regards,
iain