#include <curl/curl.h>
-#define DEBUG_CURL GNUNET_NO
+#define DEBUG_CURL GNUNET_YES
#define DEBUG_HTTP GNUNET_NO
/**
* To whom are we talking to (set to our identity
* if we are still waiting for the welcome message)
*/
- struct GNUNET_PeerIdentity sender;
+ struct GNUNET_PeerIdentity partner;
/**
* Sender's ip address to distinguish between incoming connections
hc_peer = peer->hashPubKey;
while (cur != NULL)
{
- hc_current = cur->sender.hashPubKey;
+ hc_current = cur->partner.hashPubKey;
if ( 0 == GNUNET_CRYPTO_hash_cmp( &hc_peer, &hc_current))
return cur;
cur = plugin->sessions->next;
{
memcpy(ses->addr_outbound, addr_out, sizeof (struct sockaddr_in));
}
- memcpy(&ses->sender, peer, sizeof (struct GNUNET_PeerIdentity));
- GNUNET_CRYPTO_hash_to_enc(&ses->sender.hashPubKey,&(ses->hash));
+ memcpy(&ses->partner, peer, sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_CRYPTO_hash_to_enc(&ses->partner.hashPubKey,&(ses->hash));
ses->is_active = GNUNET_NO;
ses->addr_inbound_str = NULL;
ses->pending_inbound_msg = GNUNET_malloc( sizeof (struct HTTP_Message));
cs = *httpSessionCache;
if (cs != NULL)
{
- /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&cs->sender));*/
+ /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&cs->partner));*/
/* session set to inactive */
cs->is_active = GNUNET_NO;
cs->is_put_in_progress = GNUNET_NO;
struct Session * cs;
GNUNET_assert(cls != NULL);
cs = (struct Session *) cls;
- plugin->env->receive(plugin->env->cls, &(cs->sender), message, 1, NULL , cs->addr_inbound_str, strlen(cs->addr_inbound_str));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Recieved message with type %u and size %u from `%s'\n",message->size,message->type, GNUNET_i2s(&(cs->partner)));
+ plugin->env->receive(plugin->env->cls, &(cs->partner), message, 1, NULL , cs->addr_inbound_str, strlen(cs->addr_inbound_str));
}
/**
cs = plugin->sessions;
while ( NULL != cs)
{
- res = (0 == memcmp(&pi_in,&(cs->sender), sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_YES : GNUNET_NO;
+ res = (0 == memcmp(&pi_in,&(cs->partner), sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_YES : GNUNET_NO;
if ( GNUNET_YES == res)
break;
cs = cs->next;
cs_temp->next = cs;
plugin->session_count++;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session `%s' inserted, count %u \n", GNUNET_i2s(&cs->sender), plugin->session_count);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"New Session for peer `%s' inserted, count %u \n", GNUNET_i2s(&cs->partner), plugin->session_count);
}
/* Set closure and update current session*/
if (cs->msgtok==NULL)
cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, cs, &messageTokenizerCallback, cs);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n",method, GNUNET_i2s(&cs->sender),cs->addr_inbound_str);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n",method, GNUNET_i2s(&cs->partner),cs->addr_inbound_str);
}
else
{
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Incoming message from peer `%s', while existing message with %u bytes was not forwarded to transport'\n"),
- GNUNET_i2s(&cs->sender), cs->pending_inbound_msg->pos);
+ GNUNET_i2s(&cs->partner), cs->pending_inbound_msg->pos);
cs->pending_inbound_msg->pos = 0;
}
/* not yet ready */
case CURLMSG_DONE:
if ( (msg->data.result != CURLE_OK) &&
(msg->data.result != CURLE_GOT_NOTHING) )
- {
-
+ {
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
_("%s failed for `%s' at %s:%d: `%s'\n"),
"curl_multi_perform",
- GNUNET_i2s(&cs->sender),
+ GNUNET_i2s(&cs->partner),
__FILE__,
__LINE__,
curl_easy_strerror (msg->data.result));
/* sending msg failed*/
if (( NULL != cs->pending_outbound_msg) && ( NULL != cs->pending_outbound_msg->transmit_cont))
- cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_SYSERR);
- }
+ cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->partner,GNUNET_SYSERR);
+ }
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Send to peer `%s' completed with code %u\n", GNUNET_i2s(&cs->sender),cs->pending_outbound_msg->http_result_code);
+ "Send to peer `%s' completed with code %u\n", GNUNET_i2s(&cs->partner),cs->pending_outbound_msg->http_result_code);
curl_easy_cleanup(cs->curl_handle);
cs->curl_handle=NULL;
{
/* HTTP 1xx : Last message before here was informational */
if ((cs->pending_outbound_msg->http_result_code >=100) && (cs->pending_outbound_msg->http_result_code < 200))
- cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_OK);
+ cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->partner,GNUNET_OK);
/* HTTP 2xx: successful operations */
if ((cs->pending_outbound_msg->http_result_code >=200) && (cs->pending_outbound_msg->http_result_code < 300))
- cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_OK);
+ cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->partner,GNUNET_OK);
/* HTTP 3xx..5xx: error */
if ((cs->pending_outbound_msg->http_result_code >=300) && (cs->pending_outbound_msg->http_result_code < 600))
- cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_SYSERR);
- }
- if (GNUNET_OK != remove_http_message(cs, cs->pending_outbound_msg))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message could not be removed from session `%s'", GNUNET_i2s(&cs->sender));
-
- /* send pending messages */
- if (cs->pending_outbound_msg != NULL)
- {
- send_select_init (cs);
+ cs->pending_outbound_msg->transmit_cont (cs->pending_outbound_msg->transmit_cont_cls,&cs->partner,GNUNET_SYSERR);
}
}
+ if (GNUNET_OK != remove_http_message(cs, cs->pending_outbound_msg))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message could not be removed from session `%s'", GNUNET_i2s(&cs->partner));
+ /* send pending messages */
+ if (cs->pending_outbound_msg != NULL)
+ {
+ send_select_init (cs);
+ }
return;
default:
break;
msg->transmit_cont = cont;
msg->transmit_cont_cls = cont_cls;
memcpy (msg->buf,msgbuf, msgbuf_size);
-
/* insert created message in list of pending messages */
if (ses->pending_outbound_msg == NULL)
{
{
tmp->next = msg;
}
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: sending %u bytes of data from peer `%s' to peer `%s'\n",msgbuf_size,GNUNET_i2s(plugin->env->my_identity),GNUNET_i2s(&ses->sender));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: sending %u bytes of data from peer `%4.4s' to peer `%s'\n",msgbuf_size,(char *) &my_ascii_hash_ident,GNUNET_i2s(target));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: url `%s'\n",url);
if (msg == ses->pending_outbound_msg)
{
bytes_sent = send_select_init (ses);
while ( NULL != cs)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Freeing session for peer `%s'\n",GNUNET_i2s(&cs->sender));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Freeing session for peer `%s'\n",GNUNET_i2s(&cs->partner));
cs_next = cs->next;
while (cur != NULL)
{
tmp = cur->next;
- if (NULL != cur->buf)
- GNUNET_free (cur->buf);
+ GNUNET_free_non_null(cur->dest_url);
+ GNUNET_free_non_null (cur->buf);
GNUNET_free (cur);
cur = tmp;
}