enabling use of pipes for signal communication also on UNIX to enable future integrat...
[oweals/gnunet.git] / src / ats / ats_api_scheduling.c
index ea8911ee8a0a827e1a2a2ead25b074929029a8fe..78e8d61ccef75f1dbf6a546c8eacce195808c20d 100644 (file)
@@ -678,8 +678,8 @@ interface_proc (void *cls, const char *name,
     net->netmask = (struct sockaddr *) &tmp[1];
     net->length = addrlen;
 
+    memset (&network4, 0, sizeof (network4));
     network4.sin_family = AF_INET;
-    network4.sin_port = htons (0);
 #if HAVE_SOCKADDR_IN_SIN_LEN
     network4.sin_len = sizeof (network4);
 #endif
@@ -702,8 +702,8 @@ interface_proc (void *cls, const char *name,
     net->netmask = (struct sockaddr *) &tmp[1];
     net->length = addrlen;
 
+    memset (&network6, 0, sizeof (network6));
     network6.sin6_family = AF_INET6;
-    network6.sin6_port = htons (0);
 #if HAVE_SOCKADDR_IN_SIN_LEN
     network6.sin6_len = sizeof (network6);
 #endif
@@ -721,11 +721,13 @@ interface_proc (void *cls, const char *name,
   /* Store in list */
   if (net != NULL)
   {
-    char * netmask = strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
+#if VERBOSE_ATS
+    char * netmask = GNUNET_strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding network `%s', netmask `%s'\n",
         GNUNET_a2s((struct sockaddr *) net->network, addrlen),
         netmask);
     GNUNET_free (netmask);
+# endif
     GNUNET_CONTAINER_DLL_insert(sh->net_head, sh->net_tail, net);
   }
   return GNUNET_OK;
@@ -752,12 +754,13 @@ get_addresses (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 /**
  * Returns where the address is located: LAN or WAN or ...
+ * @param sh the scheduling handle
  * @param addr address
  * @param addrlen address length
  * @return location as GNUNET_ATS_Information
  */
 
-struct GNUNET_ATS_Information
+const struct GNUNET_ATS_Information
 GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle * sh, const struct sockaddr * addr, socklen_t addrlen)
 {
   GNUNET_assert (sh != NULL);
@@ -803,7 +806,7 @@ GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle * sh, const stru
 
       if (((a4->sin_addr.s_addr & mask4->sin_addr.s_addr)) == net4->sin_addr.s_addr)
       {
-        char * net = strdup (GNUNET_a2s ((const struct sockaddr *) net4, addrlen));
+        char * net = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) net4, addrlen));
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' is in network `%s'\n",
             GNUNET_a2s ((const struct sockaddr *)a4, addrlen),
             net);
@@ -828,7 +831,7 @@ GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle * sh, const stru
 
       if (res == GNUNET_YES)
       {
-        char * net = strdup (GNUNET_a2s ((const struct sockaddr *) net6, addrlen));
+        char * net = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) net6, addrlen));
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' is in network `%s'\n",
               GNUNET_a2s ((const struct sockaddr *) a6, addrlen),
               net);
@@ -866,7 +869,7 @@ GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle * sh, const stru
 
   ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
   ats.value = htonl (type);
-  return ats;
+  return (const struct GNUNET_ATS_Information) ats;
 }
 
 /**
@@ -1018,6 +1021,11 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
   size_t namelen;
   size_t msize;
 
+  if (address == NULL)
+  {
+    GNUNET_break (0);
+    return;
+  }
   if ((address == NULL) && (session == NULL))
   {
     GNUNET_break (0);