Commit f39799f5 authored by Andre Guedes's avatar Andre Guedes Committed by Johan Hedberg

Bluetooth: Prepare start_discovery

This patch does some code refactoring in start_discovery function
in order to prepare it for interleaved discovery support.

MGMT_ADDR_* macros were moved to hci_core.h since they are now used
to define discovery type macros.

Discovery type macros were defined according to mgmt-api.txt
specification:

Possible values for the Type parameter are a bit-wise or of the
following bits:

	1	BR/EDR
	2	LE Public
	3	LE Random

By combining these e.g. the following values are possible:

	1	BR/EDR
	6	LE (public & random)
	7	BR/EDR/LE (interleaved discovery)
Signed-off-by: default avatarAndre Guedes <andre.guedes@openbossa.org>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent ea585ab5
...@@ -956,6 +956,18 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, ...@@ -956,6 +956,18 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb,
struct sock *skip_sk); struct sock *skip_sk);
/* Management interface */ /* Management interface */
#define MGMT_ADDR_BREDR 0x00
#define MGMT_ADDR_LE_PUBLIC 0x01
#define MGMT_ADDR_LE_RANDOM 0x02
#define MGMT_ADDR_INVALID 0xff
#define DISCOV_TYPE_BREDR (BIT(MGMT_ADDR_BREDR))
#define DISCOV_TYPE_LE (BIT(MGMT_ADDR_LE_PUBLIC) | \
BIT(MGMT_ADDR_LE_RANDOM))
#define DISCOV_TYPE_INTERLEAVED (BIT(MGMT_ADDR_BREDR) | \
BIT(MGMT_ADDR_LE_PUBLIC) | \
BIT(MGMT_ADDR_LE_RANDOM))
int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
int mgmt_index_added(struct hci_dev *hdev); int mgmt_index_added(struct hci_dev *hdev);
int mgmt_index_removed(struct hci_dev *hdev); int mgmt_index_removed(struct hci_dev *hdev);
......
...@@ -48,11 +48,6 @@ struct mgmt_hdr { ...@@ -48,11 +48,6 @@ struct mgmt_hdr {
__le16 len; __le16 len;
} __packed; } __packed;
#define MGMT_ADDR_BREDR 0x00
#define MGMT_ADDR_LE_PUBLIC 0x01
#define MGMT_ADDR_LE_RANDOM 0x02
#define MGMT_ADDR_INVALID 0xff
struct mgmt_addr_info { struct mgmt_addr_info {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 type; __u8 type;
......
...@@ -2157,7 +2157,6 @@ static int start_discovery(struct sock *sk, u16 index, ...@@ -2157,7 +2157,6 @@ static int start_discovery(struct sock *sk, u16 index,
void *data, u16 len) void *data, u16 len)
{ {
struct mgmt_cp_start_discovery *cp = data; struct mgmt_cp_start_discovery *cp = data;
unsigned long discov_type = cp->type;
struct pending_cmd *cmd; struct pending_cmd *cmd;
struct hci_dev *hdev; struct hci_dev *hdev;
int err; int err;
...@@ -2193,14 +2192,20 @@ static int start_discovery(struct sock *sk, u16 index, ...@@ -2193,14 +2192,20 @@ static int start_discovery(struct sock *sk, u16 index,
goto failed; goto failed;
} }
if (test_bit(MGMT_ADDR_BREDR, &discov_type)) switch (cp->type) {
case DISCOV_TYPE_BREDR:
case DISCOV_TYPE_INTERLEAVED:
err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) && break;
test_bit(MGMT_ADDR_LE_RANDOM, &discov_type))
case DISCOV_TYPE_LE:
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
else break;
default:
err = -EINVAL; err = -EINVAL;
}
if (err < 0) if (err < 0)
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment