gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11641 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r11641 - gnunet/src/transport
Date: Tue, 8 Jun 2010 18:49:26 +0200

Author: wachs
Date: 2010-06-08 18:49:26 +0200 (Tue, 08 Jun 2010)
New Revision: 11641

Modified:
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/test_plugin_transport_http.c
Log:


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-06-08 15:46:09 UTC 
(rev 11640)
+++ gnunet/src/transport/plugin_transport_http.c        2010-06-08 16:49:26 UTC 
(rev 11641)
@@ -38,6 +38,8 @@
 #include "microhttpd.h"
 #include <curl/curl.h>
 
+
+#define DEBUG_CURL GNUNET_CURL
 #define DEBUG_HTTP GNUNET_NO
 
 /**
@@ -614,7 +616,7 @@
       struct GNUNET_MessageHeader * gn_msg = NULL;
       /*check message and forward here */
       /* checking size */
-      if (cs->pending_inbound_msg->pos > sizeof (struct GNUNET_MessageHeader))
+      if (cs->pending_inbound_msg->pos >= sizeof (struct GNUNET_MessageHeader))
       {
         gn_msg = GNUNET_malloc (cs->pending_inbound_msg->pos);
         memcpy 
(gn_msg,cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos);
@@ -869,8 +871,9 @@
   url = GNUNET_malloc( 7 + strlen(ses->ip) + 7 + strlen ((char *) 
&(ses->hash)) + 1);
   /* FIXME: use correct port number */
   GNUNET_asprintf(&url,"http://%s:%u/%s",ses->ip,12389, (char *) &(ses->hash));
-
-  /* curl_easy_setopt(ses->curl_handle, CURLOPT_VERBOSE, 1L); */
+#if DEBUG_CURL
+  curl_easy_setopt(ses->curl_handle, CURLOPT_VERBOSE, 1L);
+#endif
   curl_easy_setopt(ses->curl_handle, CURLOPT_URL, url);
   curl_easy_setopt(ses->curl_handle, CURLOPT_PUT, 1L);
   curl_easy_setopt(ses->curl_handle, CURLOPT_READFUNCTION, send_read_callback);

Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c   2010-06-08 15:46:09 UTC 
(rev 11640)
+++ gnunet/src/transport/test_plugin_transport_http.c   2010-06-08 16:49:26 UTC 
(rev 11641)
@@ -255,7 +255,7 @@
 
 static GNUNET_SCHEDULER_TaskIdentifier ti_send;
 
-const struct GNUNET_PeerIdentity * p;
+//const struct GNUNET_PeerIdentity * p;
 
 /**
  * buffer for data to send
@@ -310,21 +310,6 @@
 static struct HTTP_Transfer test_too_long_ident;
 
 /**
- * Test: connect to peer and send message bigger then content length
- */
-static struct HTTP_Transfer test_msg_too_big;
-
-/**
- * Test: connect to peer and send message bigger GNUNET_SERVER_MAX_MESSAGE_SIZE
- */
-//static struct HTTP_Transfer test_msg_bigger_max;
-
-/**
- * Test: connect to peer and send message smaller then content length
- */
-//static struct HTTP_Transfer test_msg_too_small;
-
-/**
  * Test: connect to peer with valid peer identification
  */
 static struct HTTP_Transfer test_valid_ident;
@@ -334,11 +319,6 @@
  */
 static int fail;
 
-/**
- * Recieved message already returned to sender?
- */
-static int sent;
-
 CURL *curl_handle;
 
 /**
@@ -406,7 +386,6 @@
 }
 
 
-#if 0
 /**
  * Continuation called after plugin send message
  * @cls closure
@@ -421,8 +400,8 @@
   fail = GNUNET_NO;
   shutdown_clean();
 }
-#endif
 
+#if 0
 /**
  * Task sending recieved message back to peer
  * @cls closure
@@ -448,8 +427,8 @@
   */
   sent = GNUNET_YES;
 }
+#endif
 
-
 /**
  * Recieves messages from plugin, in real world transport
  */
@@ -463,34 +442,15 @@
          uint16_t sender_address_len)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from 
peer `%s' with type %u and length %u\n",  
GNUNET_i2s(peer),ntohs(message->type),ntohs(message->size));
-
-  /* take recieved message and send it back to peer */
-
-
-  p = peer;
-  void * c = (void *) message;
-  ti_send =GNUNET_SCHEDULER_add_delayed (sched, WAIT_INTERVALL, &task_send, c);
-
   return GNUNET_TIME_UNIT_ZERO;
 }
 
 static size_t send_function (void *stream, size_t size, size_t nmemb, void 
*ptr)
 {
   unsigned int len;
-  struct HTTP_Transfer * test = (struct HTTP_Transfer *) ptr;
 
   len = buffer_out.len;
 
-  if (test == &test_msg_too_big)
-  {
-    if (buffer_out.pos > len)
-      return 0;
-    if ( (2*len) < (size * nmemb))
-      memcpy(stream, buffer_out.buf,  2* len);
-    buffer_out.pos = 2* len;
-    return 2* len;
-  }
-
   if (( buffer_out.pos == len) || (len > (size * nmemb)))
     return 0;
   memcpy(stream, buffer_out.buf, len);
@@ -924,31 +884,24 @@
 
     return;
   }
-/*
-  if (test_msg_too_big.test_executed == GNUNET_NO)
-  {
-    struct GNUNET_CRYPTO_HashAsciiEncoded result;
-    unsigned int c;
 
-    GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&result);
-    host_str = GNUNET_malloc (strlen ("http://localhost:12389/";) + strlen 
((const char *) &result));
-    GNUNET_asprintf (&host_str, "http://localhost:%u/%s",port,(char *) 
&result);
 
-    buffer_out.len = 50;
-    c = 0;
-    for (c=0; c<100; c++)
-      buffer_out.buf[c] = 'A';
+  struct GNUNET_MessageHeader msg;
+  char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
+  msg.size=htons(sizeof(struct GNUNET_MessageHeader));
+  msg.type=htons(13);
+  memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
 
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with message 
bigger content length.\n"));
-    test_msg_too_big.test_executed = GNUNET_YES;
-    send_data ( &test_msg_too_big, host_str);
-    GNUNET_free (host_str);
+  api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 
0, TIMEOUT, NULL,NULL, 0, GNUNET_NO, &task_send_cont, NULL);
 
-    return;
-  }
-*/
+  /*
+  msg.size=htons(2);
+  msg.type=htons(13);
+  memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
+
+  api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 
0, TIMEOUT, NULL,NULL, 0, GNUNET_NO, &task_send_cont, NULL);
+   */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n");
-  shutdown_clean();
 }
 
 
@@ -1125,10 +1078,6 @@
   test_valid_ident.test_executed = GNUNET_NO;
   test_valid_ident.test_failed = GNUNET_YES;
 
-  /* Test: connecting with valid identification */
-  test_msg_too_big.test_executed = GNUNET_NO;
-  test_msg_too_big.test_failed = GNUNET_YES;
-
   run_connection_tests();
 
   /* testing finished */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]