nshlib/netcmds:support to set MTU

Usage:ifconfig interfacename mtu ***

Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
wangchen
2023-04-27 10:58:11 +08:00
committed by Xiang Xiao
parent 08bfc4e9c7
commit c2f75330f7
6 changed files with 120 additions and 2 deletions

View File

@@ -580,6 +580,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
FAR void *handle;
#endif
int ret;
int mtu = 0;
/* With one or no arguments, ifconfig simply shows the status of the
* network device:
@@ -720,6 +721,22 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
continue;
}
else if (!strcmp(tmp, "mtu"))
{
if (argc - 1 >= i + 1)
{
mtu = atoi(argv[i + 1]);
i++;
if (mtu < 1280)
{
mtu = 1280;
}
}
else
{
badarg = true;
}
}
else if (hostip == NULL && i <= 4)
{
/* Let first non-option be host ip, to support inet/inet6
@@ -758,6 +775,12 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
}
#endif
if (mtu != 0)
{
netlib_set_mtu(ifname, mtu);
return OK;
}
/* Set IP address */
#ifdef CONFIG_NET_IPv6