Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of lwip by
Revision 12:963887732b7c, committed 2013-12-13
- Comitter:
- rebonatto
- Date:
- Fri Dec 13 11:39:39 2013 +0000
- Parent:
- 11:4b3f6f8b92d2
- Commit message:
- modify;
Changed in this revision
diff -r 4b3f6f8b92d2 -r 963887732b7c api/api_lib.c --- a/api/api_lib.c Mon Aug 19 18:37:54 2013 +0300 +++ b/api/api_lib.c Fri Dec 13 11:39:39 2013 +0000 @@ -53,6 +53,7 @@ #include "lwip/tcp.h" #include <string.h> +#include <stdio.h> /** * Create a new netconn (of a specific type) that has a callback function. @@ -195,14 +196,15 @@ err_t err; LWIP_ERROR("netconn_connect: invalid conn", (conn != NULL), return ERR_ARG;); - msg.function = do_connect; msg.msg.conn = conn; msg.msg.msg.bc.ipaddr = addr; msg.msg.msg.bc.port = port; /* This is the only function which need to not block tcpip_thread */ err = tcpip_apimsg(&msg); - + if(err != 0) + printf("Pau em tcpip_apimsg\n"); + NETCONN_SET_SAFE_ERR(conn, err); return err; }
diff -r 4b3f6f8b92d2 -r 963887732b7c api/sockets.c --- a/api/sockets.c Mon Aug 19 18:37:54 2013 +0300 +++ b/api/sockets.c Fri Dec 13 11:39:39 2013 +0000 @@ -57,6 +57,7 @@ #endif #include <string.h> +#include <stdio.h> #define NUM_SOCKETS MEMP_NUM_NETCONN @@ -472,6 +473,7 @@ sock = get_socket(s); if (!sock) { + printf("Erro get_socket\n"); return -1; } @@ -483,6 +485,7 @@ if (name_in->sin_family == AF_UNSPEC) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); + printf("1->lwip_connect(%d, AF_UNSPEC)\n", s); err = netconn_disconnect(sock->conn); } else { ip_addr_t remote_addr; @@ -492,14 +495,18 @@ remote_port = name_in->sin_port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); + //printf("2->lwip_connect(%d, addr=", s); + ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", ntohs(remote_port))); + //printf(" port=%d\n", ntohs(remote_port)); err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); } if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); + //printf("4->lwip_connect(%d) failed, err=%d\n", s, err); sock_set_errno(sock, err_to_errno(err)); return -1; }
diff -r 4b3f6f8b92d2 -r 963887732b7c api/tcpip.c --- a/api/tcpip.c Mon Aug 19 18:37:54 2013 +0300 +++ b/api/tcpip.c Fri Dec 13 11:39:39 2013 +0000 @@ -49,6 +49,8 @@ #include "netif/etharp.h" #include "netif/ppp_oe.h" +#include <stdio.h> + /* global variables */ static tcpip_init_done_fn tcpip_init_done; static void *tcpip_init_done_arg; @@ -83,15 +85,26 @@ LOCK_TCPIP_CORE(); while (1) { /* MAIN Loop */ UNLOCK_TCPIP_CORE(); + //printf("Unlock realizado\n"); LWIP_TCPIP_THREAD_ALIVE(); /* wait for a message, timeouts are processed while waiting */ sys_timeouts_mbox_fetch(&mbox, (void **)&msg); + /* + if (msg->type == 0) + printf("Tirou do Mbox %d Tipo %d\n\n", msg->msg.apimsg, msg->type); + else + printf("Tirou InPackt %d Tipo %d\n\n", (int) msg, msg->type); + //printf("Pegou fetch\n"); + */ LOCK_TCPIP_CORE(); + //printf("Executou lock\n"); switch (msg->type) { #if LWIP_NETCONN case TCPIP_MSG_API: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg)); + msg->msg.apimsg->function(&(msg->msg.apimsg->msg)); + //printf("Executou funcao\n"); break; #endif /* LWIP_NETCONN */ @@ -104,6 +117,7 @@ } else #endif /* LWIP_ETHERNET */ { + printf("AAAAAA\n"); ip_input(msg->msg.inp.p, msg->msg.inp.netif); } memp_free(MEMP_TCPIP_MSG_INPKT, msg); @@ -181,6 +195,7 @@ msg->type = TCPIP_MSG_INPKT; msg->msg.inp.p = p; msg->msg.inp.netif = inp; + //printf("Colocou InPact %d\n", (int) msg); if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { memp_free(MEMP_TCPIP_MSG_INPKT, msg); return ERR_MEM; @@ -301,6 +316,7 @@ tcpip_apimsg(struct api_msg *apimsg) { struct tcpip_msg msg; + int x=-1; #ifdef LWIP_DEBUG /* catch functions that don't set err */ apimsg->msg.err = ERR_VAL; @@ -309,8 +325,13 @@ if (sys_mbox_valid(&mbox)) { msg.type = TCPIP_MSG_API; msg.msg.apimsg = apimsg; + //printf("Vai dar Post\n"); + sys_mbox_post(&mbox, &msg); - sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0); + //printf("Passou Post\n"); + //printf("Colocou no Mbox %d\n\n", apimsg); + x = sys_arch_sem_wait(&apimsg->msg.conn->op_completed, 0); + //printf("Passou Wait %d\n", x); return apimsg->msg.err; } return ERR_VAL;
diff -r 4b3f6f8b92d2 -r 963887732b7c core/tcp.c --- a/core/tcp.c Mon Aug 19 18:37:54 2013 +0300 +++ b/core/tcp.c Fri Dec 13 11:39:39 2013 +0000 @@ -733,8 +733,9 @@ } TCP_REG(&tcp_active_pcbs, pcb); snmp_inc_tcpactiveopens(); - + //printf("VAi para output\n"); tcp_output(pcb); + //printf("Veio para output\n"); } return ret; }
diff -r 4b3f6f8b92d2 -r 963887732b7c core/tcp_in.c --- a/core/tcp_in.c Mon Aug 19 18:37:54 2013 +0300 +++ b/core/tcp_in.c Fri Dec 13 11:39:39 2013 +0000 @@ -100,6 +100,7 @@ u8_t hdrlen; err_t err; + //printf("Entrou no TCP_In!\n"); PERF_START; TCP_STATS_INC(tcp.recv); @@ -178,6 +179,7 @@ for an active connection. */ prev = NULL; + //printf("Cheguei aqui SRC %d DEST %d \n", tcphdr->src, tcphdr->dest); for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); @@ -198,12 +200,14 @@ tcp_active_pcbs = pcb; } LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb); + //printf("Achei nas ativas\n"); break; } prev = pcb; } - + if (pcb == NULL) { + //printf("NAO ACHOU NAS ATIVAS\n"); /* If it did not go to an active connection, we check the connections in the TIME-WAIT state. */ for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { @@ -216,15 +220,17 @@ of the list since we are not very likely to receive that many segments for connections in TIME-WAIT. */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); + //printf("Achei nas TimeWait\n"); tcp_timewait_input(pcb); pbuf_free(p); return; } } - + //printf("NAO ACHOU NAS TIME-WAIT\n"); /* Finally, if we still did not get a match, we check all PCBs that are LISTENing for incoming connections. */ prev = NULL; + //printf("Vai procurar nas Listening ...\n"); for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { if (lpcb->local_port == tcphdr->dest) { #if SO_REUSE @@ -267,12 +273,13 @@ } LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); + //printf("Achou Nas Listening\n\n"); tcp_listen_input(lpcb); pbuf_free(p); return; } } - + #if TCP_INPUT_DEBUG LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); @@ -288,6 +295,7 @@ #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ + //tcp_debug_print_state(pcb->state); /* Set up a tcp_seg structure. */ inseg.next = NULL; inseg.len = p->tot_len; @@ -408,7 +416,9 @@ inseg.p = NULL; } } else { - + //printf("Vai Capeta \n"); + //tcp_debug_print_state(pcb->state); + //printf("Fudeu mesmo\n\n\n\n\n\n"); /* If no matching PCB was found, send a TCP RST (reset) to the sender. */ LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
diff -r 4b3f6f8b92d2 -r 963887732b7c lwipopts.h --- a/lwipopts.h Mon Aug 19 18:37:54 2013 +0300 +++ b/lwipopts.h Fri Dec 13 11:39:39 2013 +0000 @@ -70,7 +70,7 @@ #define LWIP_TCP_KEEPALIVE 1 // Debug Options -// #define LWIP_DEBUG + //#define LWIP_DEBUG #define UDP_LPC_EMAC LWIP_DBG_OFF #define SYS_DEBUG LWIP_DBG_OFF #define PPP_DEBUG LWIP_DBG_OFF @@ -81,7 +81,7 @@ #define API_LIB_DEBUG LWIP_DBG_OFF #define API_MSG_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF -#define SOCKETS_DEBUG LWIP_DBG_OFF +#define SOCKETS_DEBUG LWIP_DBG_ON #define TCP_DEBUG LWIP_DBG_OFF #define TCP_INPUT_DEBUG LWIP_DBG_OFF #define TCP_FR_DEBUG LWIP_DBG_OFF