1 /* 2 * ng_btsocket_sco.h 3 */ 4 5 /*- 6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * $Id: ng_btsocket_sco.h,v 1.3 2005/10/31 18:08:52 max Exp $ 31 * $FreeBSD$ 32 */ 33 34 #ifndef _NETGRAPH_BTSOCKET_SCO_H_ 35 #define _NETGRAPH_BTSOCKET_SCO_H_ 36 37 /* 38 * SCO routing entry 39 */ 40 41 struct ng_hook; 42 struct ng_message; 43 44 struct ng_btsocket_sco_rtentry { 45 bdaddr_t src; /* source BD_ADDR */ 46 u_int16_t pkt_size; /* mtu */ 47 u_int16_t num_pkts; /* buffer size */ 48 int32_t pending; /* pending packets */ 49 struct ng_hook *hook; /* downstream hook */ 50 LIST_ENTRY(ng_btsocket_sco_rtentry) next; /* link to next */ 51 }; 52 typedef struct ng_btsocket_sco_rtentry ng_btsocket_sco_rtentry_t; 53 typedef struct ng_btsocket_sco_rtentry * ng_btsocket_sco_rtentry_p; 54 55 /***************************************************************************** 56 ***************************************************************************** 57 ** SOCK_SEQPACKET SCO sockets ** 58 ***************************************************************************** 59 *****************************************************************************/ 60 61 #define NG_BTSOCKET_SCO_SENDSPACE 1024 62 #define NG_BTSOCKET_SCO_RECVSPACE (64 * 1024) 63 64 /* 65 * Bluetooth SCO socket PCB 66 */ 67 68 struct ng_btsocket_sco_pcb { 69 struct socket *so; /* Pointer to socket */ 70 71 bdaddr_t src; /* Source address */ 72 bdaddr_t dst; /* Destination address */ 73 74 u_int16_t con_handle; /* connection handle */ 75 76 u_int16_t flags; /* socket flags */ 77 #define NG_BTSOCKET_SCO_CLIENT (1 << 0) /* socket is client */ 78 #define NG_BTSOCKET_SCO_TIMO (1 << 1) /* timeout pending */ 79 80 u_int8_t state; /* socket state */ 81 #define NG_BTSOCKET_SCO_CLOSED 0 /* socket closed */ 82 #define NG_BTSOCKET_SCO_CONNECTING 1 /* wait for connect */ 83 #define NG_BTSOCKET_SCO_OPEN 2 /* socket open */ 84 #define NG_BTSOCKET_SCO_DISCONNECTING 3 /* wait for disconnect */ 85 86 struct callout timo; /* timeout */ 87 88 ng_btsocket_sco_rtentry_p rt; /* routing info */ 89 90 struct mtx pcb_mtx; /* pcb mutex */ 91 92 LIST_ENTRY(ng_btsocket_sco_pcb) next; /* link to next PCB */ 93 }; 94 typedef struct ng_btsocket_sco_pcb ng_btsocket_sco_pcb_t; 95 typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p; 96 97 #define so2sco_pcb(so) \ 98 ((struct ng_btsocket_sco_pcb *)((so)->so_pcb)) 99 100 /* 101 * Bluetooth SCO socket methods 102 */ 103 104 #ifdef _KERNEL 105 106 void ng_btsocket_sco_init (void); 107 void ng_btsocket_sco_abort (struct socket *); 108 void ng_btsocket_sco_close (struct socket *); 109 int ng_btsocket_sco_accept (struct socket *, struct sockaddr **); 110 int ng_btsocket_sco_attach (struct socket *, int, struct thread *); 111 int ng_btsocket_sco_bind (struct socket *, struct sockaddr *, 112 struct thread *); 113 int ng_btsocket_sco_connect (struct socket *, struct sockaddr *, 114 struct thread *); 115 int ng_btsocket_sco_control (struct socket *, u_long, caddr_t, 116 struct ifnet *, struct thread *); 117 int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *); 118 void ng_btsocket_sco_detach (struct socket *); 119 int ng_btsocket_sco_disconnect (struct socket *); 120 int ng_btsocket_sco_listen (struct socket *, int, struct thread *); 121 int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr **); 122 int ng_btsocket_sco_send (struct socket *, int, struct mbuf *, 123 struct sockaddr *, struct mbuf *, 124 struct thread *); 125 int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **); 126 127 #endif /* _KERNEL */ 128 129 #endif /* _NETGRAPH_BTSOCKET_SCO_H_ */ 130 131