5 bool do_stormfilter_enable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
8 const struct swi_attr *sa;
11 sa = ngadmin_getCurrentSwitch(nga);
13 printf("must be logged\n");
17 i = ngadmin_setStormFilterState(nga, 1);
25 bool do_stormfilter_disable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
28 const struct swi_attr *sa;
31 sa = ngadmin_getCurrentSwitch(nga);
33 printf("must be logged\n");
37 i = ngadmin_setStormFilterState(nga, 0);
45 bool do_stormfilter_set (int nb, const char **com, struct ngadmin *nga)
47 int i, d = BITRATE_UNSPEC, p, *ports = NULL;
48 const struct swi_attr *sa;
53 printf("Usage: stormfilt set (all <speed0>)|(<port1> <speed1> [<port2> <speed2> ...])\n");
58 sa = ngadmin_getCurrentSwitch(nga);
60 printf("must be logged\n");
65 ports=malloc(sa->ports * sizeof(int));
67 if (strcmp(com[0], "all") == 0) {
68 d = parseBitrate(com[1]);
73 for (i = 0; i < sa->ports; i++)
76 for (i = 0; i < nb; i += 2) {
77 p = strtol(com[i], NULL, 0);
78 if (p < 1 || p > sa->ports)
80 ports[p - 1] = parseBitrate(com[i + 1]);
83 i = ngadmin_setStormFilterValues(nga, ports);
93 bool do_stormfilter_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
95 int i, s, ret = true, *ports = NULL;
96 const struct swi_attr *sa;
99 sa = ngadmin_getCurrentSwitch(nga);
101 printf("must be logged\n");
106 i = ngadmin_getStormFilterState(nga, &s);
114 printf("storm filter is disabled\n");
118 printf("storm filter is enabled\n");
120 ports = malloc(sa->ports * sizeof(int));
121 i = ngadmin_getStormFilterValues(nga, ports);
128 for (i = 0; i < sa->ports; i++)
129 printf("port %i: %s\n", i + 1, bitrates[ports[i]]);