sta-info: add last_connected field
Add a last_connected field to the sta_info struct. This field can be used to determine, if and when a client was last connected to a given node. This way, other nodes can determine where a client roamed to or from. Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
@@ -172,6 +172,8 @@ usteer_local_node_set_assoc(struct usteer_local_node *ln, struct blob_attr *cl)
|
|||||||
int n_assoc = 0;
|
int n_assoc = 0;
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
|
usteer_update_time();
|
||||||
|
|
||||||
list_for_each_entry(si, &node->sta_info, node_list) {
|
list_for_each_entry(si, &node->sta_info, node_list) {
|
||||||
if (si->connected)
|
if (si->connected)
|
||||||
si->connected = STA_DISCONNECTED;
|
si->connected = STA_DISCONNECTED;
|
||||||
@@ -193,8 +195,10 @@ usteer_local_node_set_assoc(struct usteer_local_node *ln, struct blob_attr *cl)
|
|||||||
h->update_sta(node, si);
|
h->update_sta(node, si);
|
||||||
}
|
}
|
||||||
usteer_local_node_assoc_update(si, cur);
|
usteer_local_node_assoc_update(si, cur);
|
||||||
if (si->connected == STA_CONNECTED)
|
if (si->connected == STA_CONNECTED) {
|
||||||
|
si->last_connected = current_time;
|
||||||
n_assoc++;
|
n_assoc++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node->n_assoc = n_assoc;
|
node->n_assoc = n_assoc;
|
||||||
|
5
parse.c
5
parse.c
@@ -124,6 +124,7 @@ bool parse_apmsg_sta(struct apmsg_sta *msg, struct blob_attr *data)
|
|||||||
[APMSG_STA_SEEN] = { .type = BLOB_ATTR_INT32 },
|
[APMSG_STA_SEEN] = { .type = BLOB_ATTR_INT32 },
|
||||||
[APMSG_STA_TIMEOUT] = { .type = BLOB_ATTR_INT32 },
|
[APMSG_STA_TIMEOUT] = { .type = BLOB_ATTR_INT32 },
|
||||||
[APMSG_STA_CONNECTED] = { .type = BLOB_ATTR_INT8 },
|
[APMSG_STA_CONNECTED] = { .type = BLOB_ATTR_INT8 },
|
||||||
|
[APMSG_STA_LAST_CONNECTED] = { .type = BLOB_ATTR_INT32 },
|
||||||
};
|
};
|
||||||
struct blob_attr *tb[__APMSG_STA_MAX];
|
struct blob_attr *tb[__APMSG_STA_MAX];
|
||||||
|
|
||||||
@@ -132,7 +133,8 @@ bool parse_apmsg_sta(struct apmsg_sta *msg, struct blob_attr *data)
|
|||||||
!tb[APMSG_STA_SIGNAL] ||
|
!tb[APMSG_STA_SIGNAL] ||
|
||||||
!tb[APMSG_STA_SEEN] ||
|
!tb[APMSG_STA_SEEN] ||
|
||||||
!tb[APMSG_STA_TIMEOUT] ||
|
!tb[APMSG_STA_TIMEOUT] ||
|
||||||
!tb[APMSG_STA_CONNECTED])
|
!tb[APMSG_STA_CONNECTED] ||
|
||||||
|
!tb[APMSG_STA_LAST_CONNECTED])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (blob_len(tb[APMSG_STA_ADDR]) != sizeof(msg->addr))
|
if (blob_len(tb[APMSG_STA_ADDR]) != sizeof(msg->addr))
|
||||||
@@ -143,6 +145,7 @@ bool parse_apmsg_sta(struct apmsg_sta *msg, struct blob_attr *data)
|
|||||||
msg->seen = blob_get_int32(tb[APMSG_STA_SEEN]);
|
msg->seen = blob_get_int32(tb[APMSG_STA_SEEN]);
|
||||||
msg->timeout = blob_get_int32(tb[APMSG_STA_TIMEOUT]);
|
msg->timeout = blob_get_int32(tb[APMSG_STA_TIMEOUT]);
|
||||||
msg->connected = blob_get_int8(tb[APMSG_STA_CONNECTED]);
|
msg->connected = blob_get_int8(tb[APMSG_STA_CONNECTED]);
|
||||||
|
msg->last_connected = blob_get_int32(tb[APMSG_STA_LAST_CONNECTED]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
3
remote.c
3
remote.c
@@ -180,6 +180,7 @@ interface_add_station(struct usteer_remote_node *node, struct blob_attr *data)
|
|||||||
si->connected = msg.connected;
|
si->connected = msg.connected;
|
||||||
si->signal = msg.signal;
|
si->signal = msg.signal;
|
||||||
si->seen = current_time - msg.seen;
|
si->seen = current_time - msg.seen;
|
||||||
|
si->last_connected = current_time - msg.last_connected;
|
||||||
usteer_sta_info_update_timeout(si, msg.timeout);
|
usteer_sta_info_update_timeout(si, msg.timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,6 +520,7 @@ static void interface_send_msg(struct interface *iface, struct blob_attr *data){
|
|||||||
static void usteer_send_sta_info(struct sta_info *sta)
|
static void usteer_send_sta_info(struct sta_info *sta)
|
||||||
{
|
{
|
||||||
int seen = current_time - sta->seen;
|
int seen = current_time - sta->seen;
|
||||||
|
int last_connected = !!sta->connected ? 0 : current_time - sta->last_connected;
|
||||||
void *c;
|
void *c;
|
||||||
|
|
||||||
c = blob_nest_start(&buf, 0);
|
c = blob_nest_start(&buf, 0);
|
||||||
@@ -526,6 +528,7 @@ static void usteer_send_sta_info(struct sta_info *sta)
|
|||||||
blob_put_int8(&buf, APMSG_STA_CONNECTED, !!sta->connected);
|
blob_put_int8(&buf, APMSG_STA_CONNECTED, !!sta->connected);
|
||||||
blob_put_int32(&buf, APMSG_STA_SIGNAL, sta->signal);
|
blob_put_int32(&buf, APMSG_STA_SIGNAL, sta->signal);
|
||||||
blob_put_int32(&buf, APMSG_STA_SEEN, seen);
|
blob_put_int32(&buf, APMSG_STA_SEEN, seen);
|
||||||
|
blob_put_int32(&buf, APMSG_STA_LAST_CONNECTED, last_connected);
|
||||||
blob_put_int32(&buf, APMSG_STA_TIMEOUT, config.local_sta_timeout - seen);
|
blob_put_int32(&buf, APMSG_STA_TIMEOUT, config.local_sta_timeout - seen);
|
||||||
blob_nest_end(&buf, c);
|
blob_nest_end(&buf, c);
|
||||||
}
|
}
|
||||||
|
2
remote.h
2
remote.h
@@ -72,6 +72,7 @@ enum {
|
|||||||
APMSG_STA_TIMEOUT,
|
APMSG_STA_TIMEOUT,
|
||||||
APMSG_STA_SEEN,
|
APMSG_STA_SEEN,
|
||||||
APMSG_STA_CONNECTED,
|
APMSG_STA_CONNECTED,
|
||||||
|
APMSG_STA_LAST_CONNECTED,
|
||||||
__APMSG_STA_MAX
|
__APMSG_STA_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ struct apmsg_sta {
|
|||||||
int signal;
|
int signal;
|
||||||
int timeout;
|
int timeout;
|
||||||
int seen;
|
int seen;
|
||||||
|
int last_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool parse_apmsg(struct apmsg *msg, struct blob_attr *data);
|
bool parse_apmsg(struct apmsg *msg, struct blob_attr *data);
|
||||||
|
1
usteer.h
1
usteer.h
@@ -210,6 +210,7 @@ struct sta_info {
|
|||||||
struct sta_info_stats stats[__EVENT_TYPE_MAX];
|
struct sta_info_stats stats[__EVENT_TYPE_MAX];
|
||||||
uint64_t created;
|
uint64_t created;
|
||||||
uint64_t seen;
|
uint64_t seen;
|
||||||
|
uint64_t last_connected;
|
||||||
int signal;
|
int signal;
|
||||||
|
|
||||||
enum roam_trigger_state roam_state;
|
enum roam_trigger_state roam_state;
|
||||||
|
Reference in New Issue
Block a user