]> git.sur5r.net Git - ngadmin/blobdiff - cli/com_netconf.c
Add the possibility to totally disable VLANs
[ngadmin] / cli / com_netconf.c
index 99cd6baa9926b046de174619c499dd0afb15a5f8..d44b83a161260464f902bb10faa8cd59f63439ec 100644 (file)
@@ -2,23 +2,22 @@
 #include "commands.h"
 
 
-bool do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
+int do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
 {
-       int i, k;
+       int i, k, ret = 0;
        const struct swi_attr *sa;
        struct net_conf nc;
-       bool ret = true;
        
        
        if (argc == 0) {
                printf("usage: netconf set [dhcp yes|no] [ip <ip>] [mask <mask>] [gw <gw>]\n");
-               return false;
+               return 1;
        }
        
        sa = ngadmin_getCurrentSwitch(nga);
        if (sa == NULL) {
                printf("must be logged\n");
-               return false;
+               return 1;
        }
        
        memset(&nc, 0, sizeof(struct net_conf));
@@ -28,29 +27,29 @@ bool do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
                        if (strcasecmp(argv[k + 1], "yes") == 0) {
                                nc.dhcp = true;
                        } else if (strcasecmp(argv[k + 1], "no") == 0) {
-                               nc.dhcp = false;
+                               nc.dhcp = 1;
                        } else {
                                printf("Incorrect DHCP value\n");
-                               ret = false;
+                               ret = 1;
                                goto end;
                        }
                } else if (strcasecmp(argv[k], "ip") == 0) {
                        if (inet_aton(argv[k + 1], &nc.ip) == 0) {
                                printf("Incorrect IP value\n");
-                               ret = false;
+                               ret = 1;
                                goto end;
                        }
                } else if (strcasecmp(argv[k], "mask") == 0) {
                        /* TODO: check if it is a correct mask */
                        if (inet_aton(argv[k + 1], &nc.netmask) == 0) {
                                printf("Incorrect mask value\n");
-                               ret = false;
+                               ret = 1;
                                goto end;
                        }
                } else if (strcasecmp(argv[k], "gw") == 0) {
                        if (inet_aton(argv[k + 1], &nc.gw) == 0) {
                                printf("Incorrect gateway value\n");
-                               ret = false;
+                               ret = 1;
                                goto end;
                        }
                }
@@ -59,7 +58,7 @@ bool do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
        i = ngadmin_setNetConf(nga, &nc);
        if (i != ERR_OK) {
                printErrCode(i);
-               ret = false;
+               ret = 1;
        }
        
 end: