6 bool do_stormfilter_enable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
9 const struct swi_attr *sa;
12 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
13 printf("must be logged\n");
17 i=ngadmin_setStormFilterState(nga, 1);
27 bool do_stormfilter_disable (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
30 const struct swi_attr *sa;
33 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
34 printf("must be logged\n");
38 i=ngadmin_setStormFilterState(nga, 0);
48 bool do_stormfilter_set (int nb, const char **com, struct ngadmin *nga) {
50 int i, d=BITRATE_UNSPEC, p, *ports=NULL;
51 const struct swi_attr *sa;
56 printf("Usage: stormfilt set (all <speed0>)|(<port1> <speed1> [<port2> <speed2> ...])\n");
61 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
62 printf("must be logged\n");
68 ports=malloc(sa->ports*sizeof(int));
70 if ( strcmp(com[0], "all")==0 ) {
71 d=parseBitrate(com[1]);
76 for (i=0; i<sa->ports; ++i) {
80 for (i=0; i<nb; i+=2) {
81 if ( (p=strtol(com[i], NULL, 0))<1 || p>sa->ports ) continue;
82 ports[p-1]=parseBitrate(com[i+1]);
86 i=ngadmin_setStormFilterValues(nga, ports);
99 bool do_stormfilter_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga) {
101 int i, s, ret=true, *ports=NULL;
102 const struct swi_attr *sa;
105 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
106 printf("must be logged\n");
111 if ( (i=ngadmin_getStormFilterState(nga, &s))!=ERR_OK ) {
119 printf("storm filter is disabled\n");
123 printf("storm filter is enabled\n");
125 ports=malloc(sa->ports*sizeof(int));
126 if ( (i=ngadmin_getStormFilterValues(nga, ports))!=ERR_OK ) {
132 for (i=0; i<sa->ports; ++i) {
133 printf("port %i: %s\n", i+1, bitrates[ports[i]]);