From patchwork Thu May 23 02:25:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengyi Zhao X-Patchwork-Id: 245797 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 72F8D2C00A6 for ; Thu, 23 May 2013 12:25:44 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8E2989C132; Wed, 22 May 2013 22:25:41 -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 Jg3gU-I42y1i; Wed, 22 May 2013 22:25:41 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 10BD49C038; Wed, 22 May 2013 22:25:36 -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 CA5589C14D for ; Wed, 22 May 2013 22:25:34 -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 0600rzx1OyDd for ; Wed, 22 May 2013 22:25:28 -0400 (EDT) Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) (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 3B6509C106 for ; Wed, 22 May 2013 22:25:28 -0400 (EDT) Received: by mail-pb0-f47.google.com with SMTP id rr4so2363579pbb.20 for ; Wed, 22 May 2013 19:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=y3yngPgYFwPTKLuxjVtxJLOfJinO6hVLxuN0muKfc2Y=; b=d9neCWQMa7/JCatYtrJ8RwfbKPPnEd30DvCFy+UQrEoHyIb3jRYzDmiUd8I38WZ3U1 TIyWwf5qbjZwpltie9x+nF99KrMDSufPTA0CzyF7tJtIKdlvrGsNpcSr5JrIgIhCj3bw rkRyGPPBWqpbC7gb9u3K5h3BHbjc0Q1NDw3VwFgVAS3oQ22WdRfwtW3gl0IbI6mMZc2n E73HTwN0gx/uWnkEm9c3BpnjcGPTu/Q8qjipZUXnOUaMtiMj2BmWez7alD2UYKHoL8we E6t6iTq/Nt/am5OV/w1hrIUyAE6zu73vAWxu+ZAg8Tv+0f6BEZN/T767J7WREiffpq/n JGAw== X-Received: by 10.68.60.130 with SMTP id h2mr10372082pbr.208.1369275926867; Wed, 22 May 2013 19:25:26 -0700 (PDT) Received: from localhost.localdomain ([27.17.36.150]) by mx.google.com with ESMTPSA id fm2sm10545078pab.13.2013.05.22.19.25.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 May 2013 19:25:26 -0700 (PDT) From: Chengyi Zhao To: hostap@lists.shmoo.com Subject: [PATCH] wpa_supplicant: Emit signal when the station authorized or deauthorized in AP mode Date: Thu, 23 May 2013 10:25:16 +0800 Message-Id: <1369275916-5374-1-git-send-email-chengyix.zhao@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Chengyi Zhao Signed-off-by: Chengyi Zhao --- wpa_supplicant/dbus/dbus_new.c | 78 ++++++++++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 16 +++++++++ wpa_supplicant/notify.c | 4 +++ 3 files changed, 98 insertions(+) diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index e9bd51f..dfd0a8b 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -868,6 +868,72 @@ nomem: dbus_message_unref(msg); } +/** + * wpas_dbus_signal_sta - Send a station related event signal + * @wpa_s: %wpa_supplicant network interface data + * @sta: station address + * @sig_name: signal name - StaAuthorized or StaDeauthorized + * + * Notify listeners about event related with station + */ +static void wpas_dbus_signal_sta(struct wpa_supplicant *wpa_s, + const u8 *sta, const char *sig_name) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + char sta_mac[WPAS_DBUS_OBJECT_PATH_MAX]; + char *dev_mac; + + os_snprintf(sta_mac, WPAS_DBUS_OBJECT_PATH_MAX, MACSTR, MAC2STR(sta)); + dev_mac = sta_mac; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (iface == NULL) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name); + if (msg == NULL) + return; + + if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &dev_mac, + DBUS_TYPE_INVALID)) + dbus_connection_send(iface->con, msg, NULL); + else + wpa_printf(MSG_ERROR, "dbus: Failed to construct signal"); + dbus_message_unref(msg); + + wpa_printf(MSG_DEBUG, "dbus: station mac address '%s' '%s'", + sta_mac, sig_name); +} + +/** + * wpas_dbus_signal_sta_connected - Send a station connected signal + * @wpa_s: %wpa_supplicant network interface data + * @sta: station address + * + * Notify listeners about connecting a new station + */ +void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, + const u8 *sta) +{ + wpas_dbus_signal_sta(wpa_s, sta, "StaAuthorized"); +} + +/** + * wpas_dbus_signal_blob_removed - Send a station disconnected signal + * @wpa_s: %wpa_supplicant network interface data + * @sta: station address + * + * Notify listeners about disconnecting station + */ +void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, + const u8 *sta) +{ + wpas_dbus_signal_sta(wpa_s, sta, "StaDeauthorized"); +} #ifdef CONFIG_P2P @@ -3017,6 +3083,18 @@ static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = { END_ARGS } }, + { "StaAuthorized", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "name", "s", ARG_OUT }, + END_ARGS + } + }, + { "StaDeauthorized", WPAS_DBUS_NEW_IFACE_INTERFACE, + { + { "name", "s", ARG_OUT }, + END_ARGS + } + }, { NULL, NULL, { END_ARGS } } }; diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 363a7e5..2a8e176 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -222,6 +222,10 @@ void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s, const u8 *ie, size_t ie_len, u32 ssi_signal); void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, const char *status, const char *parameter); +void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, + const u8 *sta); +void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, + const u8 *sta); #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ @@ -493,6 +497,18 @@ static inline void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, { } +static inline +void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, + const u8 *sta) +{ +} + +static inline +void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, + const u8 *sta) +{ +} + #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ #endif /* CTRL_IFACE_DBUS_H_NEW */ diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index ca6f7e7..d416fb7 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -547,6 +547,8 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, */ wpas_dbus_signal_p2p_peer_joined(wpa_s, sta); #endif /* CONFIG_P2P */ + + wpas_dbus_signal_sta_authorized(wpa_s, sta); } @@ -566,6 +568,8 @@ static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, */ wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta); #endif /* CONFIG_P2P */ + + wpas_dbus_signal_sta_deauthorized(wpa_s, sta); }