gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29259 - in gnunet/src: hello include nse


From: gnunet
Subject: [GNUnet-SVN] r29259 - in gnunet/src: hello include nse
Date: Sun, 15 Sep 2013 16:27:01 +0200

Author: grothoff
Date: 2013-09-15 16:27:01 +0200 (Sun, 15 Sep 2013)
New Revision: 29259

Modified:
   gnunet/src/hello/hello.c
   gnunet/src/include/gnunet_nse_service.h
   gnunet/src/nse/gnunet-service-nse.c
   gnunet/src/nse/nse_api.c
Log:
-minor NSE cleanup

Modified: gnunet/src/hello/hello.c
===================================================================
--- gnunet/src/hello/hello.c    2013-09-15 10:07:03 UTC (rev 29258)
+++ gnunet/src/hello/hello.c    2013-09-15 14:27:01 UTC (rev 29259)
@@ -40,14 +40,14 @@
  * 1) transport-name (0-terminated)
  * 2) address-length (uint16_t, network byte order; possibly
  *    unaligned!)
- * 3) address expiration (GNUNET_TIME_AbsoluteNBO); possibly
+ * 3) address expiration (`struct GNUNET_TIME_AbsoluteNBO`); possibly
  *    unaligned!)
  * 4) address (address-length bytes; possibly unaligned!)
  */
 struct GNUNET_HELLO_Message
 {
   /**
-   * Type will be GNUNET_MESSAGE_TYPE_HELLO.
+   * Type will be #GNUNET_MESSAGE_TYPE_HELLO.
    */
   struct GNUNET_MessageHeader header;
 
@@ -93,7 +93,7 @@
   const char *pos;
 
   /**
-   * Set to GNUNET_SYSERR to indicate parse errors.
+   * Set to #GNUNET_SYSERR to indicate parse errors.
    */
   int ret;
 
@@ -107,7 +107,7 @@
 /** Return HELLO type
  *
  * @param h HELLO Message to test
- * @return GNUNET_YES or GNUNET_NO
+ * @return #GNUNET_YES or #GNUNET_NO
  */
 int
 GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h)
@@ -124,8 +124,8 @@
  * the given buffer using the format of HELLOs.
  *
  * @param address the address
- * @param expiration expiration for the address
- * @param target where to copy the address
+ * @param expiration expiration for the @a address
+ * @param target where to copy the @a address
  * @param max maximum number of bytes to copy to target
  * @return number of bytes copied, 0 if
  *         the target buffer was not big enough.
@@ -165,7 +165,9 @@
  * @return size of the entry, or 0 if max is not large enough
  */
 static size_t
