gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11879 - gnunet/src/transport
Date: Tue, 22 Jun 2010 18:46:41 +0200

Author: wachs
Date: 2010-06-22 18:46:40 +0200 (Tue, 22 Jun 2010)
New Revision: 11879

Modified:
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/test_plugin_transport_http.c
   gnunet/src/transport/test_transport_api.c
   gnunet/src/transport/test_transport_api_http_peer1.conf
   gnunet/src/transport/test_transport_api_http_peer2.conf
Log:


Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2010-06-22 16:45:37 UTC (rev 11878)
+++ gnunet/src/transport/Makefile.am    2010-06-22 16:46:40 UTC (rev 11879)
@@ -74,7 +74,7 @@
   libgnunet_plugin_transport_udp.la \
   $(HTTP_PLUGIN_LA) \
   libgnunet_plugin_transport_template.la
-# TODO: add http, nat, etc.
+# TODO: add nat, etc.
 
 libgnunet_plugin_transport_tcp_la_SOURCES = \
   plugin_transport_tcp.c
@@ -134,9 +134,9 @@
  $(HTTP_PLUGIN_CHECK) \
  test_transport_api_udp_nat \
  test_transport_api_reliability_tcp \
- test_transport_api_reliability_tcp_nat 
-# test_transport_api_http \
-# TODO: add tests for http, nat, etc.
+ test_transport_api_reliability_tcp_nat \
+ test_transport_api_http
+# TODO: add tests for nat, etc.
 
 TESTS = $(check_PROGRAMS)
 
@@ -176,11 +176,11 @@
  $(top_builddir)/src/transport/libgnunettransport.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
-#test_transport_api_http_SOURCES = \
-# test_transport_api.c
-#test_transport_api_http_LDADD = \
-# $(top_builddir)/src/transport/libgnunettransport.la \
-# $(top_builddir)/src/util/libgnunetutil.la  
+test_transport_api_http_SOURCES = \
+ test_transport_api.c
+test_transport_api_http_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/util/libgnunetutil.la  
 
 test_plugin_transport_http_SOURCES = \
  test_plugin_transport_http.c

Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-06-22 16:45:37 UTC 
(rev 11878)
+++ gnunet/src/transport/plugin_transport_http.c        2010-06-22 16:46:40 UTC 
(rev 11879)
@@ -178,18 +178,29 @@
   /**
    * Sender's ip address to distinguish between incoming connections
    */
-  struct sockaddr_in * addr_inbound;
+  //struct sockaddr_in * addr_inbound;
 
   /**
    * Sender's ip address to distinguish between incoming connections
    */
-  char * addr_inbound_str;
+  void * addr_in;
 
+  size_t addr_in_len;
 
+  void * addr_out;
+
+  size_t addr_out_len;
+
   /**
+   * Sender's ip address to distinguish between incoming connections
+   */
+  //char * addr_inbound_str;
+
+
+  /**
    * Sender's ip address specified by transport
    */
-  struct sockaddr_in * addr_outbound;
+  //struct sockaddr_in * addr_outbound;
 
   /**
    * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
@@ -363,25 +374,27 @@
  * @param peer identity
  * @return created session object
  */
