summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/agent.c33
-rw-r--r--hcid/agent.h8
-rw-r--r--hcid/dbus-hci.c10
3 files changed, 28 insertions, 23 deletions
diff --git a/hcid/agent.c b/hcid/agent.c
index b2fbe03c..90df291a 100644
--- a/hcid/agent.c
+++ b/hcid/agent.c
@@ -56,6 +56,7 @@
typedef enum {
AGENT_REQUEST_PASSKEY,
+ AGENT_REQUEST_PINCODE,
AGENT_REQUEST_AUTHORIZE,
AGENT_REQUEST_CONFIRM_MODE
} agent_request_type_t;
@@ -145,6 +146,8 @@ static void agent_free(struct agent *agent)
if (agent->request) {
DBusError err;
+ agent_pincode_cb pincode_cb;
+ agent_cb cb;
if (agent->request->call)
dbus_pending_call_cancel(agent->request->call);
@@ -152,11 +155,13 @@ static void agent_free(struct agent *agent)
dbus_error_init(&err);
dbus_set_error_const(&err, "org.bluez.Error.Failed", "Canceled");
- if (agent->request->type == AGENT_REQUEST_PASSKEY) {
- agent_passkey_cb cb = agent->request->cb;
- cb(agent, &err, NULL, agent->request->user_data);
- } else {
- agent_cb cb = agent->request->cb;
+ switch (agent->request->type) {
+ case AGENT_REQUEST_PINCODE:
+ pincode_cb = agent->request->cb;
+ pincode_cb(agent, &err, NULL, agent->request->user_data);
+ break;
+ default:
+ cb = agent->request->cb;
cb(agent, &err, agent->request->user_data);
}
@@ -364,7 +369,7 @@ int agent_authorize(struct agent *agent,
return 0;
}
-static DBusPendingCall *passkey_request_new(struct agent *agent,
+static DBusPendingCall *pincode_request_new(struct agent *agent,
const char *device_path,
dbus_bool_t numeric)
{
@@ -372,7 +377,7 @@ static DBusPendingCall *passkey_request_new(struct agent *agent,
DBusPendingCall *call;
message = dbus_message_new_method_call(agent->name, agent->path,
- "org.bluez.Agent", "RequestPasskey");
+ "org.bluez.Agent", "RequestPinCode");
if (message == NULL) {
error("Couldn't allocate D-Bus message");
return NULL;
@@ -392,12 +397,12 @@ static DBusPendingCall *passkey_request_new(struct agent *agent,
return call;
}
-static void passkey_reply(DBusPendingCall *call, void *user_data)
+static void pincode_reply(DBusPendingCall *call, void *user_data)
{
struct agent_request *req = user_data;
struct agent *agent = req->agent;
struct adapter *adapter = agent->adapter;
- agent_passkey_cb cb = req->cb;
+ agent_pincode_cb cb = req->cb;
DBusMessage *message;
DBusError err;
bdaddr_t sba;
@@ -457,21 +462,21 @@ done:
agent_free(agent);
}
-int agent_request_passkey(struct agent *agent, struct device *device,
- agent_passkey_cb cb, void *user_data)
+int agent_request_pincode(struct agent *agent, struct device *device,
+ agent_pincode_cb cb, void *user_data)
{
struct agent_request *req;
if (agent->request)
return -EBUSY;
- req = agent_request_new(agent, AGENT_REQUEST_PASSKEY, cb, user_data);
+ req = agent_request_new(agent, AGENT_REQUEST_PINCODE, cb, user_data);
- req->call = passkey_request_new(agent, device->path, FALSE);
+ req->call = pincode_request_new(agent, device->path, FALSE);
if (!req->call)
goto failed;
- dbus_pending_call_set_notify(req->call, passkey_reply, req, NULL);
+ dbus_pending_call_set_notify(req->call, pincode_reply, req, NULL);
agent->request = req;
diff --git a/hcid/agent.h b/hcid/agent.h
index 9d2ac377..31a95428 100644
--- a/hcid/agent.h
+++ b/hcid/agent.h
@@ -27,8 +27,8 @@ struct agent;
typedef void (*agent_cb) (struct agent *agent, DBusError *err,
void *user_data);
-typedef void (*agent_passkey_cb) (struct agent *agent, DBusError *err,
- const char *passkey, void *user_data);
+typedef void (*agent_pincode_cb) (struct agent *agent, DBusError *err,
+ const char *pincode, void *user_data);
typedef void (*agent_remove_cb) (struct agent *agent, void *user_data);
@@ -41,8 +41,8 @@ int agent_destroy(struct agent *agent, gboolean exited);
int agent_authorize(struct agent *agent, const char *path,
const char *uuid, agent_cb cb, void *user_data);
-int agent_request_passkey(struct agent *agent, struct device *device,
- agent_passkey_cb cb, void *user_data);
+int agent_request_pincode(struct agent *agent, struct device *device,
+ agent_pincode_cb cb, void *user_data);
int agent_confirm_mode_change(struct agent *agent, const char *new_mode,
agent_cb cb, void *user_data);
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index fec4d3bb..3c5dd591 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -931,7 +931,7 @@ void hcid_dbus_pending_pin_req_add(bdaddr_t *sba, bdaddr_t *dba)
adapter->bonding->auth_active = 1;
}
-static void passkey_cb(struct agent *agent, DBusError *err, const char *passkey,
+static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
struct device *device)
{
struct adapter *adapter = device->adapter;
@@ -957,13 +957,13 @@ static void passkey_cb(struct agent *agent, DBusError *err, const char *passkey,
goto done;
}
- len = strlen(passkey);
+ len = strlen(pincode);
set_pin_length(&sba, len);
memset(&pr, 0, sizeof(pr));
bacpy(&pr.bdaddr, &dba);
- memcpy(pr.pin_code, passkey, len);
+ memcpy(pr.pin_code, pincode, len);
pr.pin_len = len;
hci_send_cmd(dev, OGF_LINK_CTL, OCF_PIN_CODE_REPLY, PIN_CODE_REPLY_CP_SIZE, &pr);
@@ -1011,8 +1011,8 @@ int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
return -ENODEV;
}
- return agent_request_passkey(agent, device,
- (agent_passkey_cb) passkey_cb,
+ return agent_request_pincode(agent, device,
+ (agent_pincode_cb) pincode_cb,
device);
old_fallback: