aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_client.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-08-22 15:26:55 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-08-22 15:26:55 +0000
commit49bcd4e0fe48ffeeffc603cad4517bc9182a9d43 (patch)
tree61fb5ebe3fe41e01b88303c5c6e088daccf74f64 /src/transport/plugin_transport_http_client.c
parentd648243f92b916ef9ba66b71f54d90ce12a3a820 (diff)
downloadgnunet-49bcd4e0fe48ffeeffc603cad4517bc9182a9d43.tar.gz
gnunet-49bcd4e0fe48ffeeffc603cad4517bc9182a9d43.zip
changes
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r--src/transport/plugin_transport_http_client.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index e2967745e..2be86a6ee 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -238,6 +238,66 @@ client_stop (struct HTTP_Client_Plugin *plugin)
238 curl_global_cleanup (); 238 curl_global_cleanup ();
239} 239}
240 240
241/**
242 * Creates a new outbound session the transport service will use to send data to the
243 * peer
244 *
245 * @param cls the plugin
246 * @param address the address
247 * @return the session or NULL of max connections exceeded
248 */
249static struct Session *
250http_client_plugin_get_session (void *cls,
251 const struct GNUNET_HELLO_Address *address)
252{
253 struct HTTP_Client_Plugin *plugin = cls;
254 struct Session * s = NULL;
255// size_t addrlen;
256
257 GNUNET_assert (plugin != NULL);
258 GNUNET_assert (address != NULL);
259 GNUNET_assert (address->address != NULL);
260
261 GNUNET_break (0);
262
263 /* find existing session */
264#if 0
265 s = lookup_session (plugin, address);
266 if (s != NULL)
267 return s;
268
269 if (plugin->max_connections <= plugin->cur_connections)
270 {
271 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name,
272 "Maximum number of connections reached, "
273 "cannot connect to peer `%s'\n", GNUNET_i2s (&address->peer));
274 return NULL;
275 }
276
277 /* create new session */
278 addrlen = address->address_length;
279
280 GNUNET_assert (addrlen > sizeof (struct HttpAddress));
281
282 s = create_session (plugin, &address->peer, address->address, address->address_length);
283
284 /* add new session */
285 GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
286 /* initiate new connection */
287 if (GNUNET_SYSERR == client_connect (s))
288 {
289 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
290 "Cannot connect to peer `%s' address `%s''\n",
291 http_plugin_address_to_string(NULL, s->addr, s->addrlen),
292 GNUNET_i2s (&s->target));
293 GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
294 delete_session (s);
295 return NULL;
296 }
297#endif
298 return s;
299}
300
241static int 301static int
242client_start (struct HTTP_Client_Plugin *plugin) 302client_start (struct HTTP_Client_Plugin *plugin)
243{ 303{
@@ -309,6 +369,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
309 api->send = &http_client_plugin_send; 369 api->send = &http_client_plugin_send;
310 api->disconnect = &http_client_plugin_disconnect; 370 api->disconnect = &http_client_plugin_disconnect;
311 api->check_address = &http_client_plugin_address_suggested; 371 api->check_address = &http_client_plugin_address_suggested;
372 api->get_session = &http_client_plugin_get_session;
312 373
313 api->address_to_string = &http_common_plugin_address_to_string; 374 api->address_to_string = &http_common_plugin_address_to_string;
314 api->string_to_address = &http_common_plugin_string_to_address; 375 api->string_to_address = &http_common_plugin_string_to_address;