]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/net/bluetooth/hci_core.h
Bluetooth: Add name resolving support for mgmt based discovery
[mirror_ubuntu-bionic-kernel.git] / include / net / bluetooth / hci_core.h
index 5e2e984584968f0e6beea90c8657eb1639a1cba2..a8680da7f40011fce5c7222509147b3e8d012490 100644 (file)
@@ -44,14 +44,30 @@ struct inquiry_data {
 };
 
 struct inquiry_entry {
-       struct inquiry_entry    *next;
+       struct list_head        all;            /* inq_cache.all */
+       struct list_head        list;           /* unknown or resolve */
+       enum {
+               NAME_NOT_KNOWN,
+               NAME_NEEDED,
+               NAME_PENDING,
+               NAME_KNOWN,
+       } name_state;
        __u32                   timestamp;
        struct inquiry_data     data;
 };
 
-struct inquiry_cache {
-       __u32                   timestamp;
-       struct inquiry_entry    *list;
+struct discovery_state {
+       enum {
+               DISCOVERY_STOPPED,
+               DISCOVERY_STARTING,
+               DISCOVERY_INQUIRY,
+               DISCOVERY_RESOLVING,
+               DISCOVERY_STOPPING,
+       } state;
+       struct list_head all;           /* All devices found during inquiry */
+       struct list_head unknown;       /* Name state not known */
+       struct list_head resolve;       /* Name needs to be resolved */
+       __u32           timestamp;
 };
 
 struct hci_conn_hash {
@@ -127,7 +143,7 @@ struct hci_dev {
        __u8            major_class;
        __u8            minor_class;
        __u8            features[8];
-       __u8            extfeatures[8];
+       __u8            host_features[8];
        __u8            commands[64];
        __u8            ssp_mode;
        __u8            hci_ver;
@@ -217,7 +233,7 @@ struct hci_dev {
 
        struct list_head        mgmt_pending;
 
-       struct inquiry_cache    inq_cache;
+       struct discovery_state  discovery;
        struct hci_conn_hash    conn_hash;
        struct list_head        blacklist;
 
@@ -348,21 +364,26 @@ extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
 #define INQUIRY_CACHE_AGE_MAX   (HZ*30)   /* 30 seconds */
 #define INQUIRY_ENTRY_AGE_MAX   (HZ*60)   /* 60 seconds */
 
-static inline void inquiry_cache_init(struct hci_dev *hdev)
+static inline void discovery_init(struct hci_dev *hdev)
 {
-       struct inquiry_cache *c = &hdev->inq_cache;
-       c->list = NULL;
+       hdev->discovery.state = DISCOVERY_STOPPED;
+       INIT_LIST_HEAD(&hdev->discovery.all);
+       INIT_LIST_HEAD(&hdev->discovery.unknown);
+       INIT_LIST_HEAD(&hdev->discovery.resolve);
 }
 
+bool hci_discovery_active(struct hci_dev *hdev);
+
+void hci_discovery_set_state(struct hci_dev *hdev, int state);
+
 static inline int inquiry_cache_empty(struct hci_dev *hdev)
 {
-       struct inquiry_cache *c = &hdev->inq_cache;
-       return c->list == NULL;
+       return list_empty(&hdev->discovery.all);
 }
 
 static inline long inquiry_cache_age(struct hci_dev *hdev)
 {
-       struct inquiry_cache *c = &hdev->inq_cache;
+       struct discovery_state *c = &hdev->discovery;
        return jiffies - c->timestamp;
 }
 
@@ -373,7 +394,13 @@ static inline long inquiry_entry_age(struct inquiry_entry *e)
 
 struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev,
                                                        bdaddr_t *bdaddr);
-void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data);
+struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev,
+                                                       bdaddr_t *bdaddr);
+struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev,
+                                                       bdaddr_t *bdaddr,
+                                                       int state);
+bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
+                                                       bool name_known);
 
 /* ----- HCI Connections ----- */
 enum {
@@ -676,7 +703,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
 #define lmp_le_capable(dev)        ((dev)->features[4] & LMP_LE)
 
 /* ----- Extended LMP capabilities ----- */
-#define lmp_host_le_capable(dev)   ((dev)->extfeatures[0] & LMP_HOST_LE)
+#define lmp_host_le_capable(dev)   ((dev)->host_features[0] & LMP_HOST_LE)
 
 /* ----- HCI protocols ----- */
 static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
@@ -915,7 +942,8 @@ int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
 int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
                                                u8 *randomizer, u8 status);
 int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
-                               u8 addr_type, u8 *dev_class, s8 rssi, u8 *eir);
+                                       u8 addr_type, u8 *dev_class, s8 rssi,
+                                       u8 cfm_name, u8 *eir);
 int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name);
 int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
 int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);