]> git.sur5r.net Git - ngadmin/blob - cli/com_igmp.c
Cli: refactor, change coding style
[ngadmin] / cli / com_igmp.c
1
2 #include "commands.h"
3
4
5 bool do_igmp_set (int nb, const char **com, struct ngadmin *nga)
6 {
7         int i;
8         struct igmp_conf ic;
9         
10         
11         if (nb != 4) {
12                 printf("Usage: igmp set <enable> <vlan> <validate> <block>\n");
13                 return false;
14         }
15         
16         if (ngadmin_getCurrentSwitch(nga) == NULL) {
17                 printf("must be logged\n");
18                 return false;
19         }
20         
21         ic.enable = strtol(com[0], NULL, 0);
22         ic.vlan = strtol(com[1], NULL, 0);
23         ic.validate = strtol(com[2], NULL, 0);
24         ic.block = strtol(com[3], NULL, 0);
25         
26         i = ngadmin_setIGMPConf(nga, &ic);
27         printErrCode(i);
28         
29         
30         return true;
31 }
32
33
34 bool do_igmp_show (int nb UNUSED, const char **com UNUSED, struct ngadmin *nga)
35 {
36         int i;
37         const struct swi_attr *sa;
38         struct igmp_conf ic;
39         bool ret = true;
40         
41         
42         sa=ngadmin_getCurrentSwitch(nga);
43         if (sa == NULL) {
44                 printf("must be logged\n");
45                 ret = false;
46                 goto end;
47         }
48         
49         i = ngadmin_getIGMPConf(nga, &ic);
50         if (i != ERR_OK) {
51                 printErrCode(i);
52                 ret = false;
53                 goto end;
54         }
55         
56         printf("IGMP snooping enabled: %s\n", ic.enable ? "yes" : "no" );
57         printf("IGMP snooping vlan: %u\n", ic.vlan);
58         printf("Validate IGMPv3 headers: %s\n", ic.validate ? "yes" : "no" );
59         printf("Block unknown multicast addresses: %s\n", ic.block ? "yes" : "no" );
60         
61 end:
62         
63         return ret;
64 }
65
66