+/**
+ * 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;
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_min;
+
+ 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
+ = GNUNET_BANDWIDTH_value_max (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+ GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota)));
+
+ bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out,
+ n->neighbour_receive_quota);
+ send_outbound_quota_to_clients (peer,
+ bandwidth_min);
+}
+
+