[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11739 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11739 - gnunet/src/transport |
Date: |
Mon, 14 Jun 2010 13:21:52 +0200 |
Author: wachs
Date: 2010-06-14 13:21:52 +0200 (Mon, 14 Jun 2010)
New Revision: 11739
Modified:
gnunet/src/transport/plugin_transport_http.c
gnunet/src/transport/test_plugin_transport_http.c
Log:
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2010-06-14 09:37:21 UTC
(rev 11738)
+++ gnunet/src/transport/plugin_transport_http.c 2010-06-14 11:21:52 UTC
(rev 11739)
@@ -140,6 +140,18 @@
size_t len;
char * dest_url;
+
+ /**
+ * Continuation function to call once the transmission buffer
+ * has again space available. NULL if there is no
+ * continuation to call.
+ */
+ GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
+
+ /**
+ * Closure for transmit_cont.
+ */
+ void *transmit_cont_cls;
};
@@ -160,18 +172,6 @@
struct Plugin *plugin;
/**
- * Continuation function to call once the transmission buffer
- * has again space available. NULL if there is no
- * continuation to call.
- */
- GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
-
- /**
- * Closure for transmit_cont.
- */
- void *transmit_cont_cls;
-
- /**
* To whom are we talking to (set to our identity
* if we are still waiting for the welcome message)
*/
@@ -797,6 +797,7 @@
{
ses->pending_outbound_msg = cur->next;
GNUNET_free (cur->buf);
+ GNUNET_free (cur->dest_url);
GNUNET_free (cur);
cur = NULL;
return GNUNET_OK;
@@ -812,6 +813,7 @@
cur->next = cur->next->next;
GNUNET_free (cur->next->buf);
+ GNUNET_free (cur->next->dest_url);
GNUNET_free (cur->next);
cur->next = NULL;
return GNUNET_OK;
@@ -921,7 +923,6 @@
*/
static ssize_t send_select_init (struct Session* ses )
{
- char * url;
int bytes_sent = 0;
CURLMcode mret;
struct HTTP_Message * msg;
@@ -935,15 +936,12 @@
}
msg = ses->pending_outbound_msg;
- url = GNUNET_malloc( 7 + strlen(ses->ip) + 7 + strlen ((char *)
&(ses->hash)) + 1);
- /* FIXME: use correct port number */
- GNUNET_asprintf(&url,"http://%s:%u/%s",ses->ip,12389, (char *) &(ses->hash));
#if DEBUG_CURL
curl_easy_setopt(ses->curl_handle, CURLOPT_VERBOSE, 1L);
#endif
- curl_easy_setopt(ses->curl_handle, CURLOPT_URL, url);
+ curl_easy_setopt(ses->curl_handle, CURLOPT_URL, msg->dest_url);
curl_easy_setopt(ses->curl_handle, CURLOPT_PUT, 1L);
curl_easy_setopt(ses->curl_handle, CURLOPT_HEADERFUNCTION, &header_function);
curl_easy_setopt(ses->curl_handle, CURLOPT_READFUNCTION, send_read_callback);
@@ -964,7 +962,6 @@
return -1;
}
bytes_sent = send_prepare (ses );
- GNUNET_free ( url );
return bytes_sent;
}
@@ -1013,8 +1010,8 @@
__LINE__,
curl_easy_strerror (msg->data.result));
/* sending msg failed*/
- if ( NULL != cs->transmit_cont)
- cs->transmit_cont
(cs->transmit_cont_cls,&cs->sender,GNUNET_SYSERR);
+ if ( NULL != cs->pending_outbound_msg->transmit_cont)
+ cs->pending_outbound_msg->transmit_cont
(cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_SYSERR);
}
else
{
@@ -1027,8 +1024,8 @@
cs->curl_handle=NULL;
/* Calling transmit continuation */
- if ( NULL != cs->transmit_cont)
- cs->transmit_cont (NULL,&cs->sender,GNUNET_OK);
+ if ( NULL != cs->pending_outbound_msg->transmit_cont)
+ cs->pending_outbound_msg->transmit_cont
(cs->pending_outbound_msg->transmit_cont_cls,&cs->sender,GNUNET_OK);
/* send pending messages */
@@ -1149,7 +1146,7 @@
GNUNET_TRANSPORT_TransmitContinuation cont,
void *cont_cls)
{
- char address[INET6_ADDRSTRLEN];
+ char * address;
struct Session* ses;
struct Session* ses_temp;
struct HTTP_Message * msg;
@@ -1167,7 +1164,6 @@
/*FIXME: what is const void * really? Assuming struct sockaddr_in * ! */
ses = create_session(NULL, (struct sockaddr_in *) addr, target);
ses->is_active = GNUNET_YES;
- ses->transmit_cont = cont;
/* Insert session into linked list */
if ( plugin->sessions == NULL)
@@ -1190,24 +1186,31 @@
GNUNET_assert (addr!=NULL);
unsigned int port;
- if (addrlen == (sizeof (struct IPv4HttpAddress)))
+
+ /* setting url to send to */
+ if (force_address == GNUNET_YES)
+ {
+ if (addrlen == (sizeof (struct IPv4HttpAddress)))
{
+ address = GNUNET_malloc(INET_ADDRSTRLEN + 14 + strlen ((const char *)
(&ses->hash)));
inet_ntop(AF_INET,&((struct IPv4HttpAddress *)
addr)->ipv4_addr,address,INET_ADDRSTRLEN);
port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
+ GNUNET_asprintf(&address,"http://%s:%u/%s",address,port, (char *)
(&ses->hash));
}
- else if (addrlen == (sizeof (struct IPv6HttpAddress)))
+ else if (addrlen == (sizeof (struct IPv6HttpAddress)))
{
+ address = GNUNET_malloc(INET6_ADDRSTRLEN + 14 + strlen ((const char *)
(&ses->hash)));
inet_ntop(AF_INET6, &((struct IPv6HttpAddress *)
addr)->ipv6_addr,address,INET6_ADDRSTRLEN);
port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
+ GNUNET_asprintf(&address,"http://%s:%u/%s",address,port,(char *)
(&ses->hash));
}
- else
- {
- GNUNET_break (0);
- return -1;
+ else
+ {
+ GNUNET_break (0);
+ return -1;
}
+ }
- ses->transmit_cont = cont;
- ses->transmit_cont_cls = cont_cls;
timeout = to;
/* setting up message */
msg = GNUNET_malloc (sizeof (struct HTTP_Message));
@@ -1215,6 +1218,9 @@
msg->len = msgbuf_size;
msg->pos = 0;
msg->buf = GNUNET_malloc (msgbuf_size);
+ msg->dest_url = address;
+ msg->transmit_cont = cont;
+ msg->transmit_cont_cls = cont_cls;
memcpy (msg->buf,msgbuf, msgbuf_size);
/* insert created message in list of pending messages */
Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c 2010-06-14 09:37:21 UTC
(rev 11738)
+++ gnunet/src/transport/test_plugin_transport_http.c 2010-06-14 11:21:52 UTC
(rev 11739)
@@ -295,6 +295,11 @@
static int fail_addr_to_str;
/**
+ * Did the test pass or fail?
+ */
+static int fail_transmit_to_local_addrs;
+
+/**
* Test: connect to peer without peer identification
*/
static struct HTTP_Transfer test_no_ident;
@@ -343,7 +348,7 @@
/* Evaluate results */
if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO)
&& (fail_addr_to_str == GNUNET_NO) &&
(test_no_ident.test_failed == GNUNET_NO) &&
(test_too_short_ident.test_failed == GNUNET_NO) &&
(test_too_long_ident.test_failed == GNUNET_NO) &&
- (test_valid_ident.test_failed == GNUNET_NO))
+ (test_valid_ident.test_failed == GNUNET_NO) &&
(fail_transmit_to_local_addrs == GNUNET_NO))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tests successful\n");
fail = 0;
@@ -408,6 +413,19 @@
const struct GNUNET_PeerIdentity * target,
int result)
{
+ struct Plugin_Address * tmp_addr;
+ tmp_addr = addr_head;
+ while (tmp_addr->next != NULL)
+ {
+ tmp_addr = tmp_addr->next;
+ }
+
+ if (cls == tmp_addr)
+ {
+ fail_transmit_to_local_addrs = GNUNET_NO;
+ shutdown_clean();
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message was sent!\n");
fail = GNUNET_NO;
//shutdown_clean();
@@ -915,8 +933,6 @@
while (tmp_addr != NULL)
{
-
-
if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
{
inet_ntop(AF_INET, (struct in_addr *)
tmp_addr->addr,address,INET_ADDRSTRLEN);
@@ -934,7 +950,7 @@
GNUNET_break (0);
return;
}
- api->send(api->cls, &my_identity, tmp, sizeof(struct
GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen,
GNUNET_YES, &task_send_cont, NULL);
+ api->send(api->cls, &my_identity, tmp, sizeof(struct
GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen,
GNUNET_YES, &task_send_cont, tmp_addr);
tmp_addr = tmp_addr->next;
count ++;
}
@@ -970,6 +986,7 @@
fail_pretty_printer = GNUNET_YES;
fail_notify_address = GNUNET_YES;
fail_addr_to_str = GNUNET_YES;
+ fail_transmit_to_local_addrs = GNUNET_YES;
addr_head = NULL;
count_str_addr = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11739 - gnunet/src/transport,
gnunet <=