Commit 38e4a915 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Add support for SMP Invalid Parameters error code

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: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 86aae6c7
...@@ -663,7 +663,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -663,7 +663,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*req)) if (skb->len < sizeof(*req))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
if (conn->hcon->link_mode & HCI_LM_MASTER) if (conn->hcon->link_mode & HCI_LM_MASTER)
return SMP_CMD_NOTSUPP; return SMP_CMD_NOTSUPP;
...@@ -720,7 +720,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -720,7 +720,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*rsp)) if (skb->len < sizeof(*rsp))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
if (!(conn->hcon->link_mode & HCI_LM_MASTER)) if (!(conn->hcon->link_mode & HCI_LM_MASTER))
return SMP_CMD_NOTSUPP; return SMP_CMD_NOTSUPP;
...@@ -770,7 +770,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -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"); BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
if (skb->len < sizeof(smp->pcnf)) if (skb->len < sizeof(smp->pcnf))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf)); memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf));
skb_pull(skb, 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) ...@@ -794,7 +794,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(smp->rrnd)) if (skb->len < sizeof(smp->rrnd))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd));
skb_pull(skb, 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) ...@@ -836,7 +836,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*rp)) if (skb->len < sizeof(*rp))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
if (!(conn->hcon->link_mode & HCI_LM_MASTER)) if (!(conn->hcon->link_mode & HCI_LM_MASTER))
return SMP_CMD_NOTSUPP; return SMP_CMD_NOTSUPP;
...@@ -944,7 +944,7 @@ static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -944,7 +944,7 @@ static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*rp)) if (skb->len < sizeof(*rp))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
/* Ignore this PDU if it wasn't requested */ /* Ignore this PDU if it wasn't requested */
if (!(smp->remote_key_dist & SMP_DIST_ENC_KEY)) 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) ...@@ -969,7 +969,7 @@ static int smp_cmd_master_ident(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*rp)) if (skb->len < sizeof(*rp))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
/* Ignore this PDU if it wasn't requested */ /* Ignore this PDU if it wasn't requested */
if (!(smp->remote_key_dist & SMP_DIST_ENC_KEY)) 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) ...@@ -1001,7 +1001,7 @@ static int smp_cmd_ident_info(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG(""); BT_DBG("");
if (skb->len < sizeof(*info)) if (skb->len < sizeof(*info))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
/* Ignore this PDU if it wasn't requested */ /* Ignore this PDU if it wasn't requested */
if (!(smp->remote_key_dist & SMP_DIST_ID_KEY)) if (!(smp->remote_key_dist & SMP_DIST_ID_KEY))
...@@ -1025,7 +1025,7 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn, ...@@ -1025,7 +1025,7 @@ static int smp_cmd_ident_addr_info(struct l2cap_conn *conn,
BT_DBG(""); BT_DBG("");
if (skb->len < sizeof(*info)) if (skb->len < sizeof(*info))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
/* Ignore this PDU if it wasn't requested */ /* Ignore this PDU if it wasn't requested */
if (!(smp->remote_key_dist & SMP_DIST_ID_KEY)) 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) ...@@ -1075,7 +1075,7 @@ static int smp_cmd_sign_info(struct l2cap_conn *conn, struct sk_buff *skb)
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
if (skb->len < sizeof(*rp)) if (skb->len < sizeof(*rp))
return SMP_UNSPECIFIED; return SMP_INVALID_PARAMS;
/* Ignore this PDU if it wasn't requested */ /* Ignore this PDU if it wasn't requested */
if (!(smp->remote_key_dist & SMP_DIST_SIGN)) if (!(smp->remote_key_dist & SMP_DIST_SIGN))
......
...@@ -111,6 +111,7 @@ struct smp_cmd_security_req { ...@@ -111,6 +111,7 @@ struct smp_cmd_security_req {
#define SMP_CMD_NOTSUPP 0x07 #define SMP_CMD_NOTSUPP 0x07
#define SMP_UNSPECIFIED 0x08 #define SMP_UNSPECIFIED 0x08
#define SMP_REPEATED_ATTEMPTS 0x09 #define SMP_REPEATED_ATTEMPTS 0x09
#define SMP_INVALID_PARAMS 0x0a
#define SMP_MIN_ENC_KEY_SIZE 7 #define SMP_MIN_ENC_KEY_SIZE 7
#define SMP_MAX_ENC_KEY_SIZE 16 #define SMP_MAX_ENC_KEY_SIZE 16
......
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