]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libbluetooth/bluetooth.h
add -n option to suppress clearing the build tree and add -DNO_CLEAN
[FreeBSD/FreeBSD.git] / lib / libbluetooth / bluetooth.h
1 /*
2  * bluetooth.h
3  *
4  * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $Id: bluetooth.h,v 1.5 2003/09/14 23:28:42 max Exp $
29  * $FreeBSD$
30  */
31
32 #ifndef _BLUETOOTH_H_
33 #define _BLUETOOTH_H_
34
35 #include <sys/types.h>
36 #include <sys/bitstring.h>
37 #include <sys/endian.h>
38 #include <sys/socket.h>
39 #include <sys/un.h>
40 #include <netdb.h>
41 #include <netgraph/bluetooth/include/ng_hci.h>
42 #include <netgraph/bluetooth/include/ng_l2cap.h>
43 #include <netgraph/bluetooth/include/ng_btsocket.h>
44
45 __BEGIN_DECLS
46
47 /*
48  * Linux BlueZ compatibility
49  */
50
51 #define bacmp(ba1, ba2) memcmp((ba1), (ba2), sizeof(bdaddr_t))
52 #define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
53 #define ba2str(ba, str) bt_ntoa((ba), (str))
54 #define str2ba(str, ba) (bt_aton((str), (ba)) == 1? 0 : -1)
55
56 /*
57  * Interface to the outside world
58  */
59
60 struct hostent *  bt_gethostbyname    (char const *name);
61 struct hostent *  bt_gethostbyaddr    (char const *addr, int len, int type);
62 struct hostent *  bt_gethostent       (void);
63 void              bt_sethostent       (int stayopen);
64 void              bt_endhostent       (void);
65
66 struct protoent * bt_getprotobyname   (char const *name);
67 struct protoent * bt_getprotobynumber (int proto);
68 struct protoent * bt_getprotoent      (void);
69 void              bt_setprotoent      (int stayopen);
70 void              bt_endprotoent      (void);
71
72 char const *      bt_ntoa             (bdaddr_t const *ba, char *str);
73 int               bt_aton             (char const *str, bdaddr_t *ba);
74
75 /*
76  * bdaddr utility functions (from NetBSD)
77  */
78
79 static __inline int
80 bdaddr_same(const bdaddr_t *a, const bdaddr_t *b)
81 {
82         return (a->b[0] == b->b[0] && a->b[1] == b->b[1] &&
83                 a->b[2] == b->b[2] && a->b[3] == b->b[3] &&
84                 a->b[4] == b->b[4] && a->b[5] == b->b[5]);
85 }
86
87 static __inline int
88 bdaddr_any(const bdaddr_t *a)
89 {
90         return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0 &&
91                 a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0);
92 }
93
94 static __inline void
95 bdaddr_copy(bdaddr_t *d, const bdaddr_t *s)
96 {
97         d->b[0] = s->b[0];
98         d->b[1] = s->b[1];
99         d->b[2] = s->b[2];
100         d->b[3] = s->b[3];
101         d->b[4] = s->b[4];
102         d->b[5] = s->b[5];
103 }
104
105 __END_DECLS
106
107 #endif /* ndef _BLUETOOTH_H_ */
108