| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $ */ | | 1 | /* $NetBSD: hci.h,v 1.42 2017/01/28 19:07:16 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2005 Iain Hibbert. | | 4 | * Copyright (c) 2005 Iain Hibbert. |
5 | * Copyright (c) 2006 Itronix Inc. | | 5 | * Copyright (c) 2006 Itronix Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -44,27 +44,27 @@ | | | @@ -44,27 +44,27 @@ |
44 | * | | 44 | * |
45 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | | 45 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
55 | * SUCH DAMAGE. | | 55 | * SUCH DAMAGE. |
56 | * | | 56 | * |
57 | * $Id: hci.h,v 1.41 2015/11/28 09:04:34 plunky Exp $ | | 57 | * $Id: hci.h,v 1.42 2017/01/28 19:07:16 christos Exp $ |
58 | * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ | | 58 | * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ |
59 | */ | | 59 | */ |
60 | | | 60 | |
61 | /* | | 61 | /* |
62 | * This file contains everything that applications need to know from | | 62 | * This file contains everything that applications need to know from |
63 | * Host Controller Interface (HCI). Information taken from Bluetooth | | 63 | * Host Controller Interface (HCI). Information taken from Bluetooth |
64 | * Core Specifications (v1.1, v2.0, v2.1 + EDR, v3.0 + HS, | | 64 | * Core Specifications (v1.1, v2.0, v2.1 + EDR, v3.0 + HS, |
65 | * v4.0 and v4.2) | | 65 | * v4.0 and v4.2) |
66 | * | | 66 | * |
67 | * This file can be included by both kernel and userland applications. | | 67 | * This file can be included by both kernel and userland applications. |
68 | * | | 68 | * |
69 | * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth | | 69 | * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth |
70 | * specification refers to both devices and units. They are the | | 70 | * specification refers to both devices and units. They are the |
| @@ -2268,48 +2268,48 @@ typedef struct { | | | @@ -2268,48 +2268,48 @@ typedef struct { |
2268 | | | 2268 | |
2269 | /* | | 2269 | /* |
2270 | * HCI socket filter and get/set routines | | 2270 | * HCI socket filter and get/set routines |
2271 | * | | 2271 | * |
2272 | * for ease of use, we filter 256 possible events/packets | | 2272 | * for ease of use, we filter 256 possible events/packets |
2273 | */ | | 2273 | */ |
2274 | struct hci_filter { | | 2274 | struct hci_filter { |
2275 | uint32_t mask[8]; /* 256 bits */ | | 2275 | uint32_t mask[8]; /* 256 bits */ |
2276 | }; | | 2276 | }; |
2277 | | | 2277 | |
2278 | static __inline void | | 2278 | static __inline void |
2279 | hci_filter_set(uint8_t bit, struct hci_filter *filter) | | 2279 | hci_filter_set(uint8_t bit, struct hci_filter *filter) |
2280 | { | | 2280 | { |
2281 | uint8_t off = bit - 1; | | 2281 | uint8_t off = (uint8_t)((bit - 1) >> 5); |
| | | 2282 | uint8_t sh = (uint8_t)((bit - 1) & 0x1f); |
2282 | | | 2283 | |
2283 | off >>= 5; | | 2284 | filter->mask[off] |= 1 << sh; |
2284 | filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); | | | |
2285 | } | | 2285 | } |
2286 | | | 2286 | |
2287 | static __inline void | | 2287 | static __inline void |
2288 | hci_filter_clr(uint8_t bit, struct hci_filter *filter) | | 2288 | hci_filter_clr(uint8_t bit, struct hci_filter *filter) |
2289 | { | | 2289 | { |
2290 | uint8_t off = bit - 1; | | 2290 | uint8_t off = (uint8_t)((bit - 1) >> 5); |
| | | 2291 | uint8_t sh = (uint8_t)((bit - 1) & 0x1f); |
2291 | | | 2292 | |
2292 | off >>= 5; | | 2293 | filter->mask[off] &= ~(1 << sh); |
2293 | filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); | | | |
2294 | } | | 2294 | } |
2295 | | | 2295 | |
2296 | static __inline int | | 2296 | static __inline int |
2297 | hci_filter_test(uint8_t bit, const struct hci_filter *filter) | | 2297 | hci_filter_test(uint8_t bit, const struct hci_filter *filter) |
2298 | { | | 2298 | { |
2299 | uint8_t off = bit - 1; | | 2299 | uint8_t off = (uint8_t)((bit - 1) >> 5); |
| | | 2300 | uint8_t sh = (uint8_t)((bit - 1) & 0x1f); |
2300 | | | 2301 | |
2301 | off >>= 5; | | 2302 | return filter->mask[off] & (1 << sh); |
2302 | return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); | | | |
2303 | } | | 2303 | } |
2304 | | | 2304 | |
2305 | /* | | 2305 | /* |
2306 | * HCI socket ioctl's | | 2306 | * HCI socket ioctl's |
2307 | * | | 2307 | * |
2308 | * Apart from GBTINFOA, these are all indexed on the unit name | | 2308 | * Apart from GBTINFOA, these are all indexed on the unit name |
2309 | */ | | 2309 | */ |
2310 | | | 2310 | |
2311 | #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ | | 2311 | #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ |
2312 | #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ | | 2312 | #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ |
2313 | #define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */ | | 2313 | #define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */ |
2314 | | | 2314 | |
2315 | #define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */ | | 2315 | #define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */ |