linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Pass all message parameters to mgmt_start_discovery
@ 2011-11-12  9:51 johan.hedberg
  2011-11-12  9:58 ` [PATCH v2] " johan.hedberg
  0 siblings, 1 reply; 4+ messages in thread
From: johan.hedberg @ 2011-11-12  9:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The mgmt_start_discovery command contains the type of discovery that
should be started so this should be passed to the start_discovery
function. This patch doesn't yet add any action depending on the type of
the requested discovery.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
Note: This patch is intended to be applied after of the mgmt-specific
error code patch.

 include/net/bluetooth/mgmt.h |    3 +++
 net/bluetooth/mgmt.c         |   10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index bd6995d..2e50182 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -232,6 +232,9 @@ struct mgmt_cp_remove_remote_oob_data {
 } __packed;
 
 #define MGMT_OP_START_DISCOVERY		0x001B
+struct mgmt_cp_start_discovery {
+	__u8 type;
+} __packed;
 
 #define MGMT_OP_STOP_DISCOVERY		0x001C
 
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b761359..022aab1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1779,14 +1779,20 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
 	return err;
 }
 
-static int start_discovery(struct sock *sk, u16 index)
+static int start_discovery(struct sock *sk, u16 index,
+						unsigned char *data, u16 len)
 {
+	struct mgmt_cp_start_discovery *cp = (void *) data;
 	struct pending_cmd *cmd;
 	struct hci_dev *hdev;
 	int err;
 
 	BT_DBG("hci%u", index);
 
+	if (len != sizeof(*cp))
+		return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
+						MGMT_STATUS_INVALID_PARAMS);
+
 	hdev = hci_dev_get(index);
 	if (!hdev)
 		return cmd_status(sk, index, MGMT_OP_START_DISCOVERY,
@@ -2083,7 +2089,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 									len);
 		break;
 	case MGMT_OP_START_DISCOVERY:
-		err = start_discovery(sk, index);
+		err = start_discovery(sk, index, buf + sizeof(*hdr), len);
 		break;
 	case MGMT_OP_STOP_DISCOVERY:
 		err = stop_discovery(sk, index);
-- 
1.7.7.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] Bluetooth: Pass all message parameters to mgmt_start_discovery
  2011-11-12  9:51 [PATCH] Bluetooth: Pass all message parameters to mgmt_start_discovery johan.hedberg
@ 2011-11-12  9:58 ` johan.hedberg
  2011-11-12 23:30   ` Marcel Holtmann
  2011-11-16 18:33   ` Gustavo Padovan
  0 siblings, 2 replies; 4+ messages in thread
From: johan.hedberg @ 2011-11-12  9:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The mgmt_start_discovery command contains the type of discovery that
should be started so this should be passed to the start_discovery
function. This patch doesn't yet add any action depending on the type of
the requested discovery.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
v2: Fix stupid copy-paste error with the MGMT_OP in case of an invalid
message length.

 include/net/bluetooth/mgmt.h |    3 +++
 net/bluetooth/mgmt.c         |   10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index bd6995d..2e50182 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -232,6 +232,9 @@ struct mgmt_cp_remove_remote_oob_data {
 } __packed;
 
 #define MGMT_OP_START_DISCOVERY		0x001B
+struct mgmt_cp_start_discovery {
+	__u8 type;
+} __packed;
 
 #define MGMT_OP_STOP_DISCOVERY		0x001C
 
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b761359..1482455 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1779,14 +1779,20 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
 	return err;
 }
 
-static int start_discovery(struct sock *sk, u16 index)
+static int start_discovery(struct sock *sk, u16 index,
+						unsigned char *data, u16 len)
 {
+	struct mgmt_cp_start_discovery *cp = (void *) data;
 	struct pending_cmd *cmd;
 	struct hci_dev *hdev;
 	int err;
 
 	BT_DBG("hci%u", index);
 
+	if (len != sizeof(*cp))
+		return cmd_status(sk, index, MGMT_OP_START_DISCOVERY,
+						MGMT_STATUS_INVALID_PARAMS);
+
 	hdev = hci_dev_get(index);
 	if (!hdev)
 		return cmd_status(sk, index, MGMT_OP_START_DISCOVERY,
@@ -2083,7 +2089,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 									len);
 		break;
 	case MGMT_OP_START_DISCOVERY:
-		err = start_discovery(sk, index);
+		err = start_discovery(sk, index, buf + sizeof(*hdr), len);
 		break;
 	case MGMT_OP_STOP_DISCOVERY:
 		err = stop_discovery(sk, index);
-- 
1.7.7.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Bluetooth: Pass all message parameters to mgmt_start_discovery
  2011-11-12  9:58 ` [PATCH v2] " johan.hedberg
@ 2011-11-12 23:30   ` Marcel Holtmann
  2011-11-16 18:33   ` Gustavo Padovan
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2011-11-12 23:30 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> The mgmt_start_discovery command contains the type of discovery that
> should be started so this should be passed to the start_discovery
> function. This patch doesn't yet add any action depending on the type of
> the requested discovery.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> v2: Fix stupid copy-paste error with the MGMT_OP in case of an invalid
> message length.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Bluetooth: Pass all message parameters to mgmt_start_discovery
  2011-11-12  9:58 ` [PATCH v2] " johan.hedberg
  2011-11-12 23:30   ` Marcel Holtmann
@ 2011-11-16 18:33   ` Gustavo Padovan
  1 sibling, 0 replies; 4+ messages in thread
From: Gustavo Padovan @ 2011-11-16 18:33 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

* johan.hedberg@gmail.com <johan.hedberg@gmail.com> [2011-11-12 11:58:22 +0200]:

> From: Johan Hedberg <johan.hedberg@intel.com>
> 
> The mgmt_start_discovery command contains the type of discovery that
> should be started so this should be passed to the start_discovery
> function. This patch doesn't yet add any action depending on the type of
> the requested discovery.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> v2: Fix stupid copy-paste error with the MGMT_OP in case of an invalid
> message length.
> 
>  include/net/bluetooth/mgmt.h |    3 +++
>  net/bluetooth/mgmt.c         |   10 ++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)

Applied, thanks.

	Gustavo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-16 18:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-12  9:51 [PATCH] Bluetooth: Pass all message parameters to mgmt_start_discovery johan.hedberg
2011-11-12  9:58 ` [PATCH v2] " johan.hedberg
2011-11-12 23:30   ` Marcel Holtmann
2011-11-16 18:33   ` Gustavo Padovan

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).