Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 279283
b: refs/heads/master
c: 14c0b60
h: refs/heads/master
i:
  279281: a1d3429
  279279: ab5f0e6
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo F. Padovan committed Dec 18, 2011
1 parent 547e0d0 commit 9706359
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 57 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: f7c6869cebe631582fdc2ac57459ee217ce9b015
refs/heads/master: 14c0b60829751135346d71e7d11649c4f72dc9af
4 changes: 4 additions & 0 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,16 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr);
/* HCI info for socket */
#define hci_pi(sk) ((struct hci_pinfo *) sk)

/* HCI socket flags */
#define HCI_PI_MGMT_INIT 0

struct hci_pinfo {
struct bt_sock bt;
struct hci_dev *hdev;
struct hci_filter filter;
__u32 cmsg_mask;
unsigned short channel;
unsigned long flags;
};

/* HCI security filter */
Expand Down
5 changes: 0 additions & 5 deletions trunk/include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ struct mgmt_cp_set_dev_class {
__u8 minor;
} __packed;

#define MGMT_OP_SET_SERVICE_CACHE 0x000C
struct mgmt_cp_set_service_cache {
__u8 enable;
} __packed;

struct mgmt_link_key_info {
bdaddr_t bdaddr;
u8 type;
Expand Down
7 changes: 5 additions & 2 deletions trunk/net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
if (haddr.hci_channel > HCI_CHANNEL_CONTROL)
return -EINVAL;

if (haddr.hci_channel == HCI_CHANNEL_CONTROL && !enable_mgmt)
return -EINVAL;
if (haddr.hci_channel == HCI_CHANNEL_CONTROL) {
if (!enable_mgmt)
return -EINVAL;
set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags);
}

lock_sock(sk);

Expand Down
56 changes: 7 additions & 49 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ static int read_controller_info(struct sock *sk, u16 index)

hci_dev_lock(hdev);

set_bit(HCI_MGMT, &hdev->flags);
if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) {
set_bit(HCI_MGMT, &hdev->flags);
set_bit(HCI_SERVICE_CACHE, &hdev->flags);
}

memset(&rp, 0, sizeof(rp));

Expand Down Expand Up @@ -989,6 +992,9 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
hdev->major_class = cp->major;
hdev->minor_class = cp->minor;

if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->flags))
update_eir(hdev);

err = update_class(hdev);

if (err == 0)
Expand All @@ -1000,51 +1006,6 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
return err;
}

static int set_service_cache(struct sock *sk, u16 index, unsigned char *data,
u16 len)
{
struct hci_dev *hdev;
struct mgmt_cp_set_service_cache *cp;
int err;

cp = (void *) data;

if (len != sizeof(*cp))
return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE,
MGMT_STATUS_INVALID_PARAMS);

hdev = hci_dev_get(index);
if (!hdev)
return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE,
MGMT_STATUS_INVALID_PARAMS);

hci_dev_lock(hdev);

BT_DBG("hci%u enable %d", index, cp->enable);

if (cp->enable) {
set_bit(HCI_SERVICE_CACHE, &hdev->flags);
err = 0;
} else {
clear_bit(HCI_SERVICE_CACHE, &hdev->flags);
err = update_class(hdev);
if (err == 0)
err = update_eir(hdev);
}

if (err == 0)
err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL,
0);
else
cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, -err);


hci_dev_unlock(hdev);
hci_dev_put(hdev);

return err;
}

static int load_link_keys(struct sock *sk, u16 index, unsigned char *data,
u16 len)
{
Expand Down Expand Up @@ -2170,9 +2131,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
case MGMT_OP_SET_DEV_CLASS:
err = set_dev_class(sk, index, buf + sizeof(*hdr), len);
break;
case MGMT_OP_SET_SERVICE_CACHE:
err = set_service_cache(sk, index, buf + sizeof(*hdr), len);
break;
case MGMT_OP_LOAD_LINK_KEYS:
err = load_link_keys(sk, index, buf + sizeof(*hdr), len);
break;
Expand Down

0 comments on commit 9706359

Please sign in to comment.