-static struct Session * create_session (struct sockaddr_in *addr_in, struct 
sockaddr_in *addr_out, const struct GNUNET_PeerIdentity *peer)
+static struct Session * create_session (char * addr_in, size_t addrlen_in, 
char * addr_out, size_t addrlen_out, const struct GNUNET_PeerIdentity *peer)
 {
   struct Session * ses = GNUNET_malloc ( sizeof( struct Session) );
 
-  ses->addr_inbound  = GNUNET_malloc ( sizeof (struct sockaddr_in) );
-  ses->addr_outbound  = GNUNET_malloc ( sizeof (struct sockaddr_in) );
-  ses->plugin = plugin;
-  if ((NULL != addr_in) && (( AF_INET == addr_in->sin_family) || ( AF_INET6 == 
addr_in->sin_family)))
+  if (addrlen_in != 0)
   {
-    memcpy(ses->addr_inbound, addr_in, sizeof (struct sockaddr_in));
+    ses->addr_in = GNUNET_malloc (addrlen_in);
+    ses->addr_in_len = addrlen_in;
+    memcpy(ses->addr_in,addr_in,addrlen_in);
   }
-  if ((NULL != addr_out) && (( AF_INET == addr_out->sin_family) || ( AF_INET6 
== addr_out->sin_family)))
+
+  if (addrlen_out != 0)
   {
-    memcpy(ses->addr_outbound, addr_out, sizeof (struct sockaddr_in));
+    ses->addr_out = GNUNET_malloc (addrlen_out);
+    ses->addr_out_len = addrlen_out;
+    memcpy(ses->addr_out,addr_out,addrlen_out);
   }
+  ses->plugin = plugin;
   memcpy(&ses->partner, peer, sizeof (struct GNUNET_PeerIdentity));
   GNUNET_CRYPTO_hash_to_enc(&ses->partner.hashPubKey,&(ses->hash));
   ses->is_active = GNUNET_NO;
-  ses->addr_inbound_str = NULL;
   ses->pending_inbound_msg = GNUNET_malloc( sizeof (struct HTTP_Message));
   ses->pending_inbound_msg->buf = 
GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE);
   ses->pending_inbound_msg->len = GNUNET_SERVER_MAX_MESSAGE_SIZE;
@@ -418,14 +431,16 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received message with type %u and size %u from `%s'\n",
-             message->size,
-             message->type,
+             ntohs(message->type),
+              ntohs(message->size),
              GNUNET_i2s(&(cs->partner)));
   plugin->env->receive(plugin->env->cls, 
                       &cs->partner, 
                       message, 1, NULL, 
-                      cs->addr_inbound_str, 
-                      strlen(cs->addr_inbound_str));
+                      NULL, 0);
+
+                      /*(char *)cs->addr_in,
+                      cs->addr_in_len);*/
 }
 
 /**
@@ -466,8 +481,9 @@
   int res = GNUNET_NO;
   struct GNUNET_MessageHeader *cur_msg;
   int send_error_to_client;
+  struct IPv4HttpAddress ipv4addr;
+  struct IPv6HttpAddress ipv6addr;
 
-
   cur_msg = NULL;
   send_error_to_client = GNUNET_NO;
 
@@ -493,12 +509,16 @@
     {
       addrin = conn_info->client_addr;
       inet_ntop(addrin->sin_family, 
&(addrin->sin_addr),address,INET_ADDRSTRLEN);
+      memcpy(&ipv4addr.ipv4_addr,&(addrin->sin_addr),sizeof(struct in_addr));
+      ipv4addr.u_port = addrin->sin_port;
     }
     /* Incoming IPv6 connection */
     if ( AF_INET6 == conn_info->client_addr->sin_family)
     {
       addrin6 = (struct sockaddr_in6 *) conn_info->client_addr;
       inet_ntop(addrin6->sin6_family, 
&(addrin6->sin6_addr),address,INET6_ADDRSTRLEN);
+      memcpy(&ipv6addr.ipv6_addr,&(addrin6->sin6_addr),sizeof(struct in_addr));
+      ipv6addr.u6_port = addrin6->sin6_port;
     }
     /* find existing session for address */
     cs = NULL;
@@ -517,7 +537,10 @@
     if (cs == NULL )
     {
       /* create new session object */
-      cs = create_session(conn_info->client_addr, NULL, &pi_in);
+      if ( AF_INET6 == conn_info->client_addr->sin_family)
+        cs = create_session((char *) &ipv6addr, sizeof(struct 
IPv6HttpAddress),NULL, 0, &pi_in);
+      if ( AF_INET == conn_info->client_addr->sin_family)
+        cs = create_session((char *) &ipv4addr, sizeof(struct 
IPv4HttpAddress),NULL, 0, &pi_in);
 
       /* Insert session into linked list */
       if ( plugin->sessions == NULL)
@@ -543,9 +566,8 @@
     {
       *httpSessionCache = cs;
       /* Updating session */
+      /*
       memcpy(cs->addr_inbound,conn_info->client_addr, sizeof(struct 
sockaddr_in));
-      if (cs->addr_inbound_str != NULL)
-        GNUNET_free (cs->addr_inbound_str);
       if ( AF_INET == cs->addr_inbound->sin_family)
       {
         
GNUNET_asprintf(&cs->addr_inbound_str,"%s:%u",address,ntohs(cs->addr_inbound->sin_port));
@@ -556,10 +578,11 @@
         
GNUNET_asprintf(&cs->addr_inbound_str,"[%s]:%u",address,ntohs(cs->addr_inbound->sin_port));
 
       }
+      */
       if (cs->msgtok==NULL)
         cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, 
cs, &messageTokenizerCallback, cs);
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' 
request from peer `%s' (`%s')\n",method, 
GNUNET_i2s(&cs->partner),cs->addr_inbound_str);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' 
request from peer `%s'\n",method, GNUNET_i2s(&cs->partner));
   }
   else
   {
@@ -627,7 +650,7 @@
       if (cs->pending_inbound_msg->pos >= sizeof (struct GNUNET_MessageHeader))
       {
         cur_msg = (struct GNUNET_MessageHeader *) cs->pending_inbound_msg->buf;
-        res = 
GNUNET_SERVER_mst_receive(cs->msgtok,cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos,
 GNUNET_NO, GNUNET_NO);
+        res = 
GNUNET_SERVER_mst_receive(cs->msgtok,cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos,
 GNUNET_YES, GNUNET_NO);
         if ((res != GNUNET_SYSERR) && (res != GNUNET_NO))
           send_error_to_client = GNUNET_NO;
       }
@@ -1178,7 +1201,7 @@
   {
     /* create new session object */
 
-    ses = create_session(NULL, (struct sockaddr_in *) addr, target);
+    ses = create_session((char *) addr, addrlen, NULL, 0, target);
     ses->is_active = GNUNET_YES;
 
     /* Insert session into linked list */
@@ -1200,36 +1223,38 @@
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "New Session `%s' inserted, count %u\n", GNUNET_i2s(target), 
plugin->session_count);
   }
