Bluetooth: Add support for SMP Invalid Parameters error code
Subsystems (2)
PATCH 1/1 Bluetooth: Add support for SMP Invalid Parameters error code
From: Johan Hedberg <[email protected]>
The Invalid Parameters error code is used to indicate that the command length is invalid or that a parameter is outside of the specified range. This error code wasn't clearly specified in the Bluetooth 4.0 specification but since 4.1 this has been fixed.
--- net/bluetooth/smp.c | 20 ++++++++++---------- net/bluetooth/smp.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-)
net/bluetooth/smp.c +10 -10
@@ -663,7 +663,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*req)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;if (conn->hcon->link_mode &HCI_LM_MASTER )return SMP_CMD_NOTSUPP ;
@@ -720,7 +720,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*rsp)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;if (!(conn->hcon->link_mode &HCI_LM_MASTER ))return SMP_CMD_NOTSUPP ;
@@ -770,7 +770,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p %s" , conn, conn->hcon->out ?"master" :"slave" );if (skb->len <sizeof (smp->pcnf)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;memcpy (smp->pcnf, skb->data,sizeof (smp->pcnf));skb_pull (skb,sizeof (smp->pcnf));
@@ -794,7 +794,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (smp->rrnd)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;memcpy (smp->rrnd, skb->data,sizeof (smp->rrnd));skb_pull (skb,sizeof (smp->rrnd));
@@ -836,7 +836,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*rp)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;if (!(conn->hcon->link_mode &HCI_LM_MASTER ))return SMP_CMD_NOTSUPP ;
@@ -944,7 +944,7 @@ static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*rp)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;/* Ignore this PDU if it wasn't requested */ if (!(smp->remote_key_dist &SMP_DIST_ENC_KEY ))
@@ -969,7 +969,7 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*rp)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;/* Ignore this PDU if it wasn't requested */ if (!(smp->remote_key_dist &SMP_DIST_ENC_KEY ))
@@ -1001,7 +1001,7 @@ static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("" );if (skb->len <sizeof (*info)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;/* Ignore this PDU if it wasn't requested */ if (!(smp->remote_key_dist &SMP_DIST_ID_KEY ))
@@ -1025,7 +1025,7 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,BT_DBG ("" );if (skb->len <sizeof (*info)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;/* Ignore this PDU if it wasn't requested */ if (!(smp->remote_key_dist &SMP_DIST_ID_KEY ))
@@ -1075,7 +1075,7 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)BT_DBG ("conn %p" , conn);if (skb->len <sizeof (*rp)) -return SMP_UNSPECIFIED ; +return SMP_INVALID_PARAMS ;/* Ignore this PDU if it wasn't requested */ if (!(smp->remote_key_dist &SMP_DIST_SIGN ))
net/bluetooth/smp.h +1 -0
@@ -111,6 +111,7 @@ struct smp_cmd_security_req {#define SMP_CMD_NOTSUPP 0x07#define SMP_UNSPECIFIED 0x08#define SMP_REPEATED_ATTEMPTS 0x09 +#define SMP_INVALID_PARAMS 0x0a#define SMP_MIN_ENC_KEY_SIZE 7#define SMP_MAX_ENC_KEY_SIZE 16
Signature · 1 line
1.9.0
Marcel Holtmann
maintainerHi Johan,
Quoted 10 lines
The Invalid Parameters error code is used to indicate that the command length is invalid or that a parameter is outside of the specified range. This error code wasn't clearly specified in the Bluetooth 4.0 specification but since 4.1 this has been fixed.
Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/smp.c| 20 ++++++++++----------net/bluetooth/smp.h| 1 +2 files changed, 11 insertions(+), 10 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel