gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: finish (?) libgnunetatstran


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: finish (?) libgnunetatstransport for now
Date: Thu, 29 Nov 2018 22:26:27 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new e871f8368 finish (?) libgnunetatstransport for now
e871f8368 is described below

commit e871f8368c8a1f0867f68f656875e4c37c26f298
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Nov 29 22:26:21 2018 +0100

    finish (?) libgnunetatstransport for now
---
 src/arm/gnunet-service-arm.c             | 32 +++++--------------------
 src/ats/ats_api2_transport.c             | 41 +++++++++++++++++++++++++-------
 src/fs/gnunet-service-fs.c               | 10 ++------
 src/gns/gnunet-service-gns.c             | 17 ++++---------
 src/namestore/gnunet-service-namestore.c |  9 +------
 src/regex/gnunet-service-regex.c         | 12 ++--------
 src/transport/gnunet-service-tng.c       | 38 +++--------------------------
 src/util/gnunet-service-resolver.c       | 30 +++++++++--------------
 8 files changed, 62 insertions(+), 127 deletions(-)

diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index bc138e6fc..c9c9b3638 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -469,7 +469,7 @@ get_server_addresses (const char *service_name,
 #endif
     if ( (GNUNET_YES != abstract) &&
         (GNUNET_OK !=
-         GNUNET_DISK_directory_create_for_file (unixpath)) ) 
+         GNUNET_DISK_directory_create_for_file (unixpath)) )
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
                                "mkdir",
                                unixpath);
@@ -1234,18 +1234,8 @@ static int
 check_start (void *cls,
              const struct GNUNET_ARM_Message *amsg)
 {
-  uint16_t size;
-  const char *servicename;
-
   (void) cls;
-  size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
-  servicename = (const char *) &amsg[1];
-  if ( (0 == size) ||
-       (servicename[size - 1] != '\0') )
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (amsg);
   return GNUNET_OK;
 }
 
@@ -1327,18 +1317,8 @@ static int
 check_stop (void *cls,
             const struct GNUNET_ARM_Message *amsg)
 {
-  uint16_t size;
-  const char *servicename;
-
   (void) cls;
-  size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
-  servicename = (const char *) &amsg[1];
-  if ( (0 == size) ||
-       (servicename[size - 1] != '\0') )
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (amsg);
   return GNUNET_OK;
 }
 
@@ -1715,7 +1695,7 @@ delayed_restart_task (void *cls)
  * Task triggered whenever we receive a SIGCHLD (child
  * process died).
  *
- * @param cls closure, NULL 
+ * @param cls closure, NULL
  */
 static void
 maint_child_death (void *cls)
