bluetooth.h revision 1.1 1 1.1 gdamore /* $NetBSD: bluetooth.h,v 1.1 2006/06/19 15:44:36 gdamore 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.1 gdamore * $Id: bluetooth.h,v 1.1 2006/06/19 15:44:36 gdamore 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 /*
47 1.1 gdamore * Bluetooth remote device config information.
48 1.1 gdamore *
49 1.1 gdamore * Entries will be empty if no value was specified
50 1.1 gdamore * in the configuration file.
51 1.1 gdamore */
52 1.1 gdamore typedef struct {
53 1.1 gdamore bdaddr_t bdaddr; /* device address */
54 1.1 gdamore int type; /* device type */
55 1.1 gdamore char *name; /* NUL terminated string */
56 1.1 gdamore uint8_t *pin; /* uint8_t[HCI_PIN_SIZE] */
57 1.1 gdamore uint8_t *key; /* uint8_t[HCI_KEY_SIZE] */
58 1.1 gdamore uint8_t *hid_descriptor; /* uint8_t[hid_length] */
59 1.1 gdamore int hid_length;
60 1.1 gdamore uint16_t control_psm;
61 1.1 gdamore uint8_t control_channel;
62 1.1 gdamore uint16_t interrupt_psm;
63 1.1 gdamore uint8_t reconnect_initiate;
64 1.1 gdamore uint8_t normally_connectable;
65 1.1 gdamore uint8_t battery_power;
66 1.1 gdamore } bt_cfgentry_t;
67 1.1 gdamore
68 1.1 gdamore __BEGIN_DECLS
69 1.1 gdamore
70 1.1 gdamore /*
71 1.1 gdamore * Interface to the outside world
72 1.1 gdamore */
73 1.1 gdamore
74 1.1 gdamore struct hostent * bt_gethostbyname (char const *);
75 1.1 gdamore struct hostent * bt_gethostbyaddr (char const *, socklen_t, int);
76 1.1 gdamore struct hostent * bt_gethostent (void);
77 1.1 gdamore void bt_sethostent (int);
78 1.1 gdamore void bt_endhostent (void);
79 1.1 gdamore
80 1.1 gdamore struct protoent * bt_getprotobyname (char const *);
81 1.1 gdamore struct protoent * bt_getprotobynumber (int);
82 1.1 gdamore struct protoent * bt_getprotoent (void);
83 1.1 gdamore void bt_setprotoent (int);
84 1.1 gdamore void bt_endprotoent (void);
85 1.1 gdamore
86 1.1 gdamore char const * bt_ntoa (bdaddr_t const *, char *);
87 1.1 gdamore int bt_aton (char const *, bdaddr_t *);
88 1.1 gdamore
89 1.1 gdamore int bt_devaddr (const char *, bdaddr_t *);
90 1.1 gdamore int bt_devname (char *, const bdaddr_t *);
91 1.1 gdamore
92 1.1 gdamore typedef struct bt_handle *bt_handle_t;
93 1.1 gdamore
94 1.1 gdamore bt_handle_t bt_openconfig (const char *);
95 1.1 gdamore bt_cfgentry_t * bt_getconfig (bt_handle_t, const bdaddr_t *);
96 1.1 gdamore int bt_eachconfig (bt_handle_t, void (*func)(bt_cfgentry_t *, void *), void *);
97 1.1 gdamore void bt_freeconfig (bt_cfgentry_t *);
98 1.1 gdamore int bt_closeconfig (bt_handle_t);
99 1.1 gdamore int bt_printconfig (FILE *, bt_cfgentry_t *);
100 1.1 gdamore
101 1.1 gdamore #ifdef COMPAT_BLUEZ
102 1.1 gdamore /*
103 1.1 gdamore * Linux BlueZ compatibility
104 1.1 gdamore */
105 1.1 gdamore
106 1.1 gdamore #define bacmp(ba1, ba2) memcmp((ba1), (ba2), sizeof(bdaddr_t))
107 1.1 gdamore #define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
108 1.1 gdamore #define ba2str(ba, str) bt_ntoa((ba), (str))
109 1.1 gdamore #define str2ba(str, ba) (bt_aton((str), (ba)) == 1 ? 0 : -1)
110 1.1 gdamore
111 1.1 gdamore #define htobs(x) htole16(x)
112 1.1 gdamore #define htobl(x) htole32(x)
113 1.1 gdamore #define btohs(x) le16toh(x)
114 1.1 gdamore #define btohl(x) le32toh(x)
115 1.1 gdamore
116 1.1 gdamore #define bt_malloc(n) malloc(n)
117 1.1 gdamore #define bt_free(p) free(p)
118 1.1 gdamore
119 1.1 gdamore #endif /* COMPAT_BLUEZ */
120 1.1 gdamore
121 1.1 gdamore __END_DECLS
122 1.1 gdamore
123 1.1 gdamore #endif /* ndef _BLUETOOTH_H_ */
124