]> git.sur5r.net Git - ngadmin/blobdiff - cli/src/com_loop.c
Add support for loop detection setting
[ngadmin] / cli / src / com_loop.c
diff --git a/cli/src/com_loop.c b/cli/src/com_loop.c
new file mode 100644 (file)
index 0000000..45c4acd
--- /dev/null
@@ -0,0 +1,69 @@
+
+#include "commands.h"
+
+
+int do_loop_enable (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+       int i;
+       
+       
+       if (argc > 0) {
+               printf("this command takes no argument\n");
+               return 1;
+       }
+       
+       i = ngadmin_setLoopDetectionState(nga, 1);
+       printErrCode(i);
+       
+       
+       return 0;
+}
+
+
+int do_loop_disable (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+       int i;
+       
+       
+       if (argc > 0) {
+               printf("this command takes no argument\n");
+               return 1;
+       }
+       
+       i = ngadmin_setLoopDetectionState(nga, 0);
+       printErrCode(i);
+       
+       
+       return 0;
+}
+
+
+int do_loop_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+       int i, s;
+       const struct swi_attr *sa;
+       
+       
+       if (argc > 0) {
+               printf("this command takes no argument\n");
+               return 1;
+       }
+       
+       sa = ngadmin_getCurrentSwitch(nga);
+       if (sa == NULL) {
+               printf("must be logged\n");
+               return 1;
+       }
+       
+       i = ngadmin_getLoopDetectionState(nga, &s);
+       if (i != ERR_OK) {
+               printErrCode(i);
+               return 1;
+       }
+       
+       printf("loop detection is %s\n", s ? "enabled" : "disabled");
+       
+       return 0;
+}
+
+