Bluetooth: A2MP: Manage incoming connections
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Tue, 29 May 2012 10:59:17 +0000 (13:59 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Tue, 5 Jun 2012 03:34:14 +0000 (06:34 +0300)
Handle incoming A2MP connection by creating AMP manager and
processing A2MP messages.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
include/net/bluetooth/a2mp.h
net/bluetooth/a2mp.c
net/bluetooth/l2cap_core.c

index 96f9cc2cf59b4b9d7d69fd09ae48c7bc686a3d56..6a76e0a0705eff9926c3558c3120f6cfab71eb71 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef __A2MP_H
 #define __A2MP_H
 
+#include <net/bluetooth/l2cap.h>
+
 #define A2MP_FEAT_EXT  0x8000
 
 struct amp_mgr {
@@ -118,5 +120,7 @@ struct a2mp_physlink_rsp {
 
 void amp_mgr_get(struct amp_mgr *mgr);
 int amp_mgr_put(struct amp_mgr *mgr);
+struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
+                                      struct sk_buff *skb);
 
 #endif /* __A2MP_H */
index f1ec1b1d308f2e2e6dd83f9ae5fbf57f34141d3f..e08ca2ac31aa4bf10173671d8c41235d2596e920 100644 (file)
@@ -569,3 +569,19 @@ static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn)
 
        return mgr;
 }
+
+struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
+                                      struct sk_buff *skb)
+{
+       struct amp_mgr *mgr;
+
+       mgr = amp_mgr_create(conn);
+       if (!mgr) {
+               BT_ERR("Could not create AMP manager");
+               return NULL;
+       }
+
+       BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan);
+
+       return mgr->a2mp_chan;
+}
index fc572795497a1d520ecae52309b80ed4e0eca825..3daac2c6b7b4771d8626964a04f3e448e9f61909 100644 (file)
@@ -37,6 +37,7 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/l2cap.h>
 #include <net/bluetooth/smp.h>
+#include <net/bluetooth/a2mp.h>
 
 bool disable_ertm;
 
@@ -5132,10 +5133,20 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
 
        chan = l2cap_get_chan_by_scid(conn, cid);
        if (!chan) {
-               BT_DBG("unknown cid 0x%4.4x", cid);
-               /* Drop packet and return */
-               kfree_skb(skb);
-               return 0;
+               if (cid == L2CAP_CID_A2MP) {
+                       chan = a2mp_channel_create(conn, skb);
+                       if (!chan) {
+                               kfree_skb(skb);
+                               return 0;
+                       }
+
+                       l2cap_chan_lock(chan);
+               } else {
+                       BT_DBG("unknown cid 0x%4.4x", cid);
+                       /* Drop packet and return */
+                       kfree_skb(skb);
+                       return 0;
+               }
        }
 
        BT_DBG("chan %p, len %d", chan, skb->len);
This page took 0.034635 seconds and 5 git commands to generate.