summaryrefslogtreecommitdiffstats
path: root/src/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/status.c')
-rw-r--r--src/status.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/status.c b/src/status.c
index 181ab11..a868d7c 100644
--- a/src/status.c
+++ b/src/status.c
@@ -85,6 +85,11 @@ static json_object * dump_stat(const fastd_stats_t *stats, fastd_stat_type_t typ
return ret;
}
+/** Dumps a single traffic stat as a JSON object */
+static json_object * dump_iface(const fastd_iface_t *iface) {
+ return iface->name ? json_object_new_string(iface->name) : NULL;
+}
+
/** Dumps a fastd_stats_t as a JSON object */
static json_object * dump_stats(const fastd_stats_t *stats) {
struct json_object *statistics = json_object_new_object();
@@ -111,6 +116,9 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
json_object_object_add(ret, "name", peer->name ? json_object_new_string(peer->name) : NULL);
json_object_object_add(ret, "address", json_object_new_string(addr_buf));
+ if (!ctx.iface)
+ json_object_object_add(ret, "interface", dump_iface(peer->iface));
+
struct json_object *connection = NULL;
if (fastd_peer_is_established(peer)) {
@@ -163,6 +171,9 @@ static void dump_status(int fd) {
json_object_object_add(json, "uptime", json_object_new_int64(ctx.now - ctx.started));
+ if (ctx.iface)
+ json_object_object_add(json, "interface", dump_iface(ctx.iface));
+
json_object_object_add(json, "statistics", dump_stats(&ctx.stats));
struct json_object *peers = json_object_new_object();