2002-03-09 05:10:06 +08:00
|
|
|
/*
|
2004-04-03 13:11:38 +08:00
|
|
|
*
|
|
|
|
* BlueZ - Bluetooth protocol stack for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2001 Qualcomm Incorporated
|
|
|
|
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
|
2009-01-02 02:33:20 +08:00
|
|
|
* Copyright (C) 2002-2009 Marcel Holtmann <marcel@holtmann.org>
|
2004-04-03 13:11:38 +08:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2005-10-30 03:25:42 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2004-04-03 13:11:38 +08:00
|
|
|
*
|
2005-10-30 03:25:42 +08:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2004-04-03 13:11:38 +08:00
|
|
|
*
|
2005-10-30 03:25:42 +08:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-04-03 13:11:38 +08:00
|
|
|
*
|
2002-03-09 05:10:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __HCI_LIB_H
|
|
|
|
#define __HCI_LIB_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct hci_request {
|
|
|
|
uint16_t ogf;
|
|
|
|
uint16_t ocf;
|
|
|
|
int event;
|
|
|
|
void *cparam;
|
|
|
|
int clen;
|
|
|
|
void *rparam;
|
|
|
|
int rlen;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hci_version {
|
|
|
|
uint16_t manufacturer;
|
|
|
|
uint8_t hci_ver;
|
|
|
|
uint16_t hci_rev;
|
|
|
|
uint8_t lmp_ver;
|
|
|
|
uint16_t lmp_subver;
|
|
|
|
};
|
|
|
|
|
|
|
|
int hci_open_dev(int dev_id);
|
|
|
|
int hci_close_dev(int dd);
|
|
|
|
int hci_send_cmd(int dd, uint16_t ogf, uint16_t ocf, uint8_t plen, void *param);
|
|
|
|
int hci_send_req(int dd, struct hci_request *req, int timeout);
|
|
|
|
|
2004-10-25 14:44:47 +08:00
|
|
|
int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype, uint16_t clkoffset, uint8_t rswitch, uint16_t *handle, int to);
|
2002-03-23 03:45:46 +08:00
|
|
|
int hci_disconnect(int dd, uint16_t handle, uint8_t reason, int to);
|
2002-03-09 05:10:06 +08:00
|
|
|
|
2003-02-11 18:22:23 +08:00
|
|
|
int hci_inquiry(int dev_id, int len, int num_rsp, const uint8_t *lap, inquiry_info **ii, long flags);
|
2002-03-09 05:10:06 +08:00
|
|
|
int hci_devinfo(int dev_id, struct hci_dev_info *di);
|
2004-10-25 14:44:47 +08:00
|
|
|
int hci_devba(int dev_id, bdaddr_t *bdaddr);
|
2003-02-11 18:22:23 +08:00
|
|
|
int hci_devid(const char *str);
|
2002-03-09 05:10:06 +08:00
|
|
|
|
2002-08-22 18:04:18 +08:00
|
|
|
int hci_read_local_name(int dd, int len, char *name, int to);
|
2003-02-11 18:22:23 +08:00
|
|
|
int hci_write_local_name(int dd, const char *name, int to);
|
2004-10-25 14:44:47 +08:00
|
|
|
int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name, int to);
|
2005-02-22 19:42:03 +08:00
|
|
|
int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8_t pscan_rep_mode, uint16_t clkoffset, int len, char *name, int to);
|
|
|
|
int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to);
|
2002-03-23 03:45:46 +08:00
|
|
|
int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, int to);
|
2005-04-18 07:31:54 +08:00
|
|
|
int hci_read_remote_features(int dd, uint16_t handle, uint8_t *features, int to);
|
|
|
|
int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page, uint8_t *max_page, uint8_t *features, int to);
|
2003-03-22 16:00:36 +08:00
|
|
|
int hci_read_clock_offset(int dd, uint16_t handle, uint16_t *clkoffset, int to);
|
2002-03-09 05:10:06 +08:00
|
|
|
int hci_read_local_version(int dd, struct hci_version *ver, int to);
|
2005-04-18 07:14:52 +08:00
|
|
|
int hci_read_local_commands(int dd, uint8_t *commands, int to);
|
2005-01-29 11:24:48 +08:00
|
|
|
int hci_read_local_features(int dd, uint8_t *features, int to);
|
2005-04-18 07:14:52 +08:00
|
|
|
int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page, uint8_t *features, int to);
|
2005-01-29 11:24:48 +08:00
|
|
|
int hci_read_bd_addr(int dd, bdaddr_t *bdaddr, int to);
|
2002-08-22 17:19:29 +08:00
|
|
|
int hci_read_class_of_dev(int dd, uint8_t *cls, int to);
|
|
|
|
int hci_write_class_of_dev(int dd, uint32_t cls, int to);
|
2002-12-15 21:18:53 +08:00
|
|
|
int hci_read_voice_setting(int dd, uint16_t *vs, int to);
|
|
|
|
int hci_write_voice_setting(int dd, uint16_t vs, int to);
|
2002-08-22 00:38:15 +08:00
|
|
|
int hci_read_current_iac_lap(int dd, uint8_t *num_iac, uint8_t *lap, int to);
|
|
|
|
int hci_write_current_iac_lap(int dd, uint8_t num_iac, uint8_t *lap, int to);
|
2005-05-01 22:52:53 +08:00
|
|
|
int hci_read_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t all, int to);
|
|
|
|
int hci_write_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t *key, int to);
|
|
|
|
int hci_delete_stored_link_key(int dd, bdaddr_t *bdaddr, uint8_t all, int to);
|
2003-02-11 18:22:23 +08:00
|
|
|
int hci_authenticate_link(int dd, uint16_t handle, int to);
|
2004-10-25 14:44:47 +08:00
|
|
|
int hci_encrypt_link(int dd, uint16_t handle, uint8_t encrypt, int to);
|
2004-11-04 19:21:34 +08:00
|
|
|
int hci_change_link_key(int dd, uint16_t handle, int to);
|
2004-10-25 14:44:47 +08:00
|
|
|
int hci_switch_role(int dd, bdaddr_t *bdaddr, uint8_t role, int to);
|
2003-06-27 05:17:37 +08:00
|
|
|
int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval, uint16_t min_interval, int to);
|
|
|
|
int hci_exit_park_mode(int dd, uint16_t handle, int to);
|
2005-06-16 21:53:08 +08:00
|
|
|
int hci_read_inquiry_scan_type(int dd, uint8_t *type, int to);
|
|
|
|
int hci_write_inquiry_scan_type(int dd, uint8_t type, int to);
|
2004-10-25 15:36:45 +08:00
|
|
|
int hci_read_inquiry_mode(int dd, uint8_t *mode, int to);
|
|
|
|
int hci_write_inquiry_mode(int dd, uint8_t mode, int to);
|
2004-11-10 05:33:17 +08:00
|
|
|
int hci_read_afh_mode(int dd, uint8_t *mode, int to);
|
|
|
|
int hci_write_afh_mode(int dd, uint8_t mode, int to);
|
2005-08-25 08:54:48 +08:00
|
|
|
int hci_read_ext_inquiry_response(int dd, uint8_t *fec, uint8_t *data, int to);
|
|
|
|
int hci_write_ext_inquiry_response(int dd, uint8_t fec, uint8_t *data, int to);
|
2007-08-01 15:29:23 +08:00
|
|
|
int hci_read_simple_pairing_mode(int dd, uint8_t *mode, int to);
|
|
|
|
int hci_write_simple_pairing_mode(int dd, uint8_t mode, int to);
|
|
|
|
int hci_read_local_oob_data(int dd, uint8_t *hash, uint8_t *randomizer, int to);
|
2007-10-05 19:23:35 +08:00
|
|
|
int hci_read_inquiry_transmit_power_level(int dd, int8_t *level, int to);
|
|
|
|
int hci_write_inquiry_transmit_power_level(int dd, int8_t level, int to);
|
2005-02-22 10:37:49 +08:00
|
|
|
int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, int8_t *level, int to);
|
2008-06-13 05:40:14 +08:00
|
|
|
int hci_read_link_policy(int dd, uint16_t handle, uint16_t *policy, int to);
|
|
|
|
int hci_write_link_policy(int dd, uint16_t handle, uint16_t policy, int to);
|
2005-01-14 06:37:58 +08:00
|
|
|
int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to);
|
|
|
|
int hci_write_link_supervision_timeout(int dd, uint16_t handle, uint16_t timeout, int to);
|
2004-11-10 06:52:40 +08:00
|
|
|
int hci_set_afh_classification(int dd, uint8_t *map, int to);
|
2005-01-14 04:16:40 +08:00
|
|
|
int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to);
|
|
|
|
int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to);
|
2004-11-10 06:29:55 +08:00
|
|
|
int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to);
|
2005-01-26 05:36:28 +08:00
|
|
|
int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock, uint16_t *accuracy, int to);
|
2002-03-09 05:10:06 +08:00
|
|
|
|
2005-06-22 00:40:29 +08:00
|
|
|
int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg);
|
2002-06-19 00:46:54 +08:00
|
|
|
int hci_get_route(bdaddr_t *bdaddr);
|
|
|
|
|
2002-03-09 05:10:06 +08:00
|
|
|
char *hci_dtypetostr(int type);
|
|
|
|
char *hci_dflagstostr(uint32_t flags);
|
|
|
|
char *hci_ptypetostr(unsigned int ptype);
|
2005-01-14 04:05:05 +08:00
|
|
|
int hci_strtoptype(char *str, unsigned int *val);
|
2004-04-24 20:09:53 +08:00
|
|
|
char *hci_scoptypetostr(unsigned int ptype);
|
2005-01-14 04:05:05 +08:00
|
|
|
int hci_strtoscoptype(char *str, unsigned int *val);
|
2002-03-09 05:10:06 +08:00
|
|
|
char *hci_lptostr(unsigned int ptype);
|
2005-01-14 04:05:05 +08:00
|
|
|
int hci_strtolp(char *str, unsigned int *val);
|
2002-03-09 05:10:06 +08:00
|
|
|
char *hci_lmtostr(unsigned int ptype);
|
2005-01-14 04:05:05 +08:00
|
|
|
int hci_strtolm(char *str, unsigned int *val);
|
2002-03-09 05:10:06 +08:00
|
|
|
|
2005-09-08 00:14:55 +08:00
|
|
|
char *hci_cmdtostr(unsigned int cmd);
|
|
|
|
char *hci_commandstostr(uint8_t *commands, char *pref, int width);
|
|
|
|
|
2002-03-22 07:20:32 +08:00
|
|
|
char *hci_vertostr(unsigned int ver);
|
2005-01-14 04:05:05 +08:00
|
|
|
int hci_strtover(char *str, unsigned int *ver);
|
2002-03-22 07:20:32 +08:00
|
|
|
char *lmp_vertostr(unsigned int ver);
|
2005-01-14 04:05:05 +08:00
|
|
|
int lmp_strtover(char *str, unsigned int *ver);
|
2002-03-22 07:20:32 +08:00
|
|
|
|
2002-04-12 00:56:10 +08:00
|
|
|
char *lmp_featurestostr(uint8_t *features, char *pref, int width);
|
|
|
|
|
2002-03-09 05:10:06 +08:00
|
|
|
static inline void hci_set_bit(int nr, void *addr)
|
|
|
|
{
|
2004-04-03 13:11:38 +08:00
|
|
|
*((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31));
|
2002-03-09 05:10:06 +08:00
|
|
|
}
|
|
|
|
|
2002-04-23 04:12:15 +08:00
|
|
|
static inline void hci_clear_bit(int nr, void *addr)
|
|
|
|
{
|
|
|
|
*((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31));
|
|
|
|
}
|
|
|
|
|
2002-03-09 05:10:06 +08:00
|
|
|
static inline int hci_test_bit(int nr, void *addr)
|
|
|
|
{
|
|
|
|
return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HCI filter tools */
|
|
|
|
static inline void hci_filter_clear(struct hci_filter *f)
|
|
|
|
{
|
|
|
|
memset(f, 0, sizeof(*f));
|
|
|
|
}
|
|
|
|
static inline void hci_filter_set_ptype(int t, struct hci_filter *f)
|
|
|
|
{
|
2004-10-24 01:51:55 +08:00
|
|
|
hci_set_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
2002-03-09 05:10:06 +08:00
|
|
|
}
|
2002-04-23 04:12:15 +08:00
|
|
|
static inline void hci_filter_clear_ptype(int t, struct hci_filter *f)
|
|
|
|
{
|
2004-10-24 01:51:55 +08:00
|
|
|
hci_clear_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
2002-04-23 04:12:15 +08:00
|
|
|
}
|
|
|
|
static inline int hci_filter_test_ptype(int t, struct hci_filter *f)
|
|
|
|
{
|
2004-10-24 01:51:55 +08:00
|
|
|
return hci_test_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
|
2002-04-23 04:12:15 +08:00
|
|
|
}
|
2002-03-20 02:19:12 +08:00
|
|
|
static inline void hci_filter_all_ptypes(struct hci_filter *f)
|
|
|
|
{
|
2004-10-24 01:51:55 +08:00
|
|
|
memset((void *) &f->type_mask, 0xff, sizeof(f->type_mask));
|
2002-03-20 02:19:12 +08:00
|
|
|
}
|
2002-03-09 05:10:06 +08:00
|
|
|
static inline void hci_filter_set_event(int e, struct hci_filter *f)
|
|
|
|
{
|
|
|
|
hci_set_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
|
|
|
}
|
2002-04-23 04:12:15 +08:00
|
|
|
static inline void hci_filter_clear_event(int e, struct hci_filter *f)
|
|
|
|
{
|
|
|
|
hci_clear_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
|
|
|
}
|
|
|
|
static inline int hci_filter_test_event(int e, struct hci_filter *f)
|
|
|
|
{
|
|
|
|
return hci_test_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
|
|
|
|
}
|
2002-03-09 05:10:06 +08:00
|
|
|
static inline void hci_filter_all_events(struct hci_filter *f)
|
|
|
|
{
|
2004-10-24 01:51:55 +08:00
|
|
|
memset((void *) f->event_mask, 0xff, sizeof(f->event_mask));
|
2002-03-09 05:10:06 +08:00
|
|
|
}
|
|
|
|
static inline void hci_filter_set_opcode(int opcode, struct hci_filter *f)
|
|
|
|
{
|
|
|
|
f->opcode = opcode;
|
|
|
|
}
|
2002-11-23 04:27:51 +08:00
|
|
|
static inline void hci_filter_clear_opcode(struct hci_filter *f)
|
2002-04-23 04:12:15 +08:00
|
|
|
{
|
|
|
|
f->opcode = 0;
|
|
|
|
}
|
|
|
|
static inline int hci_filter_test_opcode(int opcode, struct hci_filter *f)
|
|
|
|
{
|
|
|
|
return (f->opcode == opcode);
|
|
|
|
}
|
2002-03-09 05:10:06 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __HCI_LIB_H */
|