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