From patchwork Tue Mar 13 22:24:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mukesh Agrawal X-Patchwork-Id: 146500 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C2579B6EF3 for ; Wed, 14 Mar 2012 09:25:19 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E8BCB9C192; Tue, 13 Mar 2012 18:25:15 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NzcXnOCiCbkq; Tue, 13 Mar 2012 18:25:15 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 75FEB9C19B; Tue, 13 Mar 2012 18:25:11 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CB6379C19B for ; Tue, 13 Mar 2012 18:25:09 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9QJwvrD4Q+hY for ; Tue, 13 Mar 2012 18:25:06 -0400 (EDT) Received: from mail-gx0-f172.google.com (mail-gx0-f172.google.com [209.85.161.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id E49AB9C192 for ; Tue, 13 Mar 2012 18:25:05 -0400 (EDT) Received: by ggmi1 with SMTP id i1so1518033ggm.17 for ; Tue, 13 Mar 2012 15:25:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type:content-transfer-encoding :x-system-of-record:x-gm-message-state; bh=eixQ0cqfRGCIpdtuW0fiIPdyooIfNS6PKdqhnHkK+xg=; b=Enmg1Y6iYmCppAskUwusj40NJBq+ozRluhGba7ipnegn2z2MDJM9ljVPmm6DB804k8 razYg9/cLChFd66woRrQmfqLA6pS30OmwNaBZGDyNcuz7fT41sUWSY1AqlK3nlRtXwUG aIPqPHUimQcOx/iieT600TSY/yt0Usz6FdXKS68h2sKN1h+XBu+/fjb74RLQTu2xEpOy l5HJ00DJ1iQjirIH/RP5FMPr5dg90/fihrV+FK/cDhOQ5kQONhlsXAuskZO0NZxkvGfn 2LKrfj8XezSV1sN4BxKfc5gQdkjUY0NoSAdARmhrPMsentdBnBixHnmQZn9qGdI9R4xf FLkA== Received: by 10.224.215.7 with SMTP id hc7mr671646qab.20.1331677505369; Tue, 13 Mar 2012 15:25:05 -0700 (PDT) Received: by 10.224.215.7 with SMTP id hc7mr671640qab.20.1331677505284; Tue, 13 Mar 2012 15:25:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.101.82 with HTTP; Tue, 13 Mar 2012 15:24:45 -0700 (PDT) From: Mukesh Agrawal Date: Tue, 13 Mar 2012 15:24:45 -0700 X-Google-Sender-Auth: hTxAYUjLkxm7-7DVFXIXIbmqmH8 Message-ID: Subject: [PATCH] Create DBus getter/setter for ScanInterval To: hostap X-System-Of-Record: true X-Gm-Message-State: ALoCoQkw2DEl++IlpjWRlaeFOvoz/zcE964UPc8B9BZ2YkyWJbRxKY7QS0znkQiRiduH/O4jIypiS1MLhAgzHTh7ercZnDOO9ssEp4cxuVR0M2y7OyUKW4xiQkT5uEhbWT86GSnTbQ3zQ+7AwON4kux7qf9P5NmjSQ== X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Enable control of wpa_s->scan_interval via D-Bus. This parameter controls the delay between successive scans for a suitable AP. Also, update dbus.doxygen with ScanInterval, and some other parameters that were undocumented. Signed-hostap: Mukesh Agrawal ---  doc/dbus.doxygen                        |   25 +++++++++++++++  wpa_supplicant/ctrl_iface.c             |    5 +--  wpa_supplicant/dbus/dbus_new.c          |    4 ++  wpa_supplicant/dbus/dbus_new_handlers.c |   50 +++++++++++++++++++++++++++++++  wpa_supplicant/dbus/dbus_new_handlers.h |    8 +++++  wpa_supplicant/wpa_supplicant.c         |   23 ++++++++++++++  wpa_supplicant/wpa_supplicant_i.h       |    2 +  7 files changed, 113 insertions(+), 4 deletions(-)                                    int debug_show_keys); -- 1.7.7.3 diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index eeea200..b298dd8 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -352,6 +352,21 @@ fi.w1.wpa_supplicant1.CreateInterface.            
  • +      

    BSSExpireAge - u - (read/write)

    +      

    Identical to bss_expiration_age entry in %wpa_supplicant configuration file.

    +      
  • + +      
  • +      

    BSSExpireCount - u - (read/write)

    +      

    Identical to bss_expiration_scan_count entry in %wpa_supplicant configuration file.

    +      
  • + +      
  • +      

    Country - s - (read/write)

    +      

    Identical to country entry in %wpa_supplicant configuration file.

    +      
  • + +      
  •        

    Ifname - s - (read)

           

    Name of network interface controlled by the interface, e.g., wlan0.

         
  • @@ -390,6 +405,16 @@ fi.w1.wpa_supplicant1.CreateInterface.        

    Networks - ao - (read)

           

    List of D-Bus objects paths representing configured networks.

          + +      
  • +      

    FastReauth - b - (read/write)

    +      

    Identical to fast_reauth entry in %wpa_supplicant configuration file.

    +      
  • + +      
  • +      

    ScanInterval - i - (read/write)

    +      

    Time (in seconds) between scans for a suitable AP. Must be >= 0.

    +      
  •      \subsection dbus_interface_signals Signals diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index daece5f..6995313 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2575,10 +2575,7 @@ static int wpa_supplicant_ctrl_iface_scan_interval(        struct wpa_supplicant *wpa_s, char *cmd)  {        int scan_int = atoi(cmd); -       if (scan_int < 0) -               return -1; -       wpa_s->scan_interval = scan_int; -       return 0; +       return wpa_supplicant_set_scan_interval(wpa_s, scan_int);  } diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index c7413aa..d23cac9 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -2559,6 +2559,10 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {          wpas_dbus_getter_fast_reauth,          wpas_dbus_setter_fast_reauth        }, +       { "ScanInterval", WPAS_DBUS_NEW_IFACE_INTERFACE, "i", +         wpas_dbus_getter_scan_interval, +         wpas_dbus_setter_scan_interval +       },  #ifdef CONFIG_WPS        { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",          wpas_dbus_getter_process_credentials, diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 3514b80..ca5ffa4 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -2462,6 +2462,56 @@ dbus_bool_t wpas_dbus_setter_country(DBusMessageIter *iter, DBusError *error,  /** + * wpas_dbus_getter_scan_interval - Get scan interval + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Getter function for "ScanInterval" property. + */ +dbus_bool_t wpas_dbus_getter_scan_interval(DBusMessageIter *iter, +                                          DBusError *error, +                                          void *user_data) +{ +       struct wpa_supplicant *wpa_s = user_data; +       dbus_int32_t scan_interval = wpa_s->scan_interval; + +       return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32, +                                               &scan_interval, error); +} + + +/** + * wpas_dbus_setter_scan_interval - Control scan interval + * @iter: Pointer to incoming dbus message iter + * @error: Location to store error on failure + * @user_data: Function specific data + * Returns: TRUE on success, FALSE on failure + * + * Setter function for "ScanInterval" property. + */ +dbus_bool_t wpas_dbus_setter_scan_interval(DBusMessageIter *iter, +                                          DBusError *error, +                                          void *user_data) +{ +       struct wpa_supplicant *wpa_s = user_data; +       dbus_int32_t scan_interval; + +       if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_INT32, +                                             &scan_interval)) +               return FALSE; + +       if (wpa_supplicant_set_scan_interval(wpa_s, scan_interval)) { +               dbus_set_error_const(error, DBUS_ERROR_FAILED, +                                    "scan_interval must be >= 0"); +               return FALSE; +       } +       return TRUE; +} + + +/**  * wpas_dbus_getter_ifname - Get interface name  * @iter: Pointer to incoming dbus message iter  * @error: Location to store error on failure diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h index b46658f..6383d98 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.h +++ b/wpa_supplicant/dbus/dbus_new_handlers.h @@ -168,6 +168,14 @@ dbus_bool_t wpas_dbus_getter_country(DBusMessageIter *iter, DBusError *error,  dbus_bool_t wpas_dbus_setter_country(DBusMessageIter *iter, DBusError *error,                                     void *user_data); +dbus_bool_t wpas_dbus_getter_scan_interval(DBusMessageIter *iter, +                                          DBusError *error, +                                          void *user_data); + +dbus_bool_t wpas_dbus_setter_scan_interval(DBusMessageIter *iter, +                                          DBusError *error, +                                          void *user_data); +  dbus_bool_t wpas_dbus_getter_ifname(DBusMessageIter *iter, DBusError *error,                                    void *user_data); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 36074d5..543646c 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1782,6 +1782,29 @@ int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,  /** + * wpa_supplicant_set_scan_interval - Set scan interval + * @wpa_s: wpa_supplicant structure for a network interface + * @scan_interval: scan interval in seconds + * Returns: 0 if succeed or -1 if scan_interval has an invalid value + * + */ +int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, +                                    int scan_interval) +{ +       if (scan_interval < 0) { +               wpa_msg(wpa_s, MSG_ERROR, "Invalid scan interval %d", +                       scan_interval); +               return -1; +       } +       wpa_msg(wpa_s, MSG_DEBUG, "Setting scan interval: %d sec", +               scan_interval); +       wpa_s->scan_interval = scan_interval; + +       return 0; +} + + +/**  * wpa_supplicant_set_debug_params - Set global debug params  * @global: wpa_global structure  * @debug_level: debug level diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0ba1935..d16e82e 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -583,6 +583,8 @@ int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,                                          unsigned int expire_age);  int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,                                            unsigned int expire_count); +int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, +                                    int scan_interval);  int wpa_supplicant_set_debug_params(struct wpa_global *global,                                    int debug_level, int debug_timestamp,