From c381508d884b4056427af28ccd169f188f5dde66 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 23 Jun 2010 23:04:21 -0700 Subject: [PATCH] P2P: Implement power save configuration wpa_cli p2p_set ps <0/1/2> wpa_cli p2p_set oppps <0/1> wpa_cli p2p_set ctwindow <0..> msec --- src/drivers/driver.h | 11 +++++++++++ src/drivers/driver_ndis.c | 3 ++- wpa_supplicant/ctrl_iface.c | 9 +++++++++ wpa_supplicant/driver_i.h | 10 ++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 029465201..27e883126 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1860,6 +1860,17 @@ struct wpa_driver_ops { * 0. */ int (*set_noa)(void *priv, u8 count, int start, int duration); + + /** + * set_p2p_powersave - Set P2P power save options + * @priv: Private driver interface data + * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change + * @opp_ps: 0 = disable, 1 = enable, -1 = no change + * @ctwindow: 0.. = change (msec), -1 = no change + * Returns: 0 on success or -1 on failure + */ + int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps, + int ctwindow); }; diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c index 73f50df82..b4b5cf313 100644 --- a/src/drivers/driver_ndis.c +++ b/src/drivers/driver_ndis.c @@ -3306,5 +3306,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = { NULL /* send_frame */, NULL /* shared_freq */, NULL /* get_noa */, - NULL /* set_noa */ + NULL /* set_noa */, + NULL /* set_p2p_powersave */ }; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 74daf9606..7c096b3f7 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2434,6 +2434,15 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd) return wpa_drv_set_noa(wpa_s, count, start, duration); } + if (os_strcmp(cmd, "ps") == 0) + return wpa_drv_set_p2p_powersave(wpa_s, atoi(param), -1, -1); + + if (os_strcmp(cmd, "oppps") == 0) + return wpa_drv_set_p2p_powersave(wpa_s, -1, atoi(param), -1); + + if (os_strcmp(cmd, "ctwindow") == 0) + return wpa_drv_set_p2p_powersave(wpa_s, -1, -1, atoi(param)); + if (os_strcmp(cmd, "disabled") == 0) { wpa_s->global->p2p_disabled = atoi(param); wpa_printf(MSG_DEBUG, "P2P functionality %s", diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index 80bff26a1..0868fa8fa 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -522,4 +522,14 @@ static inline int wpa_drv_set_noa(struct wpa_supplicant *wpa_s, u8 count, return wpa_s->driver->set_noa(wpa_s->drv_priv, count, start, duration); } +static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s, + int legacy_ps, int opp_ps, + int ctwindow) +{ + if (!wpa_s->driver->set_p2p_powersave) + return -1; + return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps, + opp_ps, ctwindow); +} + #endif /* DRIVER_I_H */