5 int do_ports_state (int argc, const char **argv UNUSED, struct ngadmin *nga)
8 const struct swi_attr *sa;
9 unsigned char *ports = NULL;
13 printf("this command takes no argument\n");
18 sa = ngadmin_getCurrentSwitch(nga);
20 printf("must be logged\n");
25 ports = malloc(sa->ports * sizeof(unsigned char));
26 i = ngadmin_getPortsStatus(nga, ports);
33 for (i = 0; i < sa->ports; i++) {
34 printf("port %i: ", i + 1);
54 printf("unknown (%i)", ports[i]);
67 int do_ports_statistics_reset (int argc, const char **argv UNUSED, struct ngadmin *nga)
73 printf("this command takes no argument\n");
77 if (ngadmin_getCurrentSwitch(nga) == NULL) {
78 printf("must be logged\n");
82 i = ngadmin_resetPortsStatistics(nga);
89 int do_ports_statistics_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
92 const struct swi_attr *sa;
93 struct port_stats *ps = NULL;
97 printf("this command takes no argument\n");
102 sa = ngadmin_getCurrentSwitch(nga);
104 printf("must be logged\n");
109 ps = calloc(sa->ports, sizeof(struct port_stats));
110 i = ngadmin_getPortsStatistics(nga, ps);
117 printf("Port\tReceived\tSent\tCRC errors\n");
118 for (i = 0; i < sa->ports; i++)
119 printf("% 4i%12llu%12llu%14llu\n", i + 1, ps[i].recv, ps[i].sent, ps[i].crc);