6 bool do_ports_state (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
9 const struct swi_attr *sa;
10 unsigned char *ports=NULL;
14 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
15 printf("must be logged\n");
21 ports=malloc(sa->ports*sizeof(unsigned char));
22 if ( (i=ngadmin_getPortsStatus(nga, ports))<0 ) {
28 for (i=0; i<sa->ports; i++) {
29 printf("port %i: ", i+1);
31 case 0: printf("down"); break;
32 case SPEED_10: printf("up, 10M"); break;
33 case SPEED_100: printf("up, 100M"); break;
34 case SPEED_1000: printf("up, 1000M"); break;
35 default: printf("unknown (%i)", ports[i]);
50 bool do_ports_statistics_reset (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
55 if ( ngadmin_getCurrentSwitch(nga)==NULL ) {
56 printf("must be logged\n");
60 i=ngadmin_resetPortsStatistics(nga);
70 bool do_ports_statistics_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
73 const struct swi_attr *sa;
75 struct port_stats *ps=NULL;
78 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
79 printf("must be logged\n");
84 ps=calloc(sa->ports, sizeof(struct port_stats));
85 if ( (i=ngadmin_getPortsStatistics(nga, ps))<0 ) {
91 printf("Port\tReceived\tSent\tCRC errors\n");
92 for (i=0; i<sa->ports; ++i) {
93 printf("% 4i%12llu%12llu%14llu\n", i+1, ps[i].recv, ps[i].sent, ps[i].crc);