Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 314451
b: refs/heads/master
c: 6b44d9b
h: refs/heads/master
i:
  314449: 73d1c39
  314447: b7f2b66
v: v3
  • Loading branch information
Andrei Emeltchenko authored and Johan Hedberg committed Jun 5, 2012
1 parent e366741 commit 77acd26
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e7af522e04bcf68caae6802722efc5c6e8fa63a7
refs/heads/master: 6b44d9b8d96b37f72ccd7335b32f386a67b7f1f4
65 changes: 65 additions & 0 deletions trunk/net/bluetooth/a2mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,70 @@ static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len,
kfree(cmd);
}

/* Handle A2MP signalling */
static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
{
struct a2mp_cmd *hdr = (void *) skb->data;
struct amp_mgr *mgr = chan->data;
int err = 0;

amp_mgr_get(mgr);

while (skb->len >= sizeof(*hdr)) {
struct a2mp_cmd *hdr = (void *) skb->data;
u16 len = le16_to_cpu(hdr->len);

BT_DBG("code 0x%02x id %d len %d", hdr->code, hdr->ident, len);

skb_pull(skb, sizeof(*hdr));

if (len > skb->len || !hdr->ident) {
err = -EINVAL;
break;
}

mgr->ident = hdr->ident;

switch (hdr->code) {
case A2MP_COMMAND_REJ:
case A2MP_DISCOVER_REQ:
case A2MP_CHANGE_NOTIFY:
case A2MP_GETINFO_REQ:
case A2MP_GETAMPASSOC_REQ:
case A2MP_CREATEPHYSLINK_REQ:
case A2MP_DISCONNPHYSLINK_REQ:
case A2MP_CHANGE_RSP:
case A2MP_DISCOVER_RSP:
case A2MP_GETINFO_RSP:
case A2MP_GETAMPASSOC_RSP:
case A2MP_CREATEPHYSLINK_RSP:
case A2MP_DISCONNPHYSLINK_RSP:
default:
BT_ERR("Unknown A2MP sig cmd 0x%2.2x", hdr->code);
err = -EINVAL;
break;
}
}

if (err) {
struct a2mp_cmd_rej rej;
rej.reason = __constant_cpu_to_le16(0);

BT_DBG("Send A2MP Rej: cmd 0x%2.2x err %d", hdr->code, err);

a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej),
&rej);
}

/* Always free skb and return success error code to prevent
from sending L2CAP Disconnect over A2MP channel */
kfree_skb(skb);

amp_mgr_put(mgr);

return 0;
}

static void a2mp_chan_close_cb(struct l2cap_chan *chan)
{
l2cap_chan_destroy(chan);
Expand Down Expand Up @@ -112,6 +176,7 @@ static void a2mp_chan_no_ready(struct l2cap_chan *chan)

static struct l2cap_ops a2mp_chan_ops = {
.name = "L2CAP A2MP channel",
.recv = a2mp_chan_recv_cb,
.close = a2mp_chan_close_cb,
.state_change = a2mp_chan_state_change_cb,
.alloc_skb = a2mp_chan_alloc_skb_cb,
Expand Down

0 comments on commit 77acd26

Please sign in to comment.