+enum {
+ BSS_MGMT_EN_NEIGHBOR,
+ BSS_MGMT_EN_BEACON,
+#ifdef CONFIG_WNM_AP
+ BSS_MGMT_EN_BSS_TRANSITION,
+#endif
+ __BSS_MGMT_EN_MAX
+};
+
+static bool
+__hostapd_bss_mgmt_enable_f(struct hostapd_data *hapd, int flag)
+{
+ struct hostapd_bss_config *bss = hapd->conf;
+ uint32_t flags;
+
+ switch (flag) {
+ case BSS_MGMT_EN_NEIGHBOR:
+ if (bss->radio_measurements[0] &
+ WLAN_RRM_CAPS_NEIGHBOR_REPORT)
+ return false;
+
+ bss->radio_measurements[0] |=
+ WLAN_RRM_CAPS_NEIGHBOR_REPORT;
+ hostapd_set_own_neighbor_report(hapd);
+ return true;
+ case BSS_MGMT_EN_BEACON:
+ flags = WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE |
+ WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE |
+ WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
+
+ if (bss->radio_measurements[0] & flags == flags)
+ return false;
+
+ bss->radio_measurements[0] |= (u8) flags;
+ return true;
+#ifdef CONFIG_WNM_AP
+ case BSS_MGMT_EN_BSS_TRANSITION:
+ if (bss->bss_transition)
+ return false;
+
+ bss->bss_transition = 1;
+ return true;
+#endif
+ }
+}
+
+static void
+__hostapd_bss_mgmt_enable(struct hostapd_data *hapd, uint32_t flags)
+{
+ bool update = false;
+ int i;
+
+ for (i = 0; i < __BSS_MGMT_EN_MAX; i++) {
+ if (!(flags & (1 << i)))
+ continue;
+
+ update |= __hostapd_bss_mgmt_enable_f(hapd, i);
+ }
+
+ if (update)
+ ieee802_11_update_beacons(hapd->iface);
+}
+
+
+static const struct blobmsg_policy bss_mgmt_enable_policy[__BSS_MGMT_EN_MAX] = {
+ [BSS_MGMT_EN_NEIGHBOR] = { "neighbor_report", BLOBMSG_TYPE_BOOL },
+ [BSS_MGMT_EN_BEACON] = { "beacon_report", BLOBMSG_TYPE_BOOL },
+#ifdef CONFIG_WNM_AP
+ [BSS_MGMT_EN_BSS_TRANSITION] = { "bss_transition", BLOBMSG_TYPE_BOOL },
+#endif
+};
+
+static int
+hostapd_bss_mgmt_enable(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+
+{
+ struct hostapd_data *hapd = get_hapd_from_object(obj);
+ struct blob_attr *tb[__BSS_MGMT_EN_MAX];
+ struct blob_attr *cur;
+ uint32_t flags = 0;
+ int i;
+ bool neigh = false, beacon = false;
+
+ blobmsg_parse(bss_mgmt_enable_policy, __BSS_MGMT_EN_MAX, tb, blob_data(msg), blob_len(msg));
+
+ for (i = 0; i < ARRAY_SIZE(tb); i++) {
+ if (!tb[i] || !blobmsg_get_bool(tb[i]))
+ continue;
+
+ flags |= (1 << i);
+ }
+
+ __hostapd_bss_mgmt_enable(hapd, flags);
+}
+
+
+static void
+hostapd_rrm_nr_enable(struct hostapd_data *hapd)
+{
+ __hostapd_bss_mgmt_enable(hapd, 1 << BSS_MGMT_EN_NEIGHBOR);
+}
+