aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-11 08:38:41 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-11 08:38:41 +0000
commitac8f7679c65c1bea265f2a1501a5f6901a1227e9 (patch)
tree1ebb135319274632201f49e24c542519df4e7b03 /src/transport
parent2d67d6c8e460e6cc7cf90a71eb7c175dc2907804 (diff)
downloadgnunet-ac8f7679c65c1bea265f2a1501a5f6901a1227e9.tar.gz
gnunet-ac8f7679c65c1bea265f2a1501a5f6901a1227e9.zip
new ATS api
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_ats-new.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/src/transport/gnunet-service-transport_ats-new.h b/src/transport/gnunet-service-transport_ats-new.h
new file mode 100644
index 000000000..ebb8d9da5
--- /dev/null
+++ b/src/transport/gnunet-service-transport_ats-new.h
@@ -0,0 +1,144 @@
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.h
22 * @brief automatic transport selection API
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#ifndef GNUNET_SERVICE_TRANSPORT_ATS_H
27#define GNUNET_SERVICE_TRANSPORT_ATS_H
28
29#include "gnunet_constants.h"
30#include "gnunet_util_lib.h"
31
32
33/**
34 * Handle to the ATS subsystem.
35 */
36struct GST_AtsHandle;
37
38
39/**
40 * Signature of a function called by ATS to notify the callee that the
41 * assigned bandwidth or address for a given peer was changed. If the
42 * callback is called with address/bandwidth assignments of zero, the
43 * ATS disconnect function will still be called once the disconnect
44 * actually happened.
45 *
46 * @param cls closure
47 * @param peer identity of the peer
48 * @param plugin_name name of the transport plugin, NULL to disconnect
49 * @param plugin_addr address to use, NULL to disconnect
50 * @param plugin_addr_len number of bytes in addr
51 * @param bandwidth assigned bandwidth for the connection
52 */
53typedef void (*GNUNET_TRANSPORT_ATS_AllocationNotification)(void *cls,
54 const struct GNUNET_PeerIdentity *peer,
55 const char *plugin_name,
56 const void *plugin_addr,
57 size_t plugin_addr_len,
58 GNUNET_BANDWIDTH_Value32NBO bandwidth);
59
60
61/**
62 * Initialize the ATS subsystem.
63 *
64 * @param cfg configuration to use
65 * @param alloc_cb notification to call whenever the allocation changed
66 * @param alloc_cb_cls closure for 'alloc_cb'
67 * @return ats context
68 */
69struct GST_AtsHandle *
70GST_ats_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
71 GNUNET_TRANSPORT_ATS_AddressNotification alloc_cb,
72 void *alloc_cb_cls);
73
74/**
75 * Shutdown the ATS subsystem.
76 */
77void
78GST_ats_shutdown (struct GST_AtsHandle *ats);
79
80
81/**
82 * We established a new connection with a peer (for example, because
83 * core asked for it or because the other peer connected to us).
84 * Calculate bandwidth assignments including the new peer.
85 *
86 * @param atc handle
87 * @param peer identity of the new peer
88 * @param plugin_name name of the currently used transport plugin
89 * @param plugin_addr address in use
90 * @param plugin_addr_len number of bytes in plugin_addr
91 * @param ats performance data for the connection
92 * @param ats_count number of performance records in 'ats'
93 */
94void
95GST_ats_peer_connect (struct GST_AtsHandle *atc,
96 const struct GNUNET_PeerIdentity *peer,
97 const char *plugin_name,
98 const void *plugin_addr,
99 size_t plugin_addr_len,
100 const struct GNUNET_TRANSPORT_ATS_Information *ats,
101 uint32_t ats_count);
102
103
104/**
105 * We disconnected from the given peer (for example, because ats, core
106 * or blacklist asked for it or because the other peer disconnected).
107 * Calculate bandwidth assignments without the peer.
108 *
109 * @param atc handle
110 * @param peer identity of the new peer
111 */
112void
113GST_ats_peer_disconnect (struct GST_AtsHandle *atc,
114 const struct GNUNET_PeerIdentity *peer);
115
116
117/**
118 * We have updated performance statistics for a given address. Note
119 * that this function can be called for addresses that are currently
120 * in use as well as addresses that are valid but not actively in use.
121 * Furthermore, the peer may not even be connected to us right now (in
122 * which case the call may be ignored or the information may be stored
123 * for later use). Update bandwidth assignments.
124 *
125 * @param atc handle
126 * @param peer identity of the new peer
127 * @param plugin_name name of the transport plugin
128 * @param plugin_addr address
129 * @param plugin_addr_len number of bytes in plugin_addr
130 * @param ats performance data for the address
131 * @param ats_count number of performance records in 'ats'
132 */
133void
134GST_ats_address_update (struct GST_AtsHandle *atc,
135 const struct GNUNET_PeerIdentity *peer,
136 const char *plugin_name,
137 const void *plugin_addr,
138 size_t plugin_addr_len,
139 const struct GNUNET_TRANSPORT_ATS_Information *ats,
140 uint32_t ats_count);
141
142
143#endif
144/* end of file gnunet-service-transport_ats.h */