[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11298 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11298 - gnunet/src/transport |
Date: |
Tue, 11 May 2010 10:05:29 +0200 |
Author: wachs
Date: 2010-05-11 10:05:29 +0200 (Tue, 11 May 2010)
New Revision: 11298
Modified:
gnunet/src/transport/plugin_transport_http.c
Log:
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2010-05-11 07:39:07 UTC
(rev 11297)
+++ gnunet/src/transport/plugin_transport_http.c 2010-05-11 08:05:29 UTC
(rev 11298)
@@ -76,11 +76,6 @@
struct Plugin *plugin;
/**
- * The client (used to identify this connection)
- */
- /* void *client; */
-
- /**
* Continuation function to call once the transmission buffer
* has again space available. NULL if there is no
* continuation to call.
@@ -99,6 +94,21 @@
struct GNUNET_PeerIdentity sender;
/**
+ * Sender's url
+ */
+ char * url;
+
+ /**
+ * Sender's ip address to distinguish between incoming connections
+ */
+ char * ip;
+
+ /**
+ * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
+ */
+ unsigned int is_client;
+
+ /**
* At what time did we reset last_received last?
*/
struct GNUNET_TIME_Absolute last_quota_update;
@@ -226,8 +236,47 @@
return MHD_YES;
}
+/**
+ * Finds a http session in our linked list using peer identity as a key
+ * @param peer peeridentity
+ * @return http session corresponding to peer identity
+ */
+static struct Session * find_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
+{
+ struct Session * cur;
+ GNUNET_HashCode hc_peer;
+ GNUNET_HashCode hc_current;
+ cur = plugin->sessions;
+ hc_peer = peer->hashPubKey;
+ while (cur != NULL)
+ {
+ hc_current = cur->sender.hashPubKey;
+ if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
+ return cur;
+ cur = plugin->sessions->next;
+ }
+ return NULL;
+}
+
/**
+ * Creates a http session in our linked list by peer identity
+ * @param peer peeridentity
+ * @return created http session
+ */
+static struct Session * create_session_by_pi( const struct GNUNET_PeerIdentity
*peer )
+{
+ struct Session * cur;
+
+ /* Create a new session object */
+ cur = GNUNET_malloc (sizeof (struct Session));
+
+ /* Insert into linked list */
+
+ return cur;
+}
+
+/**
* Call MHD to process pending requests and then go back
* and schedule the next run.
*/
@@ -366,10 +415,16 @@
GNUNET_TRANSPORT_TransmitContinuation
cont, void *cont_cls)
{
+ struct Session* ses;
int bytes_sent = 0;
/* struct Plugin *plugin = cls; */
CURL *curl_handle;
/* CURLcode res; */
+
+ /* find session for peer */
+ ses = find_session_by_pi (target);
+ if ( ses == NULL) create_session_by_pi (target);
+
char *url = "http://localhost:12389";
curl_handle = curl_easy_init();
@@ -539,6 +594,7 @@
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
+ plugin->sessions = NULL;
api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
api->cls = plugin;
api->send = &template_plugin_send;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11298 - gnunet/src/transport,
gnunet <=