union network_endpoint next_endpoint[__ENDPOINT_TYPE_MAX];
uint64_t last_ep_update;
- uint64_t rx_bytes;
+ uint64_t rx_bytes, tx_bytes;
uint64_t last_handshake;
uint64_t last_request;
uint64_t last_query_sent;
+ int last_handshake_diff;
int idle;
int num_net_queries;
} state;
snprintf(str + len, INET6_ADDRSTRLEN + 7 - len, ":%d",
ntohs(ep->in.sin_port));
blobmsg_add_string_buffer(buf);
+
+ blobmsg_add_u64(buf, "rx_bytes", peer->state.rx_bytes);
+ blobmsg_add_u64(buf, "tx_bytes", peer->state.tx_bytes);
+ blobmsg_add_u32(buf, "idle", peer->state.idle);
+ blobmsg_add_u32(buf, "last_handshake_sec", peer->state.last_handshake_diff);
}
blobmsg_close_table(buf, p);
if ((cur = tb[WGPEER_A_RX_BYTES]) != NULL)
wg_peer_set_rx_bytes(net, peer, nla_get_u64(cur));
+ if ((cur = tb[WGPEER_A_TX_BYTES]) != NULL)
+ wg_peer_set_tx_bytes(net, peer, nla_get_u64(cur));
+
if ((cur = tb[WGPEER_A_ENDPOINT]) != NULL)
wg_peer_set_endpoint(net, peer, nla_data(cur), nla_len(cur));
continue;
}
+ if (!strcmp(req.key, "tx_bytes")) {
+ uint64_t bytes = strtoull(req.value, NULL, 0);
+
+ wg_peer_set_tx_bytes(net, peer, bytes);
+ continue;
+ }
+
if (!strcmp(req.key, "endpoint")) {
struct addrinfo *resolved;
struct addrinfo hints = {
void wg_peer_set_last_handshake(struct network *net, struct network_peer *peer,
uint64_t now, uint64_t sec)
{
+ peer->state.last_handshake_diff = now - sec;
if (sec == peer->state.last_handshake)
return;
}
}
+void wg_peer_set_tx_bytes(struct network *net, struct network_peer *peer,
+ uint64_t bytes)
+{
+ peer->state.tx_bytes = bytes;
+}
+
void wg_peer_set_endpoint(struct network *net, struct network_peer *peer,
void *data, size_t len)
{
uint64_t now, uint64_t sec);
void wg_peer_set_rx_bytes(struct network *net, struct network_peer *peer,
uint64_t bytes);
+void wg_peer_set_tx_bytes(struct network *net, struct network_peer *peer,
+ uint64_t bytes);
void wg_peer_set_endpoint(struct network *net, struct network_peer *peer,
void *data, size_t len);