Skip to content

Commit 51db86c

Browse files
authored
Merge pull request #1464 from aozima/lwip_dev
update lwip Kconfig & cmd.
2 parents 7be20be + 7d1324e commit 51db86c

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

components/finsh/msh_cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,10 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_dns, __cmd_dns, list the information of dns);
385385
int cmd_netstat(int argc, char **argv)
386386
{
387387
extern void list_tcps(void);
388+
extern void list_udps(void);
388389

389390
list_tcps();
391+
list_udps();
390392
return 0;
391393
}
392394
FINSH_FUNCTION_EXPORT_ALIAS(cmd_netstat, __cmd_netstat, list the information of TCP / IP);

components/net/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ config RT_USING_LWIP
145145
int "the stack size of lwIP thread"
146146
default 1024
147147

148+
config LWIP_NO_RX_THREAD
149+
bool "Not use Rx thread"
150+
default n
151+
152+
config LWIP_NO_TX_THREAD
153+
bool "Not use Tx thread"
154+
default n
155+
148156
config RT_LWIP_ETHTHREAD_PRIORITY
149157
int "the priority level value of ethernet thread"
150158
default 12

components/net/lwip-1.4.1/src/netif/ethernetif.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,34 @@ void list_tcps(void)
618618
FINSH_FUNCTION_EXPORT(list_tcps, list all of tcp connections);
619619
#endif
620620

621+
#if LWIP_UDP
622+
#include "lwip/udp.h"
623+
void list_udps(void)
624+
{
625+
struct udp_pcb *pcb;
626+
rt_uint32_t num = 0;
627+
char local_ip_str[16];
628+
char remote_ip_str[16];
629+
630+
rt_enter_critical();
631+
rt_kprintf("Active UDP PCB states:\n");
632+
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next)
633+
{
634+
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
635+
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
636+
637+
rt_kprintf("#%d %d %s:%d <==> %s:%d \n",
638+
num, (int)pcb->flags,
639+
local_ip_str,
640+
pcb->local_port,
641+
remote_ip_str,
642+
pcb->remote_port);
643+
644+
num++;
645+
}
646+
rt_exit_critical();
647+
}
648+
FINSH_FUNCTION_EXPORT(list_udps, list all of udp connections);
649+
#endif /* LWIP_UDP */
650+
621651
#endif

components/net/lwip-2.0.2/src/netif/ethernetif.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ void list_if(void)
563563
if (netif->flags & NETIF_FLAG_LINK_UP) rt_kprintf(" LINK_UP");
564564
else rt_kprintf(" LINK_DOWN");
565565
if (netif->flags & NETIF_FLAG_ETHARP) rt_kprintf(" ETHARP");
566+
if (netif->flags & NETIF_FLAG_BROADCAST) rt_kprintf(" BROADCAST");
566567
if (netif->flags & NETIF_FLAG_IGMP) rt_kprintf(" IGMP");
567568
rt_kprintf("\n");
568569
rt_kprintf("ip address: %s\n", ipaddr_ntoa(&(netif->ip_addr)));
@@ -672,6 +673,36 @@ void list_tcps(void)
672673
rt_exit_critical();
673674
}
674675
FINSH_FUNCTION_EXPORT(list_tcps, list all of tcp connections);
675-
#endif
676+
#endif /* LWIP_TCP */
677+
678+
#if LWIP_UDP
679+
#include "lwip/udp.h"
680+
void list_udps(void)
681+
{
682+
struct udp_pcb *pcb;
683+
rt_uint32_t num = 0;
684+
char local_ip_str[16];
685+
char remote_ip_str[16];
686+
687+
rt_enter_critical();
688+
rt_kprintf("Active UDP PCB states:\n");
689+
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next)
690+
{
691+
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
692+
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
693+
694+
rt_kprintf("#%d %d %s:%d <==> %s:%d \n",
695+
num, (int)pcb->flags,
696+
local_ip_str,
697+
pcb->local_port,
698+
remote_ip_str,
699+
pcb->remote_port);
700+
701+
num++;
702+
}
703+
rt_exit_critical();
704+
}
705+
FINSH_FUNCTION_EXPORT(list_udps, list all of udp connections);
706+
#endif /* LWIP_UDP */
676707

677708
#endif

0 commit comments

Comments
 (0)