From 48857d1e67848fa999ef6454756522fb06f42bcf Mon Sep 17 00:00:00 2001 From: chenyong <1521761801@qq.com> Date: Tue, 2 Jul 2019 20:11:41 +0800 Subject: [PATCH] [net][netdev] Add FINSH_USING_MSH control for netdev network commands --- components/net/lwip-1.4.1/src/netif/ethernetif.c | 8 ++++++-- components/net/lwip-2.0.2/src/netif/ethernetif.c | 8 ++++++-- components/net/lwip-2.1.0/src/netif/ethernetif.c | 8 ++++++-- components/net/netdev/include/netdev.h | 3 ++- components/net/netdev/src/netdev.c | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) 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 df960fcde0..c8f171459d 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -146,8 +146,8 @@ 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, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(uint8_t dns_num, char* dns_server); - set_dns(dns_num, ipaddr_ntoa(dns_server)); + extern void dns_setserver(uint8_t dns_num, ip_addr_t *dns_server); + dns_setserver(dns_num, dns_server); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -160,6 +160,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) } #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING extern int lwip_ping_recv(int s, int *ttl); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); @@ -250,6 +251,7 @@ void lwip_netdev_netstat(struct netdev *netif) #endif } #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ const struct netdev_ops lwip_netdev_ops = { @@ -269,6 +271,7 @@ const struct netdev_ops lwip_netdev_ops = NULL, #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING lwip_netdev_ping, #else @@ -278,6 +281,7 @@ const struct netdev_ops lwip_netdev_ops = #if defined (RT_LWIP_TCP) || defined (RT_LWIP_UDP) lwip_netdev_netstat, #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ }; static int netdev_add(struct netif *lwip_netif) 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 51e1ba511d..e471e1ea23 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -154,8 +154,8 @@ 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, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(uint8_t dns_num, char* dns_server); - set_dns(dns_num, ipaddr_ntoa(dns_server)); + extern void dns_setserver(uint8_t dns_num, const ip_addr_t *dns_server); + dns_setserver(dns_num, dns_server); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -168,6 +168,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) } #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING extern int lwip_ping_recv(int s, int *ttl); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); @@ -258,6 +259,7 @@ void lwip_netdev_netstat(struct netdev *netif) #endif } #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ const struct netdev_ops lwip_netdev_ops = { @@ -277,6 +279,7 @@ const struct netdev_ops lwip_netdev_ops = NULL, #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING lwip_netdev_ping, #else @@ -286,6 +289,7 @@ const struct netdev_ops lwip_netdev_ops = #if defined (RT_LWIP_TCP) || defined (RT_LWIP_UDP) lwip_netdev_netstat, #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ }; static int netdev_add(struct netif *lwip_netif) 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 0c9e5dec5f..d73c448cf9 100755 --- a/components/net/lwip-2.1.0/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c @@ -155,8 +155,8 @@ 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, uint8_t dns_num, ip_addr_t *dns_server) { - extern void set_dns(uint8_t dns_num, char* dns_server); - set_dns(dns_num, ipaddr_ntoa(dns_server)); + extern void dns_setserver(uint8_t dns_num, const ip_addr_t *dns_server); + dns_setserver(dns_num, dns_server); return ERR_OK; } #endif /* RT_LWIP_DNS */ @@ -169,6 +169,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) } #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING extern int lwip_ping_recv(int s, int *ttl); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); @@ -259,6 +260,7 @@ void lwip_netdev_netstat(struct netdev *netif) #endif } #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ const struct netdev_ops lwip_netdev_ops = { @@ -278,6 +280,7 @@ const struct netdev_ops lwip_netdev_ops = NULL, #endif /* RT_LWIP_DHCP */ +#ifdef FINSH_USING_MSH #ifdef RT_LWIP_USING_PING lwip_netdev_ping, #else @@ -287,6 +290,7 @@ const struct netdev_ops lwip_netdev_ops = #if defined (RT_LWIP_TCP) || defined (RT_LWIP_UDP) lwip_netdev_netstat, #endif /* RT_LWIP_TCP || RT_LWIP_UDP */ +#endif /* FINSH_USING_MSH */ }; static int netdev_add(struct netif *lwip_netif) diff --git a/components/net/netdev/include/netdev.h b/components/net/netdev/include/netdev.h index 71a61be3c0..25a8493a8f 100644 --- a/components/net/netdev/include/netdev.h +++ b/components/net/netdev/include/netdev.h @@ -132,10 +132,11 @@ struct netdev_ops 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); +#ifdef FINSH_USING_MSH /* set network interface device common network interface device operations */ int (*ping)(struct netdev *netdev, const char *host, size_t data_len, uint32_t timeout, struct netdev_ping_resp *ping_resp); void (*netstat)(struct netdev *netdev); - +#endif }; /* The network interface device registered and unregistered*/ diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index eb2835364a..2c484f520e 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -985,7 +985,7 @@ FINSH_FUNCTION_EXPORT_ALIAS(netdev_ifconfig, __cmd_ifconfig, list the informatio #endif /* NETDEV_USING_IFCONFIG */ #ifdef NETDEV_USING_PING -static int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size) +int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size) { #define NETDEV_PING_DATA_SIZE 32 /** ping receive timeout - in milliseconds */