Skip to content

Commit 679efe2

Browse files
jhedbergGustavo Padovan
authored andcommitted
Bluetooth: Add helper functions for testing bdaddr types
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> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 44b20d3 commit 679efe2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎include/net/bluetooth/bluetooth.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,29 @@ typedef struct {
166166
#define BDADDR_LE_PUBLIC 0x01
167167
#define BDADDR_LE_RANDOM 0x02
168168

169+
static inline bool bdaddr_type_is_valid(__u8 type)
170+
{
171+
switch (type) {
172+
case BDADDR_BREDR:
173+
case BDADDR_LE_PUBLIC:
174+
case BDADDR_LE_RANDOM:
175+
return true;
176+
}
177+
178+
return false;
179+
}
180+
181+
static inline bool bdaddr_type_is_le(__u8 type)
182+
{
183+
switch (type) {
184+
case BDADDR_LE_PUBLIC:
185+
case BDADDR_LE_RANDOM:
186+
return true;
187+
}
188+
189+
return false;
190+
}
191+
169192
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} })
170193
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} })
171194

0 commit comments

Comments
 (0)