From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 06/10 v2] Bluetooth: Add helper functions for testing bdaddr types
Date: Sun, 20 Jan 2013 14:27:18 +0200 [thread overview]
Message-ID: <1358684842-4441-7-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1358684842-4441-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds two helper functions to test for valid bdaddr type
values. These will be particularely useful in the mgmt code to check
that user space has passed valid values to the kernel.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/bluetooth.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 2554b3f..9531bee 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -166,6 +166,29 @@ typedef struct {
#define BDADDR_LE_PUBLIC 0x01
#define BDADDR_LE_RANDOM 0x02
+static inline bool bdaddr_type_is_valid(__u8 type)
+{
+ switch (type) {
+ case BDADDR_BREDR:
+ case BDADDR_LE_PUBLIC:
+ case BDADDR_LE_RANDOM:
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool bdaddr_type_is_le(__u8 type)
+{
+ switch (type) {
+ case BDADDR_LE_PUBLIC:
+ case BDADDR_LE_RANDOM:
+ return true;
+ }
+
+ return false;
+}
+
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} })
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} })
--
1.7.10.4
next prev parent reply other threads:[~2013-01-20 12:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 12:27 [PATCH 00/10 v2] Bluetooth: Fix more mgmt parameter checks Johan Hedberg
2013-01-20 12:27 ` [PATCH 01/10 v2] Bluetooth: Fix checking for correct mgmt_load_link_keys parameters Johan Hedberg
2013-01-20 12:27 ` [PATCH 02/10 v2] Bluetooth: Fix returning proper mgmt status for Load LTKs Johan Hedberg
2013-01-20 12:27 ` [PATCH 03/10 v2] Bluetooth: Fix checking for proper key->master value in " Johan Hedberg
2013-01-20 12:27 ` [PATCH 04/10 v2] Bluetooth: Refactor valid LTK data testing into its own function Johan Hedberg
2013-01-20 12:27 ` [PATCH 05/10 v2] Bluetooth: Check for valid key->authenticated value for LTKs Johan Hedberg
2013-01-20 12:27 ` Johan Hedberg [this message]
2013-01-20 12:27 ` [PATCH 07/10 v2] Bluetooth: Fix checking for valid address type values in mgmt commands Johan Hedberg
2013-01-20 12:27 ` [PATCH 08/10 v2] Bluetooth: Fix checking for valid disconnect parameters in unpair_device Johan Hedberg
2013-01-20 12:27 ` [PATCH 09/10 v2] Bluetooth: Fix returning proper cmd_complete for mgmt_disconnect Johan Hedberg
2013-01-20 12:27 ` [PATCH 10/10 v2] Bluetooth: Fix returning proper cmd_complete for mgmt_block/unblock Johan Hedberg
2013-01-23 4:07 ` Gustavo Padovan
2013-01-22 10:45 ` [PATCH 00/10 v2] Bluetooth: Fix more mgmt parameter checks Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358684842-4441-7-git-send-email-johan.hedberg@gmail.com \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox