diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 7508ea0b87..10bcaa0c95 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -144,10 +144,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i } #ifdef RT_LWIP_DNS -static int lwip_netdev_set_dns_server(struct netdev *netif, ip_addr_t *dns_server) +static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(char* dns_server); - set_dns(ipaddr_ntoa(dns_server)); + extern void set_dns(uint8_t dns_num, char* dns_server); + set_dns(dns_num, ipaddr_ntoa(dns_server)); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -729,13 +729,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address); #if LWIP_DNS #include -void set_dns(char* dns_server) +void set_dns(uint8_t dns_num, char* dns_server) { struct ip_addr addr; if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, &addr)) { - dns_setserver(0, &addr); + dns_setserver(dns_num, &addr); } } FINSH_FUNCTION_EXPORT(set_dns, set DNS server address); diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 38e46de046..f19ec094fa 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -152,10 +152,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i } #ifdef RT_LWIP_DNS -static int lwip_netdev_set_dns_server(struct netdev *netif, ip_addr_t *dns_server) +static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(char* dns_server); - set_dns(ipaddr_ntoa(dns_server)); + extern void set_dns(uint8_t dns_num, char* dns_server); + set_dns(dns_num, ipaddr_ntoa(dns_server)); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -758,13 +758,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address); #if LWIP_DNS #include -void set_dns(char* dns_server) +void set_dns(uint8_t dns_num, char* dns_server) { ip_addr_t addr; if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, &addr)) { - dns_setserver(0, &addr); + dns_setserver(dns_num, &addr); } } FINSH_FUNCTION_EXPORT(set_dns, set DNS server address); diff --git a/components/net/lwip-2.1.0/src/netif/ethernetif.c b/components/net/lwip-2.1.0/src/netif/ethernetif.c index fd9db058e0..db28a4a55b 100755 --- a/components/net/lwip-2.1.0/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c @@ -153,10 +153,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i } #ifdef RT_LWIP_DNS -static int lwip_netdev_set_dns_server(struct netdev *netif, ip_addr_t *dns_server) +static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(char* dns_server); - set_dns(ipaddr_ntoa(dns_server)); + extern void set_dns(uint8_t dns_num, char* dns_server); + set_dns(dns_num, ipaddr_ntoa(dns_server)); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -762,13 +762,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address); #if LWIP_DNS #include -void set_dns(char* dns_server) +void set_dns(uint8_t dns_num, char* dns_server) { ip_addr_t addr; if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, &addr)) { - dns_setserver(0, &addr); + dns_setserver(dns_num, &addr); } } FINSH_FUNCTION_EXPORT(set_dns, set DNS server address); diff --git a/components/net/netdev/include/netdev.h b/components/net/netdev/include/netdev.h index e194003653..5ea8e96080 100644 --- a/components/net/netdev/include/netdev.h +++ b/components/net/netdev/include/netdev.h @@ -119,7 +119,7 @@ struct netdev_ops /* set network interface device address information operations */ int (*set_addr_info)(struct netdev *netdev, ip_addr_t *ip_addr, ip_addr_t *netmask, ip_addr_t *gw); - int (*set_dns_server)(struct netdev *netdev, ip_addr_t *dns_server); + int (*set_dns_server)(struct netdev *netdev, uint8_t dns_num, ip_addr_t *dns_server); int (*set_dhcp)(struct netdev *netdev, rt_bool_t is_enabled); /* set network interface device common network interface device operations */ diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index 4dde5f2f9c..c5b4d0e321 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -9,6 +9,7 @@ */ #include +#include #include #include @@ -510,7 +511,7 @@ int netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_ } /* execute network interface device set DNS server address operations */ - return netdev->ops->set_dns_server(netdev, (ip_addr_t *)dns_server); + return netdev->ops->set_dns_server(netdev, dns_num, (ip_addr_t *)dns_server); } /** @@ -1028,7 +1029,7 @@ static void netdev_list_dns(void) rt_hw_interrupt_enable(level); } -static void netdev_set_dns(char *netdev_name, char *dns_server) +static void netdev_set_dns(char *netdev_name, uint8_t dns_num, char *dns_server) { struct netdev *netdev = RT_NULL; ip_addr_t dns_addr; @@ -1041,7 +1042,7 @@ static void netdev_set_dns(char *netdev_name, char *dns_server) } inet_aton(dns_server, &dns_addr); - netdev_set_dns_server(netdev, 0, &dns_addr); + netdev_set_dns_server(netdev, dns_num, &dns_addr); rt_kprintf("set network interface device(%s) dns server #0: %s\n", netdev_name, dns_server); } @@ -1054,11 +1055,16 @@ int netdev_dns(int argc, char **argv) } else if (argc == 3) { - netdev_set_dns(argv[1], argv[2]); + netdev_set_dns(argv[1], 0, argv[2]); + } + else if (argc == 4) + { + netdev_set_dns(argv[1], atoi(argv[2]), argv[3]); } else { - rt_kprintf("bad parameter! e.g: dns name 114.114.114.114\n"); + rt_kprintf("bad parameter! input: dns [dns_num] \n"); + return -1; } return 0;