src/ros.c: Add information about radio_name and ap/wds to the interface output.
[routeros-api.git] / src / ros.c
index cf65a61..b7934df 100644 (file)
--- a/src/ros.c
+++ b/src/ros.c
@@ -78,7 +78,9 @@ static void regtable_dump (const ros_registration_table_t *r) /* {{{ */
        if (r == NULL)
                return;
 
-       printf ("=== %s ===\n", r->interface);
+       printf ("=== %s / %s ===\n", r->interface, r->radio_name);
+       printf ("Mode:           %12s\n",
+                       r->ap ? (r->wds ? "AP with WDS" : "Access point") : "Station");
        printf ("Rate:           %7g Mbps / %7g Mbps\n", r->rx_rate, r->tx_rate);
        printf ("Packets:        %12"PRIu64" / %12"PRIu64"\n",
                        r->rx_packets, r->tx_packets);
@@ -109,6 +111,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 +270,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);