[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17467 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17467 - gnunet/src/ats |
Date: |
Thu, 13 Oct 2011 22:54:17 +0200 |
Author: grothoff
Date: 2011-10-13 22:54:17 +0200 (Thu, 13 Oct 2011)
New Revision: 17467
Added:
gnunet/src/ats/gnunet-service-ats_addresses.c
gnunet/src/ats/gnunet-service-ats_addresses.h
Modified:
gnunet/src/ats/Makefile.am
gnunet/src/ats/gnunet-service-ats.c
Log:
moving out addresses as well
Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am 2011-10-13 20:48:27 UTC (rev 17466)
+++ gnunet/src/ats/Makefile.am 2011-10-13 20:54:17 UTC (rev 17467)
@@ -23,6 +23,7 @@
gnunet_service_ats_SOURCES = \
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_LDADD = \
Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2011-10-13 20:48:27 UTC (rev 17466)
+++ gnunet/src/ats/gnunet-service-ats.c 2011-10-13 20:54:17 UTC (rev 17467)
@@ -28,30 +28,10 @@
#include "gnunet_ats_service.h"
#include "gnunet-service-ats_performance.h"
#include "gnunet-service-ats_scheduling.h"
-// #include "gnunet-service-ats_performance.h"
+#include "gnunet-service-ats_addresses.h"
#include "ats.h"
-struct ATS_Address
-{
- struct GNUNET_PeerIdentity peer;
- size_t addr_len;
-
- uint32_t session_id;
-
- uint32_t ats_count;
-
- void * addr;
-
- char * plugin;
-
- struct GNUNET_TRANSPORT_ATS_Information * ats;
-};
-
-static struct GNUNET_CONTAINER_MultiHashMap * addresses;
-
-
-
static void
handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
@@ -80,43 +60,7 @@
}
-struct CompareAddressContext
-{
- struct ATS_Address * search;
- struct ATS_Address * result;
-};
-int compare_address_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
-{
- struct CompareAddressContext * cac = cls;
- struct ATS_Address * aa = (struct ATS_Address *) value;
- if (0 == strcmp(aa->plugin, cac->search->plugin))
- {
- if ((aa->addr_len == cac->search->addr_len) &&
- (0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)))
- cac->result = aa;
- return GNUNET_NO;
- }
- return GNUNET_YES;
-}
-
-
-static int
-free_address_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
-{
- struct ATS_Address * aa = cls;
- GNUNET_free (aa);
- return GNUNET_OK;
-}
-
-
-
-
-
/**
* Task run during shutdown.
*
@@ -126,8 +70,7 @@
static void
cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL);
- GNUNET_CONTAINER_multihashmap_destroy (addresses);
+ GAS_addresses_done ();
}
@@ -157,7 +100,7 @@
GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
{NULL, NULL, 0, 0}
};
- addresses = GNUNET_CONTAINER_multihashmap_create(128);
+ GAS_addresses_init ();
GNUNET_SERVER_add_handlers (server, handlers);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
NULL);
Added: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2011-10-13 20:54:17 UTC
(rev 17467)
@@ -0,0 +1,102 @@
+/*
+ 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_addresses.c
+ * @brief ats service address management
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet-service-ats_addresses.h"
+
+
+struct ATS_Address
+{
+ struct GNUNET_PeerIdentity peer;
+
+ size_t addr_len;
+
+ uint32_t session_id;
+
+ uint32_t ats_count;
+
+ void * addr;
+
+ char * plugin;
+
+ struct GNUNET_TRANSPORT_ATS_Information * ats;
+};
+
+static struct GNUNET_CONTAINER_MultiHashMap * addresses;
+
+
+struct CompareAddressContext
+{
+ struct ATS_Address * search;
+ struct ATS_Address * result;
+};
+
+int compare_address_it (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
+{
+ struct CompareAddressContext * cac = cls;
+ struct ATS_Address * aa = (struct ATS_Address *) value;
+ if (0 == strcmp(aa->plugin, cac->search->plugin))
+ {
+ if ((aa->addr_len == cac->search->addr_len) &&
+ (0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)))
+ cac->result = aa;
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+
+static int
+free_address_it (void *cls,
+ const GNUNET_HashCode * key,
+ void *value)
+{
+ struct ATS_Address * aa = cls;
+ GNUNET_free (aa);
+ return GNUNET_OK;
+}
+
+
+/**
+ */
+void
+GAS_addresses_done ()
+{
+ GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL);
+ GNUNET_CONTAINER_multihashmap_destroy (addresses);
+}
+
+
+/**
+ */
+void
+GAS_addresses_init ()
+{
+ addresses = GNUNET_CONTAINER_multihashmap_create(128);
+}
+
+/* end of gnunet-service-ats_addresses.c */
Added: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h
(rev 0)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h 2011-10-13 20:54:17 UTC
(rev 17467)
@@ -0,0 +1,44 @@
+/*
+ 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_addresses.c
+ * @brief ats service address management
+ * @author Matthias Wachs
+ */
+#ifndef GNUNET_SERVICE_ATS_ADDRESSES_H
+#define GNUNET_SERVICE_ATS_ADDRESSES_H
+
+#include "gnunet_util_lib.h"
+
+
+/**
+ */
+void
+GAS_addresses_init (void);
+
+
+/**
+ */
+void
+GAS_addresses_done (void);
+
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17467 - gnunet/src/ats,
gnunet <=