mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +08:00
nshlib/netcmds:support to set MTU
Usage:ifconfig interfacename mtu *** Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user