From 79903b43bc591899410c6b8607e3951c9b4224b4 Mon Sep 17 00:00:00 2001 From: darkcoven Date: Sun, 22 Sep 2013 15:56:13 +0200 Subject: [PATCH] Cli: allow VLAN 0 in port based config --- cli/com_vlan.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/com_vlan.c b/cli/com_vlan.c index 7c911bc..3496815 100644 --- a/cli/com_vlan.c +++ b/cli/com_vlan.c @@ -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; -- 2.39.2