-get_hello_address_size (const char *buf, size_t max, uint16_t * ralen)
+get_hello_address_size (const char *buf,
+                       size_t max, 
+                       uint16_t *ralen)
 {
   const char *pos;
   uint16_t alen;
@@ -260,7 +262,7 @@
  * @param return_modified if a modified copy should be returned,
  *         otherwise NULL will be returned
  * @param it iterator to call on each address
- * @param it_cls closure for it
+ * @param it_cls closure for @a it
  * @return modified HELLO message
  */
 struct GNUNET_HELLO_Message *

Modified: gnunet/src/include/gnunet_nse_service.h
===================================================================
--- gnunet/src/include/gnunet_nse_service.h     2013-09-15 10:07:03 UTC (rev 
29258)
+++ gnunet/src/include/gnunet_nse_service.h     2013-09-15 14:27:01 UTC (rev 
29259)
@@ -76,13 +76,14 @@
  */
 #define GNUNET_NSE_log_estimate_to_n(loge) pow(2.0, (loge))
 
+
 /**
  * Connect to the network size estimation service.
  *
  * @param cfg the configuration to use
  * @param func funtion to call with network size estimate
  * @param func_cls closure to pass to @a func
- * @return handle to use
+ * @return handle to use in #GNUNET_NSE_disconnect to stop NSE from invoking 
the callbacks
  */
 struct GNUNET_NSE_Handle *
 GNUNET_NSE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,

Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2013-09-15 10:07:03 UTC (rev 29258)
+++ gnunet/src/nse/gnunet-service-nse.c 2013-09-15 14:27:01 UTC (rev 29259)
@@ -53,8 +53,7 @@
 
 /**
  * Should messages be delayed randomly?  This option should be set to
- * GNUNET_NO only for experiments, not in production.  It should also
- * be removed once the initial experiments have been completed.
+ * #GNUNET_NO only for experiments, not in production.  
  */
 #define USE_RANDOM_DELAYS GNUNET_YES
 
@@ -231,7 +230,7 @@
 static double current_size_estimate;
 
 /**
- * The standard deviation of the last HISTORY_SIZE network
+ * The standard deviation of the last #HISTORY_SIZE network
  * size estimates.
  */
 static double current_std_dev = NAN;
@@ -412,12 +411,14 @@
  * @param message the message received
  */
 static void
-handle_start_message (void *cls, struct GNUNET_SERVER_Client *client,
+handle_start_message (void *cls, 
+                     struct GNUNET_SERVER_Client *client,
                       const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_NSE_ClientMessage em;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Received START message from client\n");
   GNUNET_SERVER_notification_context_add (nc, client);
   setup_estimate_message (&em);
   GNUNET_SERVER_notification_context_unicast (nc, client, &em.header,
@@ -479,7 +480,7 @@
  * Calculate the 'proof-of-work' hash (an expensive hash).
  *
  * @param buf data to hash
- * @param buf_len number of bytes in 'buf'
+ * @param buf_len number of bytes in @a buf
  * @param result where to write the resulting hash
  */
 static void
@@ -570,24 +571,27 @@
 /**
  * Task that triggers a NSE P2P transmission.
  *
- * @param cls the 'struct NSEPeerEntry'
+ * @param cls the `struct NSEPeerEntry *`
  * @param tc scheduler context
  */
 static void
-transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+transmit_task_cb (void *cls, 
+                 const struct GNUNET_SCHEDULER_TaskContext *tc);
 
 
 /**
  * Called when core is ready to send a message we asked for
  * out to the destination.
  *
- * @param cls closure (NULL)
- * @param size number of bytes available in buf
+ * @param cls closure with the `struct NSEPeerEntry *`
+ * @param size number of bytes available in @a buf
  * @param buf where the callee should write the message
- * @return number of bytes written to buf
+ * @return number of bytes written to @a buf
  */
 static size_t
-transmit_ready (void *cls, size_t size, void *buf)
+transmit_ready (void *cls, 
+               size_t size,
+               void *buf)
 {
   struct NSEPeerEntry *peer_entry = cls;
   unsigned int idx;
@@ -646,11 +650,12 @@
 /**
  * Task that triggers a NSE P2P transmission.
  *
- * @param cls the 'struct NSEPeerEntry'
+ * @param cls the `struct NSEPeerEntry *`
  * @param tc scheduler context
  */
 static void
-transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_task_cb (void *cls, 
+                 const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct NSEPeerEntry *peer_entry = cls;
 
@@ -679,7 +684,9 @@
   struct GNUNET_NSE_ClientMessage em;
 
   setup_estimate_message (&em);
-  GNUNET_SERVER_notification_context_broadcast (nc, &em.header, GNUNET_YES);
+  GNUNET_SERVER_notification_context_broadcast (nc, 
+                                               &em.header, 
+                                               GNUNET_YES);
 }
 
 
@@ -726,8 +733,8 @@
  *
  * @param cls unused
  * @param key hash of peer identity
- * @param value the 'struct NSEPeerEntry'
- * @return GNUNET_OK (continue to iterate)
+ * @param value the `struct NSEPeerEntry`
+ * @return #GNUNET_OK (continue to iterate)
  */
 static int
 schedule_current_round (void *cls, 
@@ -770,7 +777,8 @@
  * @param tc context for this message
  */
 static void
-update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+update_flood_message (void *cls, 
+                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TIME_Relative offset;
   unsigned int i;
@@ -820,11 +828,11 @@
 /**
  * Count the leading zeroes in hash.
  *
- * @param hash
+ * @param hash to count leading zeros in
  * @return the number of leading zero bits.
  */
 static unsigned int
-count_leading_zeroes (const struct GNUNET_HashCode * hash)
+count_leading_zeroes (const struct GNUNET_HashCode *hash)
 {
   unsigned int hash_count;
 
@@ -836,13 +844,12 @@
 
 
 /**
- * Check whether the given public key
- * and integer are a valid proof of work.
+ * Check whether the given public key and integer are a valid proof of
+ * work.
  *
  * @param pkey the public key
  * @param val the integer
- *
- * @return GNUNET_YES if valid, GNUNET_NO if not
+ * @return #GNUNET_YES if valid, #GNUNET_NO if not
  */
 static int
 check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey,
@@ -889,7 +896,8 @@
  * @param tc task context
  */
 static void
-find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+find_proof (void *cls,
+           const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
 #define ROUND_SIZE 10
   uint64_t counter;
@@ -944,9 +952,8 @@
  * period.  Verify the signature and/or proof of work.
  *
  * @param incoming_flood the message to verify
- *
- * @return GNUNET_YES if the message is verified
- *         GNUNET_NO if the key/signature don't verify
+ * @return #GNUNET_YES if the message is verified
+ *         #GNUNET_NO if the key/signature don't verify
  */
 static int
 verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood)
@@ -981,11 +988,13 @@
  *
  * @param cls peer entry to exclude from updates
  * @param key hash of peer identity
- * @param value the 'struct NSEPeerEntry'
- * @return GNUNET_OK (continue to iterate)
+ * @param value the `struct NSEPeerEntry *` of a peer to transmit to
+ * @return #GNUNET_OK (continue to iterate)
  */
 static int
-update_flood_times (void *cls, const struct GNUNET_HashCode * key, void *value)
+update_flood_times (void *cls, 
+                   const struct GNUNET_HashCode *key, 
+                   void *value)
 {
   struct NSEPeerEntry *exclude = cls;
   struct NSEPeerEntry *peer_entry = value;
@@ -1026,7 +1035,8 @@
  * @param peer peer identity this message is from (ignored)
  */
 static int
-handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
+handle_p2p_size_estimate (void *cls, 
+                         const struct GNUNET_PeerIdentity *peer,
                           const struct GNUNET_MessageHeader *message)
 {
   const struct GNUNET_NSE_FloodMessage *incoming_flood;
@@ -1210,13 +1220,14 @@
  * @param peer peer identity this notification is about
  */
 static void
-handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+handle_core_connect (void *cls,
+                    const struct GNUNET_PeerIdentity *peer)
 {
   struct NSEPeerEntry *peer_entry;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n",
               GNUNET_i2s (peer));
-  peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry));
+  peer_entry = GNUNET_new (struct NSEPeerEntry);
   peer_entry->id = *peer;
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey,
@@ -1237,11 +1248,13 @@
  * @param peer peer identity this notification is about
  */
 static void
-handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+handle_core_disconnect (void *cls, 
+                       const struct GNUNET_PeerIdentity *peer)
 {
   struct NSEPeerEntry *pos;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Peer `%s' disconnected from us\n",
               GNUNET_i2s (peer));
   pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
   if (NULL == pos)
@@ -1272,10 +1285,11 @@
  * message to the logger service
  *
  * @param cls NULL
- * @param size the amount of data sent
+ * @param size the amount of data sent (ignored)
  */
 static void 
-flush_comp_cb (void *cls, size_t size)
+flush_comp_cb (void *cls, 
+              size_t size)
 {
   GNUNET_TESTBED_LOGGER_disconnect (lh);
   lh = NULL;
@@ -1290,7 +1304,8 @@
  * @param tc unused
  */
 static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (GNUNET_SCHEDULER_NO_TASK != flood_task)
   {
@@ -1515,7 +1530,8 @@
  * @return 0 ok, 1 on error
  */
 int
-main (int argc, char *const *argv)
+main (int argc, 
+      char *const *argv)
 {
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc, argv, "nse", GNUNET_SERVICE_OPTION_NONE,
@@ -1529,7 +1545,8 @@
 /**
  * MINIMIZE heap size (way below 128k) since this process doesn't need much.
  */
-void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+void __attribute__ ((constructor)) 
+GNUNET_ARM_memory_init ()
 {
   mallopt (M_TRIM_THRESHOLD, 4 * 1024);
   mallopt (M_TOP_PAD, 1 * 1024);

Modified: gnunet/src/nse/nse_api.c
===================================================================
--- gnunet/src/nse/nse_api.c    2013-09-15 10:07:03 UTC (rev 29258)
+++ gnunet/src/nse/nse_api.c    2013-09-15 14:27:01 UTC (rev 29259)
@@ -35,7 +35,7 @@
 #define LOG(kind,...) GNUNET_log_from (kind, "nse-api",__VA_ARGS__)
 
 /**
- * Handle for the service.
+ * Handle for talking with the NSE service.
  */
 struct GNUNET_NSE_Handle
 {
@@ -70,7 +70,7 @@
   GNUNET_NSE_Callback recv_cb;
 
   /**
-   * Closure to pass to callback.
+   * Closure to pass to @e recv_cb callback.
    */
   void *recv_cb_cls;
 
@@ -100,13 +100,14 @@
   struct GNUNET_NSE_Handle *h = cls;
   const struct GNUNET_NSE_ClientMessage *client_msg;
 
-  if (msg == NULL)
+  if (NULL == msg)
   {
     /* Error, timeout, death */
     GNUNET_CLIENT_disconnect (h->client);
     h->client = NULL;
     h->reconnect_task =
-        GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h);
+        GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, 
+                                     &reconnect, h);
     return;
   }
   if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) ||
@@ -124,7 +125,6 @@
 }
 
 
-
 /**
  * Reschedule a connect attempt to the service.
  *
@@ -159,10 +159,10 @@
 /**
  * Transmit START message to service.
  *
- * @param cls unused
- * @param size number of bytes available in buf
+ * @param cls the `struct GNUNET_NSE_Handle *`
+ * @param size number of bytes available in @a buf
  * @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
  */
 static size_t
 send_start (void *cls, size_t size, void *buf)
@@ -175,11 +175,14 @@
   {
     /* Connect error... */
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Error while trying to transmit `%s' request.\n", "START");
+         "Error while trying to transmit `%s' request.\n", 
+        "START");
     reschedule_connect (h);
     return 0;
   }
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "START");
+  LOG (GNUNET_ERROR_TYPE_DEBUG, 
+       "Transmitting `%s' request.\n", 
+       "START");
   GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
 
   msg = (struct GNUNET_MessageHeader *) buf;
@@ -194,11 +197,12 @@
 /**
  * Try again to connect to network size estimation service.
  *
- * @param cls the handle to the transport service
+ * @param cls the `struct GNUNET_NSE_Handle *`
  * @param tc scheduler context
  */
 static void
-reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect (void *cls, 
+          const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_NSE_Handle *h = cls;
 
@@ -223,8 +227,7 @@
  *
  * @param cfg the configuration to use
  * @param func funtion to call with network size estimate
- * @param func_cls closure to pass for network size estimate callback
- *
+ * @param func_cls closure to pass to @a func
  * @return handle to use
  */
 struct GNUNET_NSE_Handle *
@@ -234,7 +237,7 @@
   struct GNUNET_NSE_Handle *ret;
 
   GNUNET_assert (func != NULL);
-  ret = GNUNET_malloc (sizeof (struct GNUNET_NSE_Handle));
+  ret = GNUNET_new (struct GNUNET_NSE_Handle);
   ret->cfg = cfg;
   ret->recv_cb = func;
   ret->recv_cb_cls = func_cls;




reply via email to

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