Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 266345
b: refs/heads/master
c: 6cd9d21
h: refs/heads/master
i:
  266343: b07c0a4
v: v3
  • Loading branch information
Luciano Coelho committed Sep 22, 2011
1 parent d9a54dd commit b6d6d54
Show file tree
Hide file tree
Showing 16 changed files with 301 additions and 545 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: bb8f2cb284f1afa430a252d306d2bb29f6b9ce64
refs/heads/master: 6cd9d21a0c1e2648c07c32c66bb25795ad3208aa
19 changes: 13 additions & 6 deletions trunk/drivers/net/wireless/wl12xx/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ static int wl1271_get_scan_channels(struct wl1271 *wl,
for (i = 0, j = 0;
i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
i++) {

flags = req->channels[i]->flags;

if (!test_bit(i, wl->scan.scanned_ch) &&
!(flags & IEEE80211_CHAN_DISABLED) &&
((!!(flags & IEEE80211_CHAN_PASSIVE_SCAN)) == passive) &&
(req->channels[i]->band == band)) {

(req->channels[i]->band == band) &&
/*
* In passive scans, we scan all remaining
* channels, even if not marked as such.
* In active scans, we only scan channels not
* marked as passive.
*/
(passive || !(flags & IEEE80211_CHAN_PASSIVE_SCAN))) {
wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
req->channels[i]->band,
req->channels[i]->center_freq);
Expand Down Expand Up @@ -158,15 +162,18 @@ static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
int ret;
u16 scan_options = 0;

/* skip active scans if we don't have SSIDs */
if (!passive && wl->scan.req->n_ssids == 0)
return WL1271_NOTHING_TO_SCAN;

cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
if (!cmd || !trigger) {
ret = -ENOMEM;
goto out;
}

/* No SSIDs means that we have a forced passive scan */
if (passive || wl->scan.req->n_ssids == 0)
if (passive)
scan_options |= WL1271_SCAN_OPT_PASSIVE;

if (WARN_ON(wl->role_id == WL12XX_INVALID_ROLE_ID)) {
Expand Down
10 changes: 0 additions & 10 deletions trunk/include/net/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,6 @@ struct hci_rp_read_bd_addr {
bdaddr_t bdaddr;
} __packed;

#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
struct hci_cp_write_page_scan_activity {
__le16 interval;
__le16 window;
} __packed;

#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
#define PAGE_SCAN_TYPE_STANDARD 0x00
#define PAGE_SCAN_TYPE_INTERLACED 0x01

#define HCI_OP_LE_SET_EVENT_MASK 0x2001
struct hci_cp_le_set_event_mask {
__u8 mask[8];
Expand Down
25 changes: 4 additions & 21 deletions trunk/include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ struct hci_dev {

__u16 init_last_cmd;

struct crypto_blkcipher *tfm;

struct inquiry_cache inq_cache;
struct hci_conn_hash conn_hash;
struct list_head blacklist;
Expand Down Expand Up @@ -346,7 +348,6 @@ enum {
HCI_CONN_RSWITCH_PEND,
HCI_CONN_MODE_CHANGE_PEND,
HCI_CONN_SCO_SETUP_PEND,
HCI_CONN_LE_SMP_PEND,
};

static inline void hci_conn_hash_init(struct hci_dev *hdev)
Expand Down Expand Up @@ -394,22 +395,6 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
}
}

static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
{
struct hci_conn_hash *h = &hdev->conn_hash;
switch (type) {
case ACL_LINK:
return h->acl_num;
case LE_LINK:
return h->le_num;
case SCO_LINK:
case ESCO_LINK:
return h->sco_num;
default:
return 0;
}
}

static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
__u16 handle)
{
Expand Down Expand Up @@ -490,7 +475,7 @@ static inline void hci_conn_put(struct hci_conn *conn)
{
if (atomic_dec_and_test(&conn->refcnt)) {
unsigned long timeo;
if (conn->type == ACL_LINK || conn->type == LE_LINK) {
if (conn->type == ACL_LINK) {
del_timer(&conn->idle_timer);
if (conn->state == BT_CONNECTED) {
timeo = msecs_to_jiffies(conn->disc_timeout);
Expand Down Expand Up @@ -853,7 +838,7 @@ int mgmt_powered(u16 index, u8 powered);
int mgmt_discoverable(u16 index, u8 discoverable);
int mgmt_connectable(u16 index, u8 connectable);
int mgmt_new_key(u16 index, struct link_key *key, u8 persistent);
int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type);
int mgmt_connected(u16 index, bdaddr_t *bdaddr);
int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
int mgmt_disconnect_failed(u16 index);
int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
Expand All @@ -873,8 +858,6 @@ int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
u8 *eir);
int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);
int mgmt_discovering(u16 index, u8 discovering);
int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr);
int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr);

/* HCI info for socket */
#define hci_pi(sk) ((struct hci_pinfo *) sk)
Expand Down
8 changes: 7 additions & 1 deletion trunk/include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,14 @@ struct l2cap_conn {

__u8 disc_reason;

__u8 preq[7]; /* SMP Pairing Request */
__u8 prsp[7]; /* SMP Pairing Response */
__u8 prnd[16]; /* SMP Pairing Random */
__u8 pcnf[16]; /* SMP Pairing Confirm */
__u8 tk[16]; /* SMP Temporary Key */
__u8 smp_key_size;

struct timer_list security_timer;
struct smp_chan *smp_chan;

struct list_head chan_l;
rwlock_t chan_lock;
Expand Down
16 changes: 0 additions & 16 deletions trunk/include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@ struct mgmt_cp_unblock_device {
bdaddr_t bdaddr;
} __packed;

#define MGMT_OP_SET_FAST_CONNECTABLE 0x001F
struct mgmt_cp_set_fast_connectable {
__u8 enable;
} __packed;

#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
Expand Down Expand Up @@ -254,7 +249,6 @@ struct mgmt_ev_new_key {
#define MGMT_EV_CONNECTED 0x000B
struct mgmt_ev_connected {
bdaddr_t bdaddr;
__u8 link_type;
} __packed;

#define MGMT_EV_DISCONNECTED 0x000C
Expand Down Expand Up @@ -307,13 +301,3 @@ struct mgmt_ev_remote_name {
} __packed;

#define MGMT_EV_DISCOVERING 0x0014

#define MGMT_EV_DEVICE_BLOCKED 0x0015
struct mgmt_ev_device_blocked {
bdaddr_t bdaddr;
} __packed;

#define MGMT_EV_DEVICE_UNBLOCKED 0x0016
struct mgmt_ev_device_unblocked {
bdaddr_t bdaddr;
} __packed;
17 changes: 0 additions & 17 deletions trunk/include/net/bluetooth/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,9 @@ struct smp_cmd_security_req {
#define SMP_MIN_ENC_KEY_SIZE 7
#define SMP_MAX_ENC_KEY_SIZE 16

struct smp_chan {
struct l2cap_conn *conn;
u8 preq[7]; /* SMP Pairing Request */
u8 prsp[7]; /* SMP Pairing Response */
u8 prnd[16]; /* SMP Pairing Random (local) */
u8 rrnd[16]; /* SMP Pairing Random (remote) */
u8 pcnf[16]; /* SMP Pairing Confirm */
u8 tk[16]; /* SMP Temporary Key */
u8 smp_key_size;
struct crypto_blkcipher *tfm;
struct work_struct confirm;
struct work_struct random;

};

/* SMP Commands */
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);

void smp_chan_destroy(struct l2cap_conn *conn);

#endif /* __SMP_H */
2 changes: 1 addition & 1 deletion trunk/net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
cp.handle = cpu_to_le16(conn->handle);
memcpy(cp.ltk, ltk, sizeof(cp.ltk));
cp.ediv = ediv;
memcpy(cp.rand, rand, sizeof(cp.rand));
memcpy(cp.rand, rand, sizeof(rand));

hci_send_cmd(hdev, HCI_OP_LE_START_ENC, sizeof(cp), &cp);
}
Expand Down
57 changes: 34 additions & 23 deletions trunk/net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,41 +1312,59 @@ int hci_blacklist_clear(struct hci_dev *hdev)
int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr)
{
struct bdaddr_list *entry;
int err;

if (bacmp(bdaddr, BDADDR_ANY) == 0)
return -EBADF;

if (hci_blacklist_lookup(hdev, bdaddr))
return -EEXIST;
hci_dev_lock_bh(hdev);

if (hci_blacklist_lookup(hdev, bdaddr)) {
err = -EEXIST;
goto err;
}

entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
if (!entry)
return -ENOMEM;
if (!entry) {
err = -ENOMEM;
goto err;
}

bacpy(&entry->bdaddr, bdaddr);

list_add(&entry->list, &hdev->blacklist);

return mgmt_device_blocked(hdev->id, bdaddr);
err = 0;

err:
hci_dev_unlock_bh(hdev);
return err;
}

int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr)
{
struct bdaddr_list *entry;
int err = 0;

hci_dev_lock_bh(hdev);

if (bacmp(bdaddr, BDADDR_ANY) == 0) {
return hci_blacklist_clear(hdev);
hci_blacklist_clear(hdev);
goto done;
}

entry = hci_blacklist_lookup(hdev, bdaddr);
if (!entry) {
return -ENOENT;
err = -ENOENT;
goto done;
}

list_del(&entry->list);
kfree(entry);

return mgmt_device_unblocked(hdev->id, bdaddr);
done:
hci_dev_unlock_bh(hdev);
return err;
}

static void hci_clear_adv_cache(unsigned long arg)
Expand Down Expand Up @@ -1505,6 +1523,11 @@ int hci_register_dev(struct hci_dev *hdev)
if (!hdev->workqueue)
goto nomem;

hdev->tfm = crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(hdev->tfm))
BT_INFO("Failed to load transform for ecb(aes): %ld",
PTR_ERR(hdev->tfm));

hci_register_sysfs(hdev);

hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev,
Expand Down Expand Up @@ -1553,6 +1576,9 @@ int hci_unregister_dev(struct hci_dev *hdev)
!test_bit(HCI_SETUP, &hdev->flags))
mgmt_index_removed(hdev->id);

