Commit Graph

23 Commits

Author SHA1 Message Date
plunky 87e2475b47 cleanup some DIAGNOSTIC and KASSERT code
- remove #ifdef DIAGNOSTIC, so that we won't act
  differently

- handle the cases where a Bluetooth adapter
  sends invalid packet data (I've not seen this,
  but it is not impossible)

- use KASSERT for actual impossible situations
  (to catch bad future development)
2011-07-27 10:25:09 +00:00
plunky 2c6dc8c043 upon device initialisation, query and cache the device features,
and cache the maximum ACL/SCO packet buffers.

provide an additional SIOCGBTFEAT ioctl to retrieve the cached
features, and add the max values to the SIOC?BTINFO results.

(btreq does not change size)
2010-11-22 19:56:51 +00:00
plunky 0ae8e53b57 slight reordering, plus only deal with ACL links 2009-09-12 18:31:46 +00:00
plunky dab1b7f787 add devices seen in "Extended Inquiry Result" to the cache 2009-08-24 20:37:36 +00:00
plunky b7dec17fbf add a per-unit master setting, to control requesting the master role
when accepting connections.
2009-08-20 21:40:59 +00:00
ad 15e29e981b Merge the socket locking patch:
- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
2008-04-24 11:38:36 +00:00
plunky a09c132d77 move the updating of num_cmd_pkts to its own function, mostly so that
pending commands will be output on the device in the order that they
were queued.
2008-03-17 09:16:17 +00:00
plunky 0b1dda7d78 insert new links at the tail of the queue so that if a create_connection
command fails to start we can find the relevant link, since it will be
the first one with the pending flag set.
2008-03-16 23:14:24 +00:00
plunky d0e804ff6e a "Create Connection" command can sometimes fail to start for whatever
reason and the command_status event returns failure but we get no
indication of which connection failed (for instance in the case where
we tried to open too many connections all at once)

So, keep a flag on the link to indicate pending status until the
command_status event is returned to help us decide which should
be failed.
2008-03-06 20:56:26 +00:00
plunky 7acc9392e5 add HCI definitions from the Bluetooth 2.1 spec 2008-02-10 17:40:54 +00:00
plunky aeab3db895 request and keep a mask of supported commands per unit in order
to block unsupported HCI commands sent by unprivileged users
reaching the device.
2007-12-30 18:26:42 +00:00
plunky 87914664c7 [experimentally] report failing commands
this does happen sometimes and I would like to see if it happens
more often than I know of.
2007-11-28 21:46:52 +00:00
plunky 736a9db087 Clean up the way that bluetooth drivers attach to the bluetooth stack,
to remove the frobbing that drivers must do in the hci_unit structure.

- driver provides a static const interface descriptor
- hci_unit is allocated by hci_attach() rather than part of softc
- statistics are compiled by driver and provided on request
- driver provides output methods and is responsible for output queue
- stack provides input methods and is responsible for input queue
- mutex is used to arbitrate device queue access
2007-11-28 20:16:11 +00:00
plunky 0b799668fb use more device_t and device_xxx() accessors
make bluetooth stack keep device_t instead of softc pointer as
device is not necessarily part of softc, and pass device_t to
driver callbacks. hci_devname is no longer required.
2007-11-10 23:12:22 +00:00
plunky a0c60c7e8f improve memo taking of known bluetooth devices
- centralise creation of new memo into function
  hci_memo_new(), when a memo exists for that address,
  just update the timestamp.

- all results of inquiry/rssi result are processed; even
  if no memo can be allocated, we may update a timestamp.

- for new connections, query the clock offset of the remote
  device, in order that we can use it to facilitate future
  reconnections

- as a connection is removed, make a memo of the clock offset
2007-09-16 19:59:30 +00:00
plunky 9ab5b2f6b0 add event processing for "Inquiry result with RSSI", and modify the memo
contents so that this will fit.
2007-09-07 18:37:30 +00:00
plunky 8e15db7550 not necessary to cast to (void *) (from caddr_t removal) 2007-07-19 20:48:51 +00:00
plunky f5db72e7b7 Add 'service level' security for L2CAP and RFCOMM connections, following
the Linux (BlueZ) API.

    - L2CAP or RFCOMM connections can require the baseband radio link
    mode be any of:
	authenticated (devices are paired)
	encrypted (implies authentication)
	secured (encryption, plus generate new link key)

    - for sockets, the mode is set using setsockopt(2) and the socket
    connection will be aborted if the mode change fails.

    - mode settings will be applied during connection establishment, and
    for safety, we enter a wait state and will only proceed when the mode
    settings are successfuly set.

    - It is possible to change the mode on already open connections, but
    not possible to guarantee that data already queued (from either end)
    will not be delivered. (this is a feature, not a bug)

    - bthidev(4) and rfcomm_sppd(1) support "auth", "encrypt" and
    "secure" options

    - btdevctl(8) by default enables "auth" for HIDs, and "encrypt" for
    keyboards (which are required to support it)
2007-04-21 06:15:22 +00:00
plunky b1afbe8d68 remove default setting of bluetooth_debug, since 'options BLUETOOTH_DEBUG'
causes it to fail
2007-04-05 19:22:18 +00:00
plunky 298d20388c remove C++ style comments 2007-03-15 19:47:50 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
plunky 264c79359e Endian issues:
hci_event.c:
 - Convert memo->response.clock_offset to host-endian.

hci_ioctl.c:
 - printf format tweak (size_t)

hci_link.c:
 - Convert memo->response.clock_offset from host-endian.
 - Tweak a DIAGNOSTIC message.

l2cap_signal.c:
 - In l2cap_recv_config_req(), rp->scid is little-endian so make sure
   we convert from host-endian.

	from scw@
2006-09-11 22:12:39 +00:00
gdamore a5c89047c0 Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.)  This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.
2006-06-19 15:44:33 +00:00