From 7d1324ee68a051c7c80bfe73213887a0c3660a3e Mon Sep 17 00:00:00 2001 From: aozima Date: Fri, 25 May 2018 23:54:16 +0800 Subject: [PATCH] [lwip] add list_udps() for lwip-1.4.1. --- .../net/lwip-1.4.1/src/netif/ethernetif.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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 7a8cde12d..ddebaf347 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