From e2402e41eb0e914078d860273bd7cf8c526664c6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 23 Mar 2015 06:22:39 +0100 Subject: Add interface information to status socket output --- src/status.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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(); -- cgit v1.2.3