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