2 * QEMU Bluetooth HCI helpers.
4 * Copyright (C) 2007 OpenMoko, Inc.
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26 } __attribute__((packed
)) bdaddr_t
;
28 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
29 #define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
30 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
32 /* Copy, swap, convert BD Address */
33 static inline int bacmp(const bdaddr_t
*ba1
, const bdaddr_t
*ba2
)
35 return memcmp(ba1
, ba2
, sizeof(bdaddr_t
));
37 static inline void bacpy(bdaddr_t
*dst
, const bdaddr_t
*src
)
39 memcpy(dst
, src
, sizeof(bdaddr_t
));
42 #define BAINIT(orig) { .b = { \
43 (orig)->b[0], (orig)->b[1], (orig)->b[2], \
44 (orig)->b[3], (orig)->b[4], (orig)->b[5], \
47 /* The twisted structures of a bluetooth environment */
49 struct bt_scatternet_s
;
53 struct bt_scatternet_s
{
54 struct bt_device_s
*slave
;
58 struct bt_device_s
*slave
, *host
;
59 uint16_t handle
; /* Master (host) side handle */
60 uint16_t acl_interval
;
74 struct bt_scatternet_s
*net
;
80 uint8_t reject_reason
;
84 void (*lmp_connection_request
)(struct bt_link_s
*link
);
85 void (*lmp_connection_complete
)(struct bt_link_s
*link
);
86 void (*lmp_disconnect_master
)(struct bt_link_s
*link
);
87 void (*lmp_disconnect_slave
)(struct bt_link_s
*link
);
88 void (*lmp_acl_data
)(struct bt_link_s
*link
, const uint8_t *data
,
90 void (*lmp_acl_resp
)(struct bt_link_s
*link
, const uint8_t *data
,
92 void (*lmp_mode_change
)(struct bt_link_s
*link
);
94 void (*handle_destroy
)(struct bt_device_s
*device
);
95 struct bt_device_s
*next
; /* Next in the piconet/scatternet */
100 uint16_t clkoff
; /* Note: Always little-endian */
104 void bt_device_init(struct bt_device_s
*dev
, struct bt_scatternet_s
*net
);
105 void bt_device_done(struct bt_device_s
*dev
);