From d9180d2db2a3f84bc4ba2d75c83bf0bdb4d6241a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 26 Nov 2009 16:18:10 +0100 Subject: [PATCH] src/ros.c: Add support for the high-level interface function. --- src/ros.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/ros.c b/src/ros.c index cf65a61..4a2fccb 100644 --- a/src/ros.c +++ b/src/ros.c @@ -109,6 +109,44 @@ static int regtable_handler (ros_connection_t *c, /* {{{ */ return (0); } /* }}} int regtable_handler */ +static void interface_dump (const ros_interface_t *i) /* {{{ */ +{ + if (i == NULL) + return; + + printf ("=== %s ===\n" + "Type: %12s\n" + "Comment: %12s\n" + "Bytes: %12"PRIu64" / %12"PRIu64"\n" + "Packets: %12"PRIu64" / %12"PRIu64"\n" + "Errors: %12"PRIu64" / %12"PRIu64"\n" + "Drops: %12"PRIu64" / %12"PRIu64"\n" + "MTU: %12u\n" + "L2 MTU: %12u\n" + "Running: %12s\n" + "Dynamic: %12s\n" + "Enabled: %12s\n" + "==========\n", + i->name, i->type, i->comment, + i->rx_bytes, i->tx_bytes, + i->rx_packets, i->tx_packets, + i->rx_errors, i->tx_errors, + i->rx_drops, i->tx_drops, + i->mtu, i->l2mtu, + i->running ? "true" : "false", + i->dynamic ? "true" : "false", + i->enabled ? "true" : "false"); + + interface_dump (i->next); +} /* }}} void interface_dump */ + +static int interface_handler (ros_connection_t *c, /* {{{ */ + const ros_interface_t *i, void *user_data) +{ + interface_dump (i); + return (0); +} /* }}} int interface_handler */ + static char *read_password (void) /* {{{ */ { FILE *tty; @@ -230,6 +268,10 @@ int main (int argc, char **argv) /* {{{ */ (size_t) (argc - (optind + 2)), (const char * const *) (argv + optind + 2), result_handler, /* user data = */ NULL); } + else if (strcmp ("interface", command) == 0) + { + ros_interface (c, interface_handler, /* user data = */ NULL); + } else if (strcmp ("registration-table", command) == 0) { ros_registration_table (c, regtable_handler, /* user data = */ NULL); -- 2.11.0