local-node: obtain channel + op-class

In order to send passive beacon-requests, channel and op-class of nodes
are required. Obtain this information per local-node from hostapd.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer
2022-01-08 23:26:03 +01:00
parent c7830b5319
commit 3b51bfbaf6
6 changed files with 52 additions and 0 deletions

View File

@@ -342,6 +342,36 @@ usteer_local_node_list_cb(struct ubus_request *req, int type, struct blob_attr *
usteer_local_node_set_assoc(ln, tb[MSG_CLIENTS]); usteer_local_node_set_assoc(ln, tb[MSG_CLIENTS]);
} }
static void
usteer_local_node_status_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{
enum {
MSG_FREQ,
MSG_CHANNEL,
MSG_OP_CLASS,
__MSG_MAX,
};
static struct blobmsg_policy policy[__MSG_MAX] = {
[MSG_FREQ] = { "freq", BLOBMSG_TYPE_INT32 },
[MSG_CHANNEL] = { "channel", BLOBMSG_TYPE_INT32 },
[MSG_OP_CLASS] = { "op_class", BLOBMSG_TYPE_INT32 },
};
struct blob_attr *tb[__MSG_MAX];
struct usteer_local_node *ln;
struct usteer_node *node;
ln = container_of(req, struct usteer_local_node, req);
node = &ln->node;
blobmsg_parse(policy, __MSG_MAX, tb, blob_data(msg), blob_len(msg));
if (tb[MSG_FREQ])
node->freq = blobmsg_get_u32(tb[MSG_FREQ]);
if (tb[MSG_CHANNEL])
node->channel = blobmsg_get_u32(tb[MSG_CHANNEL]);
if (tb[MSG_FREQ])
node->op_class = blobmsg_get_u32(tb[MSG_OP_CLASS]);
}
static void static void
usteer_local_node_rrm_nr_cb(struct ubus_request *req, int type, struct blob_attr *msg) usteer_local_node_rrm_nr_cb(struct ubus_request *req, int type, struct blob_attr *msg)
{ {
@@ -438,6 +468,10 @@ usteer_local_node_state_next(struct uloop_timeout *timeout)
ubus_invoke_async(ubus_ctx, ln->obj_id, "get_clients", b.head, &ln->req); ubus_invoke_async(ubus_ctx, ln->obj_id, "get_clients", b.head, &ln->req);
ln->req.data_cb = usteer_local_node_list_cb; ln->req.data_cb = usteer_local_node_list_cb;
break; break;
case REQ_STATUS:
ubus_invoke_async(ubus_ctx, ln->obj_id, "get_status", b.head, &ln->req);
ln->req.data_cb = usteer_local_node_status_cb;
break;
case REQ_RRM_SET_LIST: case REQ_RRM_SET_LIST:
usteer_local_node_prepare_rrm_set(ln); usteer_local_node_prepare_rrm_set(ln);
ubus_invoke_async(ubus_ctx, ln->obj_id, "rrm_nr_set", b.head, &ln->req); ubus_invoke_async(ubus_ctx, ln->obj_id, "rrm_nr_set", b.head, &ln->req);

1
node.h
View File

@@ -25,6 +25,7 @@
enum local_req_state { enum local_req_state {
REQ_IDLE, REQ_IDLE,
REQ_CLIENTS, REQ_CLIENTS,
REQ_STATUS,
REQ_RRM_SET_LIST, REQ_RRM_SET_LIST,
REQ_RRM_GET_OWN, REQ_RRM_GET_OWN,
__REQ_MAX __REQ_MAX

View File

@@ -64,6 +64,8 @@ bool parse_apmsg_node(struct apmsg_node *msg, struct blob_attr *data)
[APMSG_NODE_LOAD] = { .type = BLOB_ATTR_INT32 }, [APMSG_NODE_LOAD] = { .type = BLOB_ATTR_INT32 },
[APMSG_NODE_RRM_NR] = { .type = BLOB_ATTR_NESTED }, [APMSG_NODE_RRM_NR] = { .type = BLOB_ATTR_NESTED },
[APMSG_NODE_NODE_INFO] = { .type = BLOB_ATTR_NESTED }, [APMSG_NODE_NODE_INFO] = { .type = BLOB_ATTR_NESTED },
[APMSG_NODE_CHANNEL] = { .type = BLOB_ATTR_INT32 },
[APMSG_NODE_OP_CLASS] = { .type = BLOB_ATTR_INT32 },
}; };
struct blob_attr *tb[__APMSG_NODE_MAX]; struct blob_attr *tb[__APMSG_NODE_MAX];
struct blob_attr *cur; struct blob_attr *cur;
@@ -90,6 +92,11 @@ bool parse_apmsg_node(struct apmsg_node *msg, struct blob_attr *data)
msg->max_assoc = get_int32(tb[APMSG_NODE_MAX_ASSOC]); msg->max_assoc = get_int32(tb[APMSG_NODE_MAX_ASSOC]);
msg->rrm_nr = NULL; msg->rrm_nr = NULL;
if (tb[APMSG_NODE_CHANNEL] && tb[APMSG_NODE_OP_CLASS]) {
msg->channel = blob_get_int32(tb[APMSG_NODE_CHANNEL]);
msg->op_class = blob_get_int32(tb[APMSG_NODE_OP_CLASS]);
}
cur = tb[APMSG_NODE_RRM_NR]; cur = tb[APMSG_NODE_RRM_NR];
if (cur && blob_len(cur) >= sizeof(struct blob_attr) && if (cur && blob_len(cur) >= sizeof(struct blob_attr) &&
blob_len(cur) >= blob_pad_len(blob_data(cur))) { blob_len(cur) >= blob_pad_len(blob_data(cur))) {

View File

@@ -287,6 +287,8 @@ interface_add_node(struct usteer_remote_host *host, struct blob_attr *data)
node = interface_get_node(host, msg.name); node = interface_get_node(host, msg.name);
node->check = 0; node->check = 0;
node->node.freq = msg.freq; node->node.freq = msg.freq;
node->node.channel = msg.channel;
node->node.op_class = msg.op_class;
node->node.n_assoc = msg.n_assoc; node->node.n_assoc = msg.n_assoc;
node->node.max_assoc = msg.max_assoc; node->node.max_assoc = msg.max_assoc;
node->node.noise = msg.noise; node->node.noise = msg.noise;
@@ -565,6 +567,8 @@ static void usteer_send_node(struct usteer_node *node, struct sta_info *sta)
blob_put_int32(&buf, APMSG_NODE_LOAD, node->load); blob_put_int32(&buf, APMSG_NODE_LOAD, node->load);
blob_put_int32(&buf, APMSG_NODE_N_ASSOC, node->n_assoc); blob_put_int32(&buf, APMSG_NODE_N_ASSOC, node->n_assoc);
blob_put_int32(&buf, APMSG_NODE_MAX_ASSOC, node->max_assoc); blob_put_int32(&buf, APMSG_NODE_MAX_ASSOC, node->max_assoc);
blob_put_int32(&buf, APMSG_NODE_OP_CLASS, node->op_class);
blob_put_int32(&buf, APMSG_NODE_CHANNEL, node->channel);
blob_put(&buf, APMSG_NODE_BSSID, node->bssid, sizeof(node->bssid)); blob_put(&buf, APMSG_NODE_BSSID, node->bssid, sizeof(node->bssid));
if (node->rrm_nr) { if (node->rrm_nr) {
r = blob_nest_start(&buf, APMSG_NODE_RRM_NR); r = blob_nest_start(&buf, APMSG_NODE_RRM_NR);

View File

@@ -49,6 +49,8 @@ enum {
APMSG_NODE_RRM_NR, APMSG_NODE_RRM_NR,
APMSG_NODE_NODE_INFO, APMSG_NODE_NODE_INFO,
APMSG_NODE_BSSID, APMSG_NODE_BSSID,
APMSG_NODE_CHANNEL,
APMSG_NODE_OP_CLASS,
__APMSG_NODE_MAX __APMSG_NODE_MAX
}; };
@@ -57,6 +59,8 @@ struct apmsg_node {
const char *ssid; const char *ssid;
const char *bssid; const char *bssid;
int freq; int freq;
int channel;
int op_class;
int n_assoc; int n_assoc;
int max_assoc; int max_assoc;
int noise; int noise;

View File

@@ -83,6 +83,8 @@ struct usteer_node {
bool disabled; bool disabled;
int freq; int freq;
int channel;
int op_class;
int noise; int noise;
int n_assoc; int n_assoc;
int max_assoc; int max_assoc;