gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35335 - in gnunet/src: include transport


From: gnunet
Subject: [GNUnet-SVN] r35335 - in gnunet/src: include transport
Date: Mon, 2 Mar 2015 01:05:42 +0100

Author: grothoff
Date: 2015-03-02 01:05:42 +0100 (Mon, 02 Mar 2015)
New Revision: 35335

Modified:
   gnunet/src/include/gnunet_protocols.h
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
Log:
define quota message to transmit quota requests, towards addressing #3652

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2015-03-01 23:53:16 UTC (rev 
35334)
+++ gnunet/src/include/gnunet_protocols.h       2015-03-02 00:05:42 UTC (rev 
35335)
@@ -1286,6 +1286,13 @@
 #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT 378
 
 /**
+ * Message exchanged between transport services to
+ * indicate that the sender should limit its transmission
+ * rate to the indicated quota.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA 379
+
+/**
  * Request to monitor addresses used by a peer or all peers.
  */
 #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST 380

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2015-03-01 23:53:16 UTC 
(rev 35334)
+++ gnunet/src/transport/gnunet-service-transport.c     2015-03-02 00:05:42 UTC 
(rev 35335)
@@ -462,6 +462,10 @@
     GST_neighbours_handle_disconnect_message (&address->peer,
                                               message);
     break;
+  case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA:
+    GST_neighbours_handle_quota_message (&address->peer,
+                                         message);
+    break;
   case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE:
     GST_neighbours_keepalive (&address->peer,
                               message);

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-03-01 
23:53:16 UTC (rev 35334)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-03-02 
00:05:42 UTC (rev 35335)
@@ -157,7 +157,27 @@
   uint32_t nonce GNUNET_PACKED;
 };
 
+
 /**
+ * Message a peer sends to another when connected to indicate that
+ * the other peer should limit transmissions to the indicated
+ * quota.
+ */
+struct SessionQuotaMessage
+{
+  /**
+   * Header of type #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Quota to use (for sending), in bytes per second.
+   */
+  uint32_t quota GNUNET_PACKED;
+};
+
+
+/**
  * Message we send to the other peer to notify him that we intentionally
  * are disconnecting (to reduce timeouts).  This is just a friendly
  * notification, peers must not rely on always receiving disconnect
@@ -336,7 +356,7 @@
 
   /**
    * Main task that drives this peer (timeouts, keepalives, etc.).
-   * Always runs the 'master_task'.
+   * Always runs the #master_task().
    */
   struct GNUNET_SCHEDULER_Task *task;
 
@@ -388,6 +408,14 @@
   unsigned int quota_violation_count;
 
   /**
+   * Latest quota the other peer send us in bytes per second.
+   * We should not send more, least the other peer throttle
+   * receiving our traffic.
+   * FIXME: Not used (#3652).
+   */
+  unsigned int neighbour_receive_quota;
+
+  /**
    * The current state of the peer.
    */
   enum GNUNET_TRANSPORT_PeerState state;
@@ -2296,7 +2324,7 @@
  * We received a 'SYN' message from the other peer.
  * Consider switching to it.
  *
- * @param message possibly a 'struct TransportSynMessage' (check format)
+ * @param message possibly a `struct TransportSynMessage` (check format)
  * @param peer identity of the peer to switch the address for
  * @return #GNUNET_OK if the message was fine, #GNUNET_SYSERR on serious error
  */
@@ -3589,6 +3617,47 @@
 
 
 /**
+ * We received a quoat message from the given peer,
+ * validate and process.
+ *
+ * @param peer sender of the message
+ * @param msg the quota message
+ */
+void
+GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer,
+                                     const struct GNUNET_MessageHeader *msg)
+{
+  struct NeighbourMapEntry *n;
+  const struct SessionQuotaMessage *sqm;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received QUOTA message from peer `%s'\n",
+              GNUNET_i2s (peer));
+  if (ntohs (msg->size) != sizeof (struct SessionQuotaMessage))
+  {
+    GNUNET_break_op (0);
+    GNUNET_STATISTICS_update (GST_stats,
+                              gettext_noop ("# quota messages ignored 
(malformed)"),
+                              1,
+                              GNUNET_NO);
+    return;
+  }
+  GNUNET_STATISTICS_update (GST_stats,
+                            gettext_noop
+                            ("# QUOTA messages received"),
+                            1, GNUNET_NO);
+  sqm = (const struct SessionQuotaMessage *) msg;
+  if (NULL == (n = lookup_neighbour (peer)))
+  {
+    /* gone already */
+    return;
+  }
+  n->neighbour_receive_quota = ntohl (sqm->quota);
+  /* FIXME: tell someone? (#3652) */
+}
+
+
+/**
  * We received a disconnect message from the given peer,
  * validate and process.
  *
@@ -3602,7 +3671,7 @@
   struct NeighbourMapEntry *n;
   const struct SessionDisconnectMessage *sdm;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received DISCONNECT message from peer `%s'\n",
               GNUNET_i2s (peer));
   if (ntohs (msg->size) != sizeof (struct SessionDisconnectMessage))
@@ -3610,7 +3679,8 @@
     GNUNET_break_op (0);
     GNUNET_STATISTICS_update (GST_stats,
                               gettext_noop
-                              ("# disconnect messages ignored (malformed)"), 1,
+                              ("# disconnect messages ignored (malformed)"),
+                              1,
                               GNUNET_NO);
     return;
   }

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2015-03-01 
23:53:16 UTC (rev 35334)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2015-03-02 
00:05:42 UTC (rev 35335)
@@ -307,6 +307,18 @@
 
 
 /**
+ * We received a quoat message from the given peer,
+ * validate and process.
+ *
+ * @param peer sender of the message
+ * @param msg the quota message
+ */
+void
+GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer,
+                                     const struct GNUNET_MessageHeader *msg);
+
+
+/**
  * We received a disconnect message from the given peer,
  * validate and process.
  *




reply via email to

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