more client code
authorChristian Grothoff <christian@grothoff.org>
Fri, 5 Aug 2011 08:26:53 +0000 (08:26 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 5 Aug 2011 08:26:53 +0000 (08:26 +0000)
src/transport/gnunet-service-transport_clients.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_neighbours.h

index 97939bbf7a290c068d788a5481448463a809fbcd..5fbd60df8581eb58fcd6dda1092e5654cdd33914 100644 (file)
@@ -452,6 +452,23 @@ GST_clients_handle_set_quota (void *cls,
                              struct GNUNET_SERVER_Client *client,
                              const struct GNUNET_MessageHeader *message)
 {
+  const struct QuotaSetMessage *qsm;
+
+  qsm = (const struct QuotaSetMessage *) message;
+  GNUNET_STATISTICS_update (stats,
+                           gettext_noop ("# SET QUOTA messages received"),
+                           1,
+                           GNUNET_NO);
+#if DEBUG_TRANSPORT 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received `%s' request (new quota %u) from client for peer `%4s'\n",
+              "SET_QUOTA",
+             (unsigned int) ntohl (qsm->quota.value__),
+             GNUNET_i2s (&qsm->peer));
+#endif
+  GST_neighbours_set_incoming_quota (&qsm->peer,
+                                    qsm->quota);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 
index 4107c00125c13685cd147fb7322be67472d3203a..89a622d957c0f07ac66b5fdcf470b5229d8d2945 100644 (file)
@@ -83,6 +83,64 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
 }
 
 
+/**
+ * Transmit a message to the given target using the active connection.
+ *
+ * @param target destination
+ * @param msg message to send
+ * @param cont function to call when done
+ * @param cont_cls closure for 'cont'
+ */
+void
+GST_neighbours_send (const struct GNUNET_PeerIdentity *target,
+                    const struct GNUNET_MessageHeader *msg,
+                    GST_NeighbourSendContinuation cont,
+                    void *cont_cls)
+{
+}
+
+
+/**
+ * Change the incoming quota for the given peer.
+ *
+ * @param neighbour identity of peer to change qutoa for
+ * @param quota new quota 
+ */
+void
+GST_neighbours_set_quota (const struct GNUNET_PeerIdentity *neighbour,
+                         struct GNUNET_BANDWIDTH_Value32NBO quota)
+{
+#if 0
+
+  n = find_neighbour (neighbour);
+  if (n == NULL)
+    {
+      GNUNET_STATISTICS_update (stats,
+                               gettext_noop ("# SET QUOTA messages ignored (no such peer)"),
+                               1,
+                               GNUNET_NO);
+      return;
+    }
+  GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker,
+                                        quota);
+  if (0 != ntohl (qsm->quota.value__))
+    return;
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Disconnecting peer `%4s' due to `%s'\n",
+             GNUNET_i2s(&n->id),
+             "SET_QUOTA");
+#endif
+  GNUNET_STATISTICS_update (stats,
+                           gettext_noop ("# disconnects due to quota of 0"),
+                           1,
+                           GNUNET_NO);
+  GST_neighbours_force_disconnect (neighbour);
+
+#endif
+}
+
+
 /**
  * If we have an active connection to the given target, it must be shutdown.
  *
index 27e7d20a9113bdcb5997c35e2e25031c682a867d..26b3a11b8fd9fb22b53cdb2b50d87e8ab0dc03dc 100644 (file)
@@ -99,15 +99,14 @@ GST_neighbours_send (const struct GNUNET_PeerIdentity *target,
                     void *cont_cls);
 
 /**
- * Change the quota for the given peer.
- * FIXME: inbound or outbound quota?
+ * Change the incoming quota for the given peer.
  *
  * @param neighbour identity of peer to change qutoa for
- * @param quota new quota FIXME: fix type!
+ * @param quota new quota 
  */
 void
-GST_neighbours_set_quota (const struct GNUNET_PeerIdentity *neighbour,
-                         const float quota);
+GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
+                                  struct GNUNET_BANDWIDTH_Value32NBO quota);
 
 
 /**