From 4fada1a13a696f8db22652304316460af5622877 Mon Sep 17 00:00:00 2001 From: aozima Date: Wed, 9 Apr 2014 13:16:02 +0800 Subject: [PATCH] MSH: perfect cmd ifconfig. --- components/finsh/msh_cmd.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c index c11873dc9..83b393021 100644 --- a/components/finsh/msh_cmd.c +++ b/components/finsh/msh_cmd.c @@ -182,14 +182,32 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_mkdir, __cmd_mkdir, Create the DIRECTORY.); #ifdef RT_USING_LWIP int cmd_ifconfig(int argc, char** argv) { - extern void list_if(void); + extern void list_if(void); + extern void set_if(char* netif_name, char* ip_addr, char* gw_addr, char* nm_addr); - list_if(); - return 0; + + if(argc == 1) + { + list_if(); + } + else if(argc == 5) + { + rt_kprintf("config : %s\n", argv[1]); + rt_kprintf("IP addr: %s\n", argv[2]); + rt_kprintf("Gateway: %s\n", argv[3]); + rt_kprintf("netmask: %s\n", argv[4]); + set_if(argv[1], argv[2], argv[3], argv[4]); + } + else + { + rt_kprintf("bad parameter! e.g: ifconfig e0 192.168.1.30 192.168.1.1 255.255.255.0\n"); + } + + return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_ifconfig, __cmd_ifconfig, list the information of network interfaces); -#endif +#endif /* RT_USING_LWIP */ int cmd_ps(int argc, char** argv) { -- GitLab