From 7b65de18e8276ed3b5d2cbb64dc06c347f3b0e78 Mon Sep 17 00:00:00 2001 From: Victor Goldenshtein Date: Mon, 21 Nov 2011 17:02:52 +0200 Subject: hostapd: implement channel switch request drv ops (INTERNAL) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New hostapd_channel_switch – to handle channel switch request. Signed-hostap: Victor Goldenshtein --- src/ap/ap_config.h | 3 +++ src/ap/ap_drv_ops.c | 31 +++++++++++++++++++++++++++++++ src/ap/ap_drv_ops.h | 2 ++ src/drivers/driver.h | 19 +++++++++++++++++++ 4 files changed, 55 insertions(+) (limited to 'src') diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index 4e10a0f..d6b67fe 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -432,6 +432,9 @@ struct hostapd_config { int ieee80211d; + /* AP/GO channel switch count */ + int channel_switch_count; + struct hostapd_tx_queue_params tx_queue[NUM_TX_QUEUES]; /* diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 859b529..fbeaf9c 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -596,3 +596,34 @@ int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq, hapd->own_addr, hapd->own_addr, data, len, 0); } + + +int hostapd_channel_switch(struct hostapd_data *hapd, int freq, int flags, + u8 tx_block, u8 post_switch_block_tx) +{ + struct hostapd_channel_switch params; + + if (!hapd->driver || !hapd->driver->hapd_channel_switch) + return 0; + + if (flags & HOSTAPD_CHAN_RADAR) { + wpa_printf(MSG_ERROR, "Can't switch to radar channel, " + "DFS functionality is not supported"); + return -1; + } + + if (hapd->iface->conf->secondary_channel) { + wpa_printf(MSG_ERROR, "Channel switch is not supported " + "with HT40"); + return -1; + } + + params.freq = freq; + params.tx_block = tx_block; + params.post_switch_block_tx = post_switch_block_tx; + params.ch_switch_count = + (hapd->iconf->channel_switch_count > hapd->conf->dtim_period) ? + hapd->iconf->channel_switch_count : hapd->conf->dtim_period * 2; + + return hapd->driver->hapd_channel_switch(hapd->drv_priv, ¶ms); +} diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index e3b15c0..6305050 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -97,6 +97,8 @@ int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr, int reassoc, u16 status, const u8 *ie, size_t len); int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr, u8 *tspec_ie, size_t tspec_ielen); +int hostapd_channel_switch(struct hostapd_data *hapd, int freq, int flags, + u8 tx_block, u8 post_switch_block_tx); #include "drivers/driver.h" diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 7afbda1..b25b4b9 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -898,6 +898,16 @@ struct hostapd_freq_params { * enabled, secondary channel above primary */ }; +struct hostapd_channel_switch { + int freq; + int tx_block; /* immediately block the tx on the + * operational channel + * (prior channel switch) */ + int post_switch_block_tx; /* block tx on the target ch (after + * channel switch) */ + int ch_switch_count; +}; + enum wpa_driver_if_type { /** * WPA_IF_STATION - Station mode interface @@ -2587,6 +2597,15 @@ struct wpa_driver_ops { * Returns: 0 on success, -1 on failure */ int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len); + + /** + * hapd_channel_switch - Perform an AP channel switch + * @priv: Private driver interface data + * @params: Channels switch parameters + * Returns: 0 on success, -1 on failure + */ + int (*hapd_channel_switch)(void *priv, + struct hostapd_channel_switch *params); }; -- cgit v1.1