diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c index 7e9fd68a5f9176cbc2d0ac91f9a6be019dd27d3c..71dca1597656eb82cc2934df250a06f6e31acedc 100644 --- a/components/finsh/msh_cmd.c +++ b/components/finsh/msh_cmd.c @@ -385,8 +385,10 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_dns, __cmd_dns, list the information of dns); int cmd_netstat(int argc, char **argv) { extern void list_tcps(void); + extern void list_udps(void); list_tcps(); + list_udps(); return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_netstat, __cmd_netstat, list the information of TCP / IP); diff --git a/components/net/Kconfig b/components/net/Kconfig index 58a327ee1e83db51b6024b338ca6047bf788a257..2fa1dccf6eac40eee5178089840bb55369402b96 100644 --- a/components/net/Kconfig +++ b/components/net/Kconfig @@ -145,6 +145,14 @@ config RT_USING_LWIP int "the stack size of lwIP thread" default 1024 + config LWIP_NO_RX_THREAD + bool "Not use Rx thread" + default n + + config LWIP_NO_TX_THREAD + bool "Not use Tx thread" + default n + config RT_LWIP_ETHTHREAD_PRIORITY int "the priority level value of ethernet thread" default 12 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 7a8cde12da1d04c3e3eee9e713c3ef7a82392b14..ddebaf347e6addd608a77993bbb4f6061e9e648d 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -618,4 +618,34 @@ void list_tcps(void) FINSH_FUNCTION_EXPORT(list_tcps, list all of tcp connections); #endif +#if LWIP_UDP +#include "lwip/udp.h" +void list_udps(void) +{ + struct udp_pcb *pcb; + rt_uint32_t num = 0; + char local_ip_str[16]; + char remote_ip_str[16]; + + rt_enter_critical(); + rt_kprintf("Active UDP PCB states:\n"); + for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) + { + strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip))); + strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip))); + + rt_kprintf("#%d %d %s:%d <==> %s:%d \n", + num, (int)pcb->flags, + local_ip_str, + pcb->local_port, + remote_ip_str, + pcb->remote_port); + + num++; + } + rt_exit_critical(); +} +FINSH_FUNCTION_EXPORT(list_udps, list all of udp connections); +#endif /* LWIP_UDP */ + #endif 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 ba23528c5878f76d564fe94007fad7795bd8bf7a..8ab1727bd3b5e41c6ede5eaf4e3a5fecac60df3b 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -563,6 +563,7 @@ void list_if(void) if (netif->flags & NETIF_FLAG_LINK_UP) rt_kprintf(" LINK_UP"); else rt_kprintf(" LINK_DOWN"); if (netif->flags & NETIF_FLAG_ETHARP) rt_kprintf(" ETHARP"); + if (netif->flags & NETIF_FLAG_BROADCAST) rt_kprintf(" BROADCAST"); if (netif->flags & NETIF_FLAG_IGMP) rt_kprintf(" IGMP"); rt_kprintf("\n"); rt_kprintf("ip address: %s\n", ipaddr_ntoa(&(netif->ip_addr))); @@ -672,6 +673,36 @@ void list_tcps(void) rt_exit_critical(); } FINSH_FUNCTION_EXPORT(list_tcps, list all of tcp connections); -#endif +#endif /* LWIP_TCP */ + +#if LWIP_UDP +#include "lwip/udp.h" +void list_udps(void) +{ + struct udp_pcb *pcb; + rt_uint32_t num = 0; + char local_ip_str[16]; + char remote_ip_str[16]; + + rt_enter_critical(); + rt_kprintf("Active UDP PCB states:\n"); + for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) + { + strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip))); + strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip))); + + rt_kprintf("#%d %d %s:%d <==> %s:%d \n", + num, (int)pcb->flags, + local_ip_str, + pcb->local_port, + remote_ip_str, + pcb->remote_port); + + num++; + } + rt_exit_critical(); +} +FINSH_FUNCTION_EXPORT(list_udps, list all of udp connections); +#endif /* LWIP_UDP */ #endif