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