提交 e30e7152 编写于 作者: B bernard.xiong

add more lwip command.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@82 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 bc2283be
......@@ -258,8 +258,50 @@ rt_err_t eth_system_device_init()
#ifdef RT_USING_FINSH
#include <finsh.h>
void set_if(char* ip_addr, char* gw_addr, char* nm_addr)
{
struct ip_addr *ip;
struct in_addr addr;
ip = (struct ip_addr *)&addr;
/* set ip address */
if ((ip_addr != RT_NULL) && inet_aton(ip_addr, &addr))
{
netif_set_ipaddr(netif_default, ip);
}
/* set gateway address */
if ((gw_addr != RT_NULL) && inet_aton(gw_addr, &addr))
{
netif_set_gw(netif_default, ip);
}
/* set netmask address */
if ((nm_addr != RT_NULL) && inet_aton(nm_addr, &addr))
{
netif_set_netmask(netif_default, ip);
}
}
FINSH_FUNCTION_EXPORT(set_if, set network interface address);
#if LWIP_DNS
#include <lwip/dns.h>
void set_dns(char* dns_server)
{
struct in_addr addr;
if ((dns_server != RT_NULL) && inet_aton(dns_server, &addr))
{
dns_setserver(0, (struct ip_addr *)&addr);
}
}
FINSH_FUNCTION_EXPORT(set_dns, set DNS server address);
#endif
void list_if()
{
struct ip_addr ip_addr;
struct _ip_addr
{
rt_uint8_t addr0, addr1, addr2, addr3;
......@@ -274,6 +316,12 @@ void list_if()
addr = (struct _ip_addr*)&netif_default->netmask.addr;
rt_kprintf("net mask : %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
#if LWIP_DNS
ip_addr = dns_getserver(0);
addr = (struct _ip_addr*)&ip_addr;
rt_kprintf("dns server: %d.%d.%d.%d\n", addr->addr0, addr->addr1, addr->addr2, addr->addr3);
#endif
}
FINSH_FUNCTION_EXPORT(list_if, list network interface information);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册