5 bool do_stormfilter_enable (int argc, const char **argv UNUSED, struct ngadmin *nga)
8 const struct swi_attr *sa;
12 printf("this command takes no argument\n");
16 sa = ngadmin_getCurrentSwitch(nga);
18 printf("must be logged\n");
22 i = ngadmin_setStormFilterState(nga, 1);
30 bool do_stormfilter_disable (int argc, const char **argv UNUSED, struct ngadmin *nga)
33 const struct swi_attr *sa;
37 printf("this command takes no argument\n");
41 sa = ngadmin_getCurrentSwitch(nga);
43 printf("must be logged\n");
47 i = ngadmin_setStormFilterState(nga, 0);
55 bool do_stormfilter_set (int argc, const char **argv, struct ngadmin *nga)
57 int i, d = BITRATE_UNSPEC, p, *ports = NULL;
58 const struct swi_attr *sa;
63 printf("usage: stormfilt set (all <speed0>)|(<port1> <speed1> [<port2> <speed2> ...])\n");
68 sa = ngadmin_getCurrentSwitch(nga);
70 printf("must be logged\n");
75 ports = malloc(sa->ports * sizeof(int));
78 if (strcmp(argv[0], "all") == 0) {
79 d = parseBitrate(argv[1]);
85 for (i = 0; i < sa->ports; i++)
88 /* read and apply port specifics */
89 for (i = 0; i < argc - 1; i += 2) {
90 p = strtol(argv[i], NULL, 0);
91 if (p < 1 || p > sa->ports)
93 ports[p - 1] = parseBitrate(argv[i + 1]);
96 /* send the new configuration to the switch */
97 i = ngadmin_setStormFilterValues(nga, ports);
107 bool do_stormfilter_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
109 int i, s, ret = true, *ports = NULL;
110 const struct swi_attr *sa;
114 printf("this command takes no argument\n");
119 sa = ngadmin_getCurrentSwitch(nga);
121 printf("must be logged\n");
126 i = ngadmin_getStormFilterState(nga, &s);
134 printf("storm filter is disabled\n");
138 printf("storm filter is enabled\n");
140 ports = malloc(sa->ports * sizeof(int));
141 i = ngadmin_getStormFilterValues(nga, ports);
148 for (i = 0; i < sa->ports; i++)
149 printf("port %i: %s\n", i + 1, bitrates[ports[i]]);