1 /* 2 * ng_btsocket_sco.h 3 */ 4 5 /*- 6 * SPDX-License-Identifier: BSD-2-Clause 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 */ 34 35 #ifndef _NETGRAPH_BTSOCKET_SCO_H_ 36 #define _NETGRAPH_BTSOCKET_SCO_H_ 37 38 /* 39 * SCO routing entry 40 */ 41 42 struct ng_hook; 43 struct ng_message; 44 45 struct ng_btsocket_sco_rtentry { 46 bdaddr_t src; /* source BD_ADDR */ 47 u_int16_t pkt_size; /* mtu */ 48 u_int16_t num_pkts; /* buffer size */ 49 int32_t pending; /* pending packets */ 50 struct ng_hook *hook; /* downstream hook */ 51 LIST_ENTRY(ng_btsocket_sco_rtentry) next; /* link to next */ 52 }; 53 typedef struct ng_btsocket_sco_rtentry ng_btsocket_sco_rtentry_t; 54 typedef struct ng_btsocket_sco_rtentry * ng_btsocket_sco_rtentry_p; 55 56 /***************************************************************************** 57 ***************************************************************************** 58 ** SOCK_SEQPACKET SCO sockets ** 59 ***************************************************************************** 60 *****************************************************************************/ 61 62 #define NG_BTSOCKET_SCO_SENDSPACE 1024 63 #define NG_BTSOCKET_SCO_RECVSPACE (64 * 1024) 64 65 /* 66 * Bluetooth SCO socket PCB 67 */ 68 69 struct ng_btsocket_sco_pcb { 70 struct socket *so; /* Pointer to socket */ 71 72 bdaddr_t src; /* Source address */ 73 bdaddr_t dst; /* Destination address */ 74 75 u_int16_t con_handle; /* connection handle */ 76 77 u_int16_t flags; /* socket flags */ 78 #define NG_BTSOCKET_SCO_CLIENT (1 << 0) /* socket is client */ 79 #define NG_BTSOCKET_SCO_TIMO (1 << 1) /* timeout pending */ 80 81 u_int8_t state; /* socket state */ 82 #define NG_BTSOCKET_SCO_CLOSED 0 /* socket closed */ 83 #define NG_BTSOCKET_SCO_CONNECTING 1 /* wait for connect */ 84 #define NG_BTSOCKET_SCO_OPEN 2 /* socket open */ 85 #define NG_BTSOCKET_SCO_DISCONNECTING 3 /* wait for disconnect */ 86 87 struct callout timo; /* timeout */ 88 89 ng_btsocket_sco_rtentry_p rt; /* routing info */ 90 91 struct mtx pcb_mtx; /* pcb mutex */ 92 93 LIST_ENTRY(ng_btsocket_sco_pcb) next; /* link to next PCB */ 94 }; 95 typedef struct ng_btsocket_sco_pcb ng_btsocket_sco_pcb_t; 96 typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p; 97 98 #define so2sco_pcb(so) \ 99 ((struct ng_btsocket_sco_pcb *)((so)->so_pcb)) 100 101 /* 102 * Bluetooth SCO socket methods 103 */ 104 105 #ifdef _KERNEL 106 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, void *, 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