5 int 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 int 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 int do_stormfilter_set (int argc, const char **argv, struct ngadmin *nga)
57 int i, d = BITRATE_UNSPEC, p, *ports = NULL, ret = 0;
58 const struct swi_attr *sa;
62 printf("usage: stormfilt set (all <speed0>)|(<port1> <speed1> [<port2> <speed2> ...])\n");
67 sa = ngadmin_getCurrentSwitch(nga);
69 printf("must be logged\n");
74 ports = malloc(sa->ports * sizeof(int));
77 if (strcmp(argv[0], "all") == 0) {
78 d = parseBitrate(argv[1]);
84 for (i = 0; i < sa->ports; i++)
87 /* read and apply port specifics */
88 for (i = 0; i < argc - 1; i += 2) {
89 p = strtol(argv[i], NULL, 0);
90 if (p < 1 || p > sa->ports)
92 ports[p - 1] = parseBitrate(argv[i + 1]);
95 /* send the new configuration to the switch */
96 i = ngadmin_setStormFilterValues(nga, ports);
106 int do_stormfilter_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
108 int i, s, ret = 0, *ports = NULL;
109 const struct swi_attr *sa;
113 printf("this command takes no argument\n");
118 sa = ngadmin_getCurrentSwitch(nga);
120 printf("must be logged\n");
125 i = ngadmin_getStormFilterState(nga, &s);
133 printf("storm filter is disabled\n");
137 printf("storm filter is enabled\n");
139 ports = malloc(sa->ports * sizeof(int));
140 i = ngadmin_getStormFilterValues(nga, ports);
147 for (i = 0; i < sa->ports; i++)
148 printf("port %i: %s\n", i + 1, bitrates[ports[i]]);