if (!IS_ERR(hdev->tfm))
crypto_free_blkcipher(hdev->tfm);

hci_notify(hdev, HCI_DEV_UNREG);

if (hdev->rfkill) {
Expand Down Expand Up @@ -2048,9 +2074,6 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
min = c->sent;
conn = c;
}

if (hci_conn_num(hdev, type) == num)
break;
}

if (conn) {
Expand Down Expand Up @@ -2108,9 +2131,6 @@ static inline void hci_sched_acl(struct hci_dev *hdev)

BT_DBG("%s", hdev->name);

if (!hci_conn_num(hdev, ACL_LINK))
return;

if (!test_bit(HCI_RAW, &hdev->flags)) {
/* ACL tx timeout must be longer than maximum
* link supervision timeout (40.9 seconds) */
Expand Down Expand Up @@ -2142,9 +2162,6 @@ static inline void hci_sched_sco(struct hci_dev *hdev)

BT_DBG("%s", hdev->name);

if (!hci_conn_num(hdev, SCO_LINK))
return;

while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
BT_DBG("skb %p len %d", skb, skb->len);
Expand All @@ -2165,9 +2182,6 @@ static inline void hci_sched_esco(struct hci_dev *hdev)

BT_DBG("%s", hdev->name);

if (!hci_conn_num(hdev, ESCO_LINK))
return;

while (hdev->sco_cnt && (conn = hci_low_sent(hdev, ESCO_LINK, &quote))) {
while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
BT_DBG("skb %p len %d", skb, skb->len);
Expand All @@ -2188,9 +2202,6 @@ static inline void hci_sched_le(struct hci_dev *hdev)

BT_DBG("%s", hdev->name);

if (!hci_conn_num(hdev, LE_LINK))
return;

if (!test_bit(HCI_RAW, &hdev->flags)) {
/* LE tx timeout must be longer than maximum
* link supervision timeout (40.9 seconds) */
Expand Down
Loading

0 comments on commit b6d6d54

Please sign in to comment.