Home | History | Annotate | Line # | Download | only in netbt
bt_proto.c revision 1.1
      1  1.1  gdamore /*	$NetBSD: bt_proto.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $	*/
      2  1.1  gdamore 
      3  1.1  gdamore /*-
      4  1.1  gdamore  * Copyright (c) 2005 Iain Hibbert.
      5  1.1  gdamore  * Copyright (c) 2006 Itronix Inc.
      6  1.1  gdamore  * All rights reserved.
      7  1.1  gdamore  *
      8  1.1  gdamore  * Redistribution and use in source and binary forms, with or without
      9  1.1  gdamore  * modification, are permitted provided that the following conditions
     10  1.1  gdamore  * are met:
     11  1.1  gdamore  * 1. Redistributions of source code must retain the above copyright
     12  1.1  gdamore  *    notice, this list of conditions and the following disclaimer.
     13  1.1  gdamore  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  gdamore  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  gdamore  *    documentation and/or other materials provided with the distribution.
     16  1.1  gdamore  * 3. The name of Itronix Inc. may not be used to endorse
     17  1.1  gdamore  *    or promote products derived from this software without specific
     18  1.1  gdamore  *    prior written permission.
     19  1.1  gdamore  *
     20  1.1  gdamore  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
     21  1.1  gdamore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.1  gdamore  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.1  gdamore  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
     24  1.1  gdamore  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     25  1.1  gdamore  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26  1.1  gdamore  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     27  1.1  gdamore  * ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.1  gdamore  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.1  gdamore  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.1  gdamore  * POSSIBILITY OF SUCH DAMAGE.
     31  1.1  gdamore  */
     32  1.1  gdamore 
     33  1.1  gdamore #include <sys/cdefs.h>
     34  1.1  gdamore __KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $");
     35  1.1  gdamore 
     36  1.1  gdamore #include <sys/param.h>
     37  1.1  gdamore #include <sys/domain.h>
     38  1.1  gdamore #include <sys/kernel.h>
     39  1.1  gdamore #include <sys/protosw.h>
     40  1.1  gdamore #include <sys/socket.h>
     41  1.1  gdamore #include <sys/systm.h>
     42  1.1  gdamore 
     43  1.1  gdamore #include <net/route.h>
     44  1.1  gdamore 
     45  1.1  gdamore #include <netbt/bluetooth.h>
     46  1.1  gdamore #include <netbt/hci.h>
     47  1.1  gdamore #include <netbt/l2cap.h>
     48  1.1  gdamore #include <netbt/rfcomm.h>
     49  1.1  gdamore #include <netbt/sco.h>
     50  1.1  gdamore 
     51  1.1  gdamore DOMAIN_DEFINE(btdomain);	/* forward declare and add to link set */
     52  1.1  gdamore 
     53  1.1  gdamore const struct protosw btsw[] = {
     54  1.1  gdamore     {	/* raw HCI commands */
     55  1.1  gdamore 	SOCK_RAW,	&btdomain,
     56  1.1  gdamore 	BTPROTO_HCI,	PR_ADDR | PR_ATOMIC,
     57  1.1  gdamore 	NULL,		NULL,		NULL,		hci_ctloutput,
     58  1.1  gdamore 	hci_usrreq,	NULL,		NULL,		NULL,
     59  1.1  gdamore 	hci_drain,
     60  1.1  gdamore     },
     61  1.1  gdamore #ifdef BLUETOOTH_SCO
     62  1.1  gdamore     {	/* HCI SCO data (audio) */
     63  1.1  gdamore 	SOCK_SEQPACKET,	&btdomain,
     64  1.1  gdamore 	BTPROTO_SCO,	PR_CONNREQUIRED | PR_ATOMIC,
     65  1.1  gdamore 	NULL,		NULL,		NULL,		sco_ctloutput,
     66  1.1  gdamore 	sco_usrreq,	NULL,		NULL,		NULL,
     67  1.1  gdamore 	NULL,
     68  1.1  gdamore     },
     69  1.1  gdamore #endif
     70  1.1  gdamore     {	/* L2CAP Connection Oriented */
     71  1.1  gdamore 	SOCK_SEQPACKET,	&btdomain,
     72  1.1  gdamore 	BTPROTO_L2CAP,	PR_CONNREQUIRED | PR_ATOMIC | PR_LISTEN,
     73  1.1  gdamore 	NULL,		NULL,		NULL,		l2cap_ctloutput,
     74  1.1  gdamore 	l2cap_usrreq,	NULL,		NULL,		NULL,
     75  1.1  gdamore 	NULL,
     76  1.1  gdamore     },
     77  1.1  gdamore #if 0
     78  1.1  gdamore     {	/* L2CAP Ping Requests */
     79  1.1  gdamore 	SOCK_RAW,	&btdomain,
     80  1.1  gdamore 	BTPROTO_L2CAP,	PR_ADDR | PR_ATOMIC,
     81  1.1  gdamore 	NULL,		NULL,		NULL,		NULL,
     82  1.1  gdamore 	NULL,		NULL,		NULL,		NULL,
     83  1.1  gdamore 	NULL,
     84  1.1  gdamore     },
     85  1.1  gdamore     {	/* L2CAP Connectionless */
     86  1.1  gdamore 	SOCK_DGRAM,	&btdomain,
     87  1.1  gdamore 	BTPROTO_L2CAP,	PR_ADDR | PR_ATOMIC,
     88  1.1  gdamore 	NULL,		NULL,		NULL,		NULL,
     89  1.1  gdamore 	NULL,		NULL,		NULL,		NULL,
     90  1.1  gdamore 	NULL,
     91  1.1  gdamore     },
     92  1.1  gdamore #endif
     93  1.1  gdamore     {	/* RFCOMM */
     94  1.1  gdamore 	SOCK_STREAM,	&btdomain,
     95  1.1  gdamore 	BTPROTO_RFCOMM,	PR_CONNREQUIRED | PR_LISTEN | PR_WANTRCVD,
     96  1.1  gdamore 	NULL,		NULL,		NULL,		rfcomm_ctloutput,
     97  1.1  gdamore 	rfcomm_usrreq,	NULL,		NULL,		NULL,
     98  1.1  gdamore 	NULL,
     99  1.1  gdamore     }
    100  1.1  gdamore };
    101  1.1  gdamore 
    102  1.1  gdamore struct domain btdomain = {
    103  1.1  gdamore 	AF_BLUETOOTH,			/* family */
    104  1.1  gdamore 	"bluetooth",			/* name */
    105  1.1  gdamore 	NULL,				/* init routine */
    106  1.1  gdamore 	NULL,				/* externalise access rights */
    107  1.1  gdamore 	NULL,				/* dispose of internalised rights */
    108  1.1  gdamore 	btsw,				/* protosw */
    109  1.1  gdamore 	&btsw[sizeof(btsw)/sizeof(btsw[0])],	/* NPROTOSW */
    110  1.1  gdamore 	NULL,				/* attach to routing table */
    111  1.1  gdamore 	32,				/* rtoffset */
    112  1.1  gdamore 	sizeof(struct sockaddr_bt),	/* maxrtkey */
    113  1.1  gdamore };
    114