]> git.sur5r.net Git - ngadmin/blob - cli/src/com_loop.c
Add support for loop detection setting
[ngadmin] / cli / src / com_loop.c
1
2 #include "commands.h"
3
4
5 int do_loop_enable (int argc, const char **argv UNUSED, struct ngadmin *nga)
6 {
7         int i;
8         
9         
10         if (argc > 0) {
11                 printf("this command takes no argument\n");
12                 return 1;
13         }
14         
15         i = ngadmin_setLoopDetectionState(nga, 1);
16         printErrCode(i);
17         
18         
19         return 0;
20 }
21
22
23 int do_loop_disable (int argc, const char **argv UNUSED, struct ngadmin *nga)
24 {
25         int i;
26         
27         
28         if (argc > 0) {
29                 printf("this command takes no argument\n");
30                 return 1;
31         }
32         
33         i = ngadmin_setLoopDetectionState(nga, 0);
34         printErrCode(i);
35         
36         
37         return 0;
38 }
39
40
41 int do_loop_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
42 {
43         int i, s;
44         const struct swi_attr *sa;
45         
46         
47         if (argc > 0) {
48                 printf("this command takes no argument\n");
49                 return 1;
50         }
51         
52         sa = ngadmin_getCurrentSwitch(nga);
53         if (sa == NULL) {
54                 printf("must be logged\n");
55                 return 1;
56         }
57         
58         i = ngadmin_getLoopDetectionState(nga, &s);
59         if (i != ERR_OK) {
60                 printErrCode(i);
61                 return 1;
62         }
63         
64         printf("loop detection is %s\n", s ? "enabled" : "disabled");
65         
66         return 0;
67 }
68
69