6 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
8 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
32 * $Id: ng_btsocket_sco.h,v 1.3 2005/10/31 18:08:52 max Exp $
36 #ifndef _NETGRAPH_BTSOCKET_SCO_H_
37 #define _NETGRAPH_BTSOCKET_SCO_H_
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 */
54 typedef struct ng_btsocket_sco_rtentry ng_btsocket_sco_rtentry_t;
55 typedef struct ng_btsocket_sco_rtentry * ng_btsocket_sco_rtentry_p;
57 /*****************************************************************************
58 *****************************************************************************
59 ** SOCK_SEQPACKET SCO sockets **
60 *****************************************************************************
61 *****************************************************************************/
63 #define NG_BTSOCKET_SCO_SENDSPACE 1024
64 #define NG_BTSOCKET_SCO_RECVSPACE (64 * 1024)
67 * Bluetooth SCO socket PCB
70 struct ng_btsocket_sco_pcb {
71 struct socket *so; /* Pointer to socket */
73 bdaddr_t src; /* Source address */
74 bdaddr_t dst; /* Destination address */
76 u_int16_t con_handle; /* connection handle */
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 */
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 */
88 struct callout timo; /* timeout */
90 ng_btsocket_sco_rtentry_p rt; /* routing info */
92 struct mtx pcb_mtx; /* pcb mutex */
94 LIST_ENTRY(ng_btsocket_sco_pcb) next; /* link to next PCB */
96 typedef struct ng_btsocket_sco_pcb ng_btsocket_sco_pcb_t;
97 typedef struct ng_btsocket_sco_pcb * ng_btsocket_sco_pcb_p;
99 #define so2sco_pcb(so) \
100 ((struct ng_btsocket_sco_pcb *)((so)->so_pcb))
103 * Bluetooth SCO socket methods
108 void ng_btsocket_sco_init (void);
109 void ng_btsocket_sco_abort (struct socket *);
110 void ng_btsocket_sco_close (struct socket *);
111 int ng_btsocket_sco_accept (struct socket *, struct sockaddr **);
112 int ng_btsocket_sco_attach (struct socket *, int, struct thread *);
113 int ng_btsocket_sco_bind (struct socket *, struct sockaddr *,
115 int ng_btsocket_sco_connect (struct socket *, struct sockaddr *,
117 int ng_btsocket_sco_control (struct socket *, u_long, caddr_t,
118 struct ifnet *, struct thread *);
119 int ng_btsocket_sco_ctloutput (struct socket *, struct sockopt *);
120 void ng_btsocket_sco_detach (struct socket *);
121 int ng_btsocket_sco_disconnect (struct socket *);
122 int ng_btsocket_sco_listen (struct socket *, int, struct thread *);
123 int ng_btsocket_sco_peeraddr (struct socket *, struct sockaddr **);
124 int ng_btsocket_sco_send (struct socket *, int, struct mbuf *,
125 struct sockaddr *, struct mbuf *,
127 int ng_btsocket_sco_sockaddr (struct socket *, struct sockaddr **);
131 #endif /* _NETGRAPH_BTSOCKET_SCO_H_ */