diff options
| author | Johan Hedberg <johan.hedberg@nokia.com> | 2006-09-27 16:25:11 +0000 | 
|---|---|---|
| committer | Johan Hedberg <johan.hedberg@nokia.com> | 2006-09-27 16:25:11 +0000 | 
| commit | 255528bec9a5ffdd81ce509f2166a3a405b958d3 (patch) | |
| tree | 4f0f3944f4d5f26525f8618647d3e1c453b4dc1e /hcid/dbus-adapter.c | |
| parent | 247635fe3905e4cc084a167c6db6e53dd7b0554d (diff) | |
Return correct error reply for CreateBonding when using security mode 3
Diffstat (limited to 'hcid/dbus-adapter.c')
| -rw-r--r-- | hcid/dbus-adapter.c | 28 | 
1 files changed, 23 insertions, 5 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c index 53b65144..b7425a1a 100644 --- a/hcid/dbus-adapter.c +++ b/hcid/dbus-adapter.c @@ -1786,6 +1786,19 @@ failed:  	return -1;  } +static void reply_authentication_failure(struct bonding_request_info *bonding) +{ +	DBusMessage *reply; +	int status; + +	status = bonding->hci_status ? +			bonding->hci_status : HCI_AUTHENTICATION_FAILURE; + +	reply = new_authentication_return(bonding->rq, status); +	if (reply) +		send_reply_and_unref(bonding->conn, reply); +} +  static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,  						struct hci_dbus_data *pdata)  { @@ -1811,10 +1824,12 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,  	if (cond & (G_IO_HUP | G_IO_ERR)) {  		debug("Hangup or error on bonding IO channel"); -		if (!pdata->bonding->connected) + +		if (!pdata->bonding->auth_active)  			error_connection_attempt_failed(pdata->bonding->conn, pdata->bonding->rq, ENETDOWN);  		else -			error_authentication_failed(pdata->bonding->conn, pdata->bonding->rq); +			reply_authentication_failure(pdata->bonding); +  		goto failed;  	} @@ -1828,12 +1843,13 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,  	}  	if (ret != 0) { -		error_connection_attempt_failed(pdata->bonding->conn, pdata->bonding->rq, ret); +		if (pdata->bonding->auth_active) +			reply_authentication_failure(pdata->bonding); +		else +			error_connection_attempt_failed(pdata->bonding->conn, pdata->bonding->rq, ret);  		goto failed;  	} -	pdata->bonding->connected = 1; -  	len = sizeof(cinfo);  	if (getsockopt(sk, SOL_L2CAP, L2CAP_CONNINFO, &cinfo, &len) < 0) {  		error("Can't get connection info: %s (%d)", strerror(errno), errno); @@ -1879,6 +1895,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,  	hci_close_dev(dd); +	pdata->bonding->auth_active = 1; +  	pdata->bonding->io_id = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR,  						(GIOFunc) create_bonding_conn_complete,  						pdata);  | 
