-#include "common.h"
+#include "commands.h"
-
-static bool do_ports_state (const struct TreeNode *tn UNUSED, int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
+bool do_ports_state (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
int i;
const struct swi_attr *sa;
-static bool do_ports_stats_show (const struct TreeNode *tn UNUSED, int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
+bool do_ports_statistics_reset (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
+
+ int i;
+
+
+ if ( ngadmin_getCurrentSwitch(nga)==NULL ) {
+ printf("must be logged\n");
+ return false;
+ }
+
+ i=ngadmin_resetPortsStatistics(nga);
+ printErrCode(i);
+
+
+ return true;
+
+}
+
+
+
+bool do_ports_statistics_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
int i;
const struct swi_attr *sa;
ret=false;
goto end;
}
-
+
ps=calloc(sa->ports, sizeof(struct port_stats));
if ( (i=ngadmin_getPortsStatistics(nga, ps))<0 ) {
printErrCode(i);
goto end;
}
- printf("Port\tReceived\tSent\t\tCRC errors\n");
+ printf("Port\tReceived\tSent\tCRC errors\n");
for (i=0; i<sa->ports; ++i) {
- printf("%i\t%8llu\t%8llu\t%8llu\n", i+1, ps[i].recv, ps[i].sent, ps[i].crc);
+ printf("% 4i%12llu%12llu%14llu\n", i+1, ps[i].recv, ps[i].sent, ps[i].crc);
}
end:
-static bool do_ports_stats_reset (const struct TreeNode *tn UNUSED, int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
-
- int i;
-
-
- if ( ngadmin_getCurrentSwitch(nga)==NULL ) {
- printf("must be logged\n");
- return false;
- }
-
- i=ngadmin_resetPortsStatistics(nga);
- printErrCode(i);
-
-
- return true;
-
-}
-
-
-
-static const struct TreeNode com_ports_state=COM("state", do_ports_state, false, NULL);
-
-static const struct TreeNode com_ports_stats_show=COM("show", do_ports_stats_show, false, NULL);
-static const struct TreeNode com_ports_stats_reset=COM("reset", do_ports_stats_reset, false, NULL);
-static const struct TreeNode com_ports_stats=COM("stats", NULL, false, &com_ports_stats_reset, &com_ports_stats_show, NULL);
-
-const struct TreeNode com_ports=COM("ports", NULL, false, &com_ports_state, &com_ports_stats, NULL);
-
-
-