/**
 * hostapd_config_reload_iface_start - Start interface reload
 * @hapd_iface: Pointer to interface data.
 * @cb: The function to callback when done.
 * Returns:  0 if it starts successfully; cb will be called when done.
 *          -1 on failure; cb will not be called.
 */
static int hostapd_config_reload_iface_start(struct hostapd_iface *hapd_iface,
					     hostapd_iface_cb cb)
{
	struct hostapd_config_change *change = hapd_iface->change;
	struct hostapd_config *newconf = change->newconf;
	struct hostapd_config *oldconf = change->oldconf;
	struct hostapd_data *hapd = hapd_iface->bss[0];

	if (hapd_iface->reload_iface_cb) {
		wpa_printf(MSG_DEBUG,
			   "%s: Interface reload already in progress.",
			   hapd_iface->bss[0]->conf->iface);
		return -1;
	}

	hapd_iface->reload_iface_cb = cb;

	if (newconf->bridge_packets != oldconf->bridge_packets &&
	    hapd->iconf->bridge_packets != INTERNAL_BRIDGE_DO_NOT_CONTROL &&
	    hostapd_set_internal_bridge(hapd, hapd->iconf->bridge_packets))
		printf("Failed to set bridge_packets for kernel driver\n");

	if (newconf->channel != oldconf->channel ||
	    newconf->hw_mode != oldconf->hw_mode ||
	    rate_array_diff(newconf->supported_rates,
			    oldconf->supported_rates) ||
	    rate_array_diff(newconf->basic_rates, oldconf->basic_rates)) {
		hostapd_free_stas(hapd);

		if (hostapd_get_hw_features(hapd_iface)) {
			printf("Could not read HW feature info from the kernel"
			       " driver.\n");
			hapd_iface->reload_iface_cb = NULL;
			return -1;
		}

		if (hostapd_select_hw_mode_start(hapd_iface,
						 reload_hw_mode_done)) {
			printf("Failed to start select hw_mode.\n");
			hapd_iface->reload_iface_cb = NULL;
			return -1;
		}

		return 0;
	}

	eloop_register_timeout(0, 0, reload_iface2_handler, hapd_iface, NULL);
	return 0;
}
Ejemplo n.º 2
0
/**
 * asd_config_reload_iface_start - Start interface reload
 * @wasd_iface: Pointer to interface data.
 * @cb: The function to callback when done.
 * Returns:  0 if it starts successfully; cb will be called when done.
 *          -1 on failure; cb will not be called.
 */
static int asd_config_reload_iface_start(struct asd_iface *wasd_iface,
					     asd_iface_cb cb)
{
	struct asd_config_change *change = wasd_iface->change;
	struct asd_config *newconf = change->newconf;
	struct asd_config *oldconf = change->oldconf;
	struct asd_data *wasd = wasd_iface->bss[0];

	if (wasd_iface->reload_iface_cb) {
		asd_printf(ASD_DEFAULT,MSG_DEBUG,
			   "%s: Interface reload already in progress.",
			   wasd_iface->bss[0]->conf->iface);
		return -1;
	}

	wasd_iface->reload_iface_cb = cb;

	if (newconf->bridge_packets != oldconf->bridge_packets &&
	    wasd->iconf->bridge_packets != INTERNAL_BRIDGE_DO_NOT_CONTROL &&
	    asd_set_internal_bridge(wasd, wasd->iconf->bridge_packets))
		asd_printf(ASD_DEFAULT,MSG_DEBUG,"Failed to set bridge_packets for kernel driver\n");

	if (newconf->channel != oldconf->channel ||
	    newconf->hw_mode != oldconf->hw_mode ||
	    rate_array_diff(newconf->supported_rates,
			    oldconf->supported_rates) ||
	    rate_array_diff(newconf->basic_rates, oldconf->basic_rates)) {
		asd_free_stas(wasd);

		if (asd_get_hw_features(wasd_iface)) {
			asd_printf(ASD_DEFAULT,MSG_DEBUG,"Could not read HW feature info from the kernel"
			       " driver.\n");
			wasd_iface->reload_iface_cb = NULL;
			return -1;
		}

		if (asd_select_hw_mode_start(wasd_iface,
						 reload_hw_mode_done)) {
			asd_printf(ASD_DEFAULT,MSG_DEBUG,"Failed to start select hw_mode.\n");
			wasd_iface->reload_iface_cb = NULL;
			return -1;
		}

		return 0;
	}

	circle_register_timeout(0, 0, reload_iface2_handler, wasd_iface, NULL);
	return 0;
}