]> git.sur5r.net Git - ngadmin/commitdiff
Cli: allow VLAN 0 in port based config
authordarkcoven <admin@darkcoven.tk>
Sun, 22 Sep 2013 13:56:13 +0000 (15:56 +0200)
committerdarkcoven <admin@darkcoven.tk>
Sun, 22 Sep 2013 13:56:13 +0000 (15:56 +0200)
cli/com_vlan.c

index 7c911bccbe1ca5c0f84c5f4c8fdac1aa77b14aca..34968152b9fe9a6963cd9e4d59da26154ad7793f 100644 (file)
@@ -77,33 +77,35 @@ int do_vlan_port_set (int argc, const char **argv, struct ngadmin *nga)
        ports = malloc(sa->ports * sizeof(unsigned char));
 
        /* read defaults */
-       port = 0;
+       vlan = 0;
        if (strcmp(argv[k], "all") == 0) {
                k++;
-               port = strtoul(argv[k++], NULL, 0);
-               if (port < 1 || port > sa->ports) {
-                       printf("port out of range");
+               vlan = strtoul(argv[k++], NULL, 0);
+               /* VLAN 0 is allowed and means no change */
+               if (vlan > VLAN_PORT_MAX) {
+                       printf("vlan out of range\n");
                        ret = 1;
                        goto end;
                }
        }
        
        /* apply defaults */
-       memset(ports, port, sa->ports);
+       memset(ports, vlan, sa->ports);
        
        /* read and apply port specifics */
        while (k < argc - 1) {
                /* read port */
                port = strtoul(argv[k++], NULL, 0);
                if (port < 1 || port > sa->ports) {
-                       printf("port out of range");
+                       printf("port out of range\n");
                        ret = 1;
                        goto end;
                }
                
                /* read vlan */
                vlan = strtoul(argv[k++], NULL, 0);
-               if (vlan < VLAN_MIN || vlan > VLAN_PORT_MAX) {
+               /* VLAN 0 is allowed and means no change */
+               if (vlan > VLAN_PORT_MAX) {
                        printf("vlan out of range\n");
                        ret = 1;
                        goto end;