aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_cp.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-01-30 16:02:52 +0000
committerChristian Grothoff <christian@grothoff.org>2011-01-30 16:02:52 +0000
commitbc0e1c956bef848d2569e0c56ccbda13597418f7 (patch)
tree88d82a018890ed112c61f21fe2f38e2fe1edc89f /src/fs/gnunet-service-fs_cp.h
parentdee60c25690117fabb90b497dbe23378b3e00db1 (diff)
downloadgnunet-bc0e1c956bef848d2569e0c56ccbda13597418f7.tar.gz
gnunet-bc0e1c956bef848d2569e0c56ccbda13597418f7.zip
stuff
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.h')
-rw-r--r--src/fs/gnunet-service-fs_cp.h205
1 files changed, 153 insertions, 52 deletions
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h
index f6d6e7a0a..8886199b5 100644
--- a/src/fs/gnunet-service-fs_cp.h
+++ b/src/fs/gnunet-service-fs_cp.h
@@ -30,16 +30,90 @@
30 30
31 31
32/** 32/**
33 * A peer connected to us. Setup the connected peer 33 * Performance data kept for a peer.
34 * records. 34 */
35struct GSF_PeerPerformanceData
36{
37
38 /**
39 * Transport performance data.
40 */
41 struct GNUNET_TRANSPORT_ATS_Information *atsi;
42
43 /**
44 * List of the last clients for which this peer successfully
45 * answered a query.
46 */
47 struct GSF_LocalClient *last_client_replies[CS2P_SUCCESS_LIST_SIZE];
48
49 /**
50 * List of the last PIDs for which
51 * this peer successfully answered a query;
52 * We use 0 to indicate no successful reply.
53 */
54 GNUNET_PEER_Id last_p2p_replies[P2P_SUCCESS_LIST_SIZE];
55
56 /**
57 * Average delay between sending the peer a request and
58 * getting a reply (only calculated over the requests for
59 * which we actually got a reply). Calculated
60 * as a moving average: new_delay = ((n-1)*last_delay+curr_delay) / n
61 */
62 struct GNUNET_TIME_Relative avg_reply_delay;
63
64 /**
65 * Point in time until which this peer does not want us to migrate content
66 * to it.
67 */
68 struct GNUNET_TIME_Absolute migration_blocked_until;
69
70 /**
71 * Transmission times for the last MAX_QUEUE_PER_PEER
72 * requests for this peer. Used as a ring buffer, current
73 * offset is stored in 'last_request_times_off'. If the
74 * oldest entry is more recent than the 'avg_delay', we should
75 * not send any more requests right now.
76 */
77 struct GNUNET_TIME_Absolute last_request_times[MAX_QUEUE_PER_PEER];
78
79 /**
80 * How long does it typically take for us to transmit a message
81 * to this peer? (delay between the request being issued and
82 * the callback being invoked).
83 */
84 struct GNUNET_LOAD_Value *transmission_delay;
85
86 /**
87 * Average priority of successful replies. Calculated
88 * as a moving average: new_avg = ((n-1)*last_avg+curr_prio) / n
89 */
90 double avg_priority;
91
92 /**
93 * Number of pending queries (replies are not counted)
94 */
95 unsigned int pending_queries;
96
97 /**
98 * Number of pending replies (queries are not counted)
99 */
100 unsigned int pending_replies;
101
102};
103
104
105/**
106 * Signature of function called on a connected peer.
35 * 107 *
36 * @param peer identity of peer that connected 108 * @param cls closure
37 * @param atsi performance data for the connection 109 * @param peer identity of the peer
38 * @return handle to connected peer entry 110 * @param cp handle to the connected peer record
111 * @param perf peer performance data
39 */ 112 */
40struct GSF_ConnectedPeer * 113typedef void (*GSF_ConnectedPeerIterator)(void *cls,
41GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, 114 const struct GNUNET_PeerIdentity *peer,
42 const struct GNUNET_TRANSPORT_ATS_Information *atsi); 115 struct GSF_ConnectedPeer *cp,
116 const struct GSF_PeerPerformanceData *ppd);
43 117
44 118
45/** 119/**
@@ -56,23 +130,85 @@ typedef size_t (*GSF_GetMessageCallback)(void *cls,
56 130
57 131
58/** 132/**
133 * Signature of function called on a reservation success or failure.
134 *
135 * @param cls closure
136 * @param cp handle to the connected peer record
137 * @param success GNUNET_YES on success, GNUNET_NO on failure
138 */
139typedef void (*GSF_PeerReserveCallback)(void *cls,
140 struct GSF_ConnectedPeer *cp,
141 int success);
142
143
144/**
145 * Handle to cancel a transmission request.
146 */
147struct GSF_PeerTransmitHandle;
148
149
150/**
151 * A peer connected to us. Setup the connected peer
152 * records.
153 *
154 * @param peer identity of peer that connected
155 * @param atsi performance data for the connection
156 * @return handle to connected peer entry
157 */
158struct GSF_ConnectedPeer *
159GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
160 const struct GNUNET_TRANSPORT_ATS_Information *atsi);
161
162
163/**
59 * Transmit a message to the given peer as soon as possible. 164 * Transmit a message to the given peer as soon as possible.
60 * If the peer disconnects before the transmission can happen, 165 * If the peer disconnects before the transmission can happen,
61 * the callback is invoked with a 'NULL' buffer. 166 * the callback is invoked with a 'NULL' buffer.
62 * 167 *
63 * @param peer target peer 168 * @param peer target peer
169 * @param is_query is this a query (GNUNET_YES) or content (GNUNET_NO)
170 * @param priority how important is this request?
171 * @param timeout when does this request timeout (call gmc with error)
64 * @param size number of bytes we would like to send to the peer 172 * @param size number of bytes we would like to send to the peer
65 * @param gmc function to call to get the message 173 * @param gmc function to call to get the message
66 * @param gmc_cls closure for gmc 174 * @param gmc_cls closure for gmc
175 * @return handle to cancel request
67 */ 176 */
68void 177struct GSF_PeerTransmitHandle *
69GSF_peer_transmit_ (struct GSF_ConnectedPeer *peer, 178GSF_peer_transmit_ (struct GSF_ConnectedPeer *peer,
179 int is_query,
180 uint32_t priority,
181 struct GNUNET_TIME_Relative timeout,
70 size_t size, 182 size_t size,
71 GSF_GetMessageCallback gmc, 183 GSF_GetMessageCallback gmc,
72 void *gmc_cls); 184 void *gmc_cls);
73 185
74 186
75/** 187/**
188 * Cancel an earlier request for transmission.
189 */
190void
191GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth);
192
193
194/**
195 * Report on receiving a reply; update the performance record of the given peer.
196 *
197 * @param peer responding peer (will be updated)
198 * @param request_time time at which the original query was transmitted
199 * @param request_priority priority of the original request
200 * @param initiator_client local client on responsible for query (or NULL)
201 * @param initiator_peer other peer responsible for query (or NULL)
202 */
203void
204GSF_peer_update_performance_ (struct GSF_ConnectedPeer *peer,
205 GNUNET_TIME_Absolute request_time,
206 uint32_t request_priority,
207 const struct GSF_LocalClient *initiator_client,
208 const struct GSF_ConnectedPeer *initiator_peer);
209
210
211/**
76 * Method called whenever a given peer has a status change. 212 * Method called whenever a given peer has a status change.
77 * 213 *
78 * @param cls closure 214 * @param cls closure
@@ -105,15 +241,13 @@ GSF_peer_disconnect_handler_ (void *cls,
105 241
106 242
107/** 243/**
108 * Signature of function called on a connected peer. 244 * Notification that a local client disconnected. Clean up all of our
245 * references to the given handle.
109 * 246 *
110 * @param cls closure 247 * @param lc handle to the local client (henceforth invalid)
111 * @param peer identity of the peer
112 * @param cp handle to the connected peer record
113 */ 248 */
114typedef void (*GSF_ConnectedPeerIterator)(void *cls, 249void
115 const struct GNUNET_PeerIdentity *peer, 250GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc);
116 struct GSF_ConnectedPeer *cp);
117 251
118 252
119/** 253/**
@@ -127,42 +261,9 @@ GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it,
127 void *it_cls); 261 void *it_cls);
128 262
129 263
130/** 264// FIXME: should we allow queueing multiple reservation requests?
131 * Register callback to invoke on peer disconnect. 265// FIXME: what about cancellation?
132 * 266// FIXME: change docu on peer disconnect handling?
133 * @param cp peer to monitor
134 * @param it function to call on disconnect
135 * @param it_cls closure for it
136 */
137void
138GSF_connected_peer_register_disconnect_callback_ (struct GSF_ConnectedPeer *cp,
139 GSF_ConnectedPeerIterator it,
140 void *it_cls);
141
142
143/**
144 * Unregister callback to invoke on peer disconnect.
145 *
146 * @param cp peer to stop monitoring
147 * @param it function to no longer call on disconnect
148 * @param it_cls closure for it
149 */
150void
151GSF_connected_peer_unregister_disconnect_callback_ (struct GSF_ConnectedPeer *cp,
152 GSF_ConnectedPeerIterator it,
153 void *it_cls);
154
155
156/**
157 * Signature of function called on a reservation success.
158 *
159 * @param cls closure
160 * @param cp handle to the connected peer record
161 */
162typedef void (*GSF_PeerReserveCallback)(void *cls,
163 struct GSF_ConnectedPeer *cp);
164
165
166/** 267/**
167 * Try to reserve bandwidth (to receive data FROM the given peer). 268 * Try to reserve bandwidth (to receive data FROM the given peer).
168 * This function must only be called ONCE per connected peer at a 269 * This function must only be called ONCE per connected peer at a