]> git.sur5r.net Git - ngadmin/blob - cli/com_igmp.c
Remove Makefiles and use autotools
[ngadmin] / cli / com_igmp.c
1
2 #include "commands.h"
3
4
5 int 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 1;
14         }
15         
16         if (ngadmin_getCurrentSwitch(nga) == NULL) {
17                 printf("must be logged\n");
18                 return 1;
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 0;
31 }
32
33
34 int do_igmp_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
35 {
36         int i, ret = 0;
37         const struct swi_attr *sa;
38         struct igmp_conf ic;
39         
40         
41         if (argc > 0) {
42                 printf("this command takes no argument\n");
43                 ret = 1;
44                 goto end;
45         }
46         
47         sa = ngadmin_getCurrentSwitch(nga);
48         if (sa == NULL) {
49                 printf("must be logged\n");
50                 ret = 1;
51                 goto end;
52         }
53         
54         i = ngadmin_getIGMPConf(nga, &ic);
55         if (i != ERR_OK) {
56                 printErrCode(i);
57                 ret = 1;
58                 goto end;
59         }
60         
61         printf("IGMP snooping enabled: %s\n", ic.enable ? "yes" : "no" );
62         printf("IGMP snooping vlan: %u\n", ic.vlan);
63         printf("Validate IGMPv3 headers: %s\n", ic.validate ? "yes" : "no" );
64         printf("Block unknown multicast addresses: %s\n", ic.block ? "yes" : "no" );
65         
66 end:
67         
68         return ret;
69 }
70
71