[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17478 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17478 - gnunet/src/ats |
Date: |
Fri, 14 Oct 2011 10:46:34 +0200 |
Author: grothoff
Date: 2011-10-14 10:46:34 +0200 (Fri, 14 Oct 2011)
New Revision: 17478
Added:
gnunet/src/ats/gnunet-service-ats_reservations.c
gnunet/src/ats/gnunet-service-ats_reservations.h
Modified:
gnunet/src/ats/Makefile.am
gnunet/src/ats/gnunet-service-ats.c
gnunet/src/ats/gnunet-service-ats_performance.c
gnunet/src/ats/gnunet-service-ats_performance.h
Log:
parsing reservations
Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am 2011-10-14 08:13:38 UTC (rev 17477)
+++ gnunet/src/ats/Makefile.am 2011-10-14 08:46:34 UTC (rev 17478)
@@ -25,7 +25,8 @@
gnunet-service-ats.c \
gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
- gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h
+ gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \
+ gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h
gnunet_service_ats_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2011-10-14 08:13:38 UTC (rev 17477)
+++ gnunet/src/ats/gnunet-service-ats.c 2011-10-14 08:46:34 UTC (rev 17478)
@@ -45,19 +45,22 @@
const struct GNUNET_MessageHeader *message)
{
const struct ClientStartMessage * msg = (const struct ClientStartMessage *)
message;
+ enum StartFlag flag;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' message\n",
"ATS_START");
- switch (ntohl (msg->start_flag))
+ flag = ntohl (msg->start_flag);
+ switch (flag)
{
case START_FLAG_SCHEDULING:
GAS_scheduling_add_client (client);
break;
case START_FLAG_PERFORMANCE_WITH_PIC:
- GAS_performance_add_client (client);
+ GAS_performance_add_client (client, flag);
break;
case START_FLAG_PERFORMANCE_NO_PIC:
+ GAS_performance_add_client (client, flag);
break;
default:
GNUNET_break (0);
Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c 2011-10-14 08:13:38 UTC
(rev 17477)
+++ gnunet/src/ats/gnunet-service-ats_performance.c 2011-10-14 08:46:34 UTC
(rev 17478)
@@ -26,14 +26,12 @@
*/
#include "platform.h"
#include "gnunet-service-ats_performance.h"
+#include "gnunet-service-ats_reservations.h"
#include "ats.h"
/**
- * We keep clients that are interested in performance notifications in a
linked list.
- * Note that not ALL clients that are handeled by this module also register for
- * notifications. Only those clients that are in this list are managed by the
- * notification context.
+ * We keep clients that are interested in performance in a linked list.
*/
struct PerformanceClient
{
@@ -52,6 +50,11 @@
*/
struct GNUNET_SERVER_Client *client;
+ /**
+ * Options for the client.
+ */
+ enum StartFlag flag;
+
};
@@ -95,13 +98,15 @@
* @param client handle of the new client
*/
void
-GAS_performance_add_client (struct GNUNET_SERVER_Client *client)
+GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
+ enum StartFlag flag)
{
struct PerformanceClient * pc;
GNUNET_break (NULL == find_client (client));
pc = GNUNET_malloc (sizeof (struct PerformanceClient));
pc->client = client;
+ pc->flag = flag;
GNUNET_SERVER_notification_context_add (nc, client);
GNUNET_SERVER_client_keep (client);
GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc);
@@ -128,20 +133,59 @@
}
+/**
+ * Handle 'reservation request' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
void
GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- // const struct ReservationRequestMessage * msg = (const struct
ReservationRequestMessage *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
"RESERVATION_REQUEST");
+ const struct ReservationRequestMessage * msg = (const struct
ReservationRequestMessage *) message;
+ struct ReservationResultMessage result;
+ int32_t amount;
+ struct GNUNET_TIME_Relative res_delay;
+ if (NULL == find_client (client))
+ {
+ /* missing start message! */
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message\n",
+ "RESERVATION_REQUEST");
+ amount = (int32_t) ntohl (msg->amount);
+ res_delay = GAS_reservations_reserve (&msg->peer,
+ amount);
+ if (res_delay.rel_value > 0)
+ amount = 0;
+ result.header.size = htons (sizeof (struct ReservationResultMessage));
+ result.header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT);
+ result.amount = htonl (amount);
+ result.res_delay = GNUNET_TIME_relative_hton (res_delay);
+ GNUNET_SERVER_notification_context_unicast (nc,
+ client,
+ &result.header,
+ GNUNET_NO);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
+/**
+ * Handle 'preference change' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
void
GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
-
{
// const struct ChangePreferenceMessage * msg = (const struct
ChangePreferenceMessage *) message;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
"PREFERENCE_CHANGE");
Modified: gnunet/src/ats/gnunet-service-ats_performance.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.h 2011-10-14 08:13:38 UTC
(rev 17477)
+++ gnunet/src/ats/gnunet-service-ats_performance.h 2011-10-14 08:46:34 UTC
(rev 17478)
@@ -28,14 +28,17 @@
#define GNUNET_SERVICE_ATS_PERFORMANCE_H
#include "gnunet_util_lib.h"
+#include "ats.h"
/**
* Register a new performance client.
*
* @param client handle of the new client
+ * @param flag options for the client
*/
void
-GAS_performance_add_client (struct GNUNET_SERVER_Client *client);
+GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
+ enum StartFlag flag);
/**
@@ -48,11 +51,25 @@
GAS_performance_remove_client (struct GNUNET_SERVER_Client *client);
+/**
+ * Handle 'reservation request' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
void
GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message);
+/**
+ * Handle 'preference change' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
void
GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message);
Added: gnunet/src/ats/gnunet-service-ats_reservations.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_reservations.c
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_reservations.c 2011-10-14 08:46:34 UTC
(rev 17478)
@@ -0,0 +1,39 @@
+/*
+ This file is part of GNUnet.
+ (C) 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file ats/gnunet-service-ats_reservations.c
+ * @brief ats service, inbound bandwidth reservation management
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet-service-ats_reservations.h"
+
+
+struct GNUNET_TIME_Relative
+GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
+ int32_t amount)
+{
+ /* FIXME: implement... */
+ /* permit all reservations instantly for now */
+ return GNUNET_TIME_UNIT_ZERO;
+}
+
+/* end of gnunet-service-ats_reservations.c */
Added: gnunet/src/ats/gnunet-service-ats_reservations.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_reservations.h
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_reservations.h 2011-10-14 08:46:34 UTC
(rev 17478)
@@ -0,0 +1,37 @@
+/*
+ This file is part of GNUnet.
+ (C) 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file ats/gnunet-service-ats_reservations.h
+ * @brief ats service, inbound bandwidth reservation management
+ * @author Christian Grothoff
+ */
+#ifndef GNUNET_SERVICE_ATS_RESERVATIONS_H
+#define GNUNET_SERVICE_ATS_RESERVATIONS_H
+
+#include "gnunet_util_lib.h"
+
+
+struct GNUNET_TIME_Relative
+GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
+ int32_t amount);
+
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17478 - gnunet/src/ats,
gnunet <=