head 1.7; access; symbols netbsd-10-0-RELEASE:1.7 netbsd-10-0-RC6:1.7 netbsd-10-0-RC5:1.7 netbsd-10-0-RC4:1.7 netbsd-10-0-RC3:1.7 netbsd-10-0-RC2:1.7 thorpej-ifq:1.7.0.98 thorpej-ifq-base:1.7 thorpej-altq-separation:1.7.0.96 thorpej-altq-separation-base:1.7 netbsd-10-0-RC1:1.7 netbsd-10:1.7.0.94 netbsd-10-base:1.7 bouyer-sunxi-drm:1.7.0.92 bouyer-sunxi-drm-base:1.7 netbsd-9-3-RELEASE:1.7 thorpej-i2c-spi-conf2:1.7.0.90 thorpej-i2c-spi-conf2-base:1.7 thorpej-futex2:1.7.0.88 thorpej-futex2-base:1.7 thorpej-cfargs2:1.7.0.86 thorpej-cfargs2-base:1.7 cjep_sun2x-base1:1.7 cjep_sun2x:1.7.0.84 cjep_sun2x-base:1.7 cjep_staticlib_x-base1:1.7 netbsd-9-2-RELEASE:1.7 cjep_staticlib_x:1.7.0.82 cjep_staticlib_x-base:1.7 thorpej-i2c-spi-conf:1.7.0.80 thorpej-i2c-spi-conf-base:1.7 thorpej-cfargs:1.7.0.78 thorpej-cfargs-base:1.7 thorpej-futex:1.7.0.76 thorpej-futex-base:1.7 netbsd-9-1-RELEASE:1.7 bouyer-xenpvh-base2:1.7 phil-wifi-20200421:1.7 bouyer-xenpvh-base1:1.7 phil-wifi-20200411:1.7 bouyer-xenpvh:1.7.0.74 bouyer-xenpvh-base:1.7 is-mlppp:1.7.0.72 is-mlppp-base:1.7 phil-wifi-20200406:1.7 netbsd-8-2-RELEASE:1.7 ad-namecache-base3:1.7 netbsd-9-0-RELEASE:1.7 netbsd-9-0-RC2:1.7 ad-namecache-base2:1.7 ad-namecache-base1:1.7 ad-namecache:1.7.0.70 ad-namecache-base:1.7 netbsd-9-0-RC1:1.7 phil-wifi-20191119:1.7 netbsd-9:1.7.0.68 netbsd-9-base:1.7 phil-wifi-20190609:1.7 netbsd-8-1-RELEASE:1.7 netbsd-8-1-RC1:1.7 isaki-audio2:1.7.0.66 isaki-audio2-base:1.7 pgoyette-compat-merge-20190127:1.7 pgoyette-compat-20190127:1.7 pgoyette-compat-20190118:1.7 pgoyette-compat-1226:1.7 pgoyette-compat-1126:1.7 pgoyette-compat-1020:1.7 pgoyette-compat-0930:1.7 pgoyette-compat-0906:1.7 netbsd-7-2-RELEASE:1.7 pgoyette-compat-0728:1.7 netbsd-8-0-RELEASE:1.7 phil-wifi:1.7.0.64 phil-wifi-base:1.7 pgoyette-compat-0625:1.7 netbsd-8-0-RC2:1.7 pgoyette-compat-0521:1.7 pgoyette-compat-0502:1.7 pgoyette-compat-0422:1.7 netbsd-8-0-RC1:1.7 pgoyette-compat-0415:1.7 pgoyette-compat-0407:1.7 pgoyette-compat-0330:1.7 pgoyette-compat-0322:1.7 pgoyette-compat-0315:1.7 netbsd-7-1-2-RELEASE:1.7 pgoyette-compat:1.7.0.62 pgoyette-compat-base:1.7 netbsd-7-1-1-RELEASE:1.7 tls-maxphys-base-20171202:1.7 matt-nb8-mediatek:1.7.0.60 matt-nb8-mediatek-base:1.7 nick-nhusb-base-20170825:1.7 perseant-stdc-iso10646:1.7.0.58 perseant-stdc-iso10646-base:1.7 netbsd-8:1.7.0.56 netbsd-8-base:1.7 prg-localcount2-base3:1.7 prg-localcount2-base2:1.7 prg-localcount2-base1:1.7 prg-localcount2:1.7.0.54 prg-localcount2-base:1.7 pgoyette-localcount-20170426:1.7 bouyer-socketcan-base1:1.7 jdolecek-ncq:1.7.0.52 jdolecek-ncq-base:1.7 pgoyette-localcount-20170320:1.7 netbsd-7-1:1.7.0.50 netbsd-7-1-RELEASE:1.7 netbsd-7-1-RC2:1.7 nick-nhusb-base-20170204:1.7 netbsd-7-nhusb-base-20170116:1.7 bouyer-socketcan:1.7.0.48 bouyer-socketcan-base:1.7 pgoyette-localcount-20170107:1.7 netbsd-7-1-RC1:1.7 nick-nhusb-base-20161204:1.7 pgoyette-localcount-20161104:1.7 netbsd-7-0-2-RELEASE:1.7 nick-nhusb-base-20161004:1.7 localcount-20160914:1.7 netbsd-7-nhusb:1.7.0.46 netbsd-7-nhusb-base:1.7 pgoyette-localcount-20160806:1.7 pgoyette-localcount-20160726:1.7 pgoyette-localcount:1.7.0.44 pgoyette-localcount-base:1.7 nick-nhusb-base-20160907:1.7 nick-nhusb-base-20160529:1.7 netbsd-7-0-1-RELEASE:1.7 nick-nhusb-base-20160422:1.7 nick-nhusb-base-20160319:1.7 nick-nhusb-base-20151226:1.7 netbsd-7-0:1.7.0.42 netbsd-7-0-RELEASE:1.7 nick-nhusb-base-20150921:1.7 netbsd-7-0-RC3:1.7 netbsd-7-0-RC2:1.7 netbsd-7-0-RC1:1.7 nick-nhusb-base-20150606:1.7 nick-nhusb-base-20150406:1.7 nick-nhusb:1.7.0.40 nick-nhusb-base:1.7 netbsd-5-2-3-RELEASE:1.6 netbsd-5-1-5-RELEASE:1.6 netbsd-6-0-6-RELEASE:1.7 netbsd-6-1-5-RELEASE:1.7 netbsd-7:1.7.0.38 netbsd-7-base:1.7 yamt-pagecache-base9:1.7 yamt-pagecache-tag8:1.7 netbsd-6-1-4-RELEASE:1.7 netbsd-6-0-5-RELEASE:1.7 tls-earlyentropy:1.7.0.36 tls-earlyentropy-base:1.7 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.7 riastradh-drm2-base3:1.7 netbsd-6-1-3-RELEASE:1.7 netbsd-6-0-4-RELEASE:1.7 netbsd-5-2-2-RELEASE:1.6 netbsd-5-1-4-RELEASE:1.6 netbsd-6-1-2-RELEASE:1.7 netbsd-6-0-3-RELEASE:1.7 netbsd-5-2-1-RELEASE:1.6 netbsd-5-1-3-RELEASE:1.6 rmind-smpnet-nbase:1.7 netbsd-6-1-1-RELEASE:1.7 riastradh-drm2-base2:1.7 riastradh-drm2-base1:1.7 riastradh-drm2:1.7.0.34 riastradh-drm2-base:1.7 rmind-smpnet:1.7.0.26 rmind-smpnet-base:1.7 netbsd-6-1:1.7.0.32 netbsd-6-0-2-RELEASE:1.7 netbsd-6-1-RELEASE:1.7 khorben-n900:1.7.0.30 netbsd-6-1-RC4:1.7 netbsd-6-1-RC3:1.7 agc-symver:1.7.0.28 agc-symver-base:1.7 netbsd-6-1-RC2:1.7 netbsd-6-1-RC1:1.7 yamt-pagecache-base8:1.7 netbsd-5-2:1.6.0.26 netbsd-6-0-1-RELEASE:1.7 yamt-pagecache-base7:1.7 netbsd-5-2-RELEASE:1.6 netbsd-5-2-RC1:1.6 matt-nb6-plus-nbase:1.7 yamt-pagecache-base6:1.7 netbsd-6-0:1.7.0.24 netbsd-6-0-RELEASE:1.7 netbsd-6-0-RC2:1.7 tls-maxphys:1.7.0.22 tls-maxphys-base:1.7 matt-nb6-plus:1.7.0.20 matt-nb6-plus-base:1.7 netbsd-6-0-RC1:1.7 jmcneill-usbmp-base10:1.7 yamt-pagecache-base5:1.7 jmcneill-usbmp-base9:1.7 yamt-pagecache-base4:1.7 jmcneill-usbmp-base8:1.7 jmcneill-usbmp-base7:1.7 jmcneill-usbmp-base6:1.7 jmcneill-usbmp-base5:1.7 jmcneill-usbmp-base4:1.7 jmcneill-usbmp-base3:1.7 jmcneill-usbmp-pre-base2:1.7 jmcneill-usbmp-base2:1.7 netbsd-6:1.7.0.18 netbsd-6-base:1.7 netbsd-5-1-2-RELEASE:1.6 netbsd-5-1-1-RELEASE:1.6 jmcneill-usbmp:1.7.0.16 jmcneill-usbmp-base:1.7 jmcneill-audiomp3:1.7.0.14 jmcneill-audiomp3-base:1.7 yamt-pagecache-base3:1.7 yamt-pagecache-base2:1.7 yamt-pagecache:1.7.0.12 yamt-pagecache-base:1.7 rmind-uvmplock-nbase:1.7 cherry-xenmp:1.7.0.10 cherry-xenmp-base:1.7 bouyer-quota2-nbase:1.7 bouyer-quota2:1.7.0.8 bouyer-quota2-base:1.7 jruoho-x86intr:1.7.0.6 jruoho-x86intr-base:1.7 matt-mips64-premerge-20101231:1.7 matt-nb5-mips64-premerge-20101231:1.6 matt-nb5-pq3:1.6.0.24 matt-nb5-pq3-base:1.6 netbsd-5-1:1.6.0.22 netbsd-5-1-RELEASE:1.6 uebayasi-xip-base4:1.7 uebayasi-xip-base3:1.7 yamt-nfs-mp-base11:1.7 netbsd-5-1-RC4:1.6 matt-nb5-mips64-k15:1.6 uebayasi-xip-base2:1.7 yamt-nfs-mp-base10:1.7 netbsd-5-1-RC3:1.6 netbsd-5-1-RC2:1.6 uebayasi-xip-base1:1.7 netbsd-5-1-RC1:1.6 rmind-uvmplock:1.7.0.4 rmind-uvmplock-base:1.7 yamt-nfs-mp-base9:1.7 uebayasi-xip:1.7.0.2 uebayasi-xip-base:1.7 netbsd-5-0-2-RELEASE:1.6 matt-nb5-mips64-premerge-20091211:1.6 matt-premerge-20091211:1.7 yamt-nfs-mp-base8:1.7 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.6 matt-nb4-mips64-k7-u2a-k9b:1.6 matt-nb5-mips64-u1-k1-k5:1.6 yamt-nfs-mp-base7:1.6 matt-nb5-mips64:1.6.0.20 netbsd-5-0-1-RELEASE:1.6 jymxensuspend-base:1.6 yamt-nfs-mp-base6:1.6 yamt-nfs-mp-base5:1.6 yamt-nfs-mp-base4:1.6 jym-xensuspend-nbase:1.7 yamt-nfs-mp-base3:1.6 nick-hppapmap-base4:1.6 nick-hppapmap-base3:1.6 netbsd-5-0:1.6.0.18 netbsd-5-0-RELEASE:1.6 netbsd-5-0-RC4:1.6 netbsd-5-0-RC3:1.6 nick-hppapmap-base2:1.6 netbsd-5-0-RC2:1.6 jym-xensuspend:1.6.0.16 jym-xensuspend-base:1.6 netbsd-5-0-RC1:1.6 haad-dm-base2:1.6 haad-nbase2:1.6 ad-audiomp2:1.6.0.14 ad-audiomp2-base:1.6 netbsd-5:1.6.0.12 netbsd-5-base:1.6 nick-hppapmap:1.6.0.10 nick-hppapmap-base:1.6 matt-mips64-base2:1.6 matt-mips64:1.4.0.14 haad-dm-base1:1.6 wrstuden-revivesa-base-4:1.6 netbsd-4-0-1-RELEASE:1.1.18.1 wrstuden-revivesa-base-3:1.6 wrstuden-revivesa-base-2:1.6 wrstuden-fixsa-newbase:1.1.18.1 nick-csl-alignment-base5:1.4 haad-dm:1.6.0.8 haad-dm-base:1.6 wrstuden-revivesa-base-1:1.6 simonb-wapbl-nbase:1.6 yamt-pf42-base4:1.6 simonb-wapbl:1.6.0.6 simonb-wapbl-base:1.6 yamt-pf42-base3:1.6 hpcarm-cleanup-nbase:1.6 yamt-pf42-baseX:1.5 yamt-pf42-base2:1.6 yamt-nfs-mp-base2:1.6 wrstuden-revivesa:1.6.0.4 wrstuden-revivesa-base:1.6 yamt-nfs-mp:1.6.0.2 yamt-nfs-mp-base:1.6 yamt-pf42:1.5.0.18 yamt-pf42-base:1.5 ad-socklock-base1:1.5 yamt-lazymbuf-base15:1.5 yamt-lazymbuf-base14:1.5 keiichi-mipv6-nbase:1.5 mjf-devfs2:1.5.0.16 mjf-devfs2-base:1.6 nick-net80211-sync:1.5.0.14 nick-net80211-sync-base:1.5 keiichi-mipv6:1.5.0.12 keiichi-mipv6-base:1.5 bouyer-xeni386-merge1:1.5 matt-armv6-prevmlocking:1.4.8.1 wrstuden-fixsa-base-1:1.1.18.1 vmlocking2-base3:1.5 netbsd-4-0:1.1.18.1.0.4 netbsd-4-0-RELEASE:1.1.18.1 bouyer-xeni386-nbase:1.5 yamt-kmem-base3:1.5 cube-autoconf:1.5.0.10 cube-autoconf-base:1.5 yamt-kmem-base2:1.5 bouyer-xeni386:1.5.0.8 bouyer-xeni386-base:1.5 yamt-kmem:1.5.0.6 yamt-kmem-base:1.5 vmlocking2-base2:1.5 reinoud-bufcleanup-nbase:1.5 vmlocking2:1.5.0.4 vmlocking2-base1:1.5 netbsd-4-0-RC5:1.1.18.1 matt-nb4-arm:1.1.18.1.0.2 matt-nb4-arm-base:1.1.18.1 matt-armv6-nbase:1.5 jmcneill-base:1.5 netbsd-4-0-RC4:1.1.18.1 mjf-devfs:1.5.0.2 mjf-devfs-base:1.5 bouyer-xenamd64-base2:1.5 vmlocking-nbase:1.5 yamt-x86pmap-base4:1.4 bouyer-xenamd64:1.4.0.12 bouyer-xenamd64-base:1.5 netbsd-4-0-RC3:1.1.18.1 yamt-x86pmap-base3:1.4 yamt-x86pmap-base2:1.4 netbsd-4-0-RC2:1.1.18.1 yamt-x86pmap:1.4.0.10 yamt-x86pmap-base:1.4 netbsd-4-0-RC1:1.1.18.1 matt-armv6:1.4.0.8 matt-armv6-base:1.5 matt-mips64-base:1.4 jmcneill-pm:1.4.0.6 jmcneill-pm-base:1.5 hpcarm-cleanup:1.4.0.4 hpcarm-cleanup-base:1.5 nick-csl-alignment:1.4.0.2 nick-csl-alignment-base:1.4 yamt-idlelwp-base8:1.3 wrstuden-fixsa:1.1.0.26 wrstuden-fixsa-base:1.1.18.1 thorpej-atomic:1.2.0.6 thorpej-atomic-base:1.2 reinoud-bufcleanup:1.2.0.4 reinoud-bufcleanup-base:1.5 mjf-ufs-trans:1.2.0.2 mjf-ufs-trans-base:1.4 vmlocking:1.1.0.24 vmlocking-base:1.4 ad-audiomp:1.1.0.22 ad-audiomp-base:1.1 yamt-idlelwp:1.1.0.20 post-newlock2-merge:1.1 newlock2-nbase:1.1 yamt-splraiseipl-base5:1.1 yamt-splraiseipl-base4:1.1 yamt-splraiseipl-base3:1.1 abandoned-netbsd-4-base:1.1 abandoned-netbsd-4:1.1.0.10 yamt-splraiseipl-base2:1.1 yamt-splraiseipl:1.1.0.16 yamt-splraiseipl-base:1.1 yamt-pdpolicy-base9:1.1 rpaulo-netinet-merge-pcb-base:1.1 rpaulo-netinet-merge-pcb:1.1.0.14 newlock2:1.1.0.12 newlock2-base:1.1 yamt-pdpolicy-base8:1.1 yamt-pdpolicy-base7:1.1 netbsd-4:1.1.0.18 netbsd-4-base:1.1 gdamore-uart:1.1.0.8 yamt-pdpolicy:1.1.0.6 yamt-pdpolicy-base6:1.1 chap-midi-base:1.1 chap-midi:1.1.0.4 yamt-lazymbuf:1.1.0.2 chap-midi-nbase:1.1; locks; strict; comment @ * @; 1.7 date 2009.09.13.18.45.11; author pooka; state Exp; branches; next 1.6; 1.6 date 2008.04.24.11.38.37; author ad; state Exp; branches 1.6.2.1; next 1.5; 1.5 date 2007.11.03.17.20.17; author plunky; state Exp; branches 1.5.16.1 1.5.18.1; next 1.4; 1.4 date 2007.07.09.21.11.10; author ad; state Exp; branches 1.4.6.1 1.4.8.1 1.4.12.1; next 1.3; 1.3 date 2007.04.21.06.15.23; author plunky; state Exp; branches; next 1.2; 1.2 date 2007.03.12.18.18.35; author ad; state Exp; branches 1.2.2.1; next 1.1; 1.1 date 2006.06.19.15.44.45; author gdamore; state Exp; branches 1.1.2.1 1.1.4.1 1.1.6.1 1.1.8.1 1.1.14.1 1.1.18.1 1.1.20.1 1.1.24.1 1.1.26.1; next ; 1.6.2.1 date 2009.09.16.13.38.02; author yamt; state Exp; branches; next ; 1.5.16.1 date 2008.06.02.13.24.23; author mjf; state Exp; branches; next ; 1.5.18.1 date 2008.05.18.12.35.28; author yamt; state Exp; branches; next ; 1.4.6.1 date 2007.11.04.21.03.37; author jmcneill; state Exp; branches; next ; 1.4.8.1 date 2007.11.06.23.33.43; author matt; state Exp; branches; next ; 1.4.12.1 date 2007.11.13.16.02.48; author bouyer; state Exp; branches; next ; 1.2.2.1 date 2007.07.11.20.11.12; author mjf; state Exp; branches; next ; 1.1.2.1 date 2006.06.19.15.44.45; author yamt; state dead; branches; next 1.1.2.2; 1.1.2.2 date 2006.06.21.15.10.51; author yamt; state Exp; branches; next 1.1.2.3; 1.1.2.3 date 2007.09.03.14.42.41; author yamt; state Exp; branches; next 1.1.2.4; 1.1.2.4 date 2007.11.15.11.45.05; author yamt; state Exp; branches; next ; 1.1.4.1 date 2006.06.19.15.44.45; author chap; state dead; branches; next 1.1.4.2; 1.1.4.2 date 2006.06.22.03.39.50; author chap; state Exp; branches; next ; 1.1.6.1 date 2006.06.19.15.44.45; author yamt; state dead; branches; next 1.1.6.2; 1.1.6.2 date 2006.06.26.12.53.57; author yamt; state Exp; branches; next ; 1.1.8.1 date 2006.06.19.15.44.45; author gdamore; state dead; branches; next 1.1.8.2; 1.1.8.2 date 2006.07.13.17.49.58; author gdamore; state Exp; branches; next ; 1.1.14.1 date 2006.06.19.15.44.45; author rpaulo; state dead; branches; next 1.1.14.2; 1.1.14.2 date 2006.09.09.02.58.39; author rpaulo; state Exp; branches; next ; 1.1.18.1 date 2007.07.19.16.04.19; author liamjfoy; state Exp; branches; next ; 1.1.20.1 date 2007.03.24.14.56.09; author yamt; state Exp; branches; next 1.1.20.2; 1.1.20.2 date 2007.05.07.10.55.56; author yamt; state Exp; branches; next ; 1.1.24.1 date 2007.03.13.16.52.01; author ad; state Exp; branches; next 1.1.24.2; 1.1.24.2 date 2007.06.08.14.17.41; author ad; state Exp; branches; next 1.1.24.3; 1.1.24.3 date 2007.07.01.21.50.47; author ad; state Exp; branches; next ; 1.1.26.1 date 2007.09.03.07.05.10; author wrstuden; state Exp; branches; next ; desc @@ 1.7 log @Wipe out the last vestiges of POOL_INIT with one swift stroke. In most cases, use a proper constructor. For proplib, give a local equivalent of POOL_INIT for the kernel object implementation. This way the code structure can be preserved, and a local link set is not hazardous anyway (unless proplib is split to several modules, but that'll be the day). tested by booting a kernel in qemu and compile-testing i386/ALL @ text @/* $NetBSD: l2cap_misc.c,v 1.6 2008/04/24 11:38:37 ad Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.6 2008/04/24 11:38:37 ad Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); struct pool l2cap_req_pool, l2cap_pdu_pool; const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ void l2cap_init(void) { pool_init(&l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); pool_init(&l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); } /* * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx, 0); callout_setfunc(&req->lr_rtx, l2cap_rtx, req); callout_schedule(&req->lr_rtx, l2cap_response_timeout * hz); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; callout_destroy(&req->lr_rtx); TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; mutex_enter(bt_lock); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); mutex_exit(bt_lock); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.6 log @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@@. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $"); d52 1 a52 4 POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); d70 10 @ 1.6.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.6 2008/04/24 11:38:37 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.6 2008/04/24 11:38:37 ad Exp $"); d52 4 a55 1 struct pool l2cap_req_pool, l2cap_pdu_pool; a72 10 void l2cap_init(void) { pool_init(&l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); pool_init(&l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); } @ 1.5 log @"struct callout" -> callout_t don't use callout_reset() do use callout_destroy() @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.4 2007/07/09 21:11:10 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.4 2007/07/09 21:11:10 ad Exp $"); a187 1 int s; d189 1 a189 1 s = splsoftnet(); d200 1 a200 1 splx(s); @ 1.5.16.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD$"); d188 1 d190 1 a190 1 mutex_enter(bt_lock); d201 1 a201 1 mutex_exit(bt_lock); @ 1.5.18.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $"); d188 1 d190 1 a190 1 mutex_enter(bt_lock); d201 1 a201 1 mutex_exit(bt_lock); @ 1.4 log @Merge some of the less invasive changes from the vmlocking branch: - kthread, callout, devsw API changes - select()/poll() improvements - miscellaneous MT safety improvements @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.3 2007/04/21 06:15:23 plunky Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.3 2007/04/21 06:15:23 plunky Exp $"); d134 2 a135 1 callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); d170 2 @ 1.4.12.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD$ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD$"); d134 1 a134 2 callout_setfunc(&req->lr_rtx, l2cap_rtx, req); callout_schedule(&req->lr_rtx, l2cap_response_timeout * hz); a168 2 callout_destroy(&req->lr_rtx); @ 1.4.8.1 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $"); d134 1 a134 2 callout_setfunc(&req->lr_rtx, l2cap_rtx, req); callout_schedule(&req->lr_rtx, l2cap_response_timeout * hz); a168 2 callout_destroy(&req->lr_rtx); @ 1.4.6.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.5 2007/11/03 17:20:17 plunky Exp $"); d134 1 a134 2 callout_setfunc(&req->lr_rtx, l2cap_rtx, req); callout_schedule(&req->lr_rtx, l2cap_response_timeout * hz); a168 2 callout_destroy(&req->lr_rtx); @ 1.3 log @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) @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.2 2007/03/12 18:18:35 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.2 2007/03/12 18:18:35 ad Exp $"); d133 1 a133 1 callout_init(&req->lr_rtx); @ 1.2 log @Pass an ipl argument to pool_init/POOL_INIT to be used when initializing the pool's lock. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $"); d74 27 @ 1.2.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.4 2007/07/09 21:11:10 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.4 2007/07/09 21:11:10 ad Exp $"); a73 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* d106 1 a106 1 callout_init(&req->lr_rtx, 0); @ 1.1 log @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. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c$ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c$"); d52 4 a55 2 POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); @ 1.1.4.1 log @file l2cap_misc.c was added on branch chap-midi on 2006-06-22 03:39:50 +0000 @ text @d1 228 @ 1.1.4.2 log @Complete a sync sys/ with head. @ text @a0 228 /* $NetBSD: l2cap_misc.c,v 1.1.4.1 2006/06/22 03:39:50 chap Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.4.1 2006/06/22 03:39:50 chap Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx); callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; int s; s = splsoftnet(); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); splx(s); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.1.8.1 log @file l2cap_misc.c was added on branch gdamore-uart on 2006-07-13 17:49:58 +0000 @ text @d1 228 @ 1.1.8.2 log @Merge from HEAD. @ text @a0 228 /* $NetBSD: l2cap_misc.c,v 1.1.8.1 2006/07/13 17:49:58 gdamore Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.8.1 2006/07/13 17:49:58 gdamore Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx); callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; int s; s = splsoftnet(); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); splx(s); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.1.6.1 log @file l2cap_misc.c was added on branch yamt-pdpolicy on 2006-06-26 12:53:57 +0000 @ text @d1 228 @ 1.1.6.2 log @sync with head. @ text @a0 228 /* $NetBSD: l2cap_misc.c,v 1.1.6.1 2006/06/26 12:53:57 yamt Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.6.1 2006/06/26 12:53:57 yamt Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx); callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; int s; s = splsoftnet(); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); splx(s); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.1.14.1 log @file l2cap_misc.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:58:39 +0000 @ text @d1 228 @ 1.1.14.2 log @sync with head @ text @a0 228 /* $NetBSD: l2cap_misc.c,v 1.1.14.1 2006/09/09 02:58:39 rpaulo Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.14.1 2006/09/09 02:58:39 rpaulo Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx); callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; int s; s = splsoftnet(); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); splx(s); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.1.2.1 log @file l2cap_misc.c was added on branch yamt-lazymbuf on 2006-06-21 15:10:51 +0000 @ text @d1 228 @ 1.1.2.2 log @sync with head. @ text @a0 228 /* $NetBSD: l2cap_misc.c,v 1.1.2.1 2006/06/21 15:10:51 yamt Exp $ */ /*- * Copyright (c) 2005 Iain Hibbert. * Copyright (c) 2006 Itronix Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of Itronix Inc. may not be used to endorse * or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.2.1 2006/06/21 15:10:51 yamt Exp $"); #include #include #include #include #include #include #include #include #include struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); struct l2cap_channel_list l2cap_listen_list = LIST_HEAD_INITIALIZER(l2cap_listen_list); POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL); const l2cap_qos_t l2cap_default_qos = { 0, /* flags */ L2CAP_QOS_BEST_EFFORT, /* service type */ 0x00000000, /* token rate */ 0x00000000, /* token bucket size */ 0x00000000, /* peak bandwidth */ 0xffffffff, /* latency */ 0xffffffff /* delay variation */ }; /* * L2CAP request timeouts */ int l2cap_response_timeout = 30; /* seconds */ int l2cap_response_extended_timeout = 180; /* seconds */ /* * Allocate a new Request structure & ID and set the timer going */ int l2cap_request_alloc(struct l2cap_channel *chan, uint8_t code) { struct hci_link *link = chan->lc_link; struct l2cap_req *req; int next_id; if (link == NULL) return ENETDOWN; /* find next ID (0 is not allowed) */ next_id = link->hl_lastid + 1; if (next_id > 0xff) next_id = 1; /* Ouroboros check */ req = TAILQ_FIRST(&link->hl_reqs); if (req && req->lr_id == next_id) return ENFILE; req = pool_get(&l2cap_req_pool, PR_NOWAIT); if (req == NULL) return ENOMEM; req->lr_id = link->hl_lastid = next_id; req->lr_code = code; req->lr_chan = chan; req->lr_link = link; callout_init(&req->lr_rtx); callout_reset(&req->lr_rtx, l2cap_response_timeout*hz, l2cap_rtx, req); TAILQ_INSERT_TAIL(&link->hl_reqs, req, lr_next); return 0; } /* * Find a running request for this link */ struct l2cap_req * l2cap_request_lookup(struct hci_link *link, uint8_t id) { struct l2cap_req *req; TAILQ_FOREACH(req, &link->hl_reqs, lr_next) { if (req->lr_id == id) return req; } return NULL; } /* * Halt and free a request */ void l2cap_request_free(struct l2cap_req *req) { struct hci_link *link = req->lr_link; callout_stop(&req->lr_rtx); if (callout_invoking(&req->lr_rtx)) return; TAILQ_REMOVE(&link->hl_reqs, req, lr_next); pool_put(&l2cap_req_pool, req); } /* * Response Timeout eXpired * * No response to our request, so deal with it as best we can. * * XXX should try again at least with ertx? */ void l2cap_rtx(void *arg) { struct l2cap_req *req = arg; struct l2cap_channel *chan; int s; s = splsoftnet(); callout_ack(&req->lr_rtx); chan = req->lr_chan; l2cap_request_free(req); DPRINTF("cid %d, ident %d\n", (chan ? chan->lc_lcid : 0), req->lr_id); if (chan && chan->lc_state != L2CAP_CLOSED) l2cap_close(chan, ETIMEDOUT); splx(s); } /* * Allocate next available CID to channel. We keep a single * ordered list of channels, so find the first gap. * * If this turns out to be not enough (!), could use a * list per HCI unit.. */ int l2cap_cid_alloc(struct l2cap_channel *chan) { struct l2cap_channel *used, *prev = NULL; uint16_t cid = L2CAP_FIRST_CID; if (chan->lc_lcid != L2CAP_NULL_CID || chan->lc_state != L2CAP_CLOSED) return EISCONN; LIST_FOREACH(used, &l2cap_active_list, lc_ncid) { if (used->lc_lcid > cid) break; /* found our gap */ KASSERT(used->lc_lcid == cid); cid++; if (cid == L2CAP_LAST_CID) return ENFILE; prev = used; /* for insert after */ } chan->lc_lcid = cid; if (prev) LIST_INSERT_AFTER(prev, chan, lc_ncid); else LIST_INSERT_HEAD(&l2cap_active_list, chan, lc_ncid); return 0; } /* * Find channel with CID */ struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { struct l2cap_channel *chan; LIST_FOREACH(chan, &l2cap_active_list, lc_ncid) { if (chan->lc_lcid == cid) return chan; if (chan->lc_lcid > cid) return NULL; } return NULL; } @ 1.1.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.2.2 2007/09/03 14:42:41 yamt Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.2.2 2007/09/03 14:42:41 yamt Exp $"); d52 2 a53 4 POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); a71 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* d104 1 a104 1 callout_init(&req->lr_rtx, 0); @ 1.1.2.4 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.2.3 2007/11/15 11:45:05 yamt Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.2.3 2007/11/15 11:45:05 yamt Exp $"); d134 1 a134 2 callout_setfunc(&req->lr_rtx, l2cap_rtx, req); callout_schedule(&req->lr_rtx, l2cap_response_timeout * hz); a168 2 callout_destroy(&req->lr_rtx); @ 1.1.26.1 log @Sync w/ NetBSD-4-RC_1 @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.18.1 2007/07/19 16:04:19 liamjfoy Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.18.1 2007/07/19 16:04:19 liamjfoy Exp $"); a71 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* @ 1.1.18.1 log @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 @ text @d1 1 a1 1 /* $NetBSD$ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD$"); a71 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* @ 1.1.20.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $"); d52 2 a53 4 POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); @ 1.1.20.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.20.1 2007/03/24 14:56:09 yamt Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.20.1 2007/03/24 14:56:09 yamt Exp $"); a73 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* @ 1.1.24.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $"); d52 2 a53 4 POOL_INIT(l2cap_req_pool, sizeof(struct l2cap_req), 0, 0, 0, "l2cap_req", NULL, IPL_SOFTNET); POOL_INIT(l2cap_pdu_pool, sizeof(struct l2cap_pdu), 0, 0, 0, "l2cap_pdu", NULL, IPL_SOFTNET); @ 1.1.24.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.24.1 2007/03/13 16:52:01 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.24.1 2007/03/13 16:52:01 ad Exp $"); a73 27 * Set Link Mode on channel */ int l2cap_setmode(struct l2cap_channel *chan) { KASSERT(chan != NULL); KASSERT(chan->lc_link != NULL); DPRINTF("CID #%d, auth %s, encrypt %s, secure %s\n", chan->lc_lcid, (chan->lc_mode & L2CAP_LM_AUTH ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_ENCRYPT ? "yes" : "no"), (chan->lc_mode & L2CAP_LM_SECURE ? "yes" : "no")); if (chan->lc_mode & L2CAP_LM_AUTH) chan->lc_link->hl_flags |= HCI_LINK_AUTH_REQ; if (chan->lc_mode & L2CAP_LM_ENCRYPT) chan->lc_link->hl_flags |= HCI_LINK_ENCRYPT_REQ; if (chan->lc_mode & L2CAP_LM_SECURE) chan->lc_link->hl_flags |= HCI_LINK_SECURE_REQ; return hci_acl_setmode(chan->lc_link); } /* @ 1.1.24.3 log @Adapt to callout API change. @ text @d1 1 a1 1 /* $NetBSD: l2cap_misc.c,v 1.1.24.2 2007/06/08 14:17:41 ad Exp $ */ d34 1 a34 1 __KERNEL_RCSID(0, "$NetBSD: l2cap_misc.c,v 1.1.24.2 2007/06/08 14:17:41 ad Exp $"); d133 1 a133 1 callout_init(&req->lr_rtx, 0); @