Esempio n. 1
0
static int set_tethering(struct connman_technology *technology,
                         connman_bool_t enabled)
{
    const char *ident, *passphrase, *bridge;

    ident = technology->tethering_ident;
    passphrase = technology->tethering_passphrase;

    if (technology->driver == NULL ||
            technology->driver->set_tethering == NULL)
        return -EOPNOTSUPP;

    __sync_synchronize();
    if (technology->enabled == FALSE)
        return -EACCES;

    bridge = __connman_tethering_get_bridge();
    if (bridge == NULL)
        return -EOPNOTSUPP;

    if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
            (ident == NULL || passphrase == NULL))
        return -EINVAL;

    return technology->driver->set_tethering(technology, ident, passphrase,
            bridge, enabled);
}
Esempio n. 2
0
static int set_tethering(struct connman_technology *technology,
				connman_bool_t enabled)
{
	int result = -EOPNOTSUPP;
	int err;
	const char *ident, *passphrase, *bridge;
	GSList *tech_drivers;

	ident = technology->tethering_ident;
	passphrase = technology->tethering_passphrase;

	__sync_synchronize();
	if (technology->enabled == FALSE)
		return -EACCES;

	bridge = __connman_tethering_get_bridge();
	if (bridge == NULL)
		return -EOPNOTSUPP;

	if (technology->type == CONNMAN_SERVICE_TYPE_WIFI &&
	    (ident == NULL || passphrase == NULL))
		return -EINVAL;

	for (tech_drivers = technology->driver_list; tech_drivers != NULL;
	     tech_drivers = g_slist_next(tech_drivers)) {
		struct connman_technology_driver *driver = tech_drivers->data;

		if (driver == NULL || driver->set_tethering == NULL)
			continue;

		err = driver->set_tethering(technology, ident, passphrase,
				bridge, enabled);

		if (result == -EINPROGRESS)
			continue;

		if (err == -EINPROGRESS || err == 0) {
			result = err;
			continue;
		}
	}

	return result;
}