local-node: handle received link-measurement reports
Store link-measurement reports received from STAs as measurements. Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
39
local_node.c
39
local_node.c
@@ -236,6 +236,43 @@ usteer_local_node_handle_beacon_report(struct usteer_local_node *ln, struct blob
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
usteer_local_node_handle_link_measurement_report(struct usteer_local_node *ln, struct blob_attr *msg)
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
LMR_ADDRESS,
|
||||||
|
LMR_RCPI,
|
||||||
|
LMR_RSNI,
|
||||||
|
__LMR_MAX
|
||||||
|
};
|
||||||
|
struct blobmsg_policy policy[__LMR_MAX] = {
|
||||||
|
[LMR_ADDRESS] = { .name = "address", .type = BLOBMSG_TYPE_STRING },
|
||||||
|
[LMR_RCPI] = { .name = "rcpi", .type = BLOBMSG_TYPE_INT16 },
|
||||||
|
[LMR_RSNI] = { .name = "rsni", .type = BLOBMSG_TYPE_INT16 },
|
||||||
|
};
|
||||||
|
struct blob_attr *tb[__LMR_MAX];
|
||||||
|
uint8_t *addr;
|
||||||
|
struct sta *sta;
|
||||||
|
|
||||||
|
blobmsg_parse(policy, __LMR_MAX, tb, blob_data(msg), blob_len(msg));
|
||||||
|
if (!tb[LMR_ADDRESS] || !tb[LMR_RCPI] || !tb[LMR_RSNI])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
addr = (uint8_t *) ether_aton(blobmsg_get_string(tb[LMR_ADDRESS]));
|
||||||
|
if (!addr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
sta = usteer_sta_get(addr, false);
|
||||||
|
if (!sta)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
usteer_measurement_report_add(sta, &ln->node,
|
||||||
|
(uint8_t)blobmsg_get_u16(tb[LMR_RCPI]),
|
||||||
|
(uint8_t)blobmsg_get_u16(tb[LMR_RSNI]),
|
||||||
|
current_time);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
usteer_handle_event(struct ubus_context *ctx, struct ubus_object *obj,
|
usteer_handle_event(struct ubus_context *ctx, struct ubus_object *obj,
|
||||||
struct ubus_request_data *req, const char *method,
|
struct ubus_request_data *req, const char *method,
|
||||||
@@ -275,6 +312,8 @@ usteer_handle_event(struct ubus_context *ctx, struct ubus_object *obj,
|
|||||||
return usteer_handle_bss_tm_response(ln, msg);
|
return usteer_handle_bss_tm_response(ln, msg);
|
||||||
} else if(!strcmp(method, "beacon-report")) {
|
} else if(!strcmp(method, "beacon-report")) {
|
||||||
return usteer_local_node_handle_beacon_report(ln, msg);
|
return usteer_local_node_handle_beacon_report(ln, msg);
|
||||||
|
} else if(!strcmp(method, "link-measurement-report")) {
|
||||||
|
return usteer_local_node_handle_link_measurement_report(ln, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(event_types); i++) {
|
for (i = 0; i < ARRAY_SIZE(event_types); i++) {
|
||||||
|
Reference in New Issue
Block a user