Commit Graph

68 Commits

Author SHA1 Message Date
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
plunky f21bb76883 be more explicit and consistent in use of KASSERT with pointers,
test against NULL
2007-03-30 20:47:02 +00:00
plunky 3d47fad4b8 disallow sending command packets of unexpected length 2007-03-21 06:22:07 +00:00
plunky ac2ed142c1 discard inbound packets if the channel is not open 2007-03-20 20:25:24 +00:00
plunky 298d20388c remove C++ style comments 2007-03-15 19:47:50 +00:00
plunky f42c04d48d clean up the mess that is the channel state, now
lc_state is channel state
	lc_flags is channel flags
2007-03-12 20:34:46 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
plunky 3617998677 add validity check for inbound packets 2007-03-07 20:44:52 +00:00
plunky 5bfc159132 don't reset MTU when invalid value is given 2007-03-06 19:04:31 +00:00
plunky 162ec75621 return ENOPROTOOPT when protocol options are not known 2007-03-05 19:11:54 +00:00
plunky 070f41d51b whitespace 2007-03-05 19:05:57 +00:00
plunky 78a5a02263 add extra validity check for inbound requests 2007-03-05 19:04:46 +00:00
plunky 904dc39982 remove extraneous prototype 2007-03-05 19:02:47 +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
kiyohara 10abd6f2e2 Supprot Bluetooth HCI UART (H4) driver and daemon. 2007-02-20 16:53:20 +00:00
elad b2eb9a5389 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 19:07:03 +00:00
alc 86e5639788 CID-3819: `n' is always NULL here, remove dead code. 2006-12-26 00:00:22 +00:00
yamt 8bf7662829 merge yamt-splraiseipl branch.
- finish implementing splraiseipl (and makeiplcookie).
	  http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
	- complete workqueue(9) and fix its ipl problem, which is reported
	  to cause audio skipping.
	- fix netbt (at least compilation problems) for some ports.
	- fix PR/33218.
2006-12-21 15:55:21 +00:00
dyoung c308b1c661 Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route).  Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).

Stale IPv6 and ISO route caches will be treated by separate patches.

Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.

Here are the details:

Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.

Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.

Chain together all IPv4 route caches where ro_rt != NULL.  Provide
in_rtcache() for adding a route to the chain.  Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches.  In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain.  In in_rtflushall(), walk the chain and remove every route
cache.

In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.

In gif(4), discard the workaround for stale caches that involves
expiring them every so often.

Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).

Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.

Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.

In domain initializers, use .dom_xxx tags.

KNF here and there.
2006-12-09 05:33:04 +00:00
plunky 24f1ec09dc Do not use the output buffer to store data unless we mean it to go in
the packet, as there is a problem with overwriting information while we
still need it (opt->length in particular) which causes connections to
fail.
2006-12-07 21:36:27 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
dogcow 55ddfc9aae change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
2006-10-10 21:49:14 +00:00