This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 10eae1dc6bbee24a905a48e5ef0b14c141fa5adb Author: Zhe Weng <[email protected]> AuthorDate: Fri Feb 7 14:46:46 2025 +0800 vconfig: Support setting default PCP when creating VLAN Now we allow setting a default PCP when creating VLAN like: `vconfig add iface-name vlan-id [pcp]` e.g. `vconfig add eth0 10` will create eth0.10 with VID=10 and no PCP(0) `vconfig add eth0 10 3` will create eth0.10 with VID=10 and PCP=3 Signed-off-by: Zhe Weng <[email protected]> --- include/netutils/netlib.h | 2 +- nshlib/nsh_command.c | 4 ++-- nshlib/nsh_netcmds.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/netutils/netlib.h b/include/netutils/netlib.h index a751ed60b..5be9747b2 100644 --- a/include/netutils/netlib.h +++ b/include/netutils/netlib.h @@ -330,7 +330,7 @@ int netlib_setessid(FAR const char *ifname, FAR const char *essid); #endif #ifdef CONFIG_NET_VLAN -int netlib_add_vlan(FAR const char *ifname, int vlanid); +int netlib_add_vlan(FAR const char *ifname, int vlanid, int prio); int netlib_del_vlan(FAR const char *vlanif); #endif diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 1474b824c..03a14ace9 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -287,8 +287,8 @@ static const struct cmdmap_s g_cmdmap[] = "[dns <dns-address>] [hw <hw-mac>]"), # endif # if defined(CONFIG_NET_VLAN) && !defined(CONFIG_NSH_DISABLE_VCONFIG) - CMD_MAP("vconfig", cmd_vconfig, 3, 4, - "[add iface-name vlan-id]|[rem vlan-name]"), + CMD_MAP("vconfig", cmd_vconfig, 3, 5, + "[add iface-name vlan-id [pcp]]|[rem vlan-name]"), # endif # ifndef CONFIG_NSH_DISABLE_IFUPDOWN CMD_MAP("ifdown", cmd_ifdown, 2, 2, "<interface>"), diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index 233231a95..6010e1084 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -1108,13 +1108,20 @@ int cmd_vconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) if (!strcmp(argv[1], "add")) { - if (argc != 4) + int prio = 0; + + if (argc != 4 && argc != 5) { nsh_error(vtbl, g_fmtargrequired, argv[0]); return ERROR; } - if (netlib_add_vlan(argv[2], atoi(argv[3])) < 0) + if (argc == 5) + { + prio = atoi(argv[4]); + } + + if (netlib_add_vlan(argv[2], atoi(argv[3]), prio) < 0) { perror("Failed to add VLAN"); return ERROR;
