Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 237311
b: refs/heads/master
c: 053f021
h: refs/heads/master
i:
  237309: 237c01e
  237307: 9115340
  237303: 3e1c372
  237295: 7e292d8
  237279: 04b8cbf
  237247: e9a1e48
  237183: 88bd2c2
  237055: d093846
v: v3
  • Loading branch information
Johan Hedberg authored and Gustavo F. Padovan committed Feb 8, 2011
1 parent ce9d03b commit c9406ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 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: ebc99feba7378349e2bfae7018af062767382f6c
refs/heads/master: 053f0211d3b1a991f06a7b4aec5b762e42d7c6a4
50 changes: 29 additions & 21 deletions trunk/net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,34 @@ static int set_connectable(struct sock *sk, unsigned char *data, u16 len)
return err;
}

static int send_mode_rsp(struct sock *sk, u16 opcode, u16 index, u8 val)
{
struct mgmt_hdr *hdr;
struct mgmt_ev_cmd_complete *ev;
struct mgmt_mode *rp;
struct sk_buff *skb;

skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + sizeof(*rp), GFP_ATOMIC);
if (!skb)
return -ENOMEM;

hdr = (void *) skb_put(skb, sizeof(*hdr));
hdr->opcode = cpu_to_le16(MGMT_EV_CMD_COMPLETE);
hdr->len = cpu_to_le16(sizeof(*ev) + sizeof(*rp));

ev = (void *) skb_put(skb, sizeof(*ev));
put_unaligned_le16(opcode, &ev->opcode);

rp = (void *) skb_put(skb, sizeof(*rp));
put_unaligned_le16(index, &rp->index);
rp->val = val;

if (sock_queue_rcv_skb(sk, skb) < 0)
kfree_skb(skb);

return 0;
}

int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
{
unsigned char *buf;
Expand Down Expand Up @@ -594,33 +622,13 @@ struct cmd_lookup {

static void mode_rsp(struct pending_cmd *cmd, void *data)
{
struct mgmt_hdr *hdr;
struct mgmt_ev_cmd_complete *ev;
struct mgmt_mode *rp;
struct mgmt_mode *cp = cmd->cmd;
struct sk_buff *skb;
struct cmd_lookup *match = data;

if (cp->val != match->val)
return;

skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + sizeof(*rp), GFP_ATOMIC);
if (!skb)
return;

hdr = (void *) skb_put(skb, sizeof(*hdr));
hdr->opcode = cpu_to_le16(MGMT_EV_CMD_COMPLETE);
hdr->len = cpu_to_le16(sizeof(*ev) + sizeof(*rp));

ev = (void *) skb_put(skb, sizeof(*ev));
put_unaligned_le16(cmd->opcode, &ev->opcode);

rp = (void *) skb_put(skb, sizeof(*rp));
put_unaligned_le16(cmd->index, &rp->index);
rp->val = cp->val;

if (sock_queue_rcv_skb(cmd->sk, skb) < 0)
kfree_skb(skb);
send_mode_rsp(cmd->sk, cmd->opcode, cmd->index, cp->val);

list_del(&cmd->list);

Expand Down

0 comments on commit c9406ba

Please sign in to comment.