ng_btsocket_hci_raw.h revision 157366
11590Srgrimes/*
21590Srgrimes * ng_btsocket_hci_raw.h
31590Srgrimes */
41590Srgrimes
51590Srgrimes/*-
61590Srgrimes * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
71590Srgrimes * All rights reserved.
81590Srgrimes *
91590Srgrimes * Redistribution and use in source and binary forms, with or without
101590Srgrimes * modification, are permitted provided that the following conditions
111590Srgrimes * are met:
121590Srgrimes * 1. Redistributions of source code must retain the above copyright
131590Srgrimes *    notice, this list of conditions and the following disclaimer.
141590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
151590Srgrimes *    notice, this list of conditions and the following disclaimer in the
161590Srgrimes *    documentation and/or other materials provided with the distribution.
171590Srgrimes *
181590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
191590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
221590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281590Srgrimes * SUCH DAMAGE.
291590Srgrimes *
301590Srgrimes * $Id: ng_btsocket_hci_raw.h,v 1.3 2003/03/25 23:53:32 max Exp $
311590Srgrimes * $FreeBSD: head/sys/netgraph/bluetooth/include/ng_btsocket_hci_raw.h 157366 2006-04-01 15:15:05Z rwatson $
321590Srgrimes */
331590Srgrimes
341590Srgrimes#ifndef _NETGRAPH_BTSOCKET_HCI_RAW_H_
351590Srgrimes#define _NETGRAPH_BTSOCKET_HCI_RAW_H_
361590Srgrimes
371590Srgrimes#define NG_BTSOCKET_HCI_RAW_SENDSPACE	(4 * 1024)
381590Srgrimes#define NG_BTSOCKET_HCI_RAW_RECVSPACE	(4 * 1024)
391590Srgrimes
401590Srgrimes/*
411590Srgrimes * Bluetooth raw HCI socket PCB
421590Srgrimes */
431590Srgrimes
441590Srgrimesstruct ng_btsocket_hci_raw_pcb {
451590Srgrimes	struct socket				*so;     /* socket */
461590Srgrimes	u_int32_t				 flags;  /* flags */
471590Srgrimes#define NG_BTSOCKET_HCI_RAW_DIRECTION	(1 << 0)
481590Srgrimes#define NG_BTSOCKET_HCI_RAW_PRIVILEGED	(1 << 1)
491590Srgrimes	struct sockaddr_hci			 addr;   /* local address */
501590Srgrimes	struct ng_btsocket_hci_raw_filter	 filter; /* filter */
511590Srgrimes	u_int32_t				 token;  /* message token */
521590Srgrimes	struct ng_mesg				*msg;    /* message */
531590Srgrimes	LIST_ENTRY(ng_btsocket_hci_raw_pcb)	 next;   /* link to next */
541590Srgrimes	struct mtx				 pcb_mtx; /* pcb mutex */
551590Srgrimes};
561590Srgrimestypedef struct ng_btsocket_hci_raw_pcb		ng_btsocket_hci_raw_pcb_t;
571590Srgrimestypedef struct ng_btsocket_hci_raw_pcb *	ng_btsocket_hci_raw_pcb_p;
581590Srgrimes
591590Srgrimes#define	so2hci_raw_pcb(so) \
601590Srgrimes	((struct ng_btsocket_hci_raw_pcb *)((so)->so_pcb))
611590Srgrimes
621590Srgrimes/*
631590Srgrimes * Bluetooth raw HCI socket methods
641590Srgrimes */
651590Srgrimes
661590Srgrimes#ifdef _KERNEL
671590Srgrimes
681590Srgrimesvoid ng_btsocket_hci_raw_init       (void);
691590Srgrimesvoid ng_btsocket_hci_raw_abort      (struct socket *);
701590Srgrimesint  ng_btsocket_hci_raw_attach     (struct socket *, int, struct thread *);
711590Srgrimesint  ng_btsocket_hci_raw_bind       (struct socket *, struct sockaddr *,
721590Srgrimes                                     struct thread *);
731590Srgrimesint  ng_btsocket_hci_raw_connect    (struct socket *, struct sockaddr *,
741590Srgrimes                                     struct thread *);
751590Srgrimesint  ng_btsocket_hci_raw_control    (struct socket *, u_long, caddr_t,
761590Srgrimes                                     struct ifnet *, struct thread *);
771590Srgrimesint  ng_btsocket_hci_raw_ctloutput  (struct socket *, struct sockopt *);
781590Srgrimesint  ng_btsocket_hci_raw_detach     (struct socket *);
791590Srgrimesint  ng_btsocket_hci_raw_disconnect (struct socket *);
801590Srgrimesint  ng_btsocket_hci_raw_peeraddr   (struct socket *, struct sockaddr **);
811590Srgrimesint  ng_btsocket_hci_raw_send       (struct socket *, int, struct mbuf *,
821590Srgrimes                                     struct sockaddr *, struct mbuf *,
831590Srgrimes                                     struct thread *);
841590Srgrimesint  ng_btsocket_hci_raw_sockaddr   (struct socket *, struct sockaddr **);
851590Srgrimes
861590Srgrimes#endif /* _KERNEL */
871590Srgrimes
881590Srgrimes#endif /* ndef _NETGRAPH_BTSOCKET_HCI_RAW_H_ */
891590Srgrimes
901590Srgrimes