Commit 2983fd68 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Johan Hedberg

Bluetooth: Define and use PSM identifiers

Define assigned Protocol and Service Multiplexor (PSM) identifiers
and use them instead of magic numbers.
Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 6d3c730f
...@@ -229,6 +229,10 @@ struct l2cap_conn_rsp { ...@@ -229,6 +229,10 @@ struct l2cap_conn_rsp {
__le16 status; __le16 status;
} __packed; } __packed;
/* protocol/service multiplexer (PSM) */
#define L2CAP_PSM_SDP 0x0001
#define L2CAP_PSM_RFCOMM 0x0003
/* channel indentifier */ /* channel indentifier */
#define L2CAP_CID_SIGNALING 0x0001 #define L2CAP_CID_SIGNALING 0x0001
#define L2CAP_CID_CONN_LESS 0x0002 #define L2CAP_CID_CONN_LESS 0x0002
......
...@@ -648,7 +648,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) ...@@ -648,7 +648,7 @@ static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan)
default: default:
return HCI_AT_NO_BONDING; return HCI_AT_NO_BONDING;
} }
} else if (chan->psm == cpu_to_le16(0x0001)) { } else if (chan->psm == __constant_cpu_to_le16(L2CAP_PSM_SDP)) {
if (chan->sec_level == BT_SECURITY_LOW) if (chan->sec_level == BT_SECURITY_LOW)
chan->sec_level = BT_SECURITY_SDP; chan->sec_level = BT_SECURITY_SDP;
...@@ -3393,7 +3393,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -3393,7 +3393,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
lock_sock(parent); lock_sock(parent);
/* Check if the ACL is secure enough (if not SDP) */ /* Check if the ACL is secure enough (if not SDP) */
if (psm != cpu_to_le16(0x0001) && if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) &&
!hci_conn_check_link_mode(conn->hcon)) { !hci_conn_check_link_mode(conn->hcon)) {
conn->disc_reason = HCI_ERROR_AUTH_FAILURE; conn->disc_reason = HCI_ERROR_AUTH_FAILURE;
result = L2CAP_CR_SEC_BLOCK; result = L2CAP_CR_SEC_BLOCK;
......
...@@ -88,8 +88,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) ...@@ -88,8 +88,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
if (err < 0) if (err < 0)
goto done; goto done;
if (__le16_to_cpu(la.l2_psm) == 0x0001 || if (__le16_to_cpu(la.l2_psm) == L2CAP_PSM_SDP ||
__le16_to_cpu(la.l2_psm) == 0x0003) __le16_to_cpu(la.l2_psm) == L2CAP_PSM_RFCOMM)
chan->sec_level = BT_SECURITY_SDP; chan->sec_level = BT_SECURITY_SDP;
bacpy(&bt_sk(sk)->src, &la.l2_bdaddr); bacpy(&bt_sk(sk)->src, &la.l2_bdaddr);
......
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