Path: blob/master/include/net/bluetooth/hci_core.h
10818 views
/*1BlueZ - Bluetooth protocol stack for Linux2Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.34Written 2000,2001 by Maxim Krasnyansky <[email protected]>56This program is free software; you can redistribute it and/or modify7it under the terms of the GNU General Public License version 2 as8published by the Free Software Foundation;910THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS11OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,12FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.13IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY14CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES15WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN16ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF17OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.1819ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,20COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS21SOFTWARE IS DISCLAIMED.22*/2324#ifndef __HCI_CORE_H25#define __HCI_CORE_H2627#include <net/bluetooth/hci.h>2829/* HCI upper protocols */30#define HCI_PROTO_L2CAP 031#define HCI_PROTO_SCO 13233/* HCI Core structures */34struct inquiry_data {35bdaddr_t bdaddr;36__u8 pscan_rep_mode;37__u8 pscan_period_mode;38__u8 pscan_mode;39__u8 dev_class[3];40__le16 clock_offset;41__s8 rssi;42__u8 ssp_mode;43};4445struct inquiry_entry {46struct inquiry_entry *next;47__u32 timestamp;48struct inquiry_data data;49};5051struct inquiry_cache {52spinlock_t lock;53__u32 timestamp;54struct inquiry_entry *list;55};5657struct hci_conn_hash {58struct list_head list;59spinlock_t lock;60unsigned int acl_num;61unsigned int sco_num;62unsigned int le_num;63};6465struct bdaddr_list {66struct list_head list;67bdaddr_t bdaddr;68};6970struct bt_uuid {71struct list_head list;72u8 uuid[16];73u8 svc_hint;74};7576struct link_key {77struct list_head list;78bdaddr_t bdaddr;79u8 type;80u8 val[16];81u8 pin_len;82};8384struct oob_data {85struct list_head list;86bdaddr_t bdaddr;87u8 hash[16];88u8 randomizer[16];89};9091#define NUM_REASSEMBLY 492struct hci_dev {93struct list_head list;94spinlock_t lock;95atomic_t refcnt;9697char name[8];98unsigned long flags;99__u16 id;100__u8 bus;101__u8 dev_type;102bdaddr_t bdaddr;103__u8 dev_name[HCI_MAX_NAME_LENGTH];104__u8 eir[HCI_MAX_EIR_LENGTH];105__u8 dev_class[3];106__u8 major_class;107__u8 minor_class;108__u8 features[8];109__u8 commands[64];110__u8 ssp_mode;111__u8 hci_ver;112__u16 hci_rev;113__u8 lmp_ver;114__u16 manufacturer;115__le16 lmp_subver;116__u16 voice_setting;117__u8 io_capability;118119__u16 pkt_type;120__u16 esco_type;121__u16 link_policy;122__u16 link_mode;123124__u32 idle_timeout;125__u16 sniff_min_interval;126__u16 sniff_max_interval;127128unsigned int auto_accept_delay;129130unsigned long quirks;131132atomic_t cmd_cnt;133unsigned int acl_cnt;134unsigned int sco_cnt;135unsigned int le_cnt;136137unsigned int acl_mtu;138unsigned int sco_mtu;139unsigned int le_mtu;140unsigned int acl_pkts;141unsigned int sco_pkts;142unsigned int le_pkts;143144unsigned long acl_last_tx;145unsigned long sco_last_tx;146unsigned long le_last_tx;147148struct workqueue_struct *workqueue;149150struct work_struct power_on;151struct work_struct power_off;152struct timer_list off_timer;153154struct timer_list cmd_timer;155struct tasklet_struct cmd_task;156struct tasklet_struct rx_task;157struct tasklet_struct tx_task;158159struct sk_buff_head rx_q;160struct sk_buff_head raw_q;161struct sk_buff_head cmd_q;162163struct sk_buff *sent_cmd;164struct sk_buff *reassembly[NUM_REASSEMBLY];165166struct mutex req_lock;167wait_queue_head_t req_wait_q;168__u32 req_status;169__u32 req_result;170171__u16 init_last_cmd;172173struct inquiry_cache inq_cache;174struct hci_conn_hash conn_hash;175struct list_head blacklist;176177struct list_head uuids;178179struct list_head link_keys;180181struct list_head remote_oob_data;182183struct hci_dev_stats stat;184185struct sk_buff_head driver_init;186187void *driver_data;188void *core_data;189190atomic_t promisc;191192struct dentry *debugfs;193194struct device *parent;195struct device dev;196197struct rfkill *rfkill;198199struct module *owner;200201int (*open)(struct hci_dev *hdev);202int (*close)(struct hci_dev *hdev);203int (*flush)(struct hci_dev *hdev);204int (*send)(struct sk_buff *skb);205void (*destruct)(struct hci_dev *hdev);206void (*notify)(struct hci_dev *hdev, unsigned int evt);207int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);208};209210struct hci_conn {211struct list_head list;212213atomic_t refcnt;214spinlock_t lock;215216bdaddr_t dst;217__u16 handle;218__u16 state;219__u8 mode;220__u8 type;221__u8 out;222__u8 attempt;223__u8 dev_class[3];224__u8 features[8];225__u8 ssp_mode;226__u16 interval;227__u16 pkt_type;228__u16 link_policy;229__u32 link_mode;230__u8 key_type;231__u8 auth_type;232__u8 sec_level;233__u8 pending_sec_level;234__u8 pin_length;235__u8 io_capability;236__u8 power_save;237__u16 disc_timeout;238unsigned long pend;239240__u8 remote_cap;241__u8 remote_oob;242__u8 remote_auth;243244unsigned int sent;245246struct sk_buff_head data_q;247248struct timer_list disc_timer;249struct timer_list idle_timer;250struct timer_list auto_accept_timer;251252struct work_struct work_add;253struct work_struct work_del;254255struct device dev;256atomic_t devref;257258struct hci_dev *hdev;259void *l2cap_data;260void *sco_data;261void *priv;262263struct hci_conn *link;264265void (*connect_cfm_cb) (struct hci_conn *conn, u8 status);266void (*security_cfm_cb) (struct hci_conn *conn, u8 status);267void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason);268};269270extern struct hci_proto *hci_proto[];271extern struct list_head hci_dev_list;272extern struct list_head hci_cb_list;273extern rwlock_t hci_dev_list_lock;274extern rwlock_t hci_cb_list_lock;275276/* ----- Inquiry cache ----- */277#define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */278#define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */279280#define inquiry_cache_lock(c) spin_lock(&c->lock)281#define inquiry_cache_unlock(c) spin_unlock(&c->lock)282#define inquiry_cache_lock_bh(c) spin_lock_bh(&c->lock)283#define inquiry_cache_unlock_bh(c) spin_unlock_bh(&c->lock)284285static inline void inquiry_cache_init(struct hci_dev *hdev)286{287struct inquiry_cache *c = &hdev->inq_cache;288spin_lock_init(&c->lock);289c->list = NULL;290}291292static inline int inquiry_cache_empty(struct hci_dev *hdev)293{294struct inquiry_cache *c = &hdev->inq_cache;295return c->list == NULL;296}297298static inline long inquiry_cache_age(struct hci_dev *hdev)299{300struct inquiry_cache *c = &hdev->inq_cache;301return jiffies - c->timestamp;302}303304static inline long inquiry_entry_age(struct inquiry_entry *e)305{306return jiffies - e->timestamp;307}308309struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);310void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data);311312/* ----- HCI Connections ----- */313enum {314HCI_CONN_AUTH_PEND,315HCI_CONN_ENCRYPT_PEND,316HCI_CONN_RSWITCH_PEND,317HCI_CONN_MODE_CHANGE_PEND,318HCI_CONN_SCO_SETUP_PEND,319};320321static inline void hci_conn_hash_init(struct hci_dev *hdev)322{323struct hci_conn_hash *h = &hdev->conn_hash;324INIT_LIST_HEAD(&h->list);325spin_lock_init(&h->lock);326h->acl_num = 0;327h->sco_num = 0;328}329330static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)331{332struct hci_conn_hash *h = &hdev->conn_hash;333list_add(&c->list, &h->list);334switch (c->type) {335case ACL_LINK:336h->acl_num++;337break;338case LE_LINK:339h->le_num++;340break;341case SCO_LINK:342case ESCO_LINK:343h->sco_num++;344break;345}346}347348static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)349{350struct hci_conn_hash *h = &hdev->conn_hash;351list_del(&c->list);352switch (c->type) {353case ACL_LINK:354h->acl_num--;355break;356case LE_LINK:357h->le_num--;358break;359case SCO_LINK:360case ESCO_LINK:361h->sco_num--;362break;363}364}365366static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,367__u16 handle)368{369struct hci_conn_hash *h = &hdev->conn_hash;370struct list_head *p;371struct hci_conn *c;372373list_for_each(p, &h->list) {374c = list_entry(p, struct hci_conn, list);375if (c->handle == handle)376return c;377}378return NULL;379}380381static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,382__u8 type, bdaddr_t *ba)383{384struct hci_conn_hash *h = &hdev->conn_hash;385struct list_head *p;386struct hci_conn *c;387388list_for_each(p, &h->list) {389c = list_entry(p, struct hci_conn, list);390if (c->type == type && !bacmp(&c->dst, ba))391return c;392}393return NULL;394}395396static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,397__u8 type, __u16 state)398{399struct hci_conn_hash *h = &hdev->conn_hash;400struct list_head *p;401struct hci_conn *c;402403list_for_each(p, &h->list) {404c = list_entry(p, struct hci_conn, list);405if (c->type == type && c->state == state)406return c;407}408return NULL;409}410411void hci_acl_connect(struct hci_conn *conn);412void hci_acl_disconn(struct hci_conn *conn, __u8 reason);413void hci_add_sco(struct hci_conn *conn, __u16 handle);414void hci_setup_sync(struct hci_conn *conn, __u16 handle);415void hci_sco_setup(struct hci_conn *conn, __u8 status);416417struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst);418int hci_conn_del(struct hci_conn *conn);419void hci_conn_hash_flush(struct hci_dev *hdev);420void hci_conn_check_pending(struct hci_dev *hdev);421422struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type);423int hci_conn_check_link_mode(struct hci_conn *conn);424int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);425int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);426int hci_conn_change_link_key(struct hci_conn *conn);427int hci_conn_switch_role(struct hci_conn *conn, __u8 role);428429void hci_conn_enter_active_mode(struct hci_conn *conn);430void hci_conn_enter_sniff_mode(struct hci_conn *conn);431432void hci_conn_hold_device(struct hci_conn *conn);433void hci_conn_put_device(struct hci_conn *conn);434435static inline void hci_conn_hold(struct hci_conn *conn)436{437atomic_inc(&conn->refcnt);438del_timer(&conn->disc_timer);439}440441static inline void hci_conn_put(struct hci_conn *conn)442{443if (atomic_dec_and_test(&conn->refcnt)) {444unsigned long timeo;445if (conn->type == ACL_LINK) {446del_timer(&conn->idle_timer);447if (conn->state == BT_CONNECTED) {448timeo = msecs_to_jiffies(conn->disc_timeout);449if (!conn->out)450timeo *= 2;451} else452timeo = msecs_to_jiffies(10);453} else454timeo = msecs_to_jiffies(10);455mod_timer(&conn->disc_timer, jiffies + timeo);456}457}458459/* ----- HCI Devices ----- */460static inline void __hci_dev_put(struct hci_dev *d)461{462if (atomic_dec_and_test(&d->refcnt))463d->destruct(d);464}465466static inline void hci_dev_put(struct hci_dev *d)467{468__hci_dev_put(d);469module_put(d->owner);470}471472static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d)473{474atomic_inc(&d->refcnt);475return d;476}477478static inline struct hci_dev *hci_dev_hold(struct hci_dev *d)479{480if (try_module_get(d->owner))481return __hci_dev_hold(d);482return NULL;483}484485#define hci_dev_lock(d) spin_lock(&d->lock)486#define hci_dev_unlock(d) spin_unlock(&d->lock)487#define hci_dev_lock_bh(d) spin_lock_bh(&d->lock)488#define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock)489490struct hci_dev *hci_dev_get(int index);491struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst);492493struct hci_dev *hci_alloc_dev(void);494void hci_free_dev(struct hci_dev *hdev);495int hci_register_dev(struct hci_dev *hdev);496int hci_unregister_dev(struct hci_dev *hdev);497int hci_suspend_dev(struct hci_dev *hdev);498int hci_resume_dev(struct hci_dev *hdev);499int hci_dev_open(__u16 dev);500int hci_dev_close(__u16 dev);501int hci_dev_reset(__u16 dev);502int hci_dev_reset_stat(__u16 dev);503int hci_dev_cmd(unsigned int cmd, void __user *arg);504int hci_get_dev_list(void __user *arg);505int hci_get_dev_info(void __user *arg);506int hci_get_conn_list(void __user *arg);507int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);508int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);509int hci_inquiry(void __user *arg);510511struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);512int hci_blacklist_clear(struct hci_dev *hdev);513514int hci_uuids_clear(struct hci_dev *hdev);515516int hci_link_keys_clear(struct hci_dev *hdev);517struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);518int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,519bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);520int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);521522int hci_remote_oob_data_clear(struct hci_dev *hdev);523struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,524bdaddr_t *bdaddr);525int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,526u8 *randomizer);527int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);528529void hci_del_off_timer(struct hci_dev *hdev);530531void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);532533int hci_recv_frame(struct sk_buff *skb);534int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);535int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);536537int hci_register_sysfs(struct hci_dev *hdev);538void hci_unregister_sysfs(struct hci_dev *hdev);539void hci_conn_init_sysfs(struct hci_conn *conn);540void hci_conn_add_sysfs(struct hci_conn *conn);541void hci_conn_del_sysfs(struct hci_conn *conn);542543#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev))544545/* ----- LMP capabilities ----- */546#define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH)547#define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT)548#define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF)549#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)550#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)551#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)552#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)553#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)554555/* ----- HCI protocols ----- */556struct hci_proto {557char *name;558unsigned int id;559unsigned long flags;560561void *priv;562563int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type);564int (*connect_cfm) (struct hci_conn *conn, __u8 status);565int (*disconn_ind) (struct hci_conn *conn);566int (*disconn_cfm) (struct hci_conn *conn, __u8 reason);567int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, __u16 flags);568int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb);569int (*security_cfm) (struct hci_conn *conn, __u8 status, __u8 encrypt);570};571572static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type)573{574register struct hci_proto *hp;575int mask = 0;576577hp = hci_proto[HCI_PROTO_L2CAP];578if (hp && hp->connect_ind)579mask |= hp->connect_ind(hdev, bdaddr, type);580581hp = hci_proto[HCI_PROTO_SCO];582if (hp && hp->connect_ind)583mask |= hp->connect_ind(hdev, bdaddr, type);584585return mask;586}587588static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status)589{590register struct hci_proto *hp;591592hp = hci_proto[HCI_PROTO_L2CAP];593if (hp && hp->connect_cfm)594hp->connect_cfm(conn, status);595596hp = hci_proto[HCI_PROTO_SCO];597if (hp && hp->connect_cfm)598hp->connect_cfm(conn, status);599600if (conn->connect_cfm_cb)601conn->connect_cfm_cb(conn, status);602}603604static inline int hci_proto_disconn_ind(struct hci_conn *conn)605{606register struct hci_proto *hp;607int reason = 0x13;608609hp = hci_proto[HCI_PROTO_L2CAP];610if (hp && hp->disconn_ind)611reason = hp->disconn_ind(conn);612613hp = hci_proto[HCI_PROTO_SCO];614if (hp && hp->disconn_ind)615reason = hp->disconn_ind(conn);616617return reason;618}619620static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)621{622register struct hci_proto *hp;623624hp = hci_proto[HCI_PROTO_L2CAP];625if (hp && hp->disconn_cfm)626hp->disconn_cfm(conn, reason);627628hp = hci_proto[HCI_PROTO_SCO];629if (hp && hp->disconn_cfm)630hp->disconn_cfm(conn, reason);631632if (conn->disconn_cfm_cb)633conn->disconn_cfm_cb(conn, reason);634}635636static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)637{638register struct hci_proto *hp;639__u8 encrypt;640641if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))642return;643644encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00;645646hp = hci_proto[HCI_PROTO_L2CAP];647if (hp && hp->security_cfm)648hp->security_cfm(conn, status, encrypt);649650hp = hci_proto[HCI_PROTO_SCO];651if (hp && hp->security_cfm)652hp->security_cfm(conn, status, encrypt);653654if (conn->security_cfm_cb)655conn->security_cfm_cb(conn, status);656}657658static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt)659{660register struct hci_proto *hp;661662hp = hci_proto[HCI_PROTO_L2CAP];663if (hp && hp->security_cfm)664hp->security_cfm(conn, status, encrypt);665666hp = hci_proto[HCI_PROTO_SCO];667if (hp && hp->security_cfm)668hp->security_cfm(conn, status, encrypt);669670if (conn->security_cfm_cb)671conn->security_cfm_cb(conn, status);672}673674int hci_register_proto(struct hci_proto *hproto);675int hci_unregister_proto(struct hci_proto *hproto);676677/* ----- HCI callbacks ----- */678struct hci_cb {679struct list_head list;680681char *name;682683void (*security_cfm) (struct hci_conn *conn, __u8 status, __u8 encrypt);684void (*key_change_cfm) (struct hci_conn *conn, __u8 status);685void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role);686};687688static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)689{690struct list_head *p;691__u8 encrypt;692693hci_proto_auth_cfm(conn, status);694695if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))696return;697698encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00;699700read_lock_bh(&hci_cb_list_lock);701list_for_each(p, &hci_cb_list) {702struct hci_cb *cb = list_entry(p, struct hci_cb, list);703if (cb->security_cfm)704cb->security_cfm(conn, status, encrypt);705}706read_unlock_bh(&hci_cb_list_lock);707}708709static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt)710{711struct list_head *p;712713if (conn->sec_level == BT_SECURITY_SDP)714conn->sec_level = BT_SECURITY_LOW;715716hci_proto_encrypt_cfm(conn, status, encrypt);717718read_lock_bh(&hci_cb_list_lock);719list_for_each(p, &hci_cb_list) {720struct hci_cb *cb = list_entry(p, struct hci_cb, list);721if (cb->security_cfm)722cb->security_cfm(conn, status, encrypt);723}724read_unlock_bh(&hci_cb_list_lock);725}726727static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)728{729struct list_head *p;730731read_lock_bh(&hci_cb_list_lock);732list_for_each(p, &hci_cb_list) {733struct hci_cb *cb = list_entry(p, struct hci_cb, list);734if (cb->key_change_cfm)735cb->key_change_cfm(conn, status);736}737read_unlock_bh(&hci_cb_list_lock);738}739740static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, __u8 role)741{742struct list_head *p;743744read_lock_bh(&hci_cb_list_lock);745list_for_each(p, &hci_cb_list) {746struct hci_cb *cb = list_entry(p, struct hci_cb, list);747if (cb->role_switch_cfm)748cb->role_switch_cfm(conn, status, role);749}750read_unlock_bh(&hci_cb_list_lock);751}752753int hci_register_cb(struct hci_cb *hcb);754int hci_unregister_cb(struct hci_cb *hcb);755756int hci_register_notifier(struct notifier_block *nb);757int hci_unregister_notifier(struct notifier_block *nb);758759int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param);760void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags);761void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb);762763void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);764765void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data);766767/* ----- HCI Sockets ----- */768void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb,769struct sock *skip_sk);770771/* Management interface */772int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);773int mgmt_index_added(u16 index);774int mgmt_index_removed(u16 index);775int mgmt_powered(u16 index, u8 powered);776int mgmt_discoverable(u16 index, u8 discoverable);777int mgmt_connectable(u16 index, u8 connectable);778int mgmt_new_key(u16 index, struct link_key *key, u8 persistent);779int mgmt_connected(u16 index, bdaddr_t *bdaddr);780int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);781int mgmt_disconnect_failed(u16 index);782int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);783int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure);784int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);785int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);786int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value,787u8 confirm_hint);788int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);789int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr,790u8 status);791int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);792int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status);793int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,794u8 status);795int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,796u8 *eir);797int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);798int mgmt_discovering(u16 index, u8 discovering);799800/* HCI info for socket */801#define hci_pi(sk) ((struct hci_pinfo *) sk)802803struct hci_pinfo {804struct bt_sock bt;805struct hci_dev *hdev;806struct hci_filter filter;807__u32 cmsg_mask;808unsigned short channel;809};810811/* HCI security filter */812#define HCI_SFLT_MAX_OGF 5813814struct hci_sec_filter {815__u32 type_mask;816__u32 event_mask[2];817__u32 ocf_mask[HCI_SFLT_MAX_OGF + 1][4];818};819820/* ----- HCI requests ----- */821#define HCI_REQ_DONE 0822#define HCI_REQ_PEND 1823#define HCI_REQ_CANCELED 2824825#define hci_req_lock(d) mutex_lock(&d->req_lock)826#define hci_req_unlock(d) mutex_unlock(&d->req_lock)827828void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);829830void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,831u16 latency, u16 to_multiplier);832#endif /* __HCI_CORE_H */833834835