diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-06-07 11:06:28 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-06-07 11:06:28 +0000 |
commit | 143c6dbeb79417c7f1720d20ff981f54d146c2ad (patch) | |
tree | b64ba3a8ca6d3ec213be3ac1bd7ef2f808104a2a /hcid | |
parent | d1683035d36462b5b336169c1bbfd3a86249e2a5 (diff) |
Removed ba2adapter function
Diffstat (limited to 'hcid')
-rw-r--r-- | hcid/dbus-hci.c | 38 | ||||
-rw-r--r-- | hcid/dbus-hci.h | 1 | ||||
-rw-r--r-- | hcid/dbus-service.c | 27 | ||||
-rw-r--r-- | hcid/dbus-service.h | 2 |
4 files changed, 24 insertions, 44 deletions
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 71d8efa5..b2024ae4 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -78,7 +78,7 @@ static gint adapter_address_cmp(gconstpointer a, gconstpointer b) return strcmp(adapter->address, address); } -static struct adapter *find_adapter(bdaddr_t *sba) +struct adapter *adapter_find(const bdaddr_t *sba) { GSList *match; char address[18]; @@ -951,7 +951,7 @@ void hcid_dbus_new_auth_request(bdaddr_t *sba, bdaddr_t *dba, auth_type_t type) struct adapter *adapter; struct pending_auth_info *info; - adapter = find_adapter(sba); + adapter = adapter_find(sba); if (!adapter) { error("No matching adapter found"); return; @@ -1016,7 +1016,7 @@ int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci) struct device *device; struct agent *agent; - adapter = find_adapter(sba); + adapter = adapter_find(sba); if (!adapter) { error("No matching adapter found"); return -1; @@ -1111,7 +1111,7 @@ int hcid_dbus_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey) struct agent *agent; char addr[18]; - adapter = find_adapter(sba); + adapter = adapter_find(sba); if (!adapter) { error("No matching adapter found"); return -1; @@ -1146,7 +1146,7 @@ int hcid_dbus_user_passkey(bdaddr_t *sba, bdaddr_t *dba) struct agent *agent; char addr[18]; - adapter = find_adapter(sba); + adapter = adapter_find(sba); if (!adapter) { error("No matching adapter found"); return -1; @@ -1190,7 +1190,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, ba2str(peer, peer_addr); - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("Unable to find matching adapter"); return; @@ -1281,7 +1281,7 @@ void hcid_dbus_inquiry_start(bdaddr_t *local) { struct adapter *adapter; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("Unable to find matching adapter"); return; @@ -1444,7 +1444,7 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local) struct remote_dev_info *dev; bdaddr_t tmp; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("Unable to find matching adapter"); return; @@ -1545,7 +1545,7 @@ void hcid_dbus_periodic_inquiry_start(bdaddr_t *local, uint8_t status) if (status) return; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -1579,7 +1579,7 @@ void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status) if (status) return; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -1700,7 +1700,7 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, ba2str(local, local_addr); ba2str(peer, peer_addr); - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -1825,7 +1825,7 @@ void hcid_dbus_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class) if (old_class == class) return; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -1862,7 +1862,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char peer_addr[18]; const char *paddr = peer_addr; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -1955,7 +1955,7 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, struct adapter *adapter; GSList *l; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -2020,7 +2020,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, return; } - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -2276,7 +2276,7 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local) struct hci_request rq; int dd = -1; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -2326,7 +2326,7 @@ void hcid_dbus_write_class_complete(bdaddr_t *local) int dd; uint8_t cls[3]; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -2396,7 +2396,7 @@ void hcid_dbus_pin_code_reply(bdaddr_t *local, void *ptr) ret_pin_code_req_reply *ret = ptr + EVT_CMD_COMPLETE_SIZE; GSList *l; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return; @@ -2417,7 +2417,7 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote, uint8_t *cap, struct agent *agent; char addr[18]; - adapter = find_adapter(local); + adapter = adapter_find(local); if (!adapter) { error("No matching adapter found"); return -1; diff --git a/hcid/dbus-hci.h b/hcid/dbus-hci.h index 31c13199..509bcb7c 100644 --- a/hcid/dbus-hci.h +++ b/hcid/dbus-hci.h @@ -77,3 +77,4 @@ int discov_timeout_handler(void *data); void set_dbus_connection(DBusConnection *conn); DBusConnection *get_dbus_connection(void); +struct adapter *adapter_find(const bdaddr_t *sba); diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index 43b11c51..c05a7d6d 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -654,27 +654,6 @@ void unregister_service(const char *ident) unregister_uuids(ident); } -static struct adapter *ba2adapter(const bdaddr_t *src) -{ - DBusConnection *conn = get_dbus_connection(); - struct adapter *adapter = NULL; - char address[18], path[6]; - int dev_id; - - ba2str(src, address); - dev_id = hci_devid(address); - if (dev_id < 0) - return NULL; - - /* FIXME: id2adapter? Create a list of adapters? */ - snprintf(path, sizeof(path), "/hci%d", dev_id); - if (dbus_connection_get_object_user_data(conn, - path, (void *) &adapter) == FALSE) - return NULL; - - return adapter; -} - static void agent_auth_cb(struct agent *agent, DBusError *derr, void *user_data) { struct service_auth *auth = user_data; @@ -695,7 +674,7 @@ int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, char address[18]; gboolean trusted; - adapter = ba2adapter(src); + adapter = adapter_find(src); if (!adapter) return -EPERM; @@ -736,9 +715,9 @@ int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, return agent_authorize(agent, device->path, uuid, agent_auth_cb, auth); } -int service_cancel_auth(bdaddr_t *src) +int service_cancel_auth(const bdaddr_t *src) { - struct adapter *adapter = ba2adapter(src); + struct adapter *adapter = adapter_find(src); struct device *device; struct agent *agent; char address[18]; diff --git a/hcid/dbus-service.h b/hcid/dbus-service.h index 079cea92..99da10c0 100644 --- a/hcid/dbus-service.h +++ b/hcid/dbus-service.h @@ -44,4 +44,4 @@ void unregister_service(const char *ident); typedef void (*service_auth_cb) (DBusError *derr, void *user_data); int service_req_auth(const bdaddr_t *src, const bdaddr_t *dst, const char *uuid, service_auth_cb cb, void *user_data); -int service_cancel_auth(bdaddr_t *src); +int service_cancel_auth(const bdaddr_t *src); |