]> git.sur5r.net Git - ngadmin/blobdiff - cli/com_ports.c
Improved Makefiles.
[ngadmin] / cli / com_ports.c
index b5202187ed20a8e346e67f9281f739da0d46e32a..baa8c8f3a6fe3dcca1c36deae8902e46195553af 100644 (file)
@@ -1,10 +1,9 @@
 
-#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;
@@ -48,7 +47,27 @@ static bool do_ports_state (const struct TreeNode *tn UNUSED, int nb UNUSED, con
 
 
 
-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;
@@ -61,7 +80,7 @@ static bool do_ports_stats_show (const struct TreeNode *tn UNUSED, int nb UNUSED
   ret=false;
   goto end;
  }
-  
  ps=calloc(sa->ports, sizeof(struct port_stats));
  if ( (i=ngadmin_getPortsStatistics(nga, ps))<0 ) {
   printErrCode(i);
@@ -69,9 +88,9 @@ static bool do_ports_stats_show (const struct TreeNode *tn UNUSED, int nb UNUSED
   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:
@@ -84,33 +103,3 @@ static bool do_ports_stats_show (const struct TreeNode *tn UNUSED, int nb UNUSED
 
 
 
-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);
-
-
-