gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11045 - gnunet/src/dv


From: gnunet
Subject: [GNUnet-SVN] r11045 - gnunet/src/dv
Date: Thu, 22 Apr 2010 17:04:42 +0200

Author: nevans
Date: 2010-04-22 17:04:42 +0200 (Thu, 22 Apr 2010)
New Revision: 11045

Modified:
   gnunet/src/dv/dv.h
   gnunet/src/dv/dv_api.c
   gnunet/src/dv/gnunet-service-dv.c
Log:
only committing in case of natural disater, not to be used

Modified: gnunet/src/dv/dv.h
===================================================================
--- gnunet/src/dv/dv.h  2010-04-22 15:03:08 UTC (rev 11044)
+++ gnunet/src/dv/dv.h  2010-04-22 15:04:42 UTC (rev 11045)
@@ -29,6 +29,7 @@
 #include "gnunet_common.h"
 
 #define DEBUG_DV_GOSSIP GNUNET_NO
+#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_YES
 #define DEBUG_DV GNUNET_YES
 #define DEBUG_DV_API GNUNET_YES
 
@@ -62,17 +63,17 @@
   /**
    * The message that was sent
    */
-  size_t msg_len;
+  uint32_t msg_len;
 
   /**
    * The distance to the peer that we received the message from
    */
-  size_t distance;
+  uint32_t distance;
 
   /**
    * Length of the sender address, appended to end of this message
    */
-  size_t sender_address_len;
+  uint32_t sender_address_len;
 
 };
 
@@ -102,12 +103,12 @@
   /**
    * The distance to the peer that we received the message from
    */
-  size_t distance;
+  uint32_t distance;
 
   /**
    * Length of the sender address, appended to end of this message
    */
-  size_t sender_address_len;
+  uint32_t sender_address_len;
 
 };
 
@@ -128,19 +129,14 @@
   struct GNUNET_PeerIdentity target;
 
   /**
-   * The message(s) to be sent.
-   */
-  char *msgbuf;
-
-  /**
    * The size of the msgbuf
    */
-  size_t msgbuf_size;
+  uint32_t msgbuf_size;
 
   /**
    * Message priority
    */
-  size_t priority;
+  uint32_t priority;
 
   /**
    * How long can we delay sending?
@@ -150,8 +146,13 @@
   /**
    * Size of the address (appended to end of struct)
    */
-  size_t addrlen;
+  uint32_t addrlen;
 
+  /**
+   * The message(s) to be sent.
+   */
+  char *msgbuf;
+
   /*
    * Sender, appended to end of struct tells via whom
    * to send this message.
@@ -185,7 +186,7 @@
   /**
    * Neighbor ID to use when sending to this peer
    */
-  unsigned int neighbor_id GNUNET_PACKED;
+  uint32_t neighbor_id GNUNET_PACKED;
 
 } p2p_dv_MESSAGE_NeighborInfo;
 

Modified: gnunet/src/dv/dv_api.c
===================================================================
--- gnunet/src/dv/dv_api.c      2010-04-22 15:03:08 UTC (rev 11044)
+++ gnunet/src/dv/dv_api.c      2010-04-22 15:04:42 UTC (rev 11045)
@@ -235,7 +235,7 @@
 
   if (NULL ==
       (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client,
-                                                    
ntohs(handle->current->msg->msgbuf_size),
+                                                    
ntohl(handle->current->msg->msgbuf_size),
                                                     
handle->current->msg->timeout,
                                                     GNUNET_YES,
                                                     &transmit_pending, 
handle)))
@@ -306,8 +306,8 @@
     return;
 
   received_msg = (struct GNUNET_DV_MessageReceived *)msg;
-  packed_msg_len = ntohs(received_msg->msg_len);
-  sender_address_len = ntohs(received_msg->sender_address_len);
+  packed_msg_len = ntohl(received_msg->msg_len);
+  sender_address_len = ntohl(received_msg->sender_address_len);
 
   GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) 
+ packed_msg_len + sender_address_len));
 #if DEBUG_DV
@@ -371,10 +371,10 @@
   msg->header.size = htons(sizeof(struct GNUNET_DV_SendMessage) + addrlen + 
msgbuf_size);
   msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
   memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
-  msg->msgbuf_size = htons(msgbuf_size);
+  msg->msgbuf_size = htonl(msgbuf_size);
   msg->priority = htonl(priority);
   msg->timeout = timeout;
-  msg->addrlen = htons(addrlen);
+  msg->addrlen = htonl(addrlen);
   memcpy(&msg[1], addr, addrlen);
   end_of_message = (char *)&msg[1];
   end_of_message = &end_of_message[addrlen];

Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c   2010-04-22 15:03:08 UTC (rev 11044)
+++ gnunet/src/dv/gnunet-service-dv.c   2010-04-22 15:04:42 UTC (rev 11045)
@@ -79,12 +79,12 @@
  * How often do we check about sending out more peer information (if
  * we are connected to no peers previously).
  */
