* [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command
@ 2012-02-20 22:24 johan.hedberg
2012-02-20 22:24 ` [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event johan.hedberg
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: johan.hedberg @ 2012-02-20 22:24 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds an address type parameter to the Stop Discovery command
which should match the value given to Start Discovery.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/mgmt.h | 3 +++
net/bluetooth/mgmt.c | 33 ++++++++++++++++++++++-----------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 7e3d38b..870a3de 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -283,6 +283,9 @@ struct mgmt_cp_start_discovery {
} __packed;
#define MGMT_OP_STOP_DISCOVERY 0x0024
+struct mgmt_cp_stop_discovery {
+ __u8 type;
+} __packed;
#define MGMT_OP_CONFIRM_NAME 0x0025
struct mgmt_cp_confirm_name {
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f7c2969..3db8525 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2281,8 +2281,9 @@ failed:
return err;
}
-static int stop_discovery(struct sock *sk, u16 index)
+static int stop_discovery(struct sock *sk, u16 index, void *data, u16 len)
{
+ struct mgmt_cp_stop_discovery *mgmt_cp = data;
struct hci_dev *hdev;
struct pending_cmd *cmd;
struct hci_cp_remote_name_req_cancel cp;
@@ -2291,6 +2292,10 @@ static int stop_discovery(struct sock *sk, u16 index)
BT_DBG("hci%u", index);
+ if (len != sizeof(*mgmt_cp))
+ return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY,
+ MGMT_STATUS_INVALID_PARAMS);
+
hdev = hci_dev_get(index);
if (!hdev)
return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY,
@@ -2299,8 +2304,16 @@ static int stop_discovery(struct sock *sk, u16 index)
hci_dev_lock(hdev);
if (!hci_discovery_active(hdev)) {
- err = cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY,
- MGMT_STATUS_REJECTED);
+ err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY,
+ MGMT_STATUS_REJECTED,
+ &mgmt_cp->type, sizeof(mgmt_cp->type));
+ goto unlock;
+ }
+
+ if (hdev->discovery.type != mgmt_cp->type) {
+ err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY,
+ MGMT_STATUS_INVALID_PARAMS,
+ &mgmt_cp->type, sizeof(mgmt_cp->type));
goto unlock;
}
@@ -2323,7 +2336,7 @@ static int stop_discovery(struct sock *sk, u16 index)
if (!e) {
mgmt_pending_remove(cmd);
err = cmd_complete(sk, index, MGMT_OP_STOP_DISCOVERY, 0,
- NULL, 0);
+ &mgmt_cp->type, sizeof(mgmt_cp->type));
hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
goto unlock;
}
@@ -2706,7 +2719,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
err = start_discovery(sk, index, cp, len);
break;
case MGMT_OP_STOP_DISCOVERY:
- err = stop_discovery(sk, index);
+ err = stop_discovery(sk, index, cp, len);
break;
case MGMT_OP_CONFIRM_NAME:
err = confirm_name(sk, index, cp, len);
@@ -3369,7 +3382,9 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status)
if (!cmd)
return -ENOENT;
- err = cmd_status(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status));
+ err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status),
+ &hdev->discovery.type,
+ sizeof(hdev->discovery.type));
mgmt_pending_remove(cmd);
return err;
@@ -3389,12 +3404,8 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering)
if (cmd != NULL) {
u8 type = hdev->discovery.type;
- if (discovering)
- cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0,
+ cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0,
&type, sizeof(type));
- else
- cmd_complete(cmd->sk, hdev->id, cmd->opcode, 0,
- NULL, 0);
mgmt_pending_remove(cmd);
}
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event
2012-02-20 22:24 [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command johan.hedberg
@ 2012-02-20 22:24 ` johan.hedberg
2012-02-20 22:26 ` Marcel Holtmann
2012-02-20 22:24 ` [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command johan.hedberg
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: johan.hedberg @ 2012-02-20 22:24 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds an address type parameter to the Discovering event. The
value matches that given to Start/Stop Discovery.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/mgmt.h | 4 ++++
net/bluetooth/hci_core.c | 3 +--
net/bluetooth/mgmt.c | 8 ++++++--
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 870a3de..1dbadbe 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -402,6 +402,10 @@ struct mgmt_ev_device_found {
} __packed;
#define MGMT_EV_DISCOVERING 0x0013
+struct mgmt_ev_discovering {
+ __u8 type;
+ __u8 discovering;
+} __packed;
#define MGMT_EV_DEVICE_BLOCKED 0x0014
struct mgmt_ev_device_blocked {
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cc52e03..a7439ae 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -363,10 +363,9 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
switch (state) {
case DISCOVERY_STOPPED:
- hdev->discovery.type = 0;
-
if (hdev->discovery.state != DISCOVERY_STARTING)
mgmt_discovering(hdev, 0);
+ hdev->discovery.type = 0;
break;
case DISCOVERY_STARTING:
break;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 3db8525..86148b1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3392,6 +3392,7 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status)
int mgmt_discovering(struct hci_dev *hdev, u8 discovering)
{
+ struct mgmt_ev_discovering ev;
struct pending_cmd *cmd;
BT_DBG("%s discovering %u", hdev->name, discovering);
@@ -3409,8 +3410,11 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering)
mgmt_pending_remove(cmd);
}
- return mgmt_event(MGMT_EV_DISCOVERING, hdev, &discovering,
- sizeof(discovering), NULL);
+ memset(&ev, 0, sizeof(ev));
+ ev.type = hdev->discovery.type;
+ ev.discovering = discovering;
+
+ return mgmt_event(MGMT_EV_DISCOVERING, hdev, &ev, sizeof(ev), NULL);
}
int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command
2012-02-20 22:24 [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command johan.hedberg
2012-02-20 22:24 ` [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event johan.hedberg
@ 2012-02-20 22:24 ` johan.hedberg
2012-02-20 22:26 ` Marcel Holtmann
2012-02-20 22:24 ` [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature johan.hedberg
2012-02-20 22:25 ` [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command Marcel Holtmann
3 siblings, 1 reply; 8+ messages in thread
From: johan.hedberg @ 2012-02-20 22:24 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds rudimentary support for the Set High Speed command in
the form of a new HCI dev flag (HCI_HS_ENABLED).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/mgmt.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ad5e94c..ec37049 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -95,6 +95,7 @@ enum {
HCI_LE_SCAN,
HCI_SSP_ENABLED,
+ HCI_HS_ENABLED,
};
/* HCI ioctl defines */
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 86148b1..4281331 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -418,6 +418,9 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
settings |= MGMT_SETTING_SSP;
+ if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags))
+ settings |= MGMT_SETTING_HS;
+
return settings;
}
@@ -1093,6 +1096,41 @@ failed:
return err;
}
+static int set_hs(struct sock *sk, u16 index, void *data, u16 len)
+{
+ struct mgmt_mode *cp = data;
+ struct hci_dev *hdev;
+ int err;
+
+ BT_DBG("request for hci%u", index);
+
+ if (len != sizeof(*cp))
+ return cmd_status(sk, index, MGMT_OP_SET_SSP,
+ MGMT_STATUS_INVALID_PARAMS);
+
+ hdev = hci_dev_get(index);
+ if (!hdev)
+ return cmd_status(sk, index, MGMT_OP_SET_SSP,
+ MGMT_STATUS_INVALID_PARAMS);
+
+ if (!enable_hs) {
+ err = cmd_status(sk, index, MGMT_OP_SET_SSP,
+ MGMT_STATUS_NOT_SUPPORTED);
+ goto failed;
+ }
+
+ if (cp->val)
+ set_bit(HCI_HS_ENABLED, &hdev->dev_flags);
+ else
+ clear_bit(HCI_HS_ENABLED, &hdev->dev_flags);
+
+ err = send_settings_rsp(sk, MGMT_OP_SET_HS, hdev);
+
+failed:
+ hci_dev_put(hdev);
+ return err;
+}
+
static int add_uuid(struct sock *sk, u16 index, void *data, u16 len)
{
struct mgmt_cp_add_uuid *cp = data;
@@ -2655,6 +2693,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_SET_SSP:
err = set_ssp(sk, index, cp, len);
break;
+ case MGMT_OP_SET_HS:
+ err = set_hs(sk, index, cp, len);
+ break;
case MGMT_OP_ADD_UUID:
err = add_uuid(sk, index, cp, len);
break;
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature
2012-02-20 22:24 [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command johan.hedberg
2012-02-20 22:24 ` [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event johan.hedberg
2012-02-20 22:24 ` [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command johan.hedberg
@ 2012-02-20 22:24 ` johan.hedberg
2012-02-20 22:27 ` Marcel Holtmann
2012-02-20 22:25 ` [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command Marcel Holtmann
3 siblings, 1 reply; 8+ messages in thread
From: johan.hedberg @ 2012-02-20 22:24 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
If the local controller doesn't support SSP we should always return an
error for the Set SSP command.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4281331..508354a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1065,6 +1065,12 @@ static int set_ssp(struct sock *sk, u16 index, void *data, u16 len)
goto failed;
}
+ if (!(hdev->features[6] & LMP_SIMPLE_PAIR)) {
+ err = cmd_status(sk, index, MGMT_OP_SET_SSP,
+ MGMT_STATUS_NOT_SUPPORTED);
+ goto failed;
+ }
+
if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_SSP, MGMT_STATUS_BUSY);
goto failed;
--
1.7.9
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command
2012-02-20 22:24 [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command johan.hedberg
` (2 preceding siblings ...)
2012-02-20 22:24 ` [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature johan.hedberg
@ 2012-02-20 22:25 ` Marcel Holtmann
3 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-02-20 22:25 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch adds an address type parameter to the Stop Discovery command
> which should match the value given to Start Discovery.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/mgmt.h | 3 +++
> net/bluetooth/mgmt.c | 33 ++++++++++++++++++++++-----------
> 2 files changed, 25 insertions(+), 11 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event
2012-02-20 22:24 ` [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event johan.hedberg
@ 2012-02-20 22:26 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-02-20 22:26 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch adds an address type parameter to the Discovering event. The
> value matches that given to Start/Stop Discovery.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/mgmt.h | 4 ++++
> net/bluetooth/hci_core.c | 3 +--
> net/bluetooth/mgmt.c | 8 ++++++--
> 3 files changed, 11 insertions(+), 4 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command
2012-02-20 22:24 ` [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command johan.hedberg
@ 2012-02-20 22:26 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-02-20 22:26 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch adds rudimentary support for the Set High Speed command in
> the form of a new HCI dev flag (HCI_HS_ENABLED).
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/mgmt.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+), 0 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature
2012-02-20 22:24 ` [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature johan.hedberg
@ 2012-02-20 22:27 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2012-02-20 22:27 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> If the local controller doesn't support SSP we should always return an
> error for the Set SSP command.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-02-20 22:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20 22:24 [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command johan.hedberg
2012-02-20 22:24 ` [PATCH 2/4] Bluetooth: mgmt: Add address type parameter to Discovering event johan.hedberg
2012-02-20 22:26 ` Marcel Holtmann
2012-02-20 22:24 ` [PATCH 3/4] Bluetooth: mgmt: Add basic support for Set High Speed command johan.hedberg
2012-02-20 22:26 ` Marcel Holtmann
2012-02-20 22:24 ` [PATCH 4/4] Bluetooth: mgmt: Fix Set SSP check for supported feature johan.hedberg
2012-02-20 22:27 ` Marcel Holtmann
2012-02-20 22:25 ` [PATCH 1/4] Bluetooth: mgmt: Add address type parameter to Stop Discovery command Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).