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