-#define GNUNET_DV_DEFAULT_SEND_INTERVAL 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500))
+#define GNUNET_DV_DEFAULT_SEND_INTERVAL 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500)
 
 /**
  * How long do we wait at most between sending out information?
  */
-#define GNUNET_DV_MAX_SEND_INTERVAL 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5))
+#define GNUNET_DV_MAX_SEND_INTERVAL 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500)
 
 /**
  * How long can we have not heard from a peer and
@@ -594,9 +594,9 @@
   received_msg = GNUNET_malloc(size);
   received_msg->header.size = htons(size);
   received_msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECEIVE);
-  received_msg->sender_address_len = htons(sender_address_len);
+  received_msg->sender_address_len = htonl(sender_address_len);
   received_msg->distance = htonl(cost);
-  received_msg->msg_len = htons(message_size);
+  received_msg->msg_len = htonl(message_size);
   /* Set the sender in this message to be the original sender! */
   memcpy(&received_msg->sender, distant_neighbor, sizeof(struct 
GNUNET_PeerIdentity));
   /* Copy the intermediate sender to the end of the message, this is how the 
transport identifies this peer */
@@ -608,7 +608,7 @@
   memcpy(packed_msg_start, message, message_size);
 #if DEBUG_DV
   packed_message_header = (struct GNUNET_MessageHeader *)packed_msg_start;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dv service created received message. 
sender_address_len %lu, packed message len %d, total len %d\n", 
sender_address_len, ntohs(received_msg->msg_len), 
ntohs(received_msg->header.size));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dv service created received message. 
sender_address_len %lu, packed message len %d, total len %d\n", 
sender_address_len, ntohl(received_msg->msg_len), 
ntohs(received_msg->header.size));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dv packed message len %d, type %d\n", 
ntohs(packed_message_header->size), ntohs(packed_message_header->type));
   if (ntohs(packed_message_header->type) == GNUNET_MESSAGE_TYPE_HELLO)
   {
@@ -663,7 +663,7 @@
     {
       /* client disconnected */
 #if DEBUG_DV
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s': buffer was NULL\n", "DHT");
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "`%s': buffer was NULL\n", "DHT");
 #endif
       return 0;
     }
@@ -674,7 +674,7 @@
           (size >= off + (msize = ntohs (reply->msg->size))))
     {
 #if DEBUG_DV
-    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s' : transmit_notify (core) called 
with size %d\n", "dv service", msize);
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`%s' : transmit_notify (core) 
called with size %d\n", "dv service", msize);
 #endif
       GNUNET_CONTAINER_DLL_remove (core_pending_head,
                                    core_pending_tail,
@@ -751,7 +751,7 @@
 #if DEBUG_DV
   memcpy(&shortname, GNUNET_i2s(&specific_neighbor->identity), 4);
   shortname[4] = '\0';
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to 
destination `%s' via `%s' size %u\n", "DV", &shortname, 
GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size);
+  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Notifying core of send to 
destination `%s' via `%s' size %u\n", "DV", &shortname, 
GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size);
 #endif
 
   GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
@@ -840,7 +840,7 @@
                                      core_pending_tail,
                                      pending_message);
 #if DEBUG_DV
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to 
destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient));
+  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Notifying core of send size %d to 
destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient));
 #endif
   if (core_transmit_handle == NULL)
     core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, 
importance, timeout, &target->referrer->identity, msg_size, 
&core_transmit_notify, NULL);
@@ -913,7 +913,7 @@
   if (pos == NULL)
     {
 #if DEBUG_DV
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "%s: unknown sender (%d), size of extended_peers is %d!\n", 
"dv", ntohl(incoming->sender), GNUNET_CONTAINER_multihashmap_size 
(ctx.extended_neighbors));
 #endif
       /* unknown sender */
@@ -931,7 +931,7 @@
         {
           packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
 #if DEBUG_DV
-          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                       "%s: Receives %s message for me, size %d type %d!\n", 
"dv", "DV DATA", ntohs(packed_message->size), ntohs(packed_message->type));
 #endif
           GNUNET_break_op (ntohs (packed_message->type) != 
GNUNET_MESSAGE_TYPE_DV_GOSSIP);
@@ -1003,9 +1003,8 @@
 
 
 /**
- * Thread which chooses a peer to gossip about and a peer to gossip
- * to, then constructs the message and sends it out.  Will run until
- * done_module_dv is called.
+ *  Scheduled task which gossips about known direct peers to other connected
+ *  peers.  Will run until called with reason shutdown.
  */
 static void
 neighbor_send_task (void *cls,
@@ -1088,11 +1087,11 @@
                                          pending_message);
 
       if (core_transmit_handle == NULL)
