Bluetooth: mgmt: Change ordering of cmd_status paramters
Subsystems (2)
PATCH 1/6 Bluetooth: mgmt: Change ordering of cmd_status paramters
From: Johan Hedberg <[email protected]>
In accordance to the latest mgmt API specification the opcode comes first and then the status.
--- include/net/bluetooth/mgmt.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/net/bluetooth/mgmt.h +1 -1
@@ -318,8 +318,8 @@ struct mgmt_ev_cmd_complete {#define MGMT_EV_CMD_STATUS 0x0002struct mgmt_ev_cmd_status { -__u8 status;__le16 opcode; +__u8 status; } __packed;#define MGMT_EV_CONTROLLER_ERROR 0x0003
Signature · 1 line
1.7.9
PATCH 2/6 Bluetooth: mgmt: Move status parameters into the cmd_complete header
From: Johan Hedberg <[email protected]>
Instead of having status paramters part of each individual command response it's simpler to just have the status as part of the command complete header. This patch updates the code to follow this convention and thereby also ensures compliance with the latest mgmt API specification.
--- include/net/bluetooth/mgmt.h | 8 +--- net/bluetooth/mgmt.c | 107 +++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 59 deletions(-)
include/net/bluetooth/mgmt.h +1 -7
@@ -184,7 +184,6 @@ struct mgmt_cp_disconnect { } __packed;struct mgmt_rp_disconnect {struct mgmt_addr_info addr; -__u8 status; } __packed;#define MGMT_OP_GET_CONNECTIONS 0x0015
@@ -201,7 +200,6 @@ struct mgmt_cp_pin_code_reply { } __packed;struct mgmt_rp_pin_code_reply {struct mgmt_addr_info addr; -uint8_t status; } __packed;#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017
@@ -221,7 +219,6 @@ struct mgmt_cp_pair_device { } __packed;struct mgmt_rp_pair_device {struct mgmt_addr_info addr; -__u8 status; } __packed;#define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A
@@ -233,7 +230,6 @@ struct mgmt_cp_unpair_device { } __packed;struct mgmt_rp_unpair_device {struct mgmt_addr_info addr; -__u8 status; };#define MGMT_OP_USER_CONFIRM_REPLY 0x001C
@@ -242,7 +238,6 @@ struct mgmt_cp_user_confirm_reply { } __packed;struct mgmt_rp_user_confirm_reply {struct mgmt_addr_info addr; -__u8 status; } __packed;#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
@@ -257,7 +252,6 @@ struct mgmt_cp_user_passkey_reply { } __packed;struct mgmt_rp_user_passkey_reply {struct mgmt_addr_info addr; -__u8 status; } __packed;#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
@@ -297,7 +291,6 @@ struct mgmt_cp_confirm_name { } __packed;struct mgmt_rp_confirm_name {struct mgmt_addr_info addr; -__u8 status; } __packed;#define MGMT_OP_BLOCK_DEVICE 0x0026
@@ -313,6 +306,7 @@ struct mgmt_cp_unblock_device {#define MGMT_EV_CMD_COMPLETE 0x0001struct mgmt_ev_cmd_complete {__le16 opcode; +__u8 status;__u8 data[0 ]; } __packed;
net/bluetooth/mgmt.c +55 -52
339 lines not on this page · raw message
Signature · 1 line
1.7.9
Re: [PATCH 2/6] Bluetooth: mgmt: Move status parameters into the cmd_complete header
Hi Johan,
Quoted 11 lines
Instead of having status paramters part of each individual command response it's simpler to just have the status as part of the command complete header. This patch updates the code to follow this convention and thereby also ensures compliance with the latest mgmt API specification.
Signed-off-by Johan Hedberg <[email protected]>--- include/net/bluetooth/mgmt.h | 8 +--- net/bluetooth/mgmt.c | 107 +++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 59 deletions(-)
Regards
Marcel
PATCH 3/6 Bluetooth: mgmt: Fix Pair Device response status values
In reply to [email protected]From: Johan Hedberg <[email protected]>
This patch fixes the status in Pair Device responses to follow proper mgmt status values.
--- net/bluetooth/mgmt.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
net/bluetooth/mgmt.c +6 -8
@@ -1728,7 +1728,7 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status)if (!cmd)BT_DBG ("Unable to find a pending command" );else -pairing_complete (cmd, status); +pairing_complete (cmd,mgmt_status (status)); }static int pair_device (struct sock *sk,u16 index,void *data,u16 len)
@@ -1739,7 +1739,6 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len)struct pending_cmd *cmd;u8 sec_level, auth_type;struct hci_conn *conn; -u8 status =0 ;int err;BT_DBG ("" );
@@ -1773,17 +1772,16 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len) rp.addr.type = cp->addr.type;if (IS_ERR (conn)) { - status = -PTR_ERR (conn); - err =cmd_complete (sk, index,MGMT_OP_PAIR_DEVICE , status, - &rp,sizeof (rp)); + err =cmd_complete (sk, index,MGMT_OP_PAIR_DEVICE , +MGMT_STATUS_CONNECT_FAILED , + &rp,sizeof (rp)); goto unlock; }if (conn->connect_cfm_cb) {hci_conn_put (conn); - status =EBUSY ; - err =cmd_complete (sk, index,MGMT_OP_PAIR_DEVICE , status, - &rp,sizeof (rp)); + err =cmd_complete (sk, index,MGMT_OP_PAIR_DEVICE , +MGMT_STATUS_BUSY , &rp,sizeof (rp)); goto unlock; }
Signature · 1 line
1.7.9
Re: [PATCH 3/6] Bluetooth: mgmt: Fix Pair Device response status values
Hi Johan,
Quoted 7 lines
This patch fixes the status in Pair Device responses to follow proper mgmt status values.
Signed-off-by Johan Hedberg <[email protected]>--- net/bluetooth/mgmt.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
Regards
Marcel
PATCH 4/6 Bluetooth: mgmt: Fix Start Discovery return parameters
In reply to [email protected]From: Johan Hedberg <[email protected]>
The same address type that was passed to the Start Discovery command should also be returned in the response message.
--- net/bluetooth/mgmt.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +13 -2
@@ -3325,6 +3325,7 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,int mgmt_start_discovery_failed (struct hci_dev *hdev,u8 status) {struct pending_cmd *cmd; +u8 type;int err;hci_discovery_set_state (hdev,DISCOVERY_STOPPED );
@@ -3333,7 +3334,10 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)if (!cmd)return -ENOENT ; - err =cmd_status (cmd->sk, hdev->id, cmd->opcode,mgmt_status (status)); + type = hdev->discovery.type; + + err =cmd_complete (cmd->sk, hdev->id, cmd->opcode,mgmt_status (status), + &type,sizeof (type));mgmt_pending_remove (cmd);return err;
@@ -3366,7 +3370,14 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering) cmd =mgmt_pending_find (MGMT_OP_STOP_DISCOVERY , hdev);if (cmd !=NULL ) { -cmd_complete (cmd->sk, hdev->id, cmd->opcode,0 ,NULL ,0 ); +u8 type = hdev->discovery.type; + +if (discovering) +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); }
Signature · 1 line
1.7.9
Re: [PATCH 4/6] Bluetooth: mgmt: Fix Start Discovery return parameters
Hi Johan,
Quoted 7 lines
The same address type that was passed to the Start Discovery command should also be returned in the response message.
Signed-off-by Johan Hedberg <[email protected]>--- net/bluetooth/mgmt.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
Regards
Marcel
PATCH 5/6 Bluetooth: mgmt: Fix (Un)Block Device return parameters
In reply to [email protected]From: Johan Hedberg <[email protected]>
The same address as was passed to the (Un)Block Device command should also be returned in the command response message.
--- net/bluetooth/mgmt.c | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-)
net/bluetooth/mgmt.c +18 -13
@@ -2384,6 +2384,7 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) {struct hci_dev *hdev;struct mgmt_cp_block_device *cp = data; +u8 status;int err;BT_DBG ("hci%u" , index);
@@ -2394,18 +2395,20 @@ static int block_device(struct sock *sk, u16 index, void *data, u16 len) hdev =hci_dev_get (index);if (!hdev) -return cmd_status (sk, index,MGMT_OP_BLOCK_DEVICE , -MGMT_STATUS_INVALID_PARAMS ); +return cmd_complete (sk, index,MGMT_OP_BLOCK_DEVICE , +MGMT_STATUS_INVALID_PARAMS , + &cp->addr,sizeof (cp->addr));hci_dev_lock (hdev); err =hci_blacklist_add (hdev, &cp->addr.bdaddr, cp->addr.type);if (err <0 ) - err =cmd_status (sk, index,MGMT_OP_BLOCK_DEVICE , -MGMT_STATUS_FAILED ); + status =MGMT_STATUS_FAILED ;else - err =cmd_complete (sk, index,MGMT_OP_BLOCK_DEVICE ,0 , -NULL ,0 ); + status =0 ; + + err =cmd_complete (sk, index,MGMT_OP_BLOCK_DEVICE , status, + &cp->addr,sizeof (cp->addr));hci_dev_unlock (hdev);hci_dev_put (hdev);
@@ -2417,6 +2420,7 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) {struct hci_dev *hdev;struct mgmt_cp_unblock_device *cp = data; +u8 status;int err;BT_DBG ("hci%u" , index);
@@ -2427,19 +2431,20 @@ static int unblock_device(struct sock *sk, u16 index, void *data, u16 len) hdev =hci_dev_get (index);if (!hdev) -return cmd_status (sk, index,MGMT_OP_UNBLOCK_DEVICE , -MGMT_STATUS_INVALID_PARAMS ); +return cmd_complete (sk, index,MGMT_OP_UNBLOCK_DEVICE , +MGMT_STATUS_INVALID_PARAMS , + &cp->addr,sizeof (cp->addr));hci_dev_lock (hdev); err =hci_blacklist_del (hdev, &cp->addr.bdaddr, cp->addr.type); -if (err <0 ) - err =cmd_status (sk, index,MGMT_OP_UNBLOCK_DEVICE , -MGMT_STATUS_INVALID_PARAMS ); + status =MGMT_STATUS_INVALID_PARAMS ;else - err =cmd_complete (sk, index,MGMT_OP_UNBLOCK_DEVICE ,0 , -NULL ,0 ); + status =0 ; + + err =cmd_complete (sk, index,MGMT_OP_UNBLOCK_DEVICE , status, + &cp->addr,sizeof (cp->addr));hci_dev_unlock (hdev);hci_dev_put (hdev);
Signature · 1 line
1.7.9
Re: [PATCH 5/6] Bluetooth: mgmt: Fix (Un)Block Device return parameters
Hi Johan,
Quoted 7 lines
The same address as was passed to the (Un)Block Device command should also be returned in the command response message.
Signed-off-by Johan Hedberg <[email protected]>--- net/bluetooth/mgmt.c | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-)
Regards
Marcel
PATCH 6/6 Bluetooth: mgmt: Fix OOB command response parameters
In reply to [email protected]From: Johan Hedberg <[email protected]>
The response to the Add/Remove Out Of Band Data commands should include the same address as was given in the command itself.
--- net/bluetooth/mgmt.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-)
net/bluetooth/mgmt.c +18 -12
@@ -2094,6 +2094,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, {struct hci_dev *hdev;struct mgmt_cp_add_remote_oob_data *cp = data; +u8 status;int err;BT_DBG ("hci%u " , index);
@@ -2104,19 +2105,21 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data, hdev =hci_dev_get (index);if (!hdev) -return cmd_status (sk, index,MGMT_OP_ADD_REMOTE_OOB_DATA , -MGMT_STATUS_INVALID_PARAMS ); +return cmd_complete (sk, index,MGMT_OP_ADD_REMOTE_OOB_DATA , +MGMT_STATUS_INVALID_PARAMS , + &cp->addr,sizeof (cp->addr));hci_dev_lock (hdev); err =hci_add_remote_oob_data (hdev, &cp->addr.bdaddr, cp->hash, cp->randomizer);if (err <0 ) - err =cmd_status (sk, index,MGMT_OP_ADD_REMOTE_OOB_DATA , -MGMT_STATUS_FAILED ); + status =MGMT_STATUS_FAILED ;else - err =cmd_complete (sk, index,MGMT_OP_ADD_REMOTE_OOB_DATA ,0 , -NULL ,0 ); + status =0 ; + + err =cmd_complete (sk, index,MGMT_OP_ADD_REMOTE_OOB_DATA , status, + &cp->addr,sizeof (cp->addr));hci_dev_unlock (hdev);hci_dev_put (hdev);
@@ -2129,6 +2132,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, {struct hci_dev *hdev;struct mgmt_cp_remove_remote_oob_data *cp = data; +u8 status;int err;BT_DBG ("hci%u " , index);
@@ -2139,18 +2143,20 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, hdev =hci_dev_get (index);if (!hdev) -return cmd_status (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA , -MGMT_STATUS_INVALID_PARAMS ); +return cmd_complete (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA , +MGMT_STATUS_INVALID_PARAMS , + &cp->addr,sizeof (cp->addr));hci_dev_lock (hdev); err =hci_remove_remote_oob_data (hdev, &cp->addr.bdaddr);if (err <0 ) - err =cmd_status (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA , -MGMT_STATUS_INVALID_PARAMS ); + status =MGMT_STATUS_INVALID_PARAMS ;else - err =cmd_complete (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA , -0 ,NULL ,0 ); + status =0 ; + + err =cmd_complete (sk, index,MGMT_OP_REMOVE_REMOTE_OOB_DATA , status, + &cp->addr,sizeof (cp->addr));hci_dev_unlock (hdev);hci_dev_put (hdev);
Signature · 1 line
1.7.9
Re: [PATCH 6/6] Bluetooth: mgmt: Fix OOB command response parameters
Hi Johan,
Quoted 7 lines
The response to the Add/Remove Out Of Band Data commands should include the same address as was given in the command itself.
Signed-off-by Johan Hedberg <[email protected]>--- net/bluetooth/mgmt.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-)
Regards
Marcel
Hi Johan,
Quoted 7 lines
In accordance to the latest mgmt API specification the opcode comes first and then the status.
Signed-off-by Johan Hedberg <[email protected]>--- include/net/bluetooth/mgmt.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Regards
Marcel