aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-11 11:26:57 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-11 11:26:57 +0000
commitd60198e00c1b46ba3c3398cb13f51e9e04ded3b5 (patch)
treec3abd59d51bebe8bfd79d5dee17980e4064c61c6 /src/transport
parentfc0ed6f081909e3be3b6de5461a50be335e63e12 (diff)
downloadgnunet-d60198e00c1b46ba3c3398cb13f51e9e04ded3b5.tar.gz
gnunet-d60198e00c1b46ba3c3398cb13f51e9e04ded3b5.zip
ats
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am1
-rw-r--r--src/transport/gnunet-service-transport_ats-new.c145
-rw-r--r--src/transport/gnunet-service-transport_ats-new.h9
3 files changed, 152 insertions, 3 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 417fdef5a..5d0e40439 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -153,6 +153,7 @@ gnunet_service_transport_LDADD = \
153 153
154gnunet_service_transport_new_SOURCES = \ 154gnunet_service_transport_new_SOURCES = \
155 gnunet-service-transport-new.c gnunet-service-transport.h \ 155 gnunet-service-transport-new.c gnunet-service-transport.h \
156 gnunet-service-transport_ats-new.h gnunet-service-transport_ats-new.c \
156 gnunet-service-transport_blacklist.h gnunet-service-transport_blacklist.c \ 157 gnunet-service-transport_blacklist.h gnunet-service-transport_blacklist.c \
157 gnunet-service-transport_clients.h gnunet-service-transport_clients.c \ 158 gnunet-service-transport_clients.h gnunet-service-transport_clients.c \
158 gnunet-service-transport_hello.h gnunet-service-transport_hello.c \ 159 gnunet-service-transport_hello.h gnunet-service-transport_hello.c \
diff --git a/src/transport/gnunet-service-transport_ats-new.c b/src/transport/gnunet-service-transport_ats-new.c
new file mode 100644
index 000000000..c731ec911
--- /dev/null
+++ b/src/transport/gnunet-service-transport_ats-new.c
@@ -0,0 +1,145 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file transport/gnunet-service-transport_ats-new.c
22 * @brief automatic transport selection API
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet-service-transport_ats-new.h"
28
29
30/**
31 * Handle to the ATS subsystem.
32 */
33struct GST_AtsHandle
34{
35 const struct GNUNET_CONFIGURATION_Handle *cfg;
36
37 GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb;
38
39 void *alloc_cb_cls;
40};
41
42
43/**
44 * Initialize the ATS subsystem.
45 *
46 * @param cfg configuration to use
47 * @param alloc_cb notification to call whenever the allocation changed
48 * @param alloc_cb_cls closure for 'alloc_cb'
49 * @return ats context
50 */
51struct GST_AtsHandle *
52GST_ats_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
53 GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb,
54 void *alloc_cb_cls)
55{
56 struct GST_AtsHandle *atc;
57
58 atc = GNUNET_malloc (sizeof (struct GST_AtsHandle));
59 atc->cfg = cfg;
60 atc->alloc_cb = alloc_cb;
61 atc->alloc_cb_cls = alloc_cb_cls;
62 return atc;
63}
64
65
66/**
67 * Shutdown the ATS subsystem.
68 *
69 * @param atc handle
70 */
71void
72GST_ats_shutdown (struct GST_AtsHandle *atc)
73{
74 GNUNET_free (atc);
75}
76
77
78/**
79 * We established a new connection with a peer (for example, because
80 * core asked for it or because the other peer connected to us).
81 * Calculate bandwidth assignments including the new peer.
82 *
83 * @param atc handle
84 * @param peer identity of the new peer
85 * @param plugin_name name of the currently used transport plugin
86 * @param plugin_addr address in use
87 * @param plugin_addr_len number of bytes in plugin_addr
88 * @param ats performance data for the connection
89 * @param ats_count number of performance records in 'ats'
90 */
91void
92GST_ats_peer_connect (struct GST_AtsHandle *atc,
93 const struct GNUNET_PeerIdentity *peer,
94 const char *plugin_name,
95 const void *plugin_addr,
96 size_t plugin_addr_len,
97 const struct GNUNET_TRANSPORT_ATS_Information *ats,
98 uint32_t ats_count)
99{
100}
101
102
103/**
104 * We disconnected from the given peer (for example, because ats, core
105 * or blacklist asked for it or because the other peer disconnected).
106 * Calculate bandwidth assignments without the peer.
107 *
108 * @param atc handle
109 * @param peer identity of the new peer
110 */
111void
112GST_ats_peer_disconnect (struct GST_AtsHandle *atc,
113 const struct GNUNET_PeerIdentity *peer)
114{
115}
116
117
118/**
119 * We have updated performance statistics for a given address. Note
120 * that this function can be called for addresses that are currently
121 * in use as well as addresses that are valid but not actively in use.
122 * Furthermore, the peer may not even be connected to us right now (in
123 * which case the call may be ignored or the information may be stored
124 * for later use). Update bandwidth assignments.
125 *
126 * @param atc handle
127 * @param peer identity of the new peer
128 * @param plugin_name name of the transport plugin
129 * @param plugin_addr address
130 * @param plugin_addr_len number of bytes in plugin_addr
131 * @param ats performance data for the address
132 * @param ats_count number of performance records in 'ats'
133 */
134void
135GST_ats_address_update (struct GST_AtsHandle *atc,
136 const struct GNUNET_PeerIdentity *peer,
137 const char *plugin_name,
138 const void *plugin_addr,
139 size_t plugin_addr_len,
140 const struct GNUNET_TRANSPORT_ATS_Information *ats,
141 uint32_t ats_count)
142{
143}
144
145/* end of file gnunet-service-transport_ats.c */
diff --git a/src/transport/gnunet-service-transport_ats-new.h b/src/transport/gnunet-service-transport_ats-new.h
index ebb8d9da5..360674bb9 100644
--- a/src/transport/gnunet-service-transport_ats-new.h
+++ b/src/transport/gnunet-service-transport_ats-new.h
@@ -28,6 +28,7 @@
28 28
29#include "gnunet_constants.h" 29#include "gnunet_constants.h"
30#include "gnunet_util_lib.h" 30#include "gnunet_util_lib.h"
31#include "gnunet_transport_service.h"
31 32
32 33
33/** 34/**
@@ -55,7 +56,7 @@ typedef void (*GNUNET_TRANSPORT_ATS_AllocationNotification)(void *cls,
55 const char *plugin_name, 56 const char *plugin_name,
56 const void *plugin_addr, 57 const void *plugin_addr,
57 size_t plugin_addr_len, 58 size_t plugin_addr_len,
58 GNUNET_BANDWIDTH_Value32NBO bandwidth); 59 struct GNUNET_BANDWIDTH_Value32NBO bandwidth);
59 60
60 61
61/** 62/**
@@ -68,14 +69,16 @@ typedef void (*GNUNET_TRANSPORT_ATS_AllocationNotification)(void *cls,
68 */ 69 */
69struct GST_AtsHandle * 70struct GST_AtsHandle *
70GST_ats_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 71GST_ats_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
71 GNUNET_TRANSPORT_ATS_AddressNotification alloc_cb, 72 GNUNET_TRANSPORT_ATS_AllocationNotification alloc_cb,
72 void *alloc_cb_cls); 73 void *alloc_cb_cls);
73 74
74/** 75/**
75 * Shutdown the ATS subsystem. 76 * Shutdown the ATS subsystem.
77 *
78 * @param atc handle
76 */ 79 */
77void 80void
78GST_ats_shutdown (struct GST_AtsHandle *ats); 81GST_ats_shutdown (struct GST_AtsHandle *atc);
79 82
80 83
81/** 84/**