safety check
[oweals/gnunet.git] / src / transport / plugin_transport_http.c
index fa4cf9d9c142cc5bbb9fd92dce46d1e410345c89..8d6801ce72fb5df1e2f8f4223c53978e3582edbc 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file transport/gnunet_transport_plugin.http.c
+ * @file transport/plugin_transport_http.c
  * @brief http transport service plugin
  * @author Matthias Wachs
  */
@@ -873,9 +873,18 @@ static void mhd_write_mst_cb (void *cls,
               ntohs(message->size),
              GNUNET_i2s(&(ps->peercontext)->identity),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen));
 #endif
+  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance[0].value = htonl (1);
+  distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+  distance[1].value = htonl (0);
+
   delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls,
                                                                                                                  &pc->identity,
-                                                                                                                 message, 1, ps,
+                                                                                                                 message,
+                                                                                                                 (const struct GNUNET_TRANSPORT_ATS_Information *) &distance,
+                                                                                                                 2,
+                                                                                                                 ps,
                                                                                                                  NULL,
                                                                                                                  0);
   pc->delay = delay;
@@ -1576,9 +1585,17 @@ static void curl_receive_mst_cb  (void *cls,
               ntohs(message->size),
               GNUNET_i2s(&(pc->identity)),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen));
 #endif
+  struct GNUNET_TRANSPORT_ATS_Information distance[2];
+  distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
+  distance[0].value = htonl (1);
+  distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
+  distance[1].value = htonl (0);
+
   delay = pc->plugin->env->receive (pc->plugin->env->cls,
                                                                  &pc->identity,
-                                                             message, 1, ps,
+                                                             message,
+                                                             (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2,
+                                                             ps,
                                                              ps->addr,
                                                              ps->addrlen);
 
@@ -2296,17 +2313,15 @@ http_plugin_send (void *cls,
       if (force_address != GNUNET_YES)
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection: creating new session %X to peer %s\n", ps, GNUNET_i2s(target));
 #endif
-      if ((addrlen!=0) && (addr!=NULL))
-      {
-         ps->addr = GNUNET_malloc(addrlen);
-         memcpy(ps->addr,addr,addrlen);
-         ps->addrlen = addrlen;
-      }
+         ps->addr = GNUNET_malloc(addrlen);
+         memcpy(ps->addr,addr,addrlen);
+         ps->addrlen = addrlen;
+      /*
          else
          {
                ps->addr = NULL;
                ps->addrlen = 0;
-         }
+         }*/
          ps->direction=OUTBOUND;
          ps->recv_connected = GNUNET_NO;
          ps->recv_force_disconnect = GNUNET_NO;