+/**
+ * Handle 'reservation request' messages from clients.
+ *
+ * @param client client that sent the request
+ * @param msg the request message
+ */
+void
+GAS_handle_reservation_request (struct GNUNET_SERVICE_Client *client,
+ const struct ReservationRequestMessage *msg)
+{
+ struct GNUNET_MQ_Envelope *env;
+ struct ReservationResultMessage *result;
+ int32_t amount;
+ struct GNUNET_TIME_Relative res_delay;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received RESERVATION_REQUEST message\n");
+ amount = (int32_t) ntohl (msg->amount);
+ res_delay = reservations_reserve (&msg->peer, amount);
+ if (res_delay.rel_value_us > 0)
+ amount = 0;
+ env = GNUNET_MQ_msg (result,
+ GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT);
+ result->amount = htonl (amount);
+ result->peer = msg->peer;
+ result->res_delay = GNUNET_TIME_relative_hton (res_delay);
+ GNUNET_STATISTICS_update (GSA_stats,
+ "# reservation requests processed",
+ 1,
+ GNUNET_NO);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
+ env);
+}
+