+
+void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
+ const char *auth_alg)
+{
+ if (!hapd->ubus.obj.has_subscribers)
+ return;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_macaddr(&b, "address", sta->addr);
+ if (auth_alg)
+ blobmsg_add_string(&b, "auth-alg", auth_alg);
+
+ ubus_notify(ctx, &hapd->ubus.obj, "sta-authorized", b.head, -1);
+}
+
+void hostapd_ubus_notify_beacon_report(
+ struct hostapd_data *hapd, const u8 *addr, u8 token, u8 rep_mode,
+ struct rrm_measurement_beacon_report *rep, size_t len)
+{
+ if (!hapd->ubus.obj.has_subscribers)
+ return;
+
+ if (!addr || !rep)
+ return;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_macaddr(&b, "address", addr);
+ blobmsg_add_u16(&b, "op-class", rep->op_class);
+ blobmsg_add_u16(&b, "channel", rep->channel);
+ blobmsg_add_u64(&b, "start-time", rep->start_time);
+ blobmsg_add_u16(&b, "duration", rep->duration);
+ blobmsg_add_u16(&b, "report-info", rep->report_info);
+ blobmsg_add_u16(&b, "rcpi", rep->rcpi);
+ blobmsg_add_u16(&b, "rsni", rep->rsni);
+ blobmsg_add_macaddr(&b, "bssid", rep->bssid);
+ blobmsg_add_u16(&b, "antenna-id", rep->antenna_id);
+ blobmsg_add_u16(&b, "parent-tsf", rep->parent_tsf);
+ blobmsg_add_u16(&b, "rep-mode", rep_mode);
+
+ ubus_notify(ctx, &hapd->ubus.obj, "beacon-report", b.head, -1);
+}
+
+void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
+ int chan_width, int cf1, int cf2)
+{
+ struct hostapd_data *hapd;
+ int i;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_u16(&b, "frequency", frequency);
+ blobmsg_add_u16(&b, "width", chan_width);
+ blobmsg_add_u16(&b, "center1", cf1);
+ blobmsg_add_u16(&b, "center2", cf2);
+
+ for (i = 0; i < iface->num_bss; i++) {
+ hapd = iface->bss[i];
+ ubus_notify(ctx, &hapd->ubus.obj, "radar-detected", b.head, -1);
+ }
+}
+
+#ifdef CONFIG_WNM_AP
+static void hostapd_ubus_notify_bss_transition_add_candidate_list(
+ const u8 *candidate_list, u16 candidate_list_len)
+{
+ char *cl_str;
+ int i;
+
+ if (candidate_list_len == 0)
+ return;
+
+ cl_str = blobmsg_alloc_string_buffer(&b, "candidate-list", candidate_list_len * 2 + 1);
+ for (i = 0; i < candidate_list_len; i++)
+ snprintf(&cl_str[i*2], 3, "%02X", candidate_list[i]);
+ blobmsg_add_string_buffer(&b);
+
+}
+#endif
+
+void hostapd_ubus_notify_bss_transition_response(
+ struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
+ u8 bss_termination_delay, const u8 *target_bssid,
+ const u8 *candidate_list, u16 candidate_list_len)
+{
+#ifdef CONFIG_WNM_AP
+ u16 i;
+
+ if (!hapd->ubus.obj.has_subscribers)
+ return;
+
+ if (!addr)
+ return;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_macaddr(&b, "address", addr);
+ blobmsg_add_u8(&b, "dialog-token", dialog_token);
+ blobmsg_add_u8(&b, "status-code", status_code);
+ blobmsg_add_u8(&b, "bss-termination-delay", bss_termination_delay);
+ if (target_bssid)
+ blobmsg_add_macaddr(&b, "target-bssid", target_bssid);
+
+ hostapd_ubus_notify_bss_transition_add_candidate_list(candidate_list, candidate_list_len);
+
+ ubus_notify(ctx, &hapd->ubus.obj, "bss-transition-response", b.head, -1);
+#endif
+}
+
+int hostapd_ubus_notify_bss_transition_query(
+ struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
+ const u8 *candidate_list, u16 candidate_list_len)
+{
+#ifdef CONFIG_WNM_AP
+ struct ubus_event_req ureq = {};
+ char *cl_str;
+ u16 i;
+
+ if (!hapd->ubus.obj.has_subscribers)
+ return 0;
+
+ if (!addr)
+ return 0;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_macaddr(&b, "address", addr);
+ blobmsg_add_u8(&b, "dialog-token", dialog_token);
+ blobmsg_add_u8(&b, "reason", reason);
+ hostapd_ubus_notify_bss_transition_add_candidate_list(candidate_list, candidate_list_len);
+
+ if (!hapd->ubus.notify_response) {
+ ubus_notify(ctx, &hapd->ubus.obj, "bss-transition-query", b.head, -1);
+ return 0;
+ }
+
+ if (ubus_notify_async(ctx, &hapd->ubus.obj, "bss-transition-query", b.head, &ureq.nreq))
+ return 0;
+
+ ureq.nreq.status_cb = ubus_event_cb;
+ ubus_complete_request(ctx, &ureq.nreq.req, 100);
+
+ return ureq.resp;
+#endif
+}