]> git.sur5r.net Git - ngadmin/blob - cli/com_igmp.c
Let commands handle themselves absence of arguments
[ngadmin] / cli / com_igmp.c
1
2 #include "commands.h"
3
4
5 bool do_igmp_set (int argc, const char **argv, struct ngadmin *nga)
6 {
7         int i;
8         struct igmp_conf ic;
9         
10         
11         if (argc != 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(argv[0], NULL, 0);
22         ic.vlan = strtol(argv[1], NULL, 0);
23         ic.validate = strtol(argv[2], NULL, 0);
24         ic.block = strtol(argv[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 argc, const char **argv 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         if (argc > 0) {
43                 printf("this command takes no argument\n");
44                 ret = false;
45                 goto end;
46         }
47         
48         sa = ngadmin_getCurrentSwitch(nga);
49         if (sa == NULL) {
50                 printf("must be logged\n");
51                 ret = false;
52                 goto end;
53         }
54         
55         i = ngadmin_getIGMPConf(nga, &ic);
56         if (i != ERR_OK) {
57                 printErrCode(i);
58                 ret = false;
59                 goto end;
60         }
61         
62         printf("IGMP snooping enabled: %s\n", ic.enable ? "yes" : "no" );
63         printf("IGMP snooping vlan: %u\n", ic.vlan);
64         printf("Validate IGMPv3 headers: %s\n", ic.validate ? "yes" : "no" );
65         printf("Block unknown multicast addresses: %s\n", ic.block ? "yes" : "no" );
66         
67 end:
68         
69         return ret;
70 }
71
72