27 #include <linux/export.h>
34 static void hci_le_create_connection(
struct hci_conn *conn)
47 bacpy(&
cp.peer_addr, &conn->
dst);
58 static void hci_le_create_connection_cancel(
struct hci_conn *conn)
63 static void hci_acl_create_connection(
struct hci_conn *conn)
81 bacpy(&
cp.bdaddr, &conn->
dst);
82 cp.pscan_rep_mode = 0x02;
87 cp.pscan_rep_mode = ie->
data.pscan_rep_mode;
88 cp.pscan_mode = ie->
data.pscan_mode;
89 cp.clock_offset = ie->
data.clock_offset |
94 if (ie->
data.ssp_mode > 0)
100 cp.role_switch = 0x01;
102 cp.role_switch = 0x00;
107 static void hci_acl_create_connection_cancel(
struct hci_conn *conn)
116 bacpy(&
cp.bdaddr, &conn->
dst);
181 memset(&cp, 0,
sizeof(cp));
202 memset(&cp, 0,
sizeof(cp));
226 hci_add_sco(sco, conn->
handle);
228 hci_proto_connect_cfm(sco, status);
239 BT_DBG(
"hcon %p state %s", conn, state_to_string(conn->
state));
244 switch (conn->
state) {
249 hci_acl_create_connection_cancel(conn);
251 hci_le_create_connection_cancel(conn);
256 reason = hci_proto_disconn_ind(conn);
266 static void hci_conn_enter_sniff_mode(
struct hci_conn *conn)
301 static void hci_conn_idle(
unsigned long arg)
303 struct hci_conn *conn = (
void *) arg;
307 hci_conn_enter_sniff_mode(conn);
310 static void hci_conn_auto_accept(
unsigned long arg)
312 struct hci_conn *conn = (
void *) arg;
329 bacpy(&conn->
dst, dst);
358 skb_queue_head_init(&conn->
data_q);
364 setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
365 (
unsigned long) conn);
371 hci_conn_hash_add(hdev, conn);
419 hci_conn_hash_del(hdev, conn);
456 if (!bacmp(&d->bdaddr, src)) {
460 if (bacmp(&d->bdaddr, dst)) {
467 hdev = hci_dev_hold(hdev);
479 le = hci_conn_hash_lookup_ba(hdev,
LE_LINK, dst);
483 return ERR_PTR(-
EBUSY);
490 hci_le_create_connection(le);
501 static struct hci_conn *hci_connect_acl(
struct hci_dev *hdev, bdaddr_t *dst,
502 u8 sec_level,
u8 auth_type)
506 acl = hci_conn_hash_lookup_ba(hdev,
ACL_LINK, dst);
519 hci_acl_create_connection(acl);
526 bdaddr_t *dst,
u8 sec_level,
u8 auth_type)
531 acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
535 sco = hci_conn_hash_lookup_ba(hdev, type, dst);
574 return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
576 return hci_connect_acl(hdev, dst, sec_level, auth_type);
579 return hci_connect_sco(hdev, type, dst, sec_level, auth_type);
597 static int hci_conn_auth(
struct hci_conn *conn,
__u8 sec_level,
__u8 auth_type)
631 static void hci_conn_encrypt(
struct hci_conn *conn)
688 if (!hci_conn_auth(conn, sec_level, auth_type))
695 hci_conn_encrypt(conn);
804 hci_acl_create_connection(conn);
854 (ci + n)->type = c->
type;
856 (ci + n)->state = c->
state;
865 size =
sizeof(
req) + n *
sizeof(*ci);
886 conn = hci_conn_hash_lookup_ba(hdev, req.
type, &req.
bdaddr);
935 skb_queue_head_init(&chan->
data_q);
947 BT_DBG(
"%s hcon %p chan %p", hdev->
name, conn, chan);
949 list_del_rcu(&chan->
list);