+  if (ses != NULL)
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Session `%s' found, count %u\n", GNUNET_i2s(target), 
plugin->session_count);
 
   GNUNET_assert (addr!=NULL);
   unsigned int port;
-
-  /* setting url to send to */
-  if (force_address == GNUNET_YES)
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: len `%u'\n",addrlen);
+  if (ses->addr_out != NULL) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"have addr 
out!!!!'\n");
+  if (addrlen == (sizeof (struct IPv4HttpAddress)))
   {
-    if (addrlen == (sizeof (struct IPv4HttpAddress)))
-    {
-      address = GNUNET_malloc(INET_ADDRSTRLEN + 1);
-      inet_ntop(AF_INET, &((struct IPv4HttpAddress *) 
addr)->ipv4_addr,address,INET_ADDRSTRLEN);
-      port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
-      GNUNET_asprintf (&url,
-                      "http://%s:%u/%s";,
-                      address,
-                      port, 
-                      (char *) (&my_ascii_hash_ident));
-      GNUNET_free(address);
-    }
-    else if (addrlen == (sizeof (struct IPv6HttpAddress)))
-    {
-      address = GNUNET_malloc(INET6_ADDRSTRLEN + 1);
-      inet_ntop(AF_INET6, &((struct IPv6HttpAddress *) 
addr)->ipv6_addr,address,INET6_ADDRSTRLEN);
-      port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
-      GNUNET_asprintf(&url,
-                      "http://%s:%u/%s";,
-                      address,port,(char *) (&my_ascii_hash_ident));
-      GNUNET_free(address);
-    }
+    address = GNUNET_malloc(INET_ADDRSTRLEN + 1);
+    inet_ntop(AF_INET, &((struct IPv4HttpAddress *) 
addr)->ipv4_addr,address,INET_ADDRSTRLEN);
+    port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
+    GNUNET_asprintf (&url,
+                     "http://%s:%u/%s";,
+                     address,
+                     port,
+                     (char *) (&my_ascii_hash_ident));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: address `%s'\n",address);
+    GNUNET_free(address);
   }
+  else if (addrlen == (sizeof (struct IPv6HttpAddress)))
+  {
+    address = GNUNET_malloc(INET6_ADDRSTRLEN + 1);
+    inet_ntop(AF_INET6, &((struct IPv6HttpAddress *) 
addr)->ipv6_addr,address,INET6_ADDRSTRLEN);
+    port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
+    GNUNET_asprintf(&url,
+                    "http://%s:%u/%s";,
+                    address,port,(char *) (&my_ascii_hash_ident));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: address `%s'\n",address);
+    GNUNET_free(address);
+  }
   timeout = to;
   /* setting up message */
   msg = GNUNET_malloc (sizeof (struct HTTP_Message));
