aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-05-11 08:05:29 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-05-11 08:05:29 +0000
commitb0036678adbb776b8e4d8be81bd271905b36a223 (patch)
treecaa282e9e44154736d4ac9a5ebac7f4afe26e84d /src
parent391b2398038becbdcde1372adaff2a86da3cc1b2 (diff)
downloadgnunet-b0036678adbb776b8e4d8be81bd271905b36a223.tar.gz
gnunet-b0036678adbb776b8e4d8be81bd271905b36a223.zip
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_http.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 476025086..eb3209fd6 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -76,11 +76,6 @@ struct Session
76 struct Plugin *plugin; 76 struct Plugin *plugin;
77 77
78 /** 78 /**
79 * The client (used to identify this connection)
80 */
81 /* void *client; */
82
83 /**
84 * Continuation function to call once the transmission buffer 79 * Continuation function to call once the transmission buffer
85 * has again space available. NULL if there is no 80 * has again space available. NULL if there is no
86 * continuation to call. 81 * continuation to call.
@@ -99,6 +94,21 @@ struct Session
99 struct GNUNET_PeerIdentity sender; 94 struct GNUNET_PeerIdentity sender;
100 95
101 /** 96 /**
97 * Sender's url
98 */
99 char * url;
100
101 /**
102 * Sender's ip address to distinguish between incoming connections
103 */
104 char * ip;
105
106 /**
107 * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
108 */
109 unsigned int is_client;
110
111 /**
102 * At what time did we reset last_received last? 112 * At what time did we reset last_received last?
103 */ 113 */
104 struct GNUNET_TIME_Absolute last_quota_update; 114 struct GNUNET_TIME_Absolute last_quota_update;
@@ -226,6 +236,45 @@ accessHandlerCallback (void *cls,
226 236
227 return MHD_YES; 237 return MHD_YES;
228} 238}
239/**
240 * Finds a http session in our linked list using peer identity as a key
241 * @param peer peeridentity
242 * @return http session corresponding to peer identity
243 */
244static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity *peer )
245{
246 struct Session * cur;
247 GNUNET_HashCode hc_peer;
248 GNUNET_HashCode hc_current;
249
250 cur = plugin->sessions;
251 hc_peer = peer->hashPubKey;
252 while (cur != NULL)
253 {
254 hc_current = cur->sender.hashPubKey;
255 if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
256 return cur;
257 cur = plugin->sessions->next;
258 }
259 return NULL;
260}
261
262/**
263 * Creates a http session in our linked list by peer identity
264 * @param peer peeridentity
265 * @return created http session
266 */
267static struct Session * create_session_by_pi( const struct GNUNET_PeerIdentity *peer )
268{
269 struct Session * cur;
270
271 /* Create a new session object */
272 cur = GNUNET_malloc (sizeof (struct Session));
273
274 /* Insert into linked list */
275
276 return cur;
277}
229 278
230/** 279/**
231 * Call MHD to process pending requests and then go back 280 * Call MHD to process pending requests and then go back
@@ -366,10 +415,16 @@ template_plugin_send (void *cls,
366 GNUNET_TRANSPORT_TransmitContinuation 415 GNUNET_TRANSPORT_TransmitContinuation
367 cont, void *cont_cls) 416 cont, void *cont_cls)
368{ 417{
418 struct Session* ses;
369 int bytes_sent = 0; 419 int bytes_sent = 0;
370 /* struct Plugin *plugin = cls; */ 420 /* struct Plugin *plugin = cls; */
371 CURL *curl_handle; 421 CURL *curl_handle;
372 /* CURLcode res; */ 422 /* CURLcode res; */
423
424 /* find session for peer */
425 ses = find_session_by_pi (target);
426 if ( ses == NULL) create_session_by_pi (target);
427
373 char *url = "http://localhost:12389"; 428 char *url = "http://localhost:12389";
374 429
375 curl_handle = curl_easy_init(); 430 curl_handle = curl_easy_init();
@@ -539,6 +594,7 @@ libgnunet_plugin_transport_http_init (void *cls)
539 594
540 plugin = GNUNET_malloc (sizeof (struct Plugin)); 595 plugin = GNUNET_malloc (sizeof (struct Plugin));
541 plugin->env = env; 596 plugin->env = env;
597 plugin->sessions = NULL;
542 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 598 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
543 api->cls = plugin; 599 api->cls = plugin;
544 api->send = &template_plugin_send; 600 api->send = &template_plugin_send;