ifconfig: Allow hostip on first non-option place after inet/inet6
NuttX previous: ifconfig eth0 10.0.0.1 [inet] ifconfig eth0 2022::2 inet6 Try to be compatible with other systems: Linux: ifconfig eth0 [inet] 10.0.0.1 ifconfig eth0 [inet6] add 2022::2 FreeBSD: ifconfig eth0 inet 10.0.0.1 ifconfig eth0 inet6 2022::2 NuttX newly supported: ifconfig eth0 [inet] 10.0.0.1 ifconfig eth0 inet6 [add] 2022::2 Ref: https://man7.org/linux/man-pages/man8/ifconfig.8.html https://www.freebsd.org/cgi/man.cgi?ifconfig Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
19958f0428
commit
8f10dde6ad
@ -670,7 +670,7 @@ system image.
|
|||||||
|
|
||||||
Dump data in hexadecimal format from a file or character device.
|
Dump data in hexadecimal format from a file or character device.
|
||||||
|
|
||||||
- `ifconfig [nic_name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]`
|
- `ifconfig [nic_name [address_family] [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]`
|
||||||
|
|
||||||
Show the current configuration of the network, for example:
|
Show the current configuration of the network, for example:
|
||||||
|
|
||||||
|
@ -698,8 +698,18 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (i == 2)
|
else if (!strcmp(tmp, "add"))
|
||||||
{
|
{
|
||||||
|
/* Compatible with linux IPv6 command, do nothing. */
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (hostip == NULL && i <= 4)
|
||||||
|
{
|
||||||
|
/* Let first non-option be host ip, to support inet/inet6
|
||||||
|
* options before address.
|
||||||
|
*/
|
||||||
|
|
||||||
hostip = tmp;
|
hostip = tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user