diff options
author | Alok Barsode <alok.barsode@azingo.com> | 2008-09-03 14:11:04 +0530 |
---|---|---|
committer | Alok Barsode <alok.barsode@azingo.com> | 2008-09-03 14:11:04 +0530 |
commit | 0502c569a87101fdcb79d9f772156daa3f744baa (patch) | |
tree | 41cacd30846396b538d19f95613af0b8a30c8cdd | |
parent | f4b3a12b9a7449ab98e4d2a40c6e541d1bece92e (diff) |
Adding adapter_get_bonding_info.
-rw-r--r-- | src/adapter.c | 8 | ||||
-rw-r--r-- | src/adapter.h | 1 | ||||
-rw-r--r-- | src/dbus-hci.c | 33 |
3 files changed, 30 insertions, 12 deletions
diff --git a/src/adapter.c b/src/adapter.c index e21a5452..fbbf3ea9 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3024,6 +3024,14 @@ void adapter_free_bonding_request(struct adapter *adapter) adapter->bonding = NULL; } +struct bonding_request_info *adapter_get_bonding_info(struct adapter *adapter) +{ + if (!adapter || !adapter->bonding) + return NULL; + + return adapter->bonding; +} + int btd_register_adapter_driver(struct btd_adapter_driver *driver) { adapter_drivers = g_slist_append(adapter_drivers, driver); diff --git a/src/adapter.h b/src/adapter.h index 3644a36a..e41911e5 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -184,6 +184,7 @@ struct active_conn_info *adapter_search_active_conn_by_bdaddr(struct adapter *ad struct active_conn_info *adapter_search_active_conn_by_handle(struct adapter *adapter, uint16_t handle); void adapter_free_bonding_request(struct adapter *adapter); +struct bonding_request_info *adapter_get_bonding_info(struct adapter *adapter); struct btd_adapter_driver { const char *name; diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 703b2f41..bddadcef 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -127,9 +127,10 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode, const gchar *destination = device_get_address(device); uint16_t dev_id = adapter_get_dev_id(adapter); const gchar *source = adapter_get_address(adapter); + struct bonding_request_info *bonding = adapter_get_bonding_info(adapter); /* No need to reply anything if the authentication already failed */ - if (adapter->bonding && adapter->bonding->hci_status) + if (bonding && bonding->hci_status) return; dev = hci_open_dev(dev_id); @@ -223,9 +224,10 @@ static void confirm_cb(struct agent *agent, DBusError *err, void *user_data) struct pending_auth_info *auth; const gchar *destination = device_get_address(device); uint16_t dev_id = adapter_get_dev_id(adapter); + struct bonding_request_info *bonding = adapter_get_bonding_info(adapter); /* No need to reply anything if the authentication already failed */ - if (adapter->bonding && adapter->bonding->hci_status) + if (bonding && bonding->hci_status) return; dd = hci_open_dev(dev_id); @@ -265,9 +267,10 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey, struct pending_auth_info *auth; const gchar *destination = device_get_address(device); uint16_t dev_id = adapter_get_dev_id(adapter); + struct bonding_request_info *bonding = adapter_get_bonding_info(adapter); /* No need to reply anything if the authentication already failed */ - if (adapter->bonding && adapter->bonding->hci_status) + if (bonding && bonding->hci_status) return; dd = hci_open_dev(dev_id); @@ -521,9 +524,11 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, return; } + bonding = adapter_get_bonding_info(adapter); + if (status) { - if (adapter->bonding) - adapter->bonding->hci_status = status; + if (bonding) + bonding->hci_status = status; } auth = adapter_find_auth_request(adapter, peer); @@ -559,7 +564,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, } proceed: - bonding = adapter->bonding; + bonding = adapter_get_bonding_info(adapter); if (!bonding || bacmp(&bonding->bdaddr, peer)) return; /* skip: no bonding req pending */ @@ -1025,6 +1030,7 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, const char *paddr = peer_addr; struct adapter *adapter; const gchar *dev_path; + struct bonding_request_info *bonding; adapter = manager_find_adapter(local); if (!adapter) { @@ -1043,8 +1049,9 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, adapter_remove_auth_request(adapter, peer); - if (adapter->bonding) - adapter->bonding->hci_status = status; + bonding = adapter_get_bonding_info(adapter); + if (bonding) + bonding->hci_status = status; } else { struct btd_device *device; gboolean connected = TRUE; @@ -1078,6 +1085,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, const gchar *destination; const gchar *dev_path; uint16_t dev_id; + struct bonding_request_info *bonding; if (status) { error("Disconnection failed: 0x%02x", status); @@ -1106,15 +1114,16 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, adapter_remove_auth_request(adapter, &dev->bdaddr); + bonding = adapter_get_bonding_info(adapter); /* Check if there is a pending CreateBonding request */ - if (adapter->bonding && (bacmp(&adapter->bonding->bdaddr, &dev->bdaddr) == 0)) { - if (adapter->bonding->cancel) { + if (bonding && (bacmp(&bonding->bdaddr, &dev->bdaddr) == 0)) { + if (bonding->cancel) { /* reply authentication canceled */ - reply = new_authentication_return(adapter->bonding->msg, + reply = new_authentication_return(bonding->msg, HCI_OE_USER_ENDED_CONNECTION); g_dbus_send_message(connection, reply); } else { - reply = new_authentication_return(adapter->bonding->msg, + reply = new_authentication_return(bonding->msg, HCI_AUTHENTICATION_FAILURE); dbus_connection_send(connection, reply, NULL); dbus_message_unref(reply); |