6 * Copyright (c) 2001-2009 Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
30 * $Id: bluetooth.h,v 1.5 2003/09/14 23:28:42 max Exp $
37 #include <sys/types.h>
38 #include <sys/bitstring.h>
39 #include <sys/endian.h>
40 #include <sys/ioctl.h>
41 #include <sys/socket.h>
45 #include <netgraph/ng_message.h>
46 #include <netgraph/bluetooth/include/ng_hci.h>
47 #include <netgraph/bluetooth/include/ng_l2cap.h>
48 #include <netgraph/bluetooth/include/ng_btsocket.h>
53 * Linux BlueZ compatibility
56 #define bacmp(ba1, ba2) memcmp((ba1), (ba2), sizeof(bdaddr_t))
57 #define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
58 #define ba2str(ba, str) bt_ntoa((ba), (str))
59 #define str2ba(str, ba) (bt_aton((str), (ba)) == 1? 0 : -1)
62 * Interface to the outside world
65 struct hostent * bt_gethostbyname (char const *name);
66 struct hostent * bt_gethostbyaddr (char const *addr, int len, int type);
67 struct hostent * bt_gethostent (void);
68 void bt_sethostent (int stayopen);
69 void bt_endhostent (void);
71 struct protoent * bt_getprotobyname (char const *name);
72 struct protoent * bt_getprotobynumber (int proto);
73 struct protoent * bt_getprotoent (void);
74 void bt_setprotoent (int stayopen);
75 void bt_endprotoent (void);
77 char const * bt_ntoa (bdaddr_t const *ba, char *str);
78 int bt_aton (char const *str, bdaddr_t *ba);
80 /* bt_devXXXX() functions (inspired by NetBSD) */
81 int bt_devaddr (char const *devname, bdaddr_t *addr);
82 int bt_devname (char *devname, bdaddr_t const *addr);
85 * Bluetooth HCI functions
88 #define HCI_DEVMAX 32 /* arbitrary */
89 #define HCI_DEVNAME_SIZE NG_NODESIZ
90 #define HCI_DEVFEATURES_SIZE NG_HCI_FEATURES_SIZE
94 char devname[HCI_DEVNAME_SIZE];
96 uint32_t state; /* device/implementation specific */
101 uint8_t features[HCI_DEVFEATURES_SIZE];
124 uint16_t link_policy_info;
125 uint16_t packet_type_info;
126 uint16_t role_switch_info;
129 uint8_t _padding[20]; /* leave space for future additions */
132 typedef int (bt_devenum_cb_t)(int, struct bt_devinfo const *, void *);
134 int bt_devinfo (struct bt_devinfo *di);
135 int bt_devenum (bt_devenum_cb_t *cb, void *arg);
138 * bdaddr utility functions (from NetBSD)
142 bdaddr_same(const bdaddr_t *a, const bdaddr_t *b)
144 return (a->b[0] == b->b[0] && a->b[1] == b->b[1] &&
145 a->b[2] == b->b[2] && a->b[3] == b->b[3] &&
146 a->b[4] == b->b[4] && a->b[5] == b->b[5]);
150 bdaddr_any(const bdaddr_t *a)
152 return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0 &&
153 a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0);
157 bdaddr_copy(bdaddr_t *d, const bdaddr_t *s)
169 #endif /* ndef _BLUETOOTH_H_ */