From owner-freebsd-bluetooth@FreeBSD.ORG Thu Apr 16 12:16:34 2009 Return-Path: Delivered-To: freebsd-bluetooth@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5610B106564A for ; Thu, 16 Apr 2009 12:16:34 +0000 (UTC) (envelope-from plunky@rya-online.net) Received: from smtp02.one2one.net (smtp02.one2one.net [149.254.192.174]) by mx1.freebsd.org (Postfix) with ESMTP id E138B8FC0C for ; Thu, 16 Apr 2009 12:16:33 +0000 (UTC) (envelope-from plunky@rya-online.net) Received: from [127.0.0.1] (helo=localhost) by localhost.t-mobile.co.uk with esmtp (Exim 4.50) id 1LuQW8-0003Fm-95; Thu, 16 Apr 2009 13:16:32 +0100 Received: from localhost.t-mobile.co.uk ([127.0.0.1]) by localhost (smtpbeckt01 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12338-08; Thu, 16 Apr 2009 13:16:31 +0100 (BST) Received: from [10.215.89.122] (helo=rya-online.net) by localhost.t-mobile.co.uk with smtp (Exim 4.50) id 1LuQW5-0003FM-BH; Thu, 16 Apr 2009 13:16:31 +0100 Received: (nullmailer pid 1260 invoked by uid 1000); Thu, 16 Apr 2009 12:15:18 -0000 Date: Thu, 16 Apr 2009 13:15:18 +0100 (BST) To: Maksim Yevmenkin In-Reply-To: <1239871569.560012.1086.nullmailer@galant.ukfsn.org> References: <49D92E26.2030508@incunabulum.net> <49DD40E2.5030403@incunabulum.net> <1239264003.862926.638.nullmailer@galant.ukfsn.org> <49DE4E2F.2000805@incunabulum.net> <49DE6D42.6000004@incunabulum.net> <1239871569.560012.1086.nullmailer@galant.ukfsn.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Message-Id: <1239884118.412855.3144.nullmailer@galant.ukfsn.org> From: Iain Hibbert X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: plunky@rya-online.net X-SA-Exim-Scanned: No (on localhost.t-mobile.co.uk); SAEximRunCond expanded to false Cc: "freebsd-bluetooth@freebsd.org" Subject: Re: libhci update X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2009 12:16:34 -0000 On Thu, 16 Apr 2009, Iain Hibbert wrote: > +int > +bt_devfilter(int s, struct bt_devfilter const *new, struct bt_devfilter *old) > > And finally, the HCI filter is slightly different in NetBSD (I provided > independent PKT and EVT filters each of 256 bits) and I'm going to think > about that.. Ok, I'm not objecting in priniciple to coupling the two filters together but I think that bt_devfilter should be opaque enough that the API does not depend about its internal structure. Ie, requiring the caller to subtract 1 and manage the bitwise manipulation + f.event_mask |= (1 << (NG_HCI_EVENT_INQUIRY_COMPL - 1)); + f.event_mask |= (1 << (NG_HCI_EVENT_INQUIRY_RESULT - 1)); is too specific and makes the callers somewhat messy. Can we provide some kind of accessor functions to do that? I include below what I used in NetBSD for an example.. Also, at least for events, the full 256 bits is required because there are events such as 0xfe (BT Logo) and 0xff (Vendor) that may currently be returned and the highest value (in 2.1 spec) is 0x3d, dangerously close to the 64 bit limit. Although its not likely that there will be many packet types added, it could be that some manufacturers would introduce custom packet types with similarly high end values.. (eg for private device configuration?) regards, iain /* * HCI socket filter and get/set routines * * for ease of use, we filter 256 possible events/packets */ struct hci_filter { uint32_t mask[8]; /* 256 bits */ }; static __inline void hci_filter_set(uint8_t bit, struct hci_filter *filter) { uint8_t off = bit - 1; off >>= 5; filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); } static __inline void hci_filter_clr(uint8_t bit, struct hci_filter *filter) { uint8_t off = bit - 1; off >>= 5; filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); } static __inline int hci_filter_test(uint8_t bit, struct hci_filter *filter) { uint8_t off = bit - 1; off >>= 5; return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); }