Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 247256
b: refs/heads/master
c: 9f61656
h: refs/heads/master
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo F. Padovan committed Apr 28, 2011
1 parent cbc5168 commit 5631ff9
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7a828908a026d801c6192fd32cfb35d6843f1539
refs/heads/master: 9f61656a60c9506e3e4cd41af5efbcf6a30ee3b9
3 changes: 3 additions & 0 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ struct hci_dev {
__u16 sniff_min_interval;
__u16 sniff_max_interval;

unsigned int auto_accept_delay;

unsigned long quirks;

atomic_t cmd_cnt;
Expand Down Expand Up @@ -246,6 +248,7 @@ struct hci_conn {

struct timer_list disc_timer;
struct timer_list idle_timer;
struct timer_list auto_accept_timer;

struct work_struct work_add;
struct work_struct work_del;
Expand Down
17 changes: 17 additions & 0 deletions trunk/net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ static void hci_conn_idle(unsigned long arg)
hci_conn_enter_sniff_mode(conn);
}

static void hci_conn_auto_accept(unsigned long arg)
{
struct hci_conn *conn = (void *) arg;
struct hci_dev *hdev = conn->hdev;

hci_dev_lock(hdev);

hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
&conn->dst);

hci_dev_unlock(hdev);
}

struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
{
struct hci_conn *conn;
Expand Down Expand Up @@ -312,6 +325,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)

setup_timer(&conn->disc_timer, hci_conn_timeout, (unsigned long)conn);
setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
(unsigned long) conn);

atomic_set(&conn->refcnt, 0);

Expand Down Expand Up @@ -342,6 +357,8 @@ int hci_conn_del(struct hci_conn *conn)

del_timer(&conn->disc_timer);

del_timer(&conn->auto_accept_timer);

if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
if (sco)
Expand Down
10 changes: 9 additions & 1 deletion trunk/net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,15 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
/* If no side requires MITM protection; auto-accept */
if ((!loc_mitm || conn->remote_cap == 0x03) &&
(!rem_mitm || conn->io_capability == 0x03)) {
BT_DBG("Auto-accept of user confirmation");
BT_DBG("Auto-accept of user confirmation with %ums delay",
hdev->auto_accept_delay);

if (hdev->auto_accept_delay > 0) {
int delay = msecs_to_jiffies(hdev->auto_accept_delay);
mod_timer(&conn->auto_accept_timer, jiffies + delay);
goto unlock;
}

hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY,
sizeof(ev->bdaddr), &ev->bdaddr);
goto unlock;
Expand Down
31 changes: 31 additions & 0 deletions trunk/net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,35 @@ static const struct file_operations uuids_fops = {
.release = single_release,
};

static int auto_accept_delay_set(void *data, u64 val)
{
struct hci_dev *hdev = data;

hci_dev_lock_bh(hdev);

hdev->auto_accept_delay = val;

hci_dev_unlock_bh(hdev);

return 0;
}

static int auto_accept_delay_get(void *data, u64 *val)
{
struct hci_dev *hdev = data;

hci_dev_lock_bh(hdev);

*val = hdev->auto_accept_delay;

hci_dev_unlock_bh(hdev);

return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
auto_accept_delay_set, "%llu\n");

int hci_register_sysfs(struct hci_dev *hdev)
{
struct device *dev = &hdev->dev;
Expand Down Expand Up @@ -545,6 +574,8 @@ int hci_register_sysfs(struct hci_dev *hdev)

debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);

debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs, hdev,
&auto_accept_delay_fops);
return 0;
}

Expand Down

0 comments on commit 5631ff9

Please sign in to comment.