This allows alternate data of a different type to be passed to device_request_authentication() for other notification types such as those that require a PIN. --- src/device.c | 9 +++++---- src/device.h | 2 +- src/event.c | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/device.c b/src/device.c index 0ae52ce..0a77f80 100644 --- a/src/device.c +++ b/src/device.c @@ -2753,7 +2753,7 @@ done: } int device_request_authentication(struct btd_device *device, auth_type_t type, - uint32_t passkey, gboolean secure, void *cb) + void *data, gboolean secure, void *cb) { struct authentication_req *auth; struct agent *agent; @@ -2779,7 +2779,6 @@ int device_request_authentication(struct btd_device *device, auth_type_t type, auth->device = device; auth->cb = cb; auth->type = type; - auth->passkey = passkey; auth->secure = secure; device->authr = auth; @@ -2793,11 +2792,13 @@ int device_request_authentication(struct btd_device *device, auth_type_t type, auth, NULL); break; case AUTH_TYPE_CONFIRM: - err = agent_request_confirmation(agent, device, passkey, + auth->passkey = *(uint32_t *)data; + err = agent_request_confirmation(agent, device, auth->passkey, confirm_cb, auth, NULL); break; case AUTH_TYPE_NOTIFY_PASSKEY: - err = agent_display_passkey(agent, device, passkey); + auth->passkey = *(uint32_t *)data; + err = agent_display_passkey(agent, device, auth->passkey); break; default: err = -EINVAL; diff --git a/src/device.h b/src/device.h index d5fdf45..4aca224 100644 --- a/src/device.h +++ b/src/device.h @@ -84,7 +84,7 @@ gboolean device_is_creating(struct btd_device *device, const char *sender); gboolean device_is_bonding(struct btd_device *device, const char *sender); void device_cancel_bonding(struct btd_device *device, uint8_t status); int device_request_authentication(struct btd_device *device, auth_type_t type, - uint32_t passkey, gboolean secure, void *cb); + void *data, gboolean secure, void *cb); void device_cancel_authentication(struct btd_device *device, gboolean aborted); gboolean device_is_authenticating(struct btd_device *device); gboolean device_is_authorizing(struct btd_device *device); diff --git a/src/event.c b/src/event.c index 3259e7d..a4a60d0 100644 --- a/src/event.c +++ b/src/event.c @@ -130,7 +130,7 @@ int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba, gboolean secure) return 0; } - return device_request_authentication(device, AUTH_TYPE_PINCODE, 0, + return device_request_authentication(device, AUTH_TYPE_PINCODE, NULL, secure, pincode_cb); } @@ -179,7 +179,7 @@ int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey) return -ENODEV; return device_request_authentication(device, AUTH_TYPE_CONFIRM, - passkey, FALSE, confirm_cb); + &passkey, FALSE, confirm_cb); } int btd_event_user_passkey(bdaddr_t *sba, bdaddr_t *dba) @@ -190,7 +190,7 @@ int btd_event_user_passkey(bdaddr_t *sba, bdaddr_t *dba) if (!get_adapter_and_device(sba, dba, &adapter, &device, TRUE)) return -ENODEV; - return device_request_authentication(device, AUTH_TYPE_PASSKEY, 0, + return device_request_authentication(device, AUTH_TYPE_PASSKEY, NULL, FALSE, passkey_cb); } @@ -203,7 +203,7 @@ int btd_event_user_notify(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey) return -ENODEV; return device_request_authentication(device, AUTH_TYPE_NOTIFY_PASSKEY, - passkey, FALSE, NULL); + &passkey, FALSE, NULL); } void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer, -- 1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html