Free (GPLv2) TCP/IP stack developed by TASS Belgium

Fork of PicoTCP by Daniele Lacamera

Files at this revision

API Documentation at this revision

Comitter:
tass
Date:
Wed Jun 26 06:27:32 2013 +0000
Parent:
35:6078073547bb
Child:
37:bdf736327c71
Commit message:
Fixed send flag, that was causing assertion failure.

Changed in this revision

modules/pico_tcp.c Show annotated file Show diff for this revision Revisions of this file
--- a/modules/pico_tcp.c	Fri Jun 21 08:47:35 2013 +0000
+++ b/modules/pico_tcp.c	Wed Jun 26 06:27:32 2013 +0000
@@ -242,7 +242,7 @@
   while (head && (seq_compare(SEQN(head) + head->payload_len, seq) <= 0)) {
     struct pico_frame *cur = head;
     head = next_segment(q, cur);
-    tcp_dbg("Releasing %p\n", q);
+    //printf("Releasing %x\n", cur);
     pico_discard_segment(q, cur);
     ret++;
   }
@@ -258,7 +258,7 @@
   pico_tree_foreach_safe(idx,&q->pool,temp){
   f = idx->keyValue;
     if (seq_compare(SEQN(f) + f->payload_len, seq) <= 0) {
-      tcp_dbg("Releasing %p\n", f);
+      //printf("Releasing %p\n", f);
       pico_discard_segment(q, f);
       ret++;
     } else
@@ -1240,7 +1240,7 @@
   if( t->sock.net && ((t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_ESTABLISHED
         || (t->sock.state & 0xFF00) == PICO_SOCKET_STATE_TCP_CLOSE_WAIT) )
   {
-        tcp_dbg("\n\nTIMEOUT! backoff = %d\n", t->backoff);
+        //printf("\n\nTIMEOUT! backoff = %d\n", t->backoff);
         /* was timer cancelled? */
         if (t->timer_running == 0) {
             add_retransmission_timer(t, 0);
@@ -1309,6 +1309,7 @@
   }
   if (next_ts > 0) {
     if ((next_ts + t->rto) > pico_tick) {
+      //printf("Adding timer1\n,%d,%d,%d",next_ts,t->rto,pico_tick);
       pico_timer_add(next_ts + t->rto - pico_tick, tcp_retrans_timeout, t);
     } else {
       pico_timer_add(1, tcp_retrans_timeout, t);
@@ -1336,6 +1337,7 @@
     if (pico_enqueue(&tcp_out, cpy) > 0) {
       t->in_flight++;
       t->snd_last_out = SEQN(cpy);
+      //printf("tcp_retrans\n");
       add_retransmission_timer(t, pico_tick + t->rto);
     } else {
       pico_frame_discard(cpy);
@@ -1412,6 +1414,7 @@
   t->recv_wnd = short_be(hdr->rwnd);
 
   acked = tcp_ack_advance_una(t, f);
+  //printf("acked:%d,%d,%d\n",acked,SEQN(f),ACKN(f));
   una = first_segment(&t->tcpq_out);
 
   if ((t->x_mode == PICO_TCP_BLACKOUT) || 
@@ -1927,14 +1930,20 @@
 
   /* Those are not supported at this time. */
   flags &= ~(PICO_TCP_CWR | PICO_TCP_URG | PICO_TCP_ECN);
+  
   if (flags == PICO_TCP_SYN) {
     if (action->syn)
+    {
+      //printf("SYN\n");
       action->syn(s,f);
+    }
   } else if (flags == (PICO_TCP_SYN | PICO_TCP_ACK)) {
+    //printf("SYN-ACK\n");
     if (action->synack)
       action->synack(s,f);
   } else {
     if ((flags == PICO_TCP_ACK) || (flags == (PICO_TCP_ACK | PICO_TCP_PSH))) {
+      //printf("%s\n", flags == PICO_TCP_ACK ? "ACK" : (flags == (PICO_TCP_ACK | PICO_TCP_PSH) ? "PSH,ACK" : "x") );
       if (action->ack) {
         action->ack(s,f);
       }
@@ -1996,6 +2005,7 @@
   while((f) && (t->cwnd >= t->in_flight)) {
     hdr = (struct pico_tcp_hdr *)f->transport_hdr;
     f->timestamp = pico_tick;
+    //printf("Output frame : %x\n",f);
     tcp_add_options(t, f, hdr->flags, tcp_options_size(t, hdr->flags));
     if (seq_compare(SEQN(f) + f->payload_len, SEQN(una) + (t->recv_wnd << t->recv_wnd_scale)) > 0) {
       t->cwnd = t->in_flight;
@@ -2035,6 +2045,7 @@
   if (sent > 0) {
     if (t->rto < PICO_TCP_RTO_MIN)
       t->rto = PICO_TCP_RTO_MIN;
+    //printf("pico_tcp_output\n");
     add_retransmission_timer(t, pico_tick + t->rto);
   } else {
     // no packets in queue ??