Message ID | 1370578345-6904-1-git-send-email-chengyix.zhao@gmail.com |
---|---|
State | Accepted |
Commit | 8a901d750b1ee3b2bf892565ded62ee5dfd87d0b |
Headers | show |
Hi Jouni, Dan, Thank you very much for your expert advice. In fact this patch can help third-party modules in real-time manage stations information. Could you tell me if I need to further improve this patch? Best Regards, Chengyi 2013/6/7 Chengyi Zhao <chengyix.zhao@gmail.com>: > From: Chengyi Zhao <chengyix.zhao@gmail.com> > > Add "StaAuthorized" and "StaDeauthorized" D-Bus interface in AP mode. > After enabling the AP mode of wpa_supplicant, the other process need to get > the mac address and authorization status of every station, so wpa_supplicant > emits signal when the station is authorized or deauthorized. > > Signed-hostap: Chengyi Zhao <chengyix.zhao@gmail.com> > --- > doc/dbus.doxygen | 20 +++++++++++ > wpa_supplicant/dbus/dbus_new.c | 78 ++++++++++++++++++++++++++++++++++++++++ > wpa_supplicant/dbus/dbus_new.h | 16 +++++++++ > wpa_supplicant/notify.c | 12 +++++++ > 4 files changed, 126 insertions(+) > > diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen > index 988f769..1fa7a3a 100644 > --- a/doc/dbus.doxygen > +++ b/doc/dbus.doxygen > @@ -533,6 +533,26 @@ fi.w1.wpa_supplicant1.CreateInterface. > </li> > > <li> > + <h3>StaAuthorized ( s : mac )</h3> > + <p>A new station has been authorized to the interface.</p> > + <h4>Arguments</h4> > + <dl> > + <dt>s : mac</dt> > + <dd>A mac address which has been authorized.</dd> > + </dl> > + </li> > + > + <li> > + <h3>StaDeauthorized ( s : mac )</h3> > + <p>A station has been deauthorized to the interface.</p> > + <h4>Arguments</h4> > + <dl> > + <dt>s : mac</dt> > + <dd>A mac address which has been deauthorized.</dd> > + </dl> > + </li> > + > + <li> > <h3>PropertiesChanged ( a{sv} : properties )</h3> > <p>Some properties have changed.</p> > <h4>Arguments</h4> > diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c > index e9bd51f..b335b72 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 mac 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_authorized - Send a authorized signal > + * @wpa_s: %wpa_supplicant network interface data > + * @sta: station mac address > + * > + * Notify listeners a new station has been authorized > + */ > +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_sta_deauthorized - Send a deauthorized signal > + * @wpa_s: %wpa_supplicant network interface data > + * @sta: station mac address > + * > + * Notify listeners a station has been deauthorized > + */ > +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..9e6fa17 100644 > --- a/wpa_supplicant/notify.c > +++ b/wpa_supplicant/notify.c > @@ -547,6 +547,12 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, > */ > wpas_dbus_signal_p2p_peer_joined(wpa_s, sta); > #endif /* CONFIG_P2P */ > + > + /* > + * Notify listeners a new station > + * has been authorized > + */ > + wpas_dbus_signal_sta_authorized(wpa_s, sta); > } > > > @@ -566,6 +572,12 @@ static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, > */ > wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta); > #endif /* CONFIG_P2P */ > + > + /* > + * Notify listeners a station > + * has been deauthorized > + */ > + wpas_dbus_signal_sta_deauthorized(wpa_s, sta); > } > > > -- > 1.7.9.5 >
On Fri, Jun 07, 2013 at 12:12:25PM +0800, Chengyi Zhao wrote: > Add "StaAuthorized" and "StaDeauthorized" D-Bus interface in AP mode. > After enabling the AP mode of wpa_supplicant, the other process need to get > the mac address and authorization status of every station, so wpa_supplicant > emits signal when the station is authorized or deauthorized. Thanks, applied.
diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index 988f769..1fa7a3a 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -533,6 +533,26 @@ fi.w1.wpa_supplicant1.CreateInterface. </li> <li> + <h3>StaAuthorized ( s : mac )</h3> + <p>A new station has been authorized to the interface.</p> + <h4>Arguments</h4> + <dl> + <dt>s : mac</dt> + <dd>A mac address which has been authorized.</dd> + </dl> + </li> + + <li> + <h3>StaDeauthorized ( s : mac )</h3> + <p>A station has been deauthorized to the interface.</p> + <h4>Arguments</h4> + <dl> + <dt>s : mac</dt> + <dd>A mac address which has been deauthorized.</dd> + </dl> + </li> + + <li> <h3>PropertiesChanged ( a{sv} : properties )</h3> <p>Some properties have changed.</p> <h4>Arguments</h4> diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index e9bd51f..b335b72 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 mac 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_authorized - Send a authorized signal + * @wpa_s: %wpa_supplicant network interface data + * @sta: station mac address + * + * Notify listeners a new station has been authorized + */ +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_sta_deauthorized - Send a deauthorized signal + * @wpa_s: %wpa_supplicant network interface data + * @sta: station mac address + * + * Notify listeners a station has been deauthorized + */ +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..9e6fa17 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -547,6 +547,12 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, */ wpas_dbus_signal_p2p_peer_joined(wpa_s, sta); #endif /* CONFIG_P2P */ + + /* + * Notify listeners a new station + * has been authorized + */ + wpas_dbus_signal_sta_authorized(wpa_s, sta); } @@ -566,6 +572,12 @@ static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s, */ wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta); #endif /* CONFIG_P2P */ + + /* + * Notify listeners a station + * has been deauthorized + */ + wpas_dbus_signal_sta_deauthorized(wpa_s, sta); }
From: Chengyi Zhao <chengyix.zhao@gmail.com> Add "StaAuthorized" and "StaDeauthorized" D-Bus interface in AP mode. After enabling the AP mode of wpa_supplicant, the other process need to get the mac address and authorization status of every station, so wpa_supplicant emits signal when the station is authorized or deauthorized. Signed-hostap: Chengyi Zhao <chengyix.zhao@gmail.com> --- doc/dbus.doxygen | 20 +++++++++++ wpa_supplicant/dbus/dbus_new.c | 78 ++++++++++++++++++++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 16 +++++++++ wpa_supplicant/notify.c | 12 +++++++ 4 files changed, 126 insertions(+)