Home | History | Annotate | Download | only in netbt
History log of /src/sys/netbt/l2cap_signal.c
RevisionDateAuthorComments
 1.22  24-Dec-2022  andvar s/Reqest/Request/ and adding apostrophe for don't and didn't in comments.
 1.21  13-Mar-2022  andvar s/hander/handler/ and s/hader/header/ in comments and documentation.
 1.20  29-Feb-2020  maxv pass the address of the field, instead of relying on it being the first
field of the structure/union, no functional change, discussed with plunky@
 1.19  21-Aug-2018  plunky branches: 1.19.6;

Result of audit to check that mbuf length is checked before m_copydata()
and that any data supposedly copied out is valid before use.

prompted by maxv@, I have checked every usage of m_copydata() and made
the following corrections

hci_event.c:
hci_event_command_compl()
check that the packet does contain enough data for there to
be a status code before noting possible failures.

hci_event_num_compl_pkts()
check that the packet does contain data to cover the
stated number of handle/num pairs

l2cap_signal.c:
l2cap_recv_signal()
just ignore packets with not enough data rather than
trying to reject them (may not have cmd.ident)

l2cap_recv_command_rej()
check we have a valid reason and/or data before use
 1.18  04-Oct-2016  joerg branches: 1.18.14; 1.18.16;
The last named argument of a variadic function shall not be default
promoted according to ISO C.
 1.17  28-Nov-2015  plunky branches: 1.17.2;
note recent spec additions to L2CAP Info command regarding fixed channels
 1.16  09-Feb-2013  christos branches: 1.16.14;
CID/90001: missing va_end()
 1.15  29-Nov-2011  plunky branches: 1.15.8;
Handle some ``Quality of Service'' configuration options, to
help devices requesting them blindly succeed in connecting.

should fix a problem analysed by Nat Sloss on current-users
 1.14  27-Jul-2011  plunky branches: 1.14.2;

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)
 1.13  17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.12  06-Feb-2011  plunky respond to L2CAP Information requests
 1.11  17-Nov-2010  plunky branches: 1.11.2; 1.11.4;
do not produce an error when connections are closed normally

for L2CAP sockets, this solves an irritating error message from sdpd(8),
which can now differentiate between normal closure and error.
 1.10  25-Sep-2009  plunky branches: 1.10.4;
When the special L2CAP_PSM_ANY value is used for listening sockets,
select the next unused PSM from the dynamic range (0x1001->)
 1.9  10-Nov-2007  plunky branches: 1.9.18;
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.
 1.8  16-May-2007  plunky branches: 1.8.6; 1.8.8; 1.8.12; 1.8.14;
use the sizeof the header, not the pointer to the header

(this fixes a problem with architectures where a pointer is not 4 octets)
 1.7  21-Apr-2007  plunky 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)
 1.6  15-Mar-2007  plunky remove C++ style comments
 1.5  12-Mar-2007  plunky branches: 1.5.2;
clean up the mess that is the channel state, now
lc_state is channel state
lc_flags is channel flags
 1.4  05-Mar-2007  plunky branches: 1.4.2; 1.4.4;