-        core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, 
default_dv_priority, default_dv_delay, &to->identity, 
sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);
+        core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, 
default_dv_priority, send_context->timeout, &to->identity, 
sizeof(p2p_dv_MESSAGE_NeighborInfo), &core_transmit_notify, NULL);
 
     }
 
-  send_context->task = GNUNET_SCHEDULER_add_delayed(sched, 
send_context->timeout, &neighbor_send_task, send_context);
+  send_context->task = GNUNET_SCHEDULER_add_delayed(sched, 
GNUNET_DV_DEFAULT_SEND_INTERVAL, &neighbor_send_task, send_context);
   return;
 }
 
@@ -1189,9 +1188,9 @@
   GNUNET_assert(ntohs(message->size) > sizeof(struct GNUNET_DV_SendMessage));
   send_msg = (struct GNUNET_DV_SendMessage *)message;
 
-  address_len = ntohs(send_msg->addrlen);
+  address_len = ntohl(send_msg->addrlen);
   GNUNET_assert(address_len == sizeof(struct GNUNET_PeerIdentity) * 2);
-  message_size = ntohs(send_msg->msgbuf_size);
+  message_size = ntohl(send_msg->msgbuf_size);
 
 #if DEBUG_DV
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1227,7 +1226,7 @@
 #endif
   send_context = GNUNET_malloc(sizeof(struct DV_SendContext));
 
-  send_context->importance = ntohs(send_msg->priority);
+  send_context->importance = ntohl(send_msg->priority);
   send_context->timeout = send_msg->timeout;
   send_context->direct_peer = direct;
   send_context->distant_peer = destination;
@@ -1624,14 +1623,14 @@
       return GNUNET_SYSERR;     /* invalid message */
     }
 
-#if DEBUG_DV_GOSSIP
+#if DEBUG_DV_GOSSIP_RECEIPT
   char * encPeerAbout;
   char * encPeerFrom;
 
   encPeerAbout = GNUNET_strdup(GNUNET_i2s(&enc_message->neighbor));
   encPeerFrom = GNUNET_strdup(GNUNET_i2s(peer));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "%s: Receives %s message from peer %s about peer %s!\n", "dv", 
"DV GOSSIP", encPeerFrom, encPeerAbout);
+              "%s: Receives %s message from peer %s about peer %s distance 
%d!\n", "dv", "DV GOSSIP", encPeerFrom, encPeerAbout, ntohl (enc_message->cost) 
+ 1);
   GNUNET_free(encPeerAbout);
   GNUNET_free(encPeerFrom);
 #endif
@@ -1650,10 +1649,6 @@
   memcpy(&hello_context->distant_peer, &enc_message->neighbor, sizeof(struct 
GNUNET_PeerIdentity));
   hello_context->addresses_to_add = 1;
   hello_msg = GNUNET_HELLO_create(&enc_message->pkey, &generate_hello_address, 
hello_context);
-#if DEBUG_DV_GOSSIP
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "%s: Sending %s message to plugin, type is %d, size %d!\n", 
"dv", "HELLO", ntohs(hello_hdr->type), ntohs(hello_hdr->size));
-#endif
 
   send_to_plugin(hello_context->direct_peer, 
GNUNET_HELLO_get_header(hello_msg), GNUNET_HELLO_size(hello_msg), 
&hello_context->distant_peer, ntohl(enc_message->cost) + 1);
   GNUNET_free(hello_context);
@@ -1738,8 +1733,8 @@
   else
   {
 #if DEBUG_DV
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "%s: Distance (%d) greater than 0 or already know about peer 
(%s), not re-adding!\n", "dv", distance, GNUNET_i2s(peer));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "%s: Distance (%d) greater than 0 or already know about peer 
(%s), not re-adding!\n", "dv", distance, GNUNET_i2s(peer));
 #endif
     return;
   }
@@ -1812,9 +1807,11 @@
   ctx.direct_neighbors = GNUNET_CONTAINER_multihashmap_create (max_hosts);
   ctx.extended_neighbors =
     GNUNET_CONTAINER_multihashmap_create (ctx.max_table_size * 3);
+  client_transmit_timeout = GNUNET_TIME_relative_get_forever(); /* Only 
timeout on disconnect */
+  default_dv_delay = GNUNET_TIME_relative_get_forever(); /* Only timeout on 
disconnect */
 
-  client_transmit_timeout = 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5);
-  default_dv_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 
5);
+  //client_transmit_timeout = 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5);
+  //default_dv_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 
5);
   GNUNET_SERVER_add_handlers (server, plugin_handlers);
   coreAPI =
   GNUNET_CORE_connect (sched,





reply via email to

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