Merge pull request #41 from aozima/aozima
fixed list_tcps bug: ipaddr_ntoa isn't reentrant.
This commit is contained in:
commit
9b5d6887eb
|
@ -14,6 +14,7 @@
|
||||||
* 2012-04-10 Bernard add more compatible with RT-Thread.
|
* 2012-04-10 Bernard add more compatible with RT-Thread.
|
||||||
* 2012-11-12 Bernard The network interface can be initialized
|
* 2012-11-12 Bernard The network interface can be initialized
|
||||||
* after lwIP initialization.
|
* after lwIP initialization.
|
||||||
|
* 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -451,11 +452,16 @@ void list_if(void)
|
||||||
rt_ubase_t index;
|
rt_ubase_t index;
|
||||||
struct netif * netif;
|
struct netif * netif;
|
||||||
|
|
||||||
|
rt_enter_critical();
|
||||||
|
|
||||||
netif = netif_list;
|
netif = netif_list;
|
||||||
|
|
||||||
while( netif != RT_NULL )
|
while( netif != RT_NULL )
|
||||||
{
|
{
|
||||||
rt_kprintf("network interface: %c%c%s\n", netif->name[0], netif->name[1], (netif == netif_default)?" (Default)":"");
|
rt_kprintf("network interface: %c%c%s\n",
|
||||||
|
netif->name[0],
|
||||||
|
netif->name[1],
|
||||||
|
(netif == netif_default)?" (Default)":"");
|
||||||
rt_kprintf("MTU: %d\n", netif->mtu);
|
rt_kprintf("MTU: %d\n", netif->mtu);
|
||||||
rt_kprintf("MAC: ");
|
rt_kprintf("MAC: ");
|
||||||
for (index = 0; index < netif->hwaddr_len; index ++)
|
for (index = 0; index < netif->hwaddr_len; index ++)
|
||||||
|
@ -489,6 +495,8 @@ void list_if(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /**< #if LWIP_DNS */
|
#endif /**< #if LWIP_DNS */
|
||||||
|
|
||||||
|
rt_exit_critical();
|
||||||
}
|
}
|
||||||
FINSH_FUNCTION_EXPORT(list_if, list network interface information);
|
FINSH_FUNCTION_EXPORT(list_if, list network interface information);
|
||||||
|
|
||||||
|
@ -496,9 +504,13 @@ FINSH_FUNCTION_EXPORT(list_if, list network interface information);
|
||||||
#include <lwip/tcp.h>
|
#include <lwip/tcp.h>
|
||||||
#include <lwip/tcp_impl.h>
|
#include <lwip/tcp_impl.h>
|
||||||
|
|
||||||
void list_tcps()
|
void list_tcps(void)
|
||||||
{
|
{
|
||||||
|
rt_uint32_t num = 0;
|
||||||
struct tcp_pcb *pcb;
|
struct tcp_pcb *pcb;
|
||||||
|
char local_ip_str[16];
|
||||||
|
char remote_ip_str[16];
|
||||||
|
|
||||||
extern struct tcp_pcb *tcp_active_pcbs;
|
extern struct tcp_pcb *tcp_active_pcbs;
|
||||||
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
|
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
|
||||||
extern struct tcp_pcb *tcp_tw_pcbs;
|
extern struct tcp_pcb *tcp_tw_pcbs;
|
||||||
|
@ -508,27 +520,43 @@ void list_tcps()
|
||||||
rt_kprintf("Active PCB states:\n");
|
rt_kprintf("Active PCB states:\n");
|
||||||
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
|
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
|
||||||
{
|
{
|
||||||
rt_kprintf("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
|
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
|
||||||
ipaddr_ntoa(&(pcb->local_ip)), pcb->local_port,
|
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
|
||||||
ipaddr_ntoa(&(pcb->remote_ip)), pcb->remote_port,
|
|
||||||
pcb->snd_nxt, pcb->rcv_nxt);
|
rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
|
||||||
|
num++,
|
||||||
|
local_ip_str,
|
||||||
|
pcb->local_port,
|
||||||
|
remote_ip_str,
|
||||||
|
pcb->remote_port,
|
||||||
|
pcb->snd_nxt,
|
||||||
|
pcb->rcv_nxt);
|
||||||
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_kprintf("Listen PCB states:\n");
|
rt_kprintf("Listen PCB states:\n");
|
||||||
|
num = 0;
|
||||||
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next)
|
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next)
|
||||||
{
|
{
|
||||||
rt_kprintf("local port %d ", pcb->local_port);
|
rt_kprintf("#%d local port %d ", num++, pcb->local_port);
|
||||||
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_kprintf("TIME-WAIT PCB states:\n");
|
rt_kprintf("TIME-WAIT PCB states:\n");
|
||||||
|
num = 0;
|
||||||
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next)
|
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next)
|
||||||
{
|
{
|
||||||
rt_kprintf("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
|
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
|
||||||
ipaddr_ntoa(&(pcb->local_ip)), pcb->local_port,
|
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
|
||||||
ipaddr_ntoa(&(pcb->remote_ip)), pcb->remote_port,
|
|
||||||
pcb->snd_nxt, pcb->rcv_nxt);
|
rt_kprintf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
|
||||||
|
num++,
|
||||||
|
local_ip_str,
|
||||||
|
pcb->local_port,
|
||||||
|
remote_ip_str,
|
||||||
|
pcb->remote_port,
|
||||||
|
pcb->snd_nxt,
|
||||||
|
pcb->rcv_nxt);
|
||||||
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
|
||||||
}
|
}
|
||||||
rt_exit_critical();
|
rt_exit_critical();
|
||||||
|
|
Loading…
Reference in New Issue