1181033Semax/* 2181033Semax * ng_btsocket_sco.h 3181033Semax */ 4181033Semax 5181033Semax/*- 6181033Semax * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7181033Semax * All rights reserved. 8181033Semax * 9181033Semax * Redistribution and use in source and binary forms, with or without 10181033Semax * modification, are permitted provided that the following conditions 11181033Semax * are met: 12181033Semax * 1. Redistributions of source code must retain the above copyright 13181033Semax * notice, this list of conditions and the following disclaimer. 14181033Semax * 2. Redistributions in binary form must reproduce the above copyright 15181033Semax * notice, this list of conditions and the following disclaimer in the 16181033Semax * documentation and/or other materials provided with the distribution. 17181033Semax * 18181033Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19181033Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20181033Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21181033Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22181033Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23181033Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24181033Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25181033Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26181033Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27181033Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28181033Semax * SUCH DAMAGE. 29181033Semax * 30181033Semax * $Id: ng_btsocket_sco.h,v 1.3 2005/10/31 18:08:52 max Exp $ 31181033Semax * $FreeBSD$ 32181033Semax */ 33181033Semax 34181033Semax#ifndef _NETGRAPH_BTSOCKET_SCO_H_ 35181033Semax#define _NETGRAPH_BTSOCKET_SCO_H_ 36181033Semax 37181033Semax/* 38181033Semax * SCO routing entry 39181033Semax */ 40181033Semax 41181033Semaxstruct ng_hook; 42181033Semaxstruct ng_message; 43181033Semax 44181033Semaxstruct ng_btsocket_sco_rtentry { 45181033Semax bdaddr_t src; /* source BD_ADDR */ 46181033Semax u_int16_t pkt_size; /* mtu */ 47181033Semax u_int16_t num_pkts; /* buffer size */ 48181033Semax int32_t pending; /* pending packets */ 49181033Semax struct ng_hook *hook; /* downstream hook */ 50181033Semax LIST_ENTRY(ng_btsocket_sco_rtentry) next; /* link to next */ 51181033Semax}; 52181033Semaxtypedef struct ng_btsocket_sco_rtentry ng_btsocket_sco_rtentry_t; 53181033Semaxtypedef struct ng_btsocket_sco_rtentry * ng_btsocket_sco_rtentry_p; 54181033Semax 55181033Semax/***************************************************************************** 56181033Semax ***************************************************************************** 57181033Semax ** SOCK_SEQPACKET SCO sockets ** 58181033Semax ***************************************************************************** 59181033Semax *****************************************************************************/ 60181033Semax 61181033Semax#define NG_BTSOCKET_SCO_SENDSPACE 1024 62181033Semax#define NG_BTSOCKET_SCO_RECVSPACE (64 * 1024) 63181033Semax 64181033Semax/* 65181033Semax * Bluetooth SCO socket PCB 66181033Semax */ 67181033Semax 68181033Semaxstruct ng_btsocket_sco_pcb { 69181033Semax struct socket *so; /* Pointer to socket */ 70181033Semax 71181033Semax bdaddr_t src; /* Source address */ 72181033Semax bdaddr_t dst; /* Destination address */ 73181033Semax 74181033Semax u_int16_t con_handle; /* connection handle */ 75181033Semax 76181033Semax u_int16_t flags; /* socket flags */ 77181033Semax#define NG_BTSOCKET_SCO_CLIENT (1 << 0) /* socket is client */ 78181033Semax#define NG_BTSOCKET_SCO_TIMO (1 << 1) /* timeout pending */ 79181033Semax 80181033Semax u_int8_t state; /* socket state */ 81181033Semax#define NG_BTSOCKET_SCO_CLOSED 0 /* socket closed */ 82181033Semax#define NG_BTSOCKET_SCO_CONNECTING 1 /* wait for connect */ 83181033Semax#define NG_BTSOCKET_SCO_OPEN 2 /* socket open */ 84181033Semax#define NG_BTSOCKET_SCO_DISCONNECTING 3 /* wait for disconnect */ 85181033Semax 86181033Semax struct callout timo; /* timeout */ 87181033Semax 88181033Semax ng_btsocket_sco_rtentry_p rt; /* routing info */ 89181033Semax 90181033Semax struct mtx pcb_mtx; /* pcb mutex */ 91181033Semax 92181033Semax LIST_ENTRY(ng_btsocket_sco_pcb) next; /* link to next PCB */ 93181033Semax}; 94181033Semaxtypedef struct ng_btsocket_sco_pcb ng_btsocket_sco_pcb_t; 95181033Semaxtypedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p; 96181033Semax 97181033Semax#define so2sco_pcb(so) \ 98181033Semax ((struct ng_btsocket_sco_pcb *)((so)->so_pcb)) 99181033Semax 100181033Semax/* 101181033Semax * Bluetooth SCO socket methods 102181033Semax */ 103181033Semax 104181033Semax#ifdef _KERNEL 105181033Semax 106181033Semaxvoid ng_btsocket_sco_init (void); 107181033Semaxvoid ng_btsocket_sco_abort (struct socket *); 108181033Semaxvoid ng_btsocket_sco_close (struct socket *); 109181033Semaxint ng_btsocket_sco_accept (struct socket *, struct sockaddr **); 110181033Semaxint ng_btsocket_sco_attach (struct socket *, int, struct thread *); 111181033Semaxint ng_btsocket_sco_bind (struct socket *, struct sockaddr *, 112181033Semax struct thread *); 113181033Semaxint ng_btsocket_sco_connect (struct socket *, struct sockaddr *, 114181033Semax struct thread *); 115181033Semaxint ng_btsocket_sco_control (struct socket *, u_long, caddr_t, 116181033Semax struct ifnet *, struct thread *); 117181033Semaxint ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *); 118181033Semaxvoid ng_btsocket_sco_detach (struct socket *); 119181033Semaxint ng_btsocket_sco_disconnect (struct socket *); 120181033Semaxint ng_btsocket_sco_listen (struct socket *, int, struct thread *); 121181033Semaxint ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr **); 122181033Semaxint ng_btsocket_sco_send (struct socket *, int, struct mbuf *, 123181033Semax struct sockaddr *, struct mbuf *, 124181033Semax struct thread *); 125181033Semaxint ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **); 126181033Semax 127181033Semax#endif /* _KERNEL */ 128181033Semax 129181033Semax#endif /* _NETGRAPH_BTSOCKET_SCO_H_ */ 130181033Semax 131