Extending the testcases to use bluetooth
[oweals/gnunet.git] / src / transport / plugin_transport_http_server.c
index b5b27aa0fb5d97bb6416b48f553869cc16ab196c..19833521a06342c00b48d6f30f5f636cdc1d1327 100644 (file)
@@ -654,17 +654,23 @@ static int
 http_server_plugin_address_suggested (void *cls, const void *addr,
                size_t addrlen)
 {
-  struct HTTP_Server_Plugin *plugin = cls;
   struct HttpAddressWrapper *next;
   struct HttpAddressWrapper *pos;
+       struct HttpAddress *h_addr;
+       h_addr = (struct HttpAddress *) addr;
 
-
-  if ((NULL != plugin->ext_addr) &&
+  if ((NULL != p->ext_addr) &&
           GNUNET_YES == (http_common_cmp_addresses (addr, addrlen,
-                                          plugin->ext_addr, plugin->ext_addr_len)))
-    return GNUNET_OK;
+                                          p->ext_addr, p->ext_addr_len)))
+  {
+       /* Checking HTTP_OPTIONS_VERIFY_CERTIFICATE option for external hostname */
+       if ((ntohl(h_addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE) !=
+                       (p->options & HTTP_OPTIONS_VERIFY_CERTIFICATE))
+                       return GNUNET_NO; /* VERIFY option not set as required! */
+       return GNUNET_OK;
+  }
 
-  next  = plugin->addr_head;
+  next  = p->addr_head;
   while (NULL != (pos = next))
   {
     next = pos->next;
@@ -1118,10 +1124,6 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
       ats.type = htonl (GNUNET_ATS_NET_WAN);
       return NULL;
     }
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
-                     "Creating new session for peer `%s' connecting from `%s'\n",
-                     GNUNET_i2s (&target),
-                     http_common_plugin_address_to_string (NULL,  p->protocol, addr, addr_len));
 
     s = GNUNET_malloc (sizeof (struct Session));
     memcpy (&s->target, &target, sizeof (struct GNUNET_PeerIdentity));
@@ -1138,6 +1140,11 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
     s->connect_in_progress = GNUNET_YES;
     server_start_session_timeout(s);
     GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
+
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Creating new session %p for peer `%s' connecting from `%s'\n",
+                     s, GNUNET_i2s (&target),
+                     http_common_plugin_address_to_string (NULL, p->protocol, addr, addr_len));
   }
   sc = GNUNET_malloc (sizeof (struct ServerConnection));
   if (conn_info->client_addr->sa_family == AF_INET)
@@ -1156,7 +1163,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
   if ((NULL != s->server_send) && (NULL != s->server_recv))
   {
     s->connect_in_progress = GNUNET_NO; /* PUT and GET are connected */
-    plugin->env->session_start (NULL, &s->target, PLUGIN_NAME,s->addr, s->addrlen,s, NULL, 0);
+    plugin->env->session_start (NULL, &s->target, PLUGIN_NAME, NULL, 0 ,s, NULL, 0);
   }
 
 #if MHD_VERSION >= 0x00090E00
@@ -1305,14 +1312,11 @@ server_receive_mst_cb (void *cls, void *client,
   delay = plugin->env->receive (plugin->env->cls,
                                 &s->target,
                                 message,
-                                s, s->addr, s->addrlen);
+                                s, NULL, 0);
 
   plugin->env->update_address_metrics (plugin->env->cls,
                                       &s->target,
-                                      s->addr,
-                                      s->addrlen,
-                                      s,
-                                      &atsi, 1);
+                                      NULL, 0, s, &atsi, 1);
 
   GNUNET_asprintf (&stat_txt, "# bytes received via %s_server", plugin->protocol);
   GNUNET_STATISTICS_update (plugin->env->stats,
@@ -3008,9 +3012,15 @@ const char *http_plugin_address_to_string (void *cls,
                                            const void *addr,
                                            size_t addrlen)
 {
-       return http_common_plugin_address_to_string (cls, p->protocol, addr, addrlen);
+#if BUILD_HTTPS
+       return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
+#else
+       return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
+#endif
+
 }
 
+
 /**
  * Function obtain the network type for a session
  *
@@ -3019,13 +3029,14 @@ const char *http_plugin_address_to_string (void *cls,
  * @return the network type in HBO or GNUNET_SYSERR
  */
 static enum GNUNET_ATS_Network_Type
-http_server_get_network (void *cls, void *session)
+http_server_get_network (void *cls,
+                        struct Session *session)
 {
-       struct Session *s = (struct Session *) session;
-       GNUNET_assert (NULL != s);
-       return ntohl(s->ats_address_network_type);
+  GNUNET_assert (NULL != session);
+  return ntohl (session->ats_address_network_type);
 }
 
+
 /**
  * Entry point for the plugin.
  *