aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-20 16:49:25 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-20 16:49:25 +0000
commitc18b4fced53673e250c587935c6ff692d3936aa6 (patch)
treead872e6eb3f898a78a002f7399dcc8ccd9552375 /src/transport
parent7d9f187d106394b2451660294df9428eb50e82d7 (diff)
downloadgnunet-c18b4fced53673e250c587935c6ff692d3936aa6.tar.gz
gnunet-c18b4fced53673e250c587935c6ff692d3936aa6.zip
breaking stuff
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c19
-rw-r--r--src/transport/plugin_transport.h169
2 files changed, 50 insertions, 138 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 306efeac1..c106457d9 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -257,12 +257,11 @@ struct ReadyList
257 struct GNUNET_TIME_Relative latency; 257 struct GNUNET_TIME_Relative latency;
258 258
259 /** 259 /**
260 * If we did not successfully transmit a message to the 260 * If we did not successfully transmit a message to the given peer
261 * given peer via this connection during the specified 261 * via this connection during the specified time, we should consider
262 * time, we should consider the connection to be dead. 262 * the connection to be dead. This is used in the case that a TCP
263 * This is used in the case that a TCP transport simply 263 * transport simply stalls writing to the stream but does not
264 * stalls writing to the stream but does not formerly 264 * formerly get a signal that the other peer died.
265 * get a signal that the other peer died.
266 */ 265 */
267 struct GNUNET_TIME_Absolute timeout; 266 struct GNUNET_TIME_Absolute timeout;
268 267
@@ -286,10 +285,10 @@ struct ReadyList
286 unsigned int connect_attempts; 285 unsigned int connect_attempts;
287 286
288 /** 287 /**
289 * Is this plugin ready to transmit to the specific 288 * Is this plugin ready to transmit to the specific target?
290 * target? GNUNET_NO if not. Initially, all plugins 289 * GNUNET_NO if not. Initially, all plugins are marked ready. If a
291 * are marked ready. If a transmission is in progress, 290 * transmission is in progress, "transmit_ready" is set to
292 * "transmit_ready" is set to GNUNET_NO. 291 * GNUNET_NO.
293 */ 292 */
294 int transmit_ready; 293 int transmit_ready;
295 294
diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h
index 795d4ed25..6532357f3 100644
--- a/src/transport/plugin_transport.h
+++ b/src/transport/plugin_transport.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2010 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -43,26 +43,23 @@
43#include "gnunet_scheduler_lib.h" 43#include "gnunet_scheduler_lib.h"
44#include "gnunet_transport_service.h" 44#include "gnunet_transport_service.h"
45 45
46
46/** 47/**
47 * Function called by the transport for each received message. 48 * Function called by the transport for each received message.
48 * This function should also be called with "NULL" for the 49 * This function should also be called with "NULL" for the
49 * message to signal that the other peer disconnected. 50 * message to signal that the other peer disconnected.
50 * 51 *
51 * @param cls closure 52 * @param cls closure
52 * @param latency estimated latency for communicating with the 53 * @param distance in overlay hops; use 1 unless DV
53 * given peer; should be set to GNUNET_TIME_UNIT_FOREVER_REL 54 * @param sender_address binary address of the sender (if observed)
54 * until the transport has seen messages transmitted in 55 * @param sender_address_len number of bytes in sender_address
55 * BOTH directions (and hence been able to do an actual
56 * round-trip observation); a non-FOREVER latency is also used
57 * by the transport to know that communication in both directions
58 * using this one plugin actually works
59 * @param peer (claimed) identity of the other peer 56 * @param peer (claimed) identity of the other peer
60 * @param message the message, NULL if peer was disconnected 57 * @param message the message, NULL if peer was disconnected
61 */ 58 */
62typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, 59typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
63 struct 60 unsigned int distance,
64 GNUNET_TIME_Relative 61 const char *sender_address,
65 latency, 62 size_t sender_address_len,
66 const struct 63 const struct
67 GNUNET_PeerIdentity * 64 GNUNET_PeerIdentity *
68 peer, 65 peer,
@@ -71,31 +68,6 @@ typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
71 message); 68 message);
72 69
73 70
74/**
75 * Function that will be called if we receive a validation
76 * of an address challenge that we transmitted to another
77 * peer. Note that the validation should only be considered
78 * acceptable if the challenge matches AND if the sender
79 * address is at least a plausible address for this peer
80 * (otherwise we may be seeing a MiM attack).
81 *
82 * @param cls closure
83 * @param name name of the transport that generated the address
84 * @param peer who responded to our challenge
85 * @param challenge the challenge number we presumably used
86 * @param sender_addr string describing our sender address (as observed
87 * by the other peer in human-readable format)
88 */
89typedef void (*GNUNET_TRANSPORT_ValidationNotification) (void *cls,
90 const char *name,
91 const struct
92 GNUNET_PeerIdentity *
93 peer,
94 uint32_t challenge,
95 const char
96 *sender_addr);
97
98
99 71
100/** 72/**
101 * Function that will be called for each address the transport 73 * Function that will be called for each address the transport
@@ -118,21 +90,6 @@ typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls,
118 90
119 91
120/** 92/**
121 * Function that will be called for each address obtained from the HELLO.
122 *
123 * @param cls closure
124 * @param name name of the transport that generated the address
125 * @param addr one of the addresses of the host, NULL for the last address
126 * the specific address format depends on the transport
127 * @param addrlen length of the address
128 */
129typedef void (*GNUNET_TRANSPORT_AddressCallback) (void *cls,
130 const char *name,
131 const void *addr,
132 size_t addrlen);
133
134
135/**
136 * The transport service will pass a pointer to a struct 93 * The transport service will pass a pointer to a struct
137 * of this type as the first and only argument to the 94 * of this type as the first and only argument to the
138 * entry point of each transport plugin. 95 * entry point of each transport plugin.
@@ -150,16 +107,6 @@ struct GNUNET_TRANSPORT_PluginEnvironment
150 struct GNUNET_SCHEDULER_Handle *sched; 107 struct GNUNET_SCHEDULER_Handle *sched;
151 108
152 /** 109 /**
153 * Our public key.
154 */
155 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *my_public_key;
156
157 /**
158 * Our private key.
159 */
160 struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
161
162 /**
163 * Identity of this peer. 110 * Identity of this peer.
164 */ 111 */
165 const struct GNUNET_PeerIdentity *my_identity; 112 const struct GNUNET_PeerIdentity *my_identity;
@@ -183,14 +130,6 @@ struct GNUNET_TRANSPORT_PluginEnvironment
183 GNUNET_TRANSPORT_AddressNotification notify_address; 130 GNUNET_TRANSPORT_AddressNotification notify_address;
184 131
185 /** 132 /**
186 * Function that must be called by each plugin to notify the
187 * transport service about a successful validation of an
188 * address of another peer (or at least likely successful
189 * validation).
190 */
191 GNUNET_TRANSPORT_ValidationNotification notify_validation;
192
193 /**
194 * What is the default quota (in terms of incoming bytes per 133 * What is the default quota (in terms of incoming bytes per
195 * ms) for new connections? 134 * ms) for new connections?
196 */ 135 */
@@ -207,30 +146,6 @@ struct GNUNET_TRANSPORT_PluginEnvironment
207 146
208 147
209/** 148/**
210 * Function that can be used by the transport service to validate
211 * the address of another peer. Even if
212 * we already have a connection to this peer, this function is
213 * required to establish a new one.
214 *
215 * @param cls closure
216 * @param target who should receive this message
217 * @param challenge challenge code to use
218 * @param timeout how long should we try to transmit these?
219 * @param addrlen length of the address
220 * @param addr the address
221 * @return GNUNET_OK on success, GNUNET_SYSERR if the address
222 * format is invalid
223 */
224typedef int
225 (*GNUNET_TRANSPORT_ValidationFunction) (void *cls,
226 const struct
227 GNUNET_PeerIdentity * target,
228 uint32_t challenge,
229 struct GNUNET_TIME_Relative
230 timeout, const void *addr,
231 size_t addrlen);
232
233/**
234 * Function called by the GNUNET_TRANSPORT_TransmitFunction 149 * Function called by the GNUNET_TRANSPORT_TransmitFunction
235 * upon "completion". 150 * upon "completion".
236 * 151 *
@@ -257,24 +172,39 @@ typedef void
257 * 172 *
258 * @param cls closure 173 * @param cls closure
259 * @param target who should receive this message 174 * @param target who should receive this message
260 * @param priority how important is the message?
261 * @param msg the message to transmit 175 * @param msg the message to transmit
262 * @param timeout how long to wait at most for the transmission 176 * @param priority how important is the message (most plugins will
177 * ignore message priority and just FIFO)
178 * @param timeout how long to wait at most for the transmission (does not
179 * require plugins to discard the message after the timeout,
180 * just advisory for the desired delay; most plugins will ignore
181 * this as well)
182 * @param addr the address to use (can be NULL if the plugin
183 * is "on its own" (i.e. re-use existing TCP connection))
184 * @param addrlen length of the address in bytes
185 * @param force_address GNUNET_YES if the plugin MUST use the given address,
186 * otherwise the plugin may use other addresses or
187 * existing connections (if available)
263 * @param cont continuation to call once the message has 188 * @param cont continuation to call once the message has
264 * been transmitted (or if the transport is ready 189 * been transmitted (or if the transport is ready
265 * for the next transmission call; or if the 190 * for the next transmission call; or if the
266 * peer disconnected...); can be NULL 191 * peer disconnected...); can be NULL
267 * @param cont_cls closure for cont 192 * @param cont_cls closure for cont
193 * @return number of bytes used (on the physical network, with overheads);
194 * -1 on hard errors (i.e. address invalid); 0 is a legal value
195 * and does NOT mean that the message was not transmitted (DV)
268 */ 196 */
269typedef void 197typedef ssize_t
270 (*GNUNET_TRANSPORT_TransmitFunction) (void *cls, 198 (*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
271 const struct GNUNET_PeerIdentity * 199 const struct GNUNET_PeerIdentity *
272 target, 200 target,
201 const struct GNUNET_MessageHeader *msg,
273 unsigned int priority, 202 unsigned int priority,
274 const struct GNUNET_MessageHeader *
275 msg,
276 struct GNUNET_TIME_Relative timeout, 203 struct GNUNET_TIME_Relative timeout,
277 GNUNET_TRANSPORT_TransmitContinuation 204 const void *addr,
205 size_t addrlen,
206 int force_address,
207 GNUNET_TRANSPORT_TransmitContinuation
278 cont, void *cont_cls); 208 cont, void *cont_cls);
279 209
280 210
@@ -354,19 +284,20 @@ typedef void
354 284
355 285
356/** 286/**
357 * Another peer has suggested an address for this 287 * Another peer has suggested an address for this peer and transport
358 * peer and transport plugin. Check that this could be a valid 288 * plugin. Check that this could be a valid address. This function
359 * address. If so, consider adding it to the list 289 * is not expected to 'validate' the address in the sense of trying to
360 * of addresses. 290 * connect to it but simply to see if the binary format is technically
291 * legal for establishing a connection.
361 * 292 *
362 * @param addr pointer to the address 293 * @param addr pointer to the address
363 * @param addrlen length of addr 294 * @param addrlen length of addr
364 * @return GNUNET_OK if this is a plausible address for this peer 295 * @return GNUNET_OK if this is a plausible address for this peer
365 * and transport 296 * and transport, GNUNET_SYSERR if not
366 */ 297 */
367typedef int 298typedef int
368 (*GNUNET_TRANSPORT_SuggestAddress) (void *cls, 299 (*GNUNET_TRANSPORT_CheckAddress) (void *cls,
369 const void *addr, size_t addrlen); 300 const void *addr, size_t addrlen);
370 301
371/** 302/**
372 * Each plugin is required to return a pointer to a struct of this 303 * Each plugin is required to return a pointer to a struct of this
@@ -381,13 +312,6 @@ struct GNUNET_TRANSPORT_PluginFunctions
381 void *cls; 312 void *cls;
382 313
383 /** 314 /**
384 * Function used to send a single message to a particular
385 * peer using the specified address. Used to validate
386 * HELLOs.
387 */
388 GNUNET_TRANSPORT_ValidationFunction validate;
389
390 /**
391 * Function that the transport service will use to transmit data to 315 * Function that the transport service will use to transmit data to
392 * another peer. May be null for plugins that only support 316 * another peer. May be null for plugins that only support
393 * receiving data. After this call, the plugin call the specified 317 * receiving data. After this call, the plugin call the specified
@@ -421,23 +345,12 @@ struct GNUNET_TRANSPORT_PluginFunctions
421 GNUNET_TRANSPORT_SetQuota set_receive_quota; 345 GNUNET_TRANSPORT_SetQuota set_receive_quota;
422 346
423 /** 347 /**
424 * Function that will be called if another peer suggested that 348 * Function that will be called to check if a binary address
425 * we should use a particular address (since he is reaching 349 * for this plugin is well-formed.
426 * us at that address) for this transport.
427 */ 350 */
428 GNUNET_TRANSPORT_SuggestAddress address_suggested; 351 GNUNET_TRANSPORT_CheckAddress check_address;
352
429 353
430 /**
431 * Relative cost of this transport compared to others. This
432 * is supposed to be a static cost estimate which determines
433 * which plugins should not even be attempted if other,
434 * cheaper transports are already working. The idea is that
435 * the costs have roughly this relationship:
436 * <pre>
437 * TCP < UDP < HTTP == HTTPS < SMTP
438 * </pre>
439 */
440 unsigned int cost_estimate;
441}; 354};
442 355
443 356