Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netbt respond to L2CAP Information requests



details:   https://anonhg.NetBSD.org/src/rev/3722ad82ff2b
branches:  trunk
changeset: 761744:3722ad82ff2b
user:      plunky <plunky%NetBSD.org@localhost>
date:      Sun Feb 06 18:50:59 2011 +0000

description:
respond to L2CAP Information requests

diffstat:

 sys/netbt/l2cap.h        |  15 +++--------
 sys/netbt/l2cap_signal.c |  59 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 51 insertions(+), 23 deletions(-)

diffs (141 lines):

diff -r a5e35ddb1132 -r 3722ad82ff2b sys/netbt/l2cap.h
--- a/sys/netbt/l2cap.h Sun Feb 06 18:47:55 2011 +0000
+++ b/sys/netbt/l2cap.h Sun Feb 06 18:50:59 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $  */
+/*     $NetBSD: l2cap.h,v 1.10 2011/02/06 18:50:59 plunky Exp $        */
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -54,7 +54,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: l2cap.h,v 1.9 2009/09/13 18:45:11 pooka Exp $
+ * $Id: l2cap.h,v 1.10 2011/02/06 18:50:59 plunky Exp $
  * $FreeBSD: src/sys/netgraph/bluetooth/include/l2cap.h,v 1.4 2005/08/31 18:13:23 emax Exp $
  */
 
@@ -166,7 +166,8 @@
 /* L2CAP Information request type codes */
 #define L2CAP_CONNLESS_MTU             0x0001
 #define L2CAP_EXTENDED_FEATURES                0x0002
-/* 0x0003 - 0xffff - reserved for future use */
+#define L2CAP_FIXED_CHANNELS           0x0003
+/* 0x0004 - 0xffff - reserved for future use */
 
 /* L2CAP Information response codes */
 #define L2CAP_NOT_SUPPORTED            0x0001
@@ -320,17 +321,9 @@
        uint16_t        type;   /* requested information type */
        uint16_t        result; /* 0x00 - success */
 /*     uint8_t info[]  -- info data (depends on type)
- *
- * L2CAP_CONNLESS_MTU - 2 bytes connectionless MTU
  */
 } __packed l2cap_info_rsp_cp;
 
-typedef union {
-       /* L2CAP_CONNLESS_MTU */
-       struct {
-               uint16_t        mtu;
-       } __packed mtu;
-} l2cap_info_rsp_data_t;
 
 /**************************************************************************
  **************************************************************************
diff -r a5e35ddb1132 -r 3722ad82ff2b sys/netbt/l2cap_signal.c
--- a/sys/netbt/l2cap_signal.c  Sun Feb 06 18:47:55 2011 +0000
+++ b/sys/netbt/l2cap_signal.c  Sun Feb 06 18:50:59 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: l2cap_signal.c,v 1.11 2010/11/17 20:19:25 plunky Exp $ */
+/*     $NetBSD: l2cap_signal.c,v 1.12 2011/02/06 18:51:00 plunky Exp $ */
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: l2cap_signal.c,v 1.11 2010/11/17 20:19:25 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: l2cap_signal.c,v 1.12 2011/02/06 18:51:00 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -857,15 +857,14 @@
 }
 
 /*
- * Process Received Info Request. We must respond but alas dont
- * support anything as yet so thats easy.
+ * Process Received Info Request.
  */
 static void
 l2cap_recv_info_req(struct mbuf *m, struct hci_link *link)
 {
        l2cap_cmd_hdr_t cmd;
        l2cap_info_req_cp cp;
-       l2cap_info_rsp_cp rp;
+       uint8_t rsp[12];
 
        m_copydata(m, 0, sizeof(cmd), &cmd);
        m_adj(m, sizeof(cmd));
@@ -873,15 +872,51 @@
        m_copydata(m, 0, sizeof(cp), &cp);
        m_adj(m, sizeof(cp));
 
-       switch(le16toh(cp.type)) {
+       cp.type = le16toh(cp.type);
+       switch(cp.type) {
+       case L2CAP_EXTENDED_FEATURES:
+               /*
+                * 32-bit data field, unused bits set to zero
+                *
+                * octet bit feature
+                *   0   0   Flow control mode
+                *   0   1   Retransmission mode
+                *   0   2   Bi-directional QoS
+                *   0   3   Enhanced retransmission mode
+                *   0   4   Streaming mode
+                *   0   5   FCS option
+                *   0   6   Extended flow specification for BR/EDR
+                *   0   7   Fixed channels (SET)
+                *   1   0   Extended window size
+                *   1   1   Unicast connectionless data reception
+                */
+               le16enc(rsp + 0, cp.type);
+               le16enc(rsp + 2, L2CAP_SUCCESS);
+               le32enc(rsp + 4, 0x00000080);
+               l2cap_send_signal(link, L2CAP_INFO_RSP, cmd.ident, 8, rsp);
+               break;
+
+       case L2CAP_FIXED_CHANNELS:
+               /*
+                * 64-bit data field, unused bits set to zero
+                *
+                * octet bit channel
+                *   0   0   0x0000 Null
+                *   0   1   0x0001 L2CAP Signalling Channel (SET)
+                *   0   2   0x0002 Connectionless Reception
+                *   0   3   0x0003 AMP Manager Protocol Channel
+                */
+               le16enc(rsp + 0, cp.type);
+               le16enc(rsp + 2, L2CAP_SUCCESS);
+               le64enc(rsp + 4, 0x0000000000000002);
+               l2cap_send_signal(link, L2CAP_INFO_RSP, cmd.ident, 12, rsp);
+               break;
+
        case L2CAP_CONNLESS_MTU:
-       case L2CAP_EXTENDED_FEATURES:
        default:
-               rp.type = cp.type;
-               rp.result = htole16(L2CAP_NOT_SUPPORTED);
-
-               l2cap_send_signal(link, L2CAP_INFO_RSP, cmd.ident,
-                                       sizeof(rp), &rp);
+               le16enc(rsp + 0, cp.type);
+               le16enc(rsp + 2, L2CAP_NOT_SUPPORTED);
+               l2cap_send_signal(link, L2CAP_INFO_RSP, cmd.ident, 4, rsp);
                break;
        }
 }



Home | Main Index | Thread Index | Old Index