/*
* sta->capability is used in check_assoc_ies() for RRM enabled
* capability element.
-@@ -3025,7 +3051,7 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -2688,6 +2714,7 @@ static void handle_disassoc(struct hosta
+ wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
+ MAC2STR(mgmt->sa),
+ le_to_host16(mgmt->u.disassoc.reason_code));
++ hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
+
+ sta = ap_get_sta(hapd, mgmt->sa);
+ if (sta == NULL) {
+@@ -2742,6 +2769,8 @@ static void handle_deauth(struct hostapd
+ " reason_code=%d",
+ MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
+
++ hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
++
+ sta = ap_get_sta(hapd, mgmt->sa);
+ if (sta == NULL) {
+ wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR " trying "
+@@ -3025,7 +3054,7 @@ int ieee802_11_mgmt(struct hostapd_data
if (stype == WLAN_FC_STYPE_PROBE_REQ) {
return 1;
}
-@@ -3043,17 +3069,17 @@ int ieee802_11_mgmt(struct hostapd_data
+@@ -3043,17 +3072,17 @@ int ieee802_11_mgmt(struct hostapd_data
switch (stype) {
case WLAN_FC_STYPE_AUTH:
wpa_printf(MSG_DEBUG, "mgmt::auth");
#ifdef CONFIG_P2P
if (elems.p2p) {
wpabuf_free(sta->p2p_ie);
+--- a/src/ap/sta_info.c
++++ b/src/ap/sta_info.c
+@@ -386,6 +386,7 @@ void ap_handle_timer(void *eloop_ctx, vo
+ HOSTAPD_LEVEL_INFO, "deauthenticated due to "
+ "local deauth request");
+ ap_free_sta(hapd, sta);
++ hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
+ return;
+ }
+
+@@ -533,6 +534,7 @@ skip_poll:
+ hapd, sta,
+ WLAN_REASON_PREV_AUTH_NOT_VALID);
+ ap_free_sta(hapd, sta);
++ hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
+ break;
+ }
+ }
+--- a/src/ap/wpa_auth_glue.c
++++ b/src/ap/wpa_auth_glue.c
+@@ -159,6 +159,7 @@ static void hostapd_wpa_auth_psk_failure
+ struct hostapd_data *hapd = ctx;
+ wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
+ MAC2STR(addr));
++ hostapd_ubus_notify(hapd, "key-mismatch", addr);
+ }
+
+
return 0;
}
+enum {
+ NOTIFY_RESPONSE,
+ __NOTIFY_MAX
+};
+
+static const struct blobmsg_policy notify_policy[__NOTIFY_MAX] = {
+ [NOTIFY_RESPONSE] = { "notify_response", BLOBMSG_TYPE_INT32 },
+};
+
+static int
+hostapd_notify_response(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__NOTIFY_MAX];
+ struct hostapd_data *hapd = get_hapd_from_object(obj);
+ struct wpabuf *elems;
+ const char *pos;
+ size_t len;
+
+ blobmsg_parse(notify_policy, __NOTIFY_MAX, tb,
+ blob_data(msg), blob_len(msg));
+
+ if (!tb[NOTIFY_RESPONSE])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ hapd->ubus.notify_response = blobmsg_get_u32(tb[NOTIFY_RESPONSE]);
+
+ return UBUS_STATUS_OK;
+}
+
enum {
DEL_CLIENT_ADDR,
DEL_CLIENT_REASON,
UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy),
#endif
UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy),
+ UBUS_METHOD("notify_response", hostapd_notify_response, notify_policy),
};
static struct ubus_object_type bss_object_type =
blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal);
blobmsg_add_u32(&b, "freq", hapd->iface->freq);
+ if (!hapd->ubus.notify_response) {
+ ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1);
+ return 0;
+ }
+
if (ubus_notify_async(ctx, &hapd->ubus.obj, type, b.head, &ureq.nreq))
return 0;
return 0;
}
+
+void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *addr)
+{
+ char mac[18];
+
+ if (!hapd->ubus.obj.has_subscribers)
+ return;
+
+ if (!addr)
+ return;
+
+ snprintf(mac, sizeof(mac), MACSTR, MAC2STR(addr));
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_macaddr(&b, "address", mac);
+
+ ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1);
+}