-doxygen
[oweals/gnunet.git] / src / transport / plugin_transport_http.c
index 24d37cc3441d7e2f674e54d11a74b15b7eb25024..42743fc9624d455eb2ece093a7081b6c968ce8b4 100644 (file)
@@ -52,36 +52,6 @@ struct HttpAddressWrapper
   struct HttpAddress *addr;
 };
 
-/**
- * Context for address to string conversion.
- */
-struct PrettyPrinterContext
-{
-  /**
-   * Function to call with the result.
-   */
-  GNUNET_TRANSPORT_AddressStringCallback asc;
-
-  /**
-   * Plugin
-   */
-  struct Plugin *plugin;
-
-  /**
-   * Clsoure for 'asc'.
-   */
-  void *asc_cls;
-
-  /**
-   * Port to add after the IP address.
-   */
-  uint16_t port;
-
-  uint32_t addrlen;
-
-  int numeric;
-};
-
 
 /**
  * Encapsulation of all of the state of the plugin.
@@ -106,6 +76,7 @@ reschedule_session_timeout (struct Session *s);
 static void
 stop_session_timeout (struct Session *s);
 
+
 /**
  * Convert the transports address to a nice, human-readable
  * format.
@@ -118,7 +89,7 @@ stop_session_timeout (struct Session *s);
  * @param numeric should (IP) addresses be displayed in numeric form?
  * @param timeout after how long should we give up?
  * @param asc function to call on each string
- * @param asc_cls closure for asc
+ * @param asc_cls closure for @a asc
  */
 static void
 http_plugin_address_pretty_printer (void *cls, const char *type,
@@ -128,9 +99,9 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
                                     GNUNET_TRANSPORT_AddressStringCallback asc,
                                     void *asc_cls)
 {
-  GNUNET_assert (cls != NULL);
-  struct HttpAddress *haddr = (struct HttpAddress *) addr;
+  const struct HttpAddress *haddr = addr;
 
+  GNUNET_assert (cls != NULL);
   if (addrlen < (sizeof (struct HttpAddress)))
   {
     /* invalid address */
@@ -188,20 +159,18 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
   struct Session *s = cls;
   struct Plugin *plugin = s->plugin;
   struct GNUNET_TIME_Relative delay;
-  struct GNUNET_ATS_Information atsi[2];
+  struct GNUNET_ATS_Information atsi;
 
-  atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
-  atsi[0].value = htonl (1);
-  atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
-  atsi[1].value = session->ats_address_network_type;
+  atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
+  atsi.value = session->ats_address_network_type;
   GNUNET_break (session->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
 
   reschedule_session_timeout (session);
 
   delay =
       plugin->env->receive (plugin->env->cls, &s->target, message,
-                            (const struct GNUNET_ATS_Information *) &atsi,
-                            2, s, s->addr, s->addrlen);
+                            &atsi,
+                            1, s, s->addr, s->addrlen);
   return delay;
 }
 
@@ -218,7 +187,7 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
  * @param added length of created address
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int 
+int
 http_string_to_address (void *cls,
                        const char *addr,
                        uint16_t addrlen,
@@ -365,7 +334,7 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar
       e_peer = GNUNET_YES;
       if ( (addrlen == t->addrlen) &&
           (0 == memcmp (addr, t->addr, addrlen)) )
-       e_addr = GNUNET_YES;    
+       e_addr = GNUNET_YES;
       if ( (t == session) &&
           (t->addrlen == session->addrlen) &&
           (0 == memcmp (session->addr, t->addr, t->addrlen)) )
@@ -831,7 +800,7 @@ http_check_ipv6 (struct Plugin *plugin)
 
 
 int
-http_get_addresses (struct Plugin *plugin, const char *serviceName,
+http_get_addresses (struct Plugin *plugin, const char *service_name,
                     const struct GNUNET_CONFIGURATION_Handle *cfg,
                     struct sockaddr ***addrs, socklen_t ** addr_lens)
 {
@@ -854,10 +823,10 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName,
   disablev6 = !plugin->ipv6;
 
   port = 0;
-  if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
   {
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_number (cfg, serviceName,
+                  GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
                                                          "PORT", &port));
     if (port > 65535)
     {
@@ -875,10 +844,10 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName,
   }
 
 
-  if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO"))
+  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_string (cfg, serviceName,
+                  GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
                                                          "BINDTO", &hostname));
   }
   else
@@ -888,7 +857,7 @@ http_get_addresses (struct Plugin *plugin, const char *serviceName,
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
                      "Resolving `%s' since that is where `%s' will bind to.\n",
-                     hostname, serviceName);
+                     hostname, service_name);
     memset (&hints, 0, sizeof (struct addrinfo));
     if (disablev6)
       hints.ai_family = AF_INET;
@@ -1263,8 +1232,10 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   s->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_log (TIMEOUT_LOG,
-              "Session %p was idle for %llu ms, disconnecting\n",
-              s, (unsigned long long) TIMEOUT.rel_value);
+              "Session %p was idle for %s, disconnecting\n",
+              s,
+             GNUNET_STRINGS_relative_time_to_string (TIMEOUT,
+                                                     GNUNET_YES));
 
   /* call session destroy function */
   if (s->inbound == GNUNET_NO)
@@ -1286,8 +1257,10 @@ start_session_timeout (struct Session *s)
                                                   &session_timeout,
                                                   s);
  GNUNET_log (TIMEOUT_LOG,
-             "Timeout for session %p set to %llu ms\n",
-             s,  (unsigned long long) TIMEOUT.rel_value);
+             "Timeout for session %p set to %s\n",
+             s,
+            GNUNET_STRINGS_relative_time_to_string (TIMEOUT,
+                                                    GNUNET_YES));
 }
 
 
@@ -1305,8 +1278,10 @@ reschedule_session_timeout (struct Session *s)
                                                   &session_timeout,
                                                   s);
  GNUNET_log (TIMEOUT_LOG,
-             "Timeout rescheduled for session %p set to %llu ms\n",
-             s, (unsigned long long) TIMEOUT.rel_value);
+             "Timeout rescheduled for session %p set to %s\n",
+             s,
+            GNUNET_STRINGS_relative_time_to_String (TIMEOUT,
+                                                    GNUNET_YES));
 }