5 bool do_ports_state (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
8 const struct swi_attr *sa;
9 unsigned char *ports = NULL;
13 sa = ngadmin_getCurrentSwitch(nga);
15 printf("must be logged\n");
20 ports = malloc(sa->ports * sizeof(unsigned char));
21 i = ngadmin_getPortsStatus(nga, ports);
28 for (i = 0; i < sa->ports; i++) {
29 printf("port %i: ", i + 1);
49 printf("unknown (%i)", ports[i]);
62 bool do_ports_statistics_reset (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
66 if (ngadmin_getCurrentSwitch(nga) == NULL) {
67 printf("must be logged\n");
71 i = ngadmin_resetPortsStatistics(nga);
78 bool do_ports_statistics_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
81 const struct swi_attr *sa;
83 struct port_stats *ps = NULL;
86 sa = ngadmin_getCurrentSwitch(nga);
88 printf("must be logged\n");
93 ps = calloc(sa->ports, sizeof(struct port_stats));
94 i = ngadmin_getPortsStatistics(nga, ps);
101 printf("Port\tReceived\tSent\tCRC errors\n");
102 for (i = 0; i < sa->ports; i++)
103 printf("% 4i%12llu%12llu%14llu\n", i + 1, ps[i].recv, ps[i].sent, ps[i].crc);