Commit Graph

90 Commits

Author SHA1 Message Date
plunky 7216fe5048 update/correct specification IDs according to recently published
Assigned Numbers documents at www.bluetooth.com
2009-09-01 18:02:44 +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
plunky 4f6ac13367 reduce the number of KAUTH_DEVICE_BLUETOOTH_SEND/RECV requests
by passing the packet type as an argument rather than having
a different request for each type.

(from a suggestion by mrg)
2009-08-10 20:22:06 +00:00
plunky 80c6ec5db1 remove last usage of KAUTH_ISSUSER in bluetooth code by adding
some requests to the device scope:

	KAUTH_DEVICE_BLUETOOTH_SEND_COMMAND
	KAUTH_DEVICE_BLUETOOTH_RECV_COMMAND
	KAUTH_DEVICE_BLUETOOTH_RECV_EVENT
	KAUTH_DEVICE_BLUETOOTH_RECV_DATA

and a listener tied to the HCI protocol that will approve the basic
minimum to be sent and received.

handle the requests in the bsd44_suser listener by approving all
when the credential is root.
2009-08-10 18:25:20 +00:00
plunky 4a0feb42e7 add const to unchanged argument 2009-05-14 15:34:38 +00:00
elad fda35a52f4 Add a bluetooth action to the device scope and use it in netbt as a
replacement for KAUTH_GENERIC_ISSUSER.

Mailing list reference:

	http://mail-index.netbsd.org/tech-kern/2009/04/25/msg004905.html

Bluetooth-specific authorization wrapper might come later.
2009-05-03 17:21:12 +00:00
gmcgarry 0de5da9678 Replace most gcc-specific __attribute__ uses with BSD-style sys/cdef.h
preprocessor macros.
2008-09-08 23:36:53 +00:00
plunky fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00
plunky c5ce5d1afa adjust message for previous change 2008-08-05 13:08:31 +00:00
plunky 516804fedf drop packets that exceed the negotiated MTU 2008-08-05 13:02:10 +00:00
plunky d7fdc240c9 do not hold bt_lock while detaching bthub, as devices may need to aquire
it in order to detach cleanly.
2008-06-26 14:17:27 +00:00
ad 387c23dfb9 PRU_CONTROL: acquire bt_lock manually. 2008-04-29 18:41:06 +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 5f997830fe we always know the bdaddr and type of a link when creating it, so
pass them to the _alloc() function and let it set them.
2008-03-16 23:28:10 +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 6f45ff2e8b do not destroy session callout until the session is definitely finished
with, otherwise trying to stop it will cause a panic
2008-01-31 19:30:23 +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 2f47a8f906 remove unused def for btr_uclass 2007-12-29 11:30:27 +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 166b860e06 allow listening to channel RFCOMM_CHANNEL_ANY, which means that
we should allocate the first available channel at the given
device address.
2007-11-20 20:25:57 +00:00
plunky fb5c91f9fc when listening, don't attach to the 'any' address unless
we wanted to listen to the 'any' address.
2007-11-20 20:19:24 +00:00
plunky cd286130a6 don't explicitly list unused and NULL entries in the domain declaration 2007-11-20 20:18:00 +00:00
plunky 176a9c6143 include <sys/device.h> for device_t 2007-11-12 19:08:29 +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 fb65dc6e6b 'struct device *' -> 'device-t' 2007-11-10 12:33:21 +00:00
plunky d43f6db858 struct callout => callout_t 2007-11-03 17:39:14 +00:00
plunky 644e69cd47 "struct callout" -> callout_t
don't use callout_reset()
do use callout_destroy()
2007-11-03 17:20:17 +00:00
plunky b9a4fe408b constify hci_devname 2007-11-02 20:27:14 +00:00
plunky f7ac443042 for PRU_ATTACH, we should make sure that so_pcb is not allocated when
there is any error
2007-10-15 18:04:34 +00:00
ad 46ed8f7d77 Use the softint API. 2007-10-08 16:18:02 +00:00
rillig feff384922 Macros that are meant for statements (instead of expressions) SHALL
never be defined to an empty string, because in that case,

	if (condition) DPRINTF(...); else err(...);

results in a gcc warning, and possibly worse things.
2007-09-17 01:23:17 +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 ef349c282b adjust typedef name for consistency with other parts, since hci_rssi_response
is only a packet segment it should not be in _ep namespace.
2007-09-07 18:14:33 +00:00
plunky 8e15db7550 not necessary to cast to (void *) (from caddr_t removal) 2007-07-19 20:48:51 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
plunky 539d75b79d use the sizeof the header, not the pointer to the header
(this fixes a problem with architectures where a pointer is not 4 octets)
2007-05-16 18:34:49 +00:00
dyoung 72f0a6dfb0 Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing.  Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously.  Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs.  I have
  introduced routines for allocating, copying, and duplicating,
  and freeing sockaddrs:

        struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
        struct sockaddr *sockaddr_copy(struct sockaddr *dst,
                                       const struct sockaddr *src);
        struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
        void sockaddr_free(struct sockaddr *sa);

  sockaddr_alloc() returns either a sockaddr from the pool belonging
  to the specified family, or NULL if the pool is exhausted.  The
  returned sockaddr has the right size for that family; sa_family
  and sa_len fields are initialized to the family and sockaddr
  length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
  sockaddr_in).  sockaddr_free() puts the given sockaddr back into
  its family's pool.

  sockaddr_dup() and sockaddr_copy() work analogously to strdup()
  and strcpy(), respectively.  sockaddr_copy() KASSERTs that the
  family of the destination and source sockaddrs are alike.

  The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
  passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
  family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
  etc.  They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more.  All protocol families
  use struct route.  I have changed the route cache, 'struct route',
  so that it does not contain storage space for a sockaddr.  Instead,
  struct route points to a sockaddr coming from the pool the sockaddr
  belongs to.  I added a new method to struct route, rtcache_setdst(),
  for setting the cache destination:

        int rtcache_setdst(struct route *, const struct sockaddr *);

  rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
  available to create the sockaddr storage.

  It is now possible for rtcache_getdst() to return NULL if, say,
  rtcache_setdst() failed.  I check the return value for NULL
  everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
  caches, dom_rtcache.  rtflushall(sa_family_t af) looks up the
  domain indicated by 'af', walks the domain's list of route caches
  and invalidates each one.
2007-05-02 20:40:22 +00:00
msaitoh 8ce1f4fff2 fix typos 2007-04-29 20:23:34 +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 844c714a45 rework ordering of error conditions for setopt, prefer to return EINVAL
rather than EBUSY.
2007-04-06 17:09:00 +00:00
plunky f517728680 add const attribute to the CRC table 2007-04-06 16:27:52 +00:00
plunky f03422c7ce use structure initializers for protocol switch table
(while here, delete unused entries)
2007-04-06 11:49:24 +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 fb76dbd4fc change declaration for protosw.h const symbolic strings to static, so that
they can be used by more than one source file without causing duplicate
definitions.
2007-03-31 18:17:13 +00:00