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