summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-23 06:22:39 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-23 06:22:39 +0100
commite2402e41eb0e914078d860273bd7cf8c526664c6 (patch)
tree6d4353d2fd44646a39e550c51fce53342c1bd7e9
parent57ae84e07661e7e9db668f67ac45f2e42584a35b (diff)
downloadfastd-e2402e41eb0e914078d860273bd7cf8c526664c6.tar
fastd-e2402e41eb0e914078d860273bd7cf8c526664c6.zip
Add interface information to status socket output
-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();