5 bool do_ports_state (int argc, const char **argv UNUSED, struct ngadmin *nga)
8 const struct swi_attr *sa;
9 unsigned char *ports = NULL;
14 printf("this command takes no argument\n");
19 sa = ngadmin_getCurrentSwitch(nga);
21 printf("must be logged\n");
26 ports = malloc(sa->ports * sizeof(unsigned char));
27 i = ngadmin_getPortsStatus(nga, ports);
34 for (i = 0; i < sa->ports; i++) {
35 printf("port %i: ", i + 1);
55 printf("unknown (%i)", ports[i]);
68 bool do_ports_statistics_reset (int argc, const char **argv UNUSED, struct ngadmin *nga)
74 printf("this command takes no argument\n");
78 if (ngadmin_getCurrentSwitch(nga) == NULL) {
79 printf("must be logged\n");
83 i = ngadmin_resetPortsStatistics(nga);
90 bool do_ports_statistics_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
93 const struct swi_attr *sa;
95 struct port_stats *ps = NULL;
99 printf("this command takes no argument\n");
104 sa = ngadmin_getCurrentSwitch(nga);
106 printf("must be logged\n");
111 ps = calloc(sa->ports, sizeof(struct port_stats));
112 i = ngadmin_getPortsStatistics(nga, ps);
119 printf("Port\tReceived\tSent\tCRC errors\n");
120 for (i = 0; i < sa->ports; i++)
121 printf("% 4i%12llu%12llu%14llu\n", i + 1, ps[i].recv, ps[i].sent, ps[i].crc);