OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 18... | Line 18... | |||
18 | #include "ubus.h" |
18 | #include "ubus.h" |
|
19 | #include "ap_drv_ops.h" |
19 | #include "ap_drv_ops.h" |
|
20 | #include "beacon.h" |
20 | #include "beacon.h" |
|
21 | #include "rrm.h" |
21 | #include "rrm.h" |
|
22 | #include "wnm_ap.h" |
22 | #include "wnm_ap.h" |
|
23 | #include "taxonomy.h" |
- | ||
Line 24... | Line 23... | |||
24 | |
23 | |
|
25 | static struct ubus_context *ctx; |
24 | static struct ubus_context *ctx; |
|
26 | static struct blob_buf b; |
25 | static struct blob_buf b; |
|
Line 183... | Line 182... | |||
183 | r = blobmsg_open_array(&b, "rrm"); |
182 | r = blobmsg_open_array(&b, "rrm"); |
|
184 | for (i = 0; i < ARRAY_SIZE(sta->rrm_enabled_capa); i++) |
183 | for (i = 0; i < ARRAY_SIZE(sta->rrm_enabled_capa); i++) |
|
185 | blobmsg_add_u32(&b, "", sta->rrm_enabled_capa[i]); |
184 | blobmsg_add_u32(&b, "", sta->rrm_enabled_capa[i]); |
|
186 | blobmsg_close_array(&b, r); |
185 | blobmsg_close_array(&b, r); |
|
187 | blobmsg_add_u32(&b, "aid", sta->aid); |
186 | blobmsg_add_u32(&b, "aid", sta->aid); |
|
188 | #ifdef CONFIG_TAXONOMY |
- | ||
189 | r = blobmsg_alloc_string_buffer(&b, "signature", 1024); |
- | ||
190 | if (retrieve_sta_taxonomy(hapd, sta, r, 1024) > 0) |
- | ||
191 | blobmsg_add_string_buffer(&b); |
- | ||
192 | #endif |
- | ||
193 | blobmsg_close_table(&b, c); |
187 | blobmsg_close_table(&b, c); |
|
194 | } |
188 | } |
|
195 | blobmsg_close_array(&b, list); |
189 | blobmsg_close_array(&b, list); |
|
196 | ubus_send_reply(ctx, req, b.head); |
190 | ubus_send_reply(ctx, req, b.head); |
|
Line 197... | Line 191... | |||
197 | |
191 | |
|
198 | return 0; |
192 | return 0; |
|
Line 199... | Line -... | |||
199 | } |
- | ||
200 | |
- | ||
201 | static int |
- | ||
202 | hostapd_bss_get_features(struct ubus_context *ctx, struct ubus_object *obj, |
- | ||
203 | struct ubus_request_data *req, const char *method, |
- | ||
204 | struct blob_attr *msg) |
- | ||
205 | { |
- | ||
206 | struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj); |
- | ||
207 | |
- | ||
208 | blob_buf_init(&b, 0); |
- | ||
209 | blobmsg_add_u8(&b, "ht_supported", ht_supported(hapd->iface->hw_features)); |
- | ||
210 | blobmsg_add_u8(&b, "vht_supported", vht_supported(hapd->iface->hw_features)); |
- | ||
211 | ubus_send_reply(ctx, req, b.head); |
- | ||
212 | |
- | ||
213 | return 0; |
- | ||
214 | } |
193 | } |
|
215 | |
194 | |
|
216 | enum { |
195 | enum { |
|
217 | NOTIFY_RESPONSE, |
196 | NOTIFY_RESPONSE, |
|
Line 380... | Line 359... | |||
380 | } |
359 | } |
|
Line 381... | Line 360... | |||
381 | |
360 | |
|
382 | enum { |
361 | enum { |
|
383 | CSA_FREQ, |
362 | CSA_FREQ, |
|
384 | CSA_BCN_COUNT, |
- | ||
385 | CSA_CENTER_FREQ1, |
- | ||
386 | CSA_CENTER_FREQ2, |
- | ||
387 | CSA_BANDWIDTH, |
- | ||
388 | CSA_SEC_CHANNEL_OFFSET, |
- | ||
389 | CSA_HT, |
- | ||
390 | CSA_VHT, |
- | ||
391 | CSA_BLOCK_TX, |
363 | CSA_BCN_COUNT, |
|
392 | __CSA_MAX |
364 | __CSA_MAX |
|
Line 393... | Line 365... | |||
393 | }; |
365 | }; |
|
- | 366 | |
||
- | 367 | static const struct blobmsg_policy csa_policy[__CSA_MAX] = { |
||
- | 368 | /* |
||
- | 369 | * for now, frequency and beacon count are enough, add more |
||
394 | |
370 | * parameters on demand |
|
395 | static const struct blobmsg_policy csa_policy[__CSA_MAX] = { |
371 | */ |
|
396 | [CSA_FREQ] = { "freq", BLOBMSG_TYPE_INT32 }, |
- | ||
397 | [CSA_BCN_COUNT] = { "bcn_count", BLOBMSG_TYPE_INT32 }, |
- | ||
398 | [CSA_CENTER_FREQ1] = { "center_freq1", BLOBMSG_TYPE_INT32 }, |
- | ||
399 | [CSA_CENTER_FREQ2] = { "center_freq2", BLOBMSG_TYPE_INT32 }, |
- | ||
400 | [CSA_BANDWIDTH] = { "bandwidth", BLOBMSG_TYPE_INT32 }, |
- | ||
401 | [CSA_SEC_CHANNEL_OFFSET] = { "sec_channel_offset", BLOBMSG_TYPE_INT32 }, |
- | ||
402 | [CSA_HT] = { "ht", BLOBMSG_TYPE_BOOL }, |
- | ||
403 | [CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL }, |
372 | [CSA_FREQ] = { "freq", BLOBMSG_TYPE_INT32 }, |
|
Line 404... | Line 373... | |||
404 | [CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL }, |
373 | [CSA_BCN_COUNT] = { "bcn_count", BLOBMSG_TYPE_INT32 }, |
|
405 | }; |
374 | }; |
|
406 | |
375 | |
|
Line 419... | Line 388... | |||
419 | if (!tb[CSA_FREQ]) |
388 | if (!tb[CSA_FREQ]) |
|
420 | return UBUS_STATUS_INVALID_ARGUMENT; |
389 | return UBUS_STATUS_INVALID_ARGUMENT; |
|
Line 421... | Line 390... | |||
421 | |
390 | |
|
422 | memset(&css, 0, sizeof(css)); |
391 | memset(&css, 0, sizeof(css)); |
|
423 | css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); |
- | ||
424 | |
- | ||
425 | #define SET_CSA_SETTING(name, field, type) \ |
- | ||
426 | do { \ |
392 | css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]); |
|
427 | if (tb[name]) \ |
393 | if (tb[CSA_BCN_COUNT]) |
|
428 | css.field = blobmsg_get_ ## type(tb[name]); \ |
- | ||
429 | } while(0) |
- | ||
430 | |
- | ||
431 | SET_CSA_SETTING(CSA_BCN_COUNT, cs_count, u32); |
- | ||
432 | SET_CSA_SETTING(CSA_CENTER_FREQ1, freq_params.center_freq1, u32); |
- | ||
433 | SET_CSA_SETTING(CSA_CENTER_FREQ2, freq_params.center_freq2, u32); |
- | ||
434 | SET_CSA_SETTING(CSA_BANDWIDTH, freq_params.bandwidth, u32); |
- | ||
435 | SET_CSA_SETTING(CSA_SEC_CHANNEL_OFFSET, freq_params.sec_channel_offset, u32); |
- | ||
436 | SET_CSA_SETTING(CSA_HT, freq_params.ht_enabled, bool); |
- | ||
437 | SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool); |
- | ||
438 | SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool); |
- | ||
Line 439... | Line 394... | |||
439 | |
394 | css.cs_count = blobmsg_get_u32(tb[CSA_BCN_COUNT]); |
|
440 | |
395 | |
|
441 | if (hostapd_switch_channel(hapd, &css) != 0) |
396 | if (hostapd_switch_channel(hapd, &css) != 0) |
|
442 | return UBUS_STATUS_NOT_SUPPORTED; |
- | ||
443 | return UBUS_STATUS_OK; |
397 | return UBUS_STATUS_NOT_SUPPORTED; |
|
444 | #undef SET_CSA_SETTING |
398 | return UBUS_STATUS_OK; |
|
Line 445... | Line 399... | |||
445 | } |
399 | } |
|
446 | #endif |
400 | #endif |
|
Line 953... | Line 907... | |||
953 | UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy), |
907 | UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy), |
|
954 | UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans), |
908 | UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans), |
|
955 | UBUS_METHOD_NOARG("wps_start", hostapd_bss_wps_start), |
909 | UBUS_METHOD_NOARG("wps_start", hostapd_bss_wps_start), |
|
956 | UBUS_METHOD_NOARG("wps_cancel", hostapd_bss_wps_cancel), |
910 | UBUS_METHOD_NOARG("wps_cancel", hostapd_bss_wps_cancel), |
|
957 | UBUS_METHOD_NOARG("update_beacon", hostapd_bss_update_beacon), |
911 | UBUS_METHOD_NOARG("update_beacon", hostapd_bss_update_beacon), |
|
958 | UBUS_METHOD_NOARG("get_features", hostapd_bss_get_features), |
- | ||
959 | #ifdef NEED_AP_MLME |
912 | #ifdef NEED_AP_MLME |
|
960 | UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy), |
913 | UBUS_METHOD("switch_chan", hostapd_switch_chan, csa_policy), |
|
961 | #endif |
914 | #endif |
|
962 | UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy), |
915 | UBUS_METHOD("set_vendor_elements", hostapd_vendor_elements, ve_policy), |
|
963 | UBUS_METHOD("notify_response", hostapd_notify_response, notify_policy), |
916 | UBUS_METHOD("notify_response", hostapd_notify_response, notify_policy), |
|
Line 1067... | Line 1020... | |||
1067 | blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da); |
1020 | blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da); |
|
1068 | if (req->frame_info) |
1021 | if (req->frame_info) |
|
1069 | blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal); |
1022 | blobmsg_add_u32(&b, "signal", req->frame_info->ssi_signal); |
|
1070 | blobmsg_add_u32(&b, "freq", hapd->iface->freq); |
1023 | blobmsg_add_u32(&b, "freq", hapd->iface->freq); |
|
Line 1071... | Line -... | |||
1071 | |
- | ||
1072 | if (req->elems) { |
- | ||
1073 | if(req->elems->ht_capabilities) |
- | ||
1074 | { |
- | ||
1075 | struct ieee80211_ht_capabilities *ht_capabilities; |
- | ||
1076 | void *ht_cap, *ht_cap_mcs_set, *mcs_set; |
- | ||
1077 | |
- | ||
1078 | |
- | ||
1079 | ht_capabilities = (struct ieee80211_ht_capabilities*) req->elems->ht_capabilities; |
- | ||
1080 | ht_cap = blobmsg_open_table(&b, "ht_capabilities"); |
- | ||
1081 | blobmsg_add_u16(&b, "ht_capabilities_info", ht_capabilities->ht_capabilities_info); |
- | ||
1082 | ht_cap_mcs_set = blobmsg_open_table(&b, "supported_mcs_set"); |
- | ||
1083 | blobmsg_add_u16(&b, "a_mpdu_params", ht_capabilities->a_mpdu_params); |
- | ||
1084 | blobmsg_add_u16(&b, "ht_extended_capabilities", ht_capabilities->ht_extended_capabilities); |
- | ||
1085 | blobmsg_add_u32(&b, "tx_bf_capability_info", ht_capabilities->tx_bf_capability_info); |
- | ||
1086 | blobmsg_add_u16(&b, "asel_capabilities", ht_capabilities->asel_capabilities); |
- | ||
1087 | mcs_set = blobmsg_open_array(&b, "supported_mcs_set"); |
- | ||
1088 | for (int i = 0; i < 16; i++) { |
- | ||
1089 | blobmsg_add_u16(&b, NULL, (u16) ht_capabilities->supported_mcs_set[i]); |
- | ||
1090 | } |
- | ||
1091 | blobmsg_close_array(&b, mcs_set); |
- | ||
1092 | blobmsg_close_table(&b, ht_cap_mcs_set); |
- | ||
1093 | blobmsg_close_table(&b, ht_cap); |
- | ||
1094 | } |
- | ||
1095 | if(req->elems->vht_capabilities) |
- | ||
1096 | { |
- | ||
1097 | struct ieee80211_vht_capabilities *vht_capabilities; |
- | ||
1098 | void *vht_cap, *vht_cap_mcs_set; |
- | ||
1099 | |
- | ||
1100 | vht_capabilities = (struct ieee80211_vht_capabilities*) req->elems->vht_capabilities; |
- | ||
1101 | vht_cap = blobmsg_open_table(&b, "vht_capabilities"); |
- | ||
1102 | blobmsg_add_u32(&b, "vht_capabilities_info", vht_capabilities->vht_capabilities_info); |
- | ||
1103 | vht_cap_mcs_set = blobmsg_open_table(&b, "vht_supported_mcs_set"); |
- | ||
1104 | blobmsg_add_u16(&b, "rx_map", vht_capabilities->vht_supported_mcs_set.rx_map); |
- | ||
1105 | blobmsg_add_u16(&b, "rx_highest", vht_capabilities->vht_supported_mcs_set.rx_highest); |
- | ||
1106 | blobmsg_add_u16(&b, "tx_map", vht_capabilities->vht_supported_mcs_set.tx_map); |
- | ||
1107 | blobmsg_add_u16(&b, "tx_highest", vht_capabilities->vht_supported_mcs_set.tx_highest); |
- | ||
1108 | blobmsg_close_table(&b, vht_cap_mcs_set); |
- | ||
1109 | blobmsg_close_table(&b, vht_cap); |
- | ||
1110 | } |
- | ||
1111 | } |
- | ||
1112 | |
1024 | |
|
1113 | if (!hapd->ubus.notify_response) { |
1025 | if (!hapd->ubus.notify_response) { |
|
1114 | ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1); |
1026 | ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1); |
|
1115 | return WLAN_STATUS_SUCCESS; |
1027 | return WLAN_STATUS_SUCCESS; |