Home | History | Annotate | Line # | Download | only in libbluetooth
bluetooth.h revision 1.2
      1 /*	$NetBSD: bluetooth.h,v 1.2 2006/07/26 11:11:04 tron Exp $	*/
      2 
      3 /*
      4  * bluetooth.h
      5  *
      6  * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin (at) yahoo.com>
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  *
     30  * $Id: bluetooth.h,v 1.2 2006/07/26 11:11:04 tron Exp $
     31  * $FreeBSD: src/lib/libbluetooth/bluetooth.h,v 1.2 2005/03/17 21:39:44 emax Exp $
     32  */
     33 
     34 #ifndef _BLUETOOTH_H_
     35 #define _BLUETOOTH_H_
     36 
     37 #include <sys/types.h>
     38 #include <sys/endian.h>
     39 #include <sys/socket.h>
     40 #include <netdb.h>
     41 #include <netbt/bluetooth.h>
     42 #include <netbt/hci.h>
     43 #include <netbt/l2cap.h>
     44 #include <stdio.h>
     45 
     46 __BEGIN_DECLS
     47 
     48 /*
     49  * Interface to the outside world
     50  */
     51 
     52 struct hostent *  bt_gethostbyname    (char const *);
     53 struct hostent *  bt_gethostbyaddr    (char const *, socklen_t, int);
     54 struct hostent *  bt_gethostent       (void);
     55 void              bt_sethostent       (int);
     56 void              bt_endhostent       (void);
     57 
     58 struct protoent * bt_getprotobyname   (char const *);
     59 struct protoent * bt_getprotobynumber (int);
     60 struct protoent * bt_getprotoent      (void);
     61 void              bt_setprotoent      (int);
     62 void              bt_endprotoent      (void);
     63 
     64 char const *      bt_ntoa             (bdaddr_t const *, char *);
     65 int               bt_aton             (char const *, bdaddr_t *);
     66 
     67 int               bt_devaddr          (const char *, bdaddr_t *);
     68 int               bt_devname          (char *, const bdaddr_t *);
     69 
     70 #ifdef COMPAT_BLUEZ
     71 /*
     72  * Linux BlueZ compatibility
     73  */
     74 
     75 #define	bacmp(ba1, ba2)	memcmp((ba1), (ba2), sizeof(bdaddr_t))
     76 #define	bacpy(dst, src)	memcpy((dst), (src), sizeof(bdaddr_t))
     77 #define ba2str(ba, str)	bt_ntoa((ba), (str))
     78 #define str2ba(str, ba)	(bt_aton((str), (ba)) == 1 ? 0 : -1)
     79 
     80 #define htobs(x)	htole16(x)
     81 #define htobl(x)	htole32(x)
     82 #define btohs(x)	le16toh(x)
     83 #define btohl(x)	le32toh(x)
     84 
     85 #define bt_malloc(n)	malloc(n)
     86 #define bt_free(p)	free(p)
     87 
     88 #endif	/* COMPAT_BLUEZ */
     89 
     90 __END_DECLS
     91 
     92 #endif /* ndef _BLUETOOTH_H_ */
     93