aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-05-08 07:19:11 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-05-08 10:50:02 -0400
commit38e4a915663f3f3c03b753d90a34fbb6164ea55d (patch)
tree4a822a38a4db528106c1b9148a50eb1a8771fc65 /net
parent86aae6c7b577654b7293374973985a153e0c147e (diff)
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: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/smp.c20
-rw-r--r--net/bluetooth/smp.h1
2 files changed, 11 insertions, 10 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index dfb4e1161c10..b5b926399e76 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -663,7 +663,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
663 BT_DBG("conn %p", conn); 663 BT_DBG("conn %p", conn);
664 664
665 if (skb->len < sizeof(*req)) 665 if (skb->len < sizeof(*req))
666 return SMP_UNSPECIFIED; 666 return SMP_INVALID_PARAMS;
667 667
668 if (conn->hcon->link_mode & HCI_LM_MASTER) 668 if (conn->hcon->link_mode & HCI_LM_MASTER)
669 return SMP_CMD_NOTSUPP; 669 return SMP_CMD_NOTSUPP;
@@ -720,7 +720,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
720 BT_DBG("conn %p", conn); 720 BT_DBG("conn %p", conn);
721 721
722 if (skb->len < sizeof(*rsp)) 722 if (skb->len < sizeof(*rsp))
723 return SMP_UNSPECIFIED; 723 return SMP_INVALID_PARAMS;
724 724
725 if (!(conn->hcon->link_mode & HCI_LM_MASTER)) 725 if (!(conn->hcon->link_mode & HCI_LM_MASTER))
726 return SMP_CMD_NOTSUPP; 726 return SMP_CMD_NOTSUPP;
@@ -770,7 +770,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
770 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); 770 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
771 771
772 if (skb->len < sizeof(smp->pcnf)) 772 if (skb->len < sizeof(smp->pcnf))
773 return SMP_UNSPECIFIED; 773 return SMP_INVALID_PARAMS;
774 774
775 memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf)); 775 memcpy(smp->pcnf, skb->data, sizeof(smp->pcnf));
776 skb_pull(skb, sizeof(smp->pcnf)); 776 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 BT_DBG("conn %p", conn); 794 BT_DBG("conn %p", conn);
795 795
796 if (skb->len < sizeof(smp->rrnd)) 796 if (skb->len < sizeof(smp->rrnd))
797 return SMP_UNSPECIFIED; 797 return SMP_INVALID_PARAMS;
798 798
799 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); 799 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd));
800 skb_pull(skb, sizeof(smp->rrnd)); 800 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 BT_DBG("conn %p", conn); 836 BT_DBG("conn %p", conn);
837 837
838 if (skb->len < sizeof(*rp)) 838 if (skb->len < sizeof(*rp))
839 return SMP_UNSPECIFIED; 839 return SMP_INVALID_PARAMS;
840 840
841 if (!(conn->hcon->link_mode & HCI_LM_MASTER)) 841 if (!(conn->hcon->link_mode & HCI_LM_MASTER))
842 return SMP_CMD_NOTSUPP; 842 return SMP_CMD_NOTSUPP;
@@ -944,7 +944,7 @@ static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb)
944 BT_DBG("conn %p", conn); 944 BT_DBG("conn %p", conn);
945 945
946 if (skb->len < sizeof(*rp)) 946 if (skb->len < sizeof(*rp))
947 return SMP_UNSPECIFIED; 947 return SMP_INVALID_PARAMS;
948 948
949 /* Ignore this PDU if it wasn't requested */ 949 /* Ignore this PDU if it wasn't requested */
950 if (!(smp->remote_key_dist & SMP_DIST_ENC_KEY)) 950 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 BT_DBG("conn %p", conn); 969 BT_DBG("conn %p", conn);
970 970
971 if (skb->len < sizeof(*rp)) 971 if (skb->len < sizeof(*rp))
972 return SMP_UNSPECIFIED; 972 return SMP_INVALID_PARAMS;
973 973
974 /* Ignore this PDU if it wasn't requested */ 974 /* Ignore this PDU if it wasn't requested */
975 if (!(smp->remote_key_dist & SMP_DIST_ENC_KEY)) 975 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 BT_DBG(""); 1001 BT_DBG("");
1002 1002
1003 if (skb->len < sizeof(*info)) 1003 if (skb->len < sizeof(*info))
1004 return SMP_UNSPECIFIED; 1004 return SMP_INVALID_PARAMS;
1005 1005
1006 /* Ignore this PDU if it wasn't requested */ 1006 /* Ignore this PDU if it wasn't requested */
1007 if (!(smp->remote_key_dist & SMP_DIST_ID_KEY)) 1007 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 BT_DBG(""); 1025 BT_DBG("");
1026 1026
1027 if (skb->len < sizeof(*info)) 1027 if (skb->len < sizeof(*info))
1028 return SMP_UNSPECIFIED; 1028 return SMP_INVALID_PARAMS;
1029 1029
1030 /* Ignore this PDU if it wasn't requested */ 1030 /* Ignore this PDU if it wasn't requested */
1031 if (!(smp->remote_key_dist & SMP_DIST_ID_KEY)) 1031 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 BT_DBG("conn %p", conn); 1075 BT_DBG("conn %p", conn);
1076 1076
1077 if (skb->len < sizeof(*rp)) 1077 if (skb->len < sizeof(*rp))
1078 return SMP_UNSPECIFIED; 1078 return SMP_INVALID_PARAMS;
1079 1079
1080 /* Ignore this PDU if it wasn't requested */ 1080 /* Ignore this PDU if it wasn't requested */
1081 if (!(smp->remote_key_dist & SMP_DIST_SIGN)) 1081 if (!(smp->remote_key_dist & SMP_DIST_SIGN))
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h
index 1277147a9150..afd16231db13 100644
--- a/net/bluetooth/smp.h
+++ b/net/bluetooth/smp.h
@@ -111,6 +111,7 @@ struct smp_cmd_security_req {
111#define SMP_CMD_NOTSUPP 0x07 111#define SMP_CMD_NOTSUPP 0x07
112#define SMP_UNSPECIFIED 0x08 112#define SMP_UNSPECIFIED 0x08
113#define SMP_REPEATED_ATTEMPTS 0x09 113#define SMP_REPEATED_ATTEMPTS 0x09
114#define SMP_INVALID_PARAMS 0x0a
114 115
115#define SMP_MIN_ENC_KEY_SIZE 7 116#define SMP_MIN_ENC_KEY_SIZE 7
116#define SMP_MAX_ENC_KEY_SIZE 16 117#define SMP_MAX_ENC_KEY_SIZE 16