提交 2fe93c92 编写于 作者: B bernard.xiong@gmail.com

fixed lwip accept issue, if this connection has been deleted; added list_tcps...

fixed lwip accept issue, if this connection has been deleted; added list_tcps function in finsh shell.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1693 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 694a78f1
...@@ -369,8 +369,12 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) ...@@ -369,8 +369,12 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
#endif /* API_MSG_DEBUG */ #endif /* API_MSG_DEBUG */
conn = (struct netconn *)arg; conn = (struct netconn *)arg;
LWIP_ERROR("accept_function: invalid conn->acceptmbox", /* check whether acceptmbox is valid */
conn->acceptmbox != SYS_MBOX_NULL, return ERR_VAL;); if (conn->acceptmbox == SYS_MBOX_NULL)
{
LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: acceptmbox already deleted\n"));
return ERR_VAL;
}
/* We have to set the callback here even though /* We have to set the callback here even though
* the new socket is unknown. conn->socket is marked as -1. */ * the new socket is unknown. conn->socket is marked as -1. */
...@@ -508,6 +512,7 @@ netconn_alloc(enum netconn_type t, netconn_callback callback) ...@@ -508,6 +512,7 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
(DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE) (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE)
size = DEFAULT_RAW_RECVMBOX_SIZE; size = DEFAULT_RAW_RECVMBOX_SIZE;
#else #else
size = 0; /* skip warning */
switch(NETCONNTYPE_GROUP(t)) { switch(NETCONNTYPE_GROUP(t)) {
#if LWIP_RAW #if LWIP_RAW
case NETCONN_RAW: case NETCONN_RAW:
......
...@@ -89,9 +89,13 @@ typedef rt_uint32_t mem_ptr_t; ...@@ -89,9 +89,13 @@ typedef rt_uint32_t mem_ptr_t;
#endif #endif
void sys_arch_assert(const char* file, int line); void sys_arch_assert(const char* file, int line);
#ifdef LWIP_DEBUG
#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0)
#define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); } #define LWIP_PLATFORM_ASSERT(x) { rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__); }
#else
#define LWIP_PLATFORM_DIAG(x)
#define LWIP_PLATFORM_ASSERT(x)
#endif
#include "string.h" #include "string.h"
......
...@@ -118,6 +118,8 @@ ...@@ -118,6 +118,8 @@
/* the number of simultaneously queued TCP */ /* the number of simultaneously queued TCP */
#ifdef RT_LWIP_TCP_SEG_NUM #ifdef RT_LWIP_TCP_SEG_NUM
#define MEMP_NUM_TCP_SEG RT_LWIP_TCP_SEG_NUM #define MEMP_NUM_TCP_SEG RT_LWIP_TCP_SEG_NUM
#else
#define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
#endif #endif
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
......
...@@ -367,4 +367,45 @@ void list_if() ...@@ -367,4 +367,45 @@ void list_if()
#endif #endif
} }
FINSH_FUNCTION_EXPORT(list_if, list network interface information); FINSH_FUNCTION_EXPORT(list_if, list network interface information);
#include <lwip/tcp.h>
void list_tcps()
{
struct tcp_pcb *pcb;
extern struct tcp_pcb *tcp_active_pcbs;
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
extern struct tcp_pcb *tcp_tw_pcbs;
extern const char *tcp_state_str[];
rt_enter_critical();
rt_kprintf("Active PCB states:\n");
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
{
rt_kprintf("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
inet_ntoa(*((struct in_addr*)&(pcb->local_ip))), pcb->local_port,
inet_ntoa(*((struct in_addr*)&(pcb->remote_ip))), pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt);
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
}
rt_kprintf("Listen PCB states:\n");
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next)
{
rt_kprintf("local port %d ", pcb->local_port);
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
}
rt_kprintf("TIME-WAIT PCB states:\n");
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next)
{
rt_kprintf("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
inet_ntoa(*((struct in_addr*)&(pcb->local_ip))), pcb->local_port,
inet_ntoa(*((struct in_addr*)&(pcb->remote_ip))), pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt);
rt_kprintf("state: %s\n", tcp_state_str[pcb->state]);
}
rt_exit_critical();
}
FINSH_FUNCTION_EXPORT(list_tcps, list all of tcp pcb);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册