@@ -2230,7 +2210,7 @@ run (void *cls,
   start_system = GNUNET_CONFIGURATION_get_value_yesno (cfg,
                                             "ARM",
                                             "START_SYSTEM_SERVICES");
-  if ( (GNUNET_NO == start_user) && 
+  if ( (GNUNET_NO == start_user) &&
        (GNUNET_NO == start_system) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/ats/ats_api2_transport.c b/src/ats/ats_api2_transport.c
index 6add4baf5..5ad9fb40e 100644
--- a/src/ats/ats_api2_transport.c
+++ b/src/ats/ats_api2_transport.c
@@ -131,6 +131,29 @@ struct GNUNET_ATS_TransportHandle
 };
 
 
+
+/**
+ * Convert ATS properties from host to network byte order.
+ *
+ * @param nbo[OUT] value written
+ * @param hbo value read
+ */
+static void
+properties_hton (struct PropertiesNBO *nbo,
+                 const struct GNUNET_ATS_Properties *hbo)
+{
+  nbo->delay = GNUNET_TIME_relative_hton (hbo->delay);
+  nbo->goodput_out = htonl (hbo->goodput_out);
+  nbo->goodput_in = htonl (hbo->goodput_in);
+  nbo->utilization_out = htonl (hbo->utilization_out);
+  nbo->utilization_in = htonl (hbo->utilization_in);
+  nbo->distance = htonl (hbo->distance);
+  nbo->mtu = htonl (hbo->mtu);
+  nbo->nt = htonl ((uint32_t) hbo->nt);
+  nbo->cc = htonl ((uint32_t) hbo->cc);
+}
+
+
 /**
  * Re-establish the connection to the ATS service.
  *
@@ -250,10 +273,10 @@ match_session_cb (void *cls,
 
   (void) pid;
   if (fc->session_id == sr->slot)
-    {
-      fc->sr = sr;
-      return GNUNET_NO;
-    }
+  {
+    fc->sr = sr;
+    return GNUNET_NO;
+  }
   return GNUNET_YES;
 }
 
@@ -366,8 +389,8 @@ send_add_session_message (const struct 
GNUNET_ATS_SessionRecord *ar)
                             : GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD);
   m->peer = ar->pid;
   m->session_id = htonl (ar->slot);
-  // FIXME: convert endianess here!
-  // m->properties = ar->properties;
+  properties_hton (&m->properties,
+                   &ar->properties);
   GNUNET_memcpy (&m[1],
                  ar->address,
                  alen);
@@ -580,7 +603,7 @@ GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle 
*ath,
   alen = strlen (address) + 1;
   ar = GNUNET_malloc (sizeof (struct GNUNET_ATS_SessionRecord) + alen);
   ar->ath = ath;
-  ar->slot = 42; // FIXME: make up unique number!
+  ar->slot = s;
   ar->session = session;
   ar->address = (const char *) &ar[1];
   ar->pid = *pid;
@@ -627,8 +650,8 @@ GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord 
*ar,
                       GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE);
   m->session_id = htonl (ar->slot);
   m->peer = ar->pid;
-  // FIXME: convert endianess here!
-  // m->properties = ar->properties;
+  properties_hton (&m->properties,
+                   &ar->properties);
   GNUNET_MQ_send (ath->mq,
                   ev);
 }
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index fea22f279..04d483847 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -965,15 +965,9 @@ static int
 check_client_index_start (void *cls,
                           const struct IndexStartMessage *ism)
 {
-  uint16_t msize;
   char *fn;
 
-  msize = ntohs (ism->header.size);
-  if (((const char *) ism)[msize - 1] != '\0')
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (ism);
   if (0 != ism->reserved)
   {
     GNUNET_break (0);
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 71e744733..bd9d17895 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -396,19 +396,12 @@ static int
 check_lookup (void *cls,
               const struct LookupMessage *l_msg)
 {
-  size_t msg_size;
-  const char* name;
+  size_t nlen;
 
   (void) cls;
-  msg_size = ntohs (l_msg->header.size);
-  if (msg_size < sizeof (struct LookupMessage))
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  name = (const char *) &l_msg[1];
-  if ( ('\0' != name[msg_size - sizeof (struct LookupMessage) - 1]) ||
-       (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) )
+  GNUNET_MQ_check_zero_termination (l_msg);
+  nlen = ntohs (l_msg->header.size) - sizeof (struct LookupMessage);
+  if (nlen > GNUNET_DNSPARSER_MAX_NAME_LENGTH)
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
diff --git a/src/namestore/gnunet-service-namestore.c 
b/src/namestore/gnunet-service-namestore.c
index cdd52cc42..0558649ca 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1221,7 +1221,6 @@ check_record_lookup (void *cls,
 {
   uint32_t name_len;
   size_t src_size;
-  const char *name_tmp;
 
   (void) cls;
   name_len = ntohl (ll_msg->label_len);
@@ -1231,13 +1230,7 @@ check_record_lookup (void *cls,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-
-  name_tmp = (const char *) &ll_msg[1];
-  if ('\0' != name_tmp[name_len -1])
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (ll_msg);
   return GNUNET_OK;
 }
 
diff --git a/src/regex/gnunet-service-regex.c b/src/regex/gnunet-service-regex.c
index eb10e7c07..9b9cad231 100644
--- a/src/regex/gnunet-service-regex.c
+++ b/src/regex/gnunet-service-regex.c
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -131,16 +131,8 @@ check_announce (void *cls,
                 const struct AnnounceMessage *am)
 {
   struct ClientEntry *ce = cls;
-  const char *regex;
-  uint16_t size;
 
-  size = ntohs (am->header.size) - sizeof (*am);
-  regex = (const char *) &am[1];
-  if ('\0' != regex[size - 1])
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (am);
   if (NULL != ce->ah)
   {
     /* only one announcement per client allowed */
diff --git a/src/transport/gnunet-service-tng.c 
b/src/transport/gnunet-service-tng.c
index b184a0600..feaa0cfff 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -1078,7 +1078,6 @@ check_communicator_available (void *cls,
                               const struct 
GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
 {
   struct TransportClient *tc = cls;
-  const char *addr;
   uint16_t size;
 
   if (CT_NONE != tc->type)
@@ -1090,12 +1089,7 @@ check_communicator_available (void *cls,
   size = ntohs (cam->header.size) - sizeof (*cam);
   if (0 == size)
     return GNUNET_OK; /* receive-only communicator */
-  addr = (const char *) &cam[1];
-  if ('\0' != addr[size-1])
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (cam);
   return GNUNET_OK;
 }
 
@@ -1135,26 +1129,13 @@ check_add_address (void *cls,
                    const struct GNUNET_TRANSPORT_AddAddressMessage *aam)
 {
   struct TransportClient *tc = cls;
-  const char *addr;
-  uint16_t size;
 
   if (CT_COMMUNICATOR != tc->type)
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  size = ntohs (aam->header.size) - sizeof (*aam);
-  if (0 == size)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  addr = (const char *) &aam[1];
-  if ('\0' != addr[size-1])
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (aam);
   return GNUNET_OK;
 }
 
@@ -1363,26 +1344,13 @@ check_add_queue_message (void *cls,
                          const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
 {
   struct TransportClient *tc = cls;
-  const char *addr;
-  uint16_t size;
 
   if (CT_COMMUNICATOR != tc->type)
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  size = ntohs (aqm->header.size) - sizeof (*aqm);
-  if (0 == size)
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  addr = (const char *) &aqm[1];
-  if ('\0' != addr[size-1])
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
+  GNUNET_MQ_check_zero_termination (aqm);
   return GNUNET_OK;
 }
 
diff --git a/src/util/gnunet-service-resolver.c 
b/src/util/gnunet-service-resolver.c
index 3b871ce33..5f8957d8c 100644
--- a/src/util/gnunet-service-resolver.c
+++ b/src/util/gnunet-service-resolver.c
@@ -365,12 +365,12 @@ lookup_dns_servers (char ***server_addrs)
     return -1;
   }
   if ((size_t) bytes_read > SIZE_MAX)
-  { 
+  {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                "/etc/resolv.conf file too large to mmap. "
                "DNS resolution will not be possible.\n");
     GNUNET_DISK_file_close (fh);
-    return -1;   
+    return -1;
   }
   buf = GNUNET_DISK_file_map (fh,
                              &mh,
@@ -600,7 +600,7 @@ remove_expired (struct ResolveCache *rc)
                                    pos);
       GNUNET_DNSPARSER_free_record (pos->record);
       GNUNET_free (pos->record);
-      GNUNET_free (pos);      
+      GNUNET_free (pos);
     }
   }
   if (NULL == rc->records_head)
@@ -1062,7 +1062,7 @@ process_get (const char *hostname,
             struct GNUNET_SERVICE_Client *client)
 {
   char fqdn[255];
-  
+
   if (  (NULL != my_domain) &&
        (NULL == strchr (hostname,
                         (unsigned char) '.')) &&
@@ -1072,7 +1072,7 @@ process_get (const char *hostname,
                     sizeof (fqdn),
                     "%s.%s",
                     hostname,
-                    my_domain);                     
+                    my_domain);
   }
   else if (strlen (hostname) < 255)
   {
@@ -1126,15 +1126,7 @@ check_get (void *cls,
   direction = ntohl (get->direction);
   if (GNUNET_NO == direction)
   {
-    /* IP from hostname */
-    const char *hostname;
-
-    hostname = (const char *) &get[1];
-    if (hostname[size - 1] != '\0')
-    {
-      GNUNET_break (0);
-      return GNUNET_SYSERR;
-    }
+    GNUNET_MQ_check_zero_termination (get);
     return GNUNET_OK;
   }
   af = ntohl (get->af);
@@ -1257,7 +1249,7 @@ shutdown_task (void *cls)
 
 
 /**
- * Add information about a host from /etc/hosts 
+ * Add information about a host from /etc/hosts
  * to our cache.
  *
  * @param hostname the name of the host
@@ -1278,7 +1270,7 @@ add_host (const char *hostname,
   rec = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_Record));
   rec->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS;
   rec->type = rec_type;
-  rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;  
+  rec->dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
   rec->name = GNUNET_strdup (hostname);
   rec->data.raw.data = GNUNET_memdup (data,
                                      data_size);
@@ -1298,7 +1290,7 @@ add_host (const char *hostname,
 
 /**
  * Extract host information from a line in /etc/hosts
- * 
+ *
  * @param line the line to parse
  * @param line_len number of bytes in @a line
  */
@@ -1389,12 +1381,12 @@ load_etc_hosts (void)
     return;
   }
   if ((size_t) bytes_read > SIZE_MAX)
-  { 
+  {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                "/etc/hosts file too large to mmap. "
                "DNS resolution will not be possible.\n");
     GNUNET_DISK_file_close (fh);
-    return;   
+    return;
   }
   buf = GNUNET_DISK_file_map (fh,
                              &mh,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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