add crc8
[oweals/gnunet.git] / src / util / socks.c
index d90fa26d1209293bb3ec6aed9d4299b66f093e9d..3ae63b6fc06ff33194ddee065556ff2d413e52f7 100644 (file)
@@ -369,23 +369,19 @@ transmit_ready (void *cls,
       }
       return 0;
     }
-    printf("Erronious socks.c transmit_ready() callback on step %u with reason %u.\n", 
-       ih->step, reason );
     /* if (reason == 48) register_sender (ih); */
     /* GNUNET_break(0); */
     return 0;
-  } else 
-    printf("Good socks.c transmit_ready() callback on step %u with reason %u.\n", 
-       ih->step, GNUNET_SCHEDULER_get_reason () );
+  }
 
   GNUNET_assert (1024 >= size && size > 0);
   GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
   unsigned char * b = ih->outstep[ih->step];
-  unsigned char * e = ih->outstep[ih->step++];
+  unsigned char * e = ih->outstep[ih->step+1];
   GNUNET_assert (e <= &ih->outbuf[1024]);
   unsigned l = e - b;
   GNUNET_assert (size >= l && l >= 0);
-  memcpy(b, buf, l);
+  memcpy(buf, b, l);
   register_reciever (ih, register_reciever_wants(ih));
   return l;
 }
@@ -403,13 +399,13 @@ register_sender (struct GNUNET_SOCKS_Handshake *ih)
 {
   struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_MINUTES;
 
-  GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
+  GNUNET_assert (SOCKS5_step_done > ih->step);
+  GNUNET_assert (ih->step >= 0);
   if (0 == ih->step)
     timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3);
   unsigned char * b = ih->outstep[ih->step];
   unsigned char * e = ih->outstep[ih->step+1];
   GNUNET_assert (ih->outbuf <= b && b < e && e < &ih->outbuf[1024]);
-  printf("register_sender on step %u for %u bytes.\n", ih->step, (unsigned)(e - b) );
   ih->th = GNUNET_CONNECTION_notify_transmit_ready (ih->socks5_connection,
                                                     e - b,
                                                     timeout,
@@ -463,6 +459,8 @@ GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
 
   ih->outstep[SOCKS5_step_cmd] = b;
 
+  ih->inend = ih->instart = ih->inbuf;
+
   return ih;
 }