*/
struct Plugin *plugin;
- struct HTTP_Session * head;
- struct HTTP_Session * tail;
+ struct Session * head;
+ struct Session * tail;
};
-struct HTTP_Session
+struct Session
{
- struct HTTP_Session * next;
- struct HTTP_Session * prev;
+ /**
+ * API requirement.
+ */
+ struct SessionHeader header;
+ /**
+ * next session in linked list
+ */
+ struct Session * next;
+
+ /**
+ * previous session in linked list
+ */
+ struct Session * prev;
+
+ /**
+ * address of this session
+ */
void * addr;
+
+ /**
+ * address length
+ */
size_t addrlen;
/**
/**
* session direction
- * outbound: GNUNET_YES
- * inbound : GNUNET_NO
+ * outbound: OUTBOUND (GNUNET_YES)
+ * inbound : INBOUND (GNUNET_NO)
*/
unsigned int direction;
- unsigned int send_connected;
- unsigned int send_active;
- unsigned int recv_connected;
- unsigned int recv_active;
-
- /**
- * entity managing sending data
- */
- void * send_endpoint;
-
- /**
- * entity managing recieving data
- */
- void * recv_endpoint;
-};
-
-
-/**
- * Session handle for connections.
- */
-struct Session
-{
-
- /**
- * API requirement.
- */
- struct SessionHeader header;
-
- /**
- * Stored in a linked list.
- */
- struct Session *next;
-
- /**
- * Pointer to the global plugin struct.
- */
- struct Plugin *plugin;
-
/**
- * To whom are we talking to (set to our identity
- * if we are still waiting for the welcome message)
+ * is session connected to send data?
*/
- struct GNUNET_PeerIdentity identity;
+ unsigned int send_connected;
/**
- * Did we initiate the connection (GNUNET_YES) or the other peer (GNUNET_NO)?
+ * is send connection active?
*/
- int is_client;
+ unsigned int send_active;
/**
- * At what time did we reset last_received last?
+ * is session connected to receive data?
*/
- struct GNUNET_TIME_Absolute last_quota_update;
+ unsigned int recv_connected;
/**
- * How many bytes have we received since the "last_quota_update"
- * timestamp?
+ * is receive connection active?
*/
- uint64_t last_received;
+ unsigned int recv_active;
/**
- * Number of bytes per ms that this peer is allowed
- * to send to us.
+ * entity managing sending data
+ * outbound session: pointer to curl easy handle
*/
- uint32_t quota;
+ void * send_endpoint;
/**
- * Encoded hash
+ * entity managing recieving data
+ * outbound session: pointer to curl easy handle
*/
- struct GNUNET_CRYPTO_HashAsciiEncoded hash;
+ void * recv_endpoint;
};
/**
* @return GNUNET_SYSERR if msg not found, GNUNET_OK on success
*/
-static int remove_http_message(struct HTTP_Session * ps, struct HTTP_Message * msg)
+static int remove_http_message(struct Session * ps, struct HTTP_Message * msg)
{
GNUNET_CONTAINER_DLL_remove(ps->pending_msgs_head,ps->pending_msgs_tail,msg);
GNUNET_free(msg);
return GNUNET_OK;
}
-static struct HTTP_Session * get_HTTP_Session (void * cls, struct HTTP_PeerContext *pc, const void * addr, size_t addr_len)
+static struct Session * get_Session (void * cls, struct HTTP_PeerContext *pc, const void * addr, size_t addr_len)
{
- struct HTTP_Session * cc = pc->head;
- struct HTTP_Session * con = NULL;
+ struct Session * cc = pc->head;
+ struct Session * con = NULL;
unsigned int count = 0;
GNUNET_assert((addr_len == sizeof (struct IPv4HttpAddress)) || (addr_len == sizeof (struct IPv6HttpAddress)));
*/
static void requestCompletedCallback (void *cls, struct MHD_Connection * connection, void **httpSessionCache)
{
- struct HTTP_Session * ps = *httpSessionCache;
+ struct Session * ps = *httpSessionCache;
if (ps == NULL)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&ps->peercontext->identity));
const struct GNUNET_MessageHeader *message)
{
- struct HTTP_Session *ps = cls;
+ struct Session *ps = cls;
struct HTTP_PeerContext *pc = ps->peercontext;
GNUNET_assert(ps != NULL);
GNUNET_assert(pc != NULL);
pc->plugin->env->receive (ps->peercontext->plugin->env->cls,
&pc->identity,
- message, 1, ps,
+ message, 1, NULL,
+ //message, 1, ps,
ps->addr,
ps->addrlen);
}
void *client,
const struct GNUNET_MessageHeader *message)
{
- struct HTTP_Session *ps = cls;
+ struct Session *ps = cls;
struct HTTP_PeerContext *pc = ps->peercontext;
GNUNET_assert(ps != NULL);
GNUNET_assert(pc != NULL);
pc->plugin->env->receive (pc->plugin->env->cls,
&pc->identity,
- message, 1, ps,
+ message, 1, NULL,
+ //message, 1, ps,
ps->addr,
ps->addrlen);
}
{
int bytes_read = 0;
- struct HTTP_Session * ps = cls;
+ struct Session * ps = cls;
struct HTTP_PeerContext * pc;
struct HTTP_Message * msg;
int res;res=5;
struct IPv6HttpAddress ipv6addr;
struct HTTP_PeerContext *pc;
- struct HTTP_Session *ps;
+ struct Session *ps;
int res = GNUNET_NO;
int send_error_to_client;
addr_len = sizeof(struct IPv6HttpAddress);
}
/* Set closure and update current session*/
- ps = get_HTTP_Session(plugin, pc, addr, addr_len);
+ ps = get_Session(plugin, pc, addr, addr_len);
if (ps==NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"RECV: CREATING NEW SESSION %s\n",http_plugin_address_to_string(NULL, addr, addr_len));
- ps = GNUNET_malloc(sizeof (struct HTTP_Session));
+ ps = GNUNET_malloc(sizeof (struct Session));
ps->addr = GNUNET_malloc(addr_len);
memcpy(ps->addr,addr,addr_len);
ps->addrlen = addr_len;
* @param con connection
* @return bytes sent to peer
*/
-static ssize_t send_check_connections (void *cls, struct Session* ses , struct HTTP_Session *ps);
+static ssize_t send_check_connections (void *cls, struct Session* ses , struct Session *ps);
static size_t curl_get_header_function( void *ptr, size_t size, size_t nmemb, void *stream)
{
- struct HTTP_Session * ps = stream;
+ struct Session * ps = stream;
char * tmp;
size_t len = size * nmemb;
static size_t curl_put_header_function( void *ptr, size_t size, size_t nmemb, void *stream)
{
- struct HTTP_Session * ps = stream;
+ struct Session * ps = stream;
char * tmp;
size_t len = size * nmemb;
*/
static size_t send_curl_send_callback(void *stream, size_t size, size_t nmemb, void *ptr)
{
- struct HTTP_Session * ps = ptr;
+ struct Session * ps = ptr;
struct HTTP_Message * msg = ps->pending_msgs_tail;
size_t bytes_sent;
size_t len;
*/
static size_t send_curl_receive_callback( void *stream, size_t size, size_t nmemb, void *ptr)
{
- struct HTTP_Session * ps = ptr;
+ struct Session * ps = ptr;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes recieved\n",ps, size*nmemb);
GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO);
* @param con connection
* @return bytes sent to peer
*/
-static ssize_t send_check_connections (void *cls, struct Session* ses , struct HTTP_Session *ps)
+static ssize_t send_check_connections (void *cls, struct Session* ses , struct Session *ps)
{
struct Plugin *plugin = cls;
int bytes_sent = 0;
int running;
struct CURLMsg *msg;
CURLMcode mret;
- struct HTTP_Session *ps = NULL;
+ struct Session *ps = NULL;
struct HTTP_PeerContext *pc = NULL;
struct HTTP_Message * cur_msg = NULL;
long http_result;
struct HTTP_Message *msg;
struct HTTP_PeerContext * pc;
- struct HTTP_Session * ps;
+ struct Session * ps;
GNUNET_assert(cls !=NULL);
GNUNET_assert ((addr!=NULL) && (addrlen != 0));
memcpy(&pc->identity, target, sizeof(struct GNUNET_PeerIdentity));
GNUNET_CONTAINER_multihashmap_put(plugin->peers, &pc->identity.hashPubKey, pc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
- ps = get_HTTP_Session(plugin, pc, addr, addrlen);
+ ps = get_Session(plugin, pc, addr, addrlen);
/* session not existing, but address forced -> creating new session */
if ((ps==NULL) && (force_address == GNUNET_YES))
{
- ps = GNUNET_malloc(sizeof (struct HTTP_Session));
+ ps = GNUNET_malloc(sizeof (struct Session));
ps->addr = GNUNET_malloc(addrlen);
memcpy(ps->addr,addr,addrlen);
ps->addrlen = addrlen;
if ((ps==NULL) && (force_address == GNUNET_NO))
{
/* FIXME: CREATING SESSION, SHOULD CHOOSE EXISTING */
- ps = GNUNET_malloc(sizeof (struct HTTP_Session));
+ ps = GNUNET_malloc(sizeof (struct Session));
ps->addr = GNUNET_malloc(addrlen);
memcpy(ps->addr,addr,addrlen);
ps->addrlen = addrlen;
if ((ps==NULL) && (force_address == GNUNET_SYSERR))
{
/* FIXME: CREATING SESSION, SHOULD CHOOSE EXISTING */
- ps = GNUNET_malloc(sizeof (struct HTTP_Session));
+ ps = GNUNET_malloc(sizeof (struct Session));
ps->addr = GNUNET_malloc(addrlen);
memcpy(ps->addr,addr,addrlen);
ps->addrlen = addrlen;
struct Plugin *plugin = cls;
struct HTTP_PeerContext *pc = NULL;
- struct HTTP_Session *ps = NULL;
+ struct Session *ps = NULL;
pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey);
if (pc==NULL)
ps->send_active = GNUNET_NO;
ps=ps->next;
}
-
-#if 0
- /* get peercontext from hashmap */
- cs = session_get(plugin, target);
- con = cs->outbound_connections_head;
-
- while (con!=NULL)
- {
- if (con->put_curl_handle!=NULL)
- curl_easy_cleanup(con->put_curl_handle);
- con->put_curl_handle=NULL;
- con->put_connected = GNUNET_NO;
- while (con->pending_msgs_head!=NULL)
- {
- //remove_http_message(con, con->pending_msgs_head);
- }
- con=con->next;
- }
-#endif
}
int peer_context_Iterator (void *cls, const GNUNET_HashCode *key, void *value)
{
struct HTTP_PeerContext * pc = value;
- struct HTTP_Session * ps = pc->head;
- struct HTTP_Session * tmp = NULL;
+ struct Session * ps = pc->head;
+ struct Session * tmp = NULL;
struct HTTP_Message * msg = NULL;
struct HTTP_Message * msg_tmp = NULL;