Exemplo n.º 1
0
int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
{
	int err;

	if (conn->state != BT_CONN_CONNECTED) {
		return -ENOTCONN;
	}

#if defined(CONFIG_BLUETOOTH_SMP_SC_ONLY)
	if (sec < BT_SECURITY_FIPS) {
		return -EOPNOTSUPP;
	}
#endif/* CONFIG_BLUETOOTH_SMP_SC_ONLY */

	/* nothing to do */
	if (conn->sec_level >= sec || conn->required_sec_level >= sec) {
		return 0;
	}

	conn->required_sec_level = sec;

	err = start_security(conn);

	/* reset required security level in case of error */
	if (err) {
		conn->required_sec_level = conn->sec_level;
	}

	return err;
}
Exemplo n.º 2
0
int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
{
	int err;

	BT_DBG("conn %p sec %u", conn, sec);

	if (conn->state != BT_CONN_CONNECTED) {
		return -ENOTCONN;
	}

	/* nothing to do */
	if (conn->sec_level >= sec || conn->required_sec_level >= sec) {
		return 0;
	}

	conn->required_sec_level = sec;

	err = start_security(conn);
	if (err) {
		conn->required_sec_level = conn->sec_level;
	}

	return err;
}