diff options
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 9f5c5f244502..3843f1897c86 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -2047,15 +2047,53 @@ unlock: | |||
2047 | hci_conn_check_pending(hdev); | 2047 | hci_conn_check_pending(hdev); |
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | void hci_conn_accept(struct hci_conn *conn, int mask) | ||
2051 | { | ||
2052 | struct hci_dev *hdev = conn->hdev; | ||
2053 | |||
2054 | BT_DBG("conn %p", conn); | ||
2055 | |||
2056 | conn->state = BT_CONFIG; | ||
2057 | |||
2058 | if (!lmp_esco_capable(hdev)) { | ||
2059 | struct hci_cp_accept_conn_req cp; | ||
2060 | |||
2061 | bacpy(&cp.bdaddr, &conn->dst); | ||
2062 | |||
2063 | if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) | ||
2064 | cp.role = 0x00; /* Become master */ | ||
2065 | else | ||
2066 | cp.role = 0x01; /* Remain slave */ | ||
2067 | |||
2068 | hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); | ||
2069 | } else /* lmp_esco_capable(hdev)) */ { | ||
2070 | struct hci_cp_accept_sync_conn_req cp; | ||
2071 | |||
2072 | bacpy(&cp.bdaddr, &conn->dst); | ||
2073 | cp.pkt_type = cpu_to_le16(conn->pkt_type); | ||
2074 | |||
2075 | cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40); | ||
2076 | cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40); | ||
2077 | cp.max_latency = __constant_cpu_to_le16(0xffff); | ||
2078 | cp.content_format = cpu_to_le16(hdev->voice_setting); | ||
2079 | cp.retrans_effort = 0xff; | ||
2080 | |||
2081 | hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, | ||
2082 | sizeof(cp), &cp); | ||
2083 | } | ||
2084 | } | ||
2085 | |||
2050 | static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | 2086 | static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) |
2051 | { | 2087 | { |
2052 | struct hci_ev_conn_request *ev = (void *) skb->data; | 2088 | struct hci_ev_conn_request *ev = (void *) skb->data; |
2053 | int mask = hdev->link_mode; | 2089 | int mask = hdev->link_mode; |
2090 | __u8 flags = 0; | ||
2054 | 2091 | ||
2055 | BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr, | 2092 | BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr, |
2056 | ev->link_type); | 2093 | ev->link_type); |
2057 | 2094 | ||
2058 | mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type); | 2095 | mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type, |
2096 | &flags); | ||
2059 | 2097 | ||
2060 | if ((mask & HCI_LM_ACCEPT) && | 2098 | if ((mask & HCI_LM_ACCEPT) && |
2061 | !hci_blacklist_lookup(hdev, &ev->bdaddr)) { | 2099 | !hci_blacklist_lookup(hdev, &ev->bdaddr)) { |
@@ -2081,12 +2119,13 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2081 | } | 2119 | } |
2082 | 2120 | ||
2083 | memcpy(conn->dev_class, ev->dev_class, 3); | 2121 | memcpy(conn->dev_class, ev->dev_class, 3); |
2084 | conn->state = BT_CONNECT; | ||
2085 | 2122 | ||
2086 | hci_dev_unlock(hdev); | 2123 | hci_dev_unlock(hdev); |
2087 | 2124 | ||
2088 | if (ev->link_type == ACL_LINK || !lmp_esco_capable(hdev)) { | 2125 | if (ev->link_type == ACL_LINK || |
2126 | (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { | ||
2089 | struct hci_cp_accept_conn_req cp; | 2127 | struct hci_cp_accept_conn_req cp; |
2128 | conn->state = BT_CONNECT; | ||
2090 | 2129 | ||
2091 | bacpy(&cp.bdaddr, &ev->bdaddr); | 2130 | bacpy(&cp.bdaddr, &ev->bdaddr); |
2092 | 2131 | ||
@@ -2097,8 +2136,9 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2097 | 2136 | ||
2098 | hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), | 2137 | hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), |
2099 | &cp); | 2138 | &cp); |
2100 | } else { | 2139 | } else if (!(flags & HCI_PROTO_DEFER)) { |
2101 | struct hci_cp_accept_sync_conn_req cp; | 2140 | struct hci_cp_accept_sync_conn_req cp; |
2141 | conn->state = BT_CONNECT; | ||
2102 | 2142 | ||
2103 | bacpy(&cp.bdaddr, &ev->bdaddr); | 2143 | bacpy(&cp.bdaddr, &ev->bdaddr); |
2104 | cp.pkt_type = cpu_to_le16(conn->pkt_type); | 2144 | cp.pkt_type = cpu_to_le16(conn->pkt_type); |
@@ -2111,6 +2151,10 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2111 | 2151 | ||
2112 | hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, | 2152 | hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ, |
2113 | sizeof(cp), &cp); | 2153 | sizeof(cp), &cp); |
2154 | } else { | ||
2155 | conn->state = BT_CONNECT2; | ||
2156 | hci_proto_connect_cfm(conn, 0); | ||
2157 | hci_conn_put(conn); | ||
2114 | } | 2158 | } |
2115 | } else { | 2159 | } else { |
2116 | /* Connection rejected */ | 2160 | /* Connection rejected */ |