add extra validity check for inbound requests
 1.3  07-Dec-2006  plunky branches: 1.3.2;
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.
 1.2  11-Sep-2006  plunky branches: 1.2.2; 1.2.4;
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@
 1.1  19-Jun-2006  gdamore branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.12; 1.1.14;
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.
 1.1.14.2  09-Sep-2006  rpaulo sync with head
 1.1.14.1  19-Jun-2006  rpaulo file l2cap_signal.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:58:39 +0000
 1.1.12.2  12-Jan-2007  ad Sync with head.
 1.1.12.1  18-Nov-2006  ad Sync with head.
 1.1.10.1  14-Sep-2006  riz Pull up following revision(s) (requested by plunky in ticket #161):
sys/dev/bluetooth/btdev.h: revision 1.4
distrib/sets/lists/comp/mi: revision 1.922
usr.sbin/postinstall/postinstall: revision 1.25
sys/netbt/hci_unit.c: revision 1.3
sys/netbt/hci_ioctl.c: revision 1.4
usr.sbin/sdpd/profile.c: revision 1.2
usr.sbin/btdevctl/btdevctl.c: revision 1.2
share/man/man4/Makefile: revision 1.405
distrib/sets/lists/man/mi: revision 1.930
distrib/sets/lists/etc/mi: revision 1.176
usr.sbin/sdpd/profile.c: revision 1.3
usr.sbin/btdevctl/btdevctl.c: revision 1.3
etc/MAKEDEV.tmpl: revision 1.62
distrib/sets/lists/base/mi: revision 1.650
usr.sbin/btdevctl/btdevctl.h: revision 1.2
usr.bin/sdpquery/sdpquery.1: revision 1.4
sys/netbt/rfcomm_session.c: revision 1.2
usr.sbin/btdevctl/btdevctl.8: revision 1.3
usr.bin/sdpquery/search.c: revision 1.2
usr.sbin/sdpd/Makefile: revision 1.2
sys/dev/bluetooth/Makefile: revision 1.3
usr.sbin/btdevctl/cfg.c: file removal
sys/netbt/files.netbt: revision 1.4
usr.sbin/btdevctl/sdp.c: revision 1.1
sys/dev/bluetooth/bthidev.c: revision 1.3
etc/bluetooth/Makefile: revision 1.3
sys/dev/pcmcia/files.pcmcia: revision 1.51
sys/dev/bluetooth/bthidev.c: revision 1.4
sys/dev/bluetooth/bthidev.h: revision 1.3
usr.sbin/btdevctl/dev.c: file removal
sys/dev/bluetooth/files.bluetooth: revision 1.10
sys/arch/i386/conf/GENERIC: revision 1.777
share/man/man4/ubt.4: revision 1.6
share/man/man4/bthub.4: revision 1.3
sys/netbt/hci.h: revision 1.5
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.202
lib/libsdp/sdp.h: revision 1.2
usr.sbin/btdevctl/print.c: revision 1.1
share/man/man4/bthidev.4: revision 1.5
share/man/man4/btdev.4: file removal
usr.sbin/btdevctl/print.c: revision 1.2
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.205
usr.sbin/btdevctl/Makefile: revision 1.2
sys/dev/usb/files.usb: revision 1.70
sys/netbt/l2cap_signal.c: revision 1.2
sys/netbt/hci_link.c: revision 1.4
sys/dev/bluetooth/bthub.c: revision 1.3
share/man/man4/btsco.4: revision 1.5
sys/netbt/hci_link.c: revision 1.5
share/man/man4/btdev.4: revision 1.4
sys/dev/bluetooth/btkbd.c: revision 1.3
sys/dev/bluetooth/btdev.c: file removal
sys/netbt/hci_event.c: revision 1.2
sys/dev/bluetooth/btsco.h: revision 1.2
etc/mtree/special: revision 1.101
sys/dev/bluetooth/btsco.c: revision 1.3
sys/conf/majors: revision 1.27
usr.sbin/sdpd/hf.c: revision 1.1
sys/dev/bluetooth/btsco.c: revision 1.4
share/man/man5/rc.conf.5: revision 1.107
sys/dev/bluetooth/btdev.c: revision 1.2
etc/rc.d/btdevctl: revision 1.2
usr.sbin/btdevctl/db.c: revision 1.1
etc/rc.d/btdevctl: revision 1.3
etc/bluetooth/btdevctl.conf: revision 1.1
usr.sbin/btdevctl/hid.c: file removal
sys/arch/i386/conf/GENERIC: revision 1.781
sys/dev/bluetooth/btdev.h: revision 1.3
Make btdev default count explicit
Fix typo in variable name
update to bluetooth device attachment:
remove pseudo-device btdev(4) and inherent limitations
add bthub(4) which autoconfigures at bluetooth controllers as they
are enabled. bluetooth devices now attach here.
btdevctl(8) and its cache is updated to handle new semantics
etc/rc.d/btdevctl is updated to configure devices from a list
in /etc/bluetooth/btdevctl.conf
also include service name in dictionary being sent to kernel.
(this is not used just yet, but it might be in the future and it will
be easier if we dont have to provide code to handle its absence)
clarify the CAVEAT section somewhat
Add service discovery support for the Handsfree profile
Replace static 'FreeBSD' string with operating system name gleaned
from uname(3)
Halt the callout on detach
btsco.c:
- sco_getopt(..., SO_SCO_MTU, ...) expects the address of a uint16_t,
not an int. So change sc_mtu's type to uint16_t.
- Try a little harder to ensure btsco_round_blocksize() does not
return zero. Prevents a subsequent panic in audio_init_ringbuffer().
from scw@
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@
hci_link.c:
- In hci_link_free(), do not unlink items from a LIST queue within
a LIST_FOREACH() iterator.
rfcomm_session.c:
- In rfcomm_session_recv_mcc_nsc(), do not unlink items from a LIST
queue within a LIST_FOREACH() iterator.
from scw@
guard against a possible situation where the list of l2cap channels is changed
when the bluetooth code is not expecting it to be. During a disconnect, we can
detach the channel that is being disconnected, but its not really safe to detach
any others.
Print explicit 64-bit types using the format macros from int_fmtio.h.
Unbreaks the build for our LP64 ports, where "long long" typically is
not 64 bits.
 1.1.8.2  13-Jul-2006  gdamore Merge from HEAD.
 1.1.8.1  19-Jun-2006  gdamore file l2cap_signal.c was added on branch gdamore-uart on 2006-07-13 17:49:58 +0000
 1.1.6.3  14-Sep-2006  yamt sync with head.
 1.1.6.2  26-Jun-2006  yamt sync with head.
 1.1.6.1  19-Jun-2006  yamt file l2cap_signal.c was added on branch yamt-pdpolicy on 2006-06-26 12:53:57 +0000
 1.1.4.2  22-Jun-2006  chap Complete a sync sys/ with head.
 1.1.4.1  19-Jun-2006  chap file l2cap_signal.c was added on branch chap-midi on 2006-06-22 03:39:50 +0000
 1.1.2.5  15-Nov-2007  yamt sync with head.
 1.1.2.4  03-Sep-2007  yamt sync with head.
 1.1.2.3  30-Dec-2006  yamt sync with head.
 1.1.2.2  21-Jun-2006  yamt sync with head.
 1.1.2.1  19-Jun-2006  yamt file l2cap_signal.c was added on branch yamt-lazymbuf on 2006-06-21 15:10:51 +0000
 1.2.4.3  19-Jul-2007  liamjfoy Pull up following revision(s) (requested by plunky in ticket #744):
sys/netbt/l2cap_lower.c: revision 1.6
sys/dev/bluetooth/btdev.h: revision 1.6
sys/netbt/sco_socket.c: revision 1.9
sys/netbt/rfcomm_upper.c: revision 1.3
sys/netbt/l2cap_socket.c: revision 1.7
sys/netbt/rfcomm_upper.c: revision 1.5
lib/libusbhid/usbhid.h: revision 1.5
sys/netbt/rfcomm_upper.c: revision 1.6
usr.sbin/btdevctl/btdevctl.c: revision 1.4
usr.sbin/btdevctl/btdevctl.h: revision 1.3
usr.sbin/btdevctl/btdevctl.8: revision 1.4
sys/netbt/rfcomm_session.c: revision 1.5
sys/netbt/hci.h: revision 1.10
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.6
sys/netbt/hci_link.c: revision 1.11
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.7
usr.bin/rfcomm_sppd/rfcomm_sppd.c: revision 1.8
sys/dev/bluetooth/btsco.c: revision 1.14
sys/netbt/rfcomm_session.c: revision 1.9
usr.sbin/btdevctl/sdp.c: revision 1.2
share/man/man9/bluetooth.9: revision 1.2
usr.sbin/btdevctl/sdp.c: revision 1.3
sys/dev/bluetooth/bthidev.c: revision 1.8
sys/netbt/l2cap.h: revision 1.4
sys/netbt/rfcomm.h: revision 1.3
sys/netbt/l2cap.h: revision 1.5
sys/netbt/l2cap_misc.c: revision 1.3
share/man/man4/bluetooth.4: revision 1.5
lib/libusbhid/usbhid.3: revision 1.11
sys/netbt/bluetooth.h: revision 1.5
share/man/man4/bthidev.4: revision 1.8
sys/netbt/rfcomm_dlc.c: revision 1.3
usr.sbin/btdevctl/print.c: revision 1.8
sys/netbt/rfcomm_socket.c: revision 1.7
sys/netbt/l2cap_signal.c: revision 1.4
sys/netbt/l2cap_signal.c: revision 1.5
sys/netbt/l2cap_signal.c: revision 1.7
sys/netbt/hci_event.c: revision 1.6
usr.bin/rfcomm_sppd/rfcomm_sppd.1: revision 1.5
sys/netbt/l2cap_upper.c: revision 1.3
sys/netbt/l2cap_lower.c: revision 1.2
usr.sbin/btdevctl/db.c: revision 1.3
sys/netbt/l2cap_upper.c: revision 1.6
lib/libusbhid/descr.c: revision 1.5
sys/netbt/l2cap_upper.c: revision 1.7
sys/netbt/l2cap_lower.c: revision 1.4
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)
- ALSO INCLUDES OTHER MINOR FIXES
 1.2.4.2  23-May-2007  pavel Pull up following revision(s) (requested by plunky in ticket #660):
sys/netbt/l2cap_signal.c: revision 1.8
use the sizeof the header, not the pointer to the header
(this fixes a problem with architectures where a pointer is not 4 octets)
 1.2.4.1  17-Dec-2006  riz branches: 1.2.4.1.2;
Pull up following revision(s) (requested by plunky in ticket #277):
sys/netbt/l2cap_signal.c: revision 1.3
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.
 1.2.4.1.2.2  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.2.4.1.2.1  04-Jun-2007  wrstuden Update to today's netbsd-4.
 1.2.2.1  10-Dec-2006  yamt sync with head.
 1.3.2.4  17-May-2007  yamt sync with head.
 1.3.2.3  07-May-2007  yamt sync with head.
 1.3.2.2  24-Mar-2007  yamt sync with head.
 1.3.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.4.4.1  11-Jul-2007  mjf Sync with head.
 1.4.2.3  08-Jun-2007  ad Sync with head.
 1.4.2.2  10-Apr-2007  ad Sync with head.
 1.4.2.1  13-Mar-2007  ad Sync with head.
 1.5.2.1  18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.8.14.1  19-Nov-2007  mjf Sync with HEAD.
 1.8.12.1  13-Nov-2007  bouyer Sync with HEAD
 1.8.8.1  09-Jan-2008  matt sync with HEAD
 1.8.6.1  11-Nov-2007  joerg Sync with HEAD.
 1.9.18.1  11-Mar-2010  yamt sync with head
 1.10.4.1  05-Mar-2011  rmind sync with head
 1.11.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.11.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.14.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.1  17-Apr-2012  yamt sync with head
 1.15.8.2  03-Dec-2017  jdolecek update from HEAD
 1.15.8.1  25-Feb-2013  tls resync with head
 1.16.14.2  05-Oct-2016  skrll Sync with HEAD
 1.16.14.1  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.18.16.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.18.16.1  10-Jun-2019  christos Sync with HEAD
 1.18.14.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.19.6.1  29-Feb-2020  ad Sync with head.

RSS XML Feed