@@ -1591,9 +1616,8 @@
       GNUNET_SERVER_mst_destroy (cs->msgtok);
       GNUNET_free (cs->pending_inbound_msg->buf);
       GNUNET_free (cs->pending_inbound_msg);
-      GNUNET_free_non_null (cs->addr_inbound);
-      GNUNET_free_non_null (cs->addr_inbound_str);
-      GNUNET_free_non_null (cs->addr_outbound);
+      GNUNET_free_non_null (cs->addr_in);
+      GNUNET_free_non_null (cs->addr_out);
       GNUNET_free (cs);
 
       plugin->session_count--;

Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c   2010-06-22 16:45:37 UTC 
(rev 11878)
+++ gnunet/src/transport/test_plugin_transport_http.c   2010-06-22 16:46:40 UTC 
(rev 11879)
@@ -1025,6 +1025,20 @@
   msg2->type = htons(41);
   api->send(api->cls, &my_identity, tmp, 4 * sizeof(struct 
GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, 
GNUNET_YES, &task_send_cont, NULL);
 
+
+  /* send a multiple GNUNET_messages at a time, second message has incorrect 
size*/
+/*  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Ping Hello Message\n");
+  GNUNET_free(tmp);
+  tmp = GNUNET_malloc(425);
+  msg1 = (struct GNUNET_MessageHeader *) tmp;
+  msg1->size = htons(353);
+  msg1->type = htons(16);
+  msg2 = &tmp[353];
+  msg2->size = htons(72);
+  msg2->type = htons(32);
+  api->send(api->cls, &my_identity, tmp, 425, 0, TIMEOUT, 
NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, NULL);*/
+
+
   /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE )*/
   GNUNET_free(tmp);
   tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE);

Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c   2010-06-22 16:45:37 UTC (rev 
11878)
+++ gnunet/src/transport/test_transport_api.c   2010-06-22 16:46:40 UTC (rev 
11879)
@@ -36,7 +36,7 @@
 #include "gnunet_transport_service.h"
 #include "transport.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 #define VERBOSE_ARM GNUNET_NO
 

Modified: gnunet/src/transport/test_transport_api_http_peer1.conf
===================================================================
--- gnunet/src/transport/test_transport_api_http_peer1.conf     2010-06-22 
16:45:37 UTC (rev 11878)
+++ gnunet/src/transport/test_transport_api_http_peer1.conf     2010-06-22 
16:46:40 UTC (rev 11879)
@@ -87,7 +87,7 @@
 
 [transport-http]
 PORT = 12389
-DEBUG = YES
+DEBUG = NO
 
 [transport-tcp]
 PORT = 12399

Modified: gnunet/src/transport/test_transport_api_http_peer2.conf
===================================================================
--- gnunet/src/transport/test_transport_api_http_peer2.conf     2010-06-22 
16:45:37 UTC (rev 11878)
+++ gnunet/src/transport/test_transport_api_http_peer2.conf     2010-06-22 
16:46:40 UTC (rev 11879)
@@ -94,7 +94,7 @@
 
 [transport-http]
 PORT = 22389
-DEBUG = YES
+DEBUG = NO
 
 [transport-tcp]
 PORT = 22399




reply via email to

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