aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-09-26 13:35:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-09-26 13:35:28 +0000
commitdb7a7ef28e42cb253d5be3bde6ee580215f89f0a (patch)
tree6b8e959c34ea6f6b3131058e1dc1d27f8df995e7 /src/transport
parent535d51c21e7ed8b8e1f9bec144c54f177de6b2f5 (diff)
downloadgnunet-db7a7ef28e42cb253d5be3bde6ee580215f89f0a.tar.gz
gnunet-db7a7ef28e42cb253d5be3bde6ee580215f89f0a.zip
removing incoherent address formats
cleaning up logging
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_http.h2
-rw-r--r--src/transport/plugin_transport_http_client.c56
-rw-r--r--src/transport/plugin_transport_http_new.c236
-rw-r--r--src/transport/plugin_transport_http_server.c61
4 files changed, 167 insertions, 188 deletions
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h
index 5264df5f9..249b92c9d 100644
--- a/src/transport/plugin_transport_http.h
+++ b/src/transport/plugin_transport_http.h
@@ -249,7 +249,7 @@ struct Session
249 void *server_recv; 249 void *server_recv;
250 void *server_send; 250 void *server_send;
251 struct GNUNET_TIME_Absolute delay; 251 struct GNUNET_TIME_Absolute delay;
252 GNUNET_SCHEDULER_TaskIdentifier reset_task; 252 GNUNET_SCHEDULER_TaskIdentifier recv_wakeup_task;
253 uint32_t tag; 253 uint32_t tag;
254 254
255}; 255};
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index 715125dd0..c5fea94a1 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -51,7 +51,11 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls)
51 text[size] = '\n'; 51 text[size] = '\n';
52 text[size + 1] = '\0'; 52 text[size + 1] = '\0';
53 } 53 }
54 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client: %X - %s", cls, text); 54#if BUILD_HTTPS
55 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https", "Client: %X - %s", cls, text);
56#else
57 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http", "Client: %X - %s", cls, text);
58#endif
55 } 59 }
56 return 0; 60 return 0;
57} 61}
@@ -61,6 +65,8 @@ int
61client_send (struct Session *s, struct HTTP_Message *msg) 65client_send (struct Session *s, struct HTTP_Message *msg)
62{ 66{
63 GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); 67 GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg);
68 if (s != NULL)
69 curl_easy_pause(s->client_put, CURLPAUSE_CONT);
64 return GNUNET_OK; 70 return GNUNET_OK;
65} 71}
66 72
@@ -183,7 +189,7 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
183 { 189 {
184#if DEBUG_HTTP 190#if DEBUG_HTTP
185 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 191 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
186 "Connection to '%s' %s ended\n", GNUNET_i2s(&s->target), GNUNET_a2s (s->addr, s->addrlen)); 192 "Client: %X connection to '%s' %s ended\n", s, GNUNET_i2s(&s->target), GNUNET_a2s (s->addr, s->addrlen));
187#endif 193#endif
188 client_disconnect(s); 194 client_disconnect(s);
189 //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen)); 195 //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), http_plugin_address_to_string (plugin, s->addr, s->addrlen));
@@ -210,7 +216,8 @@ client_disconnect (struct Session *s)
210 216
211#if DEBUG_HTTP 217#if DEBUG_HTTP
212 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 218 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
213 "Client: Deleting outbound PUT session to peer `%s'\n", 219 "Client: %X Deleting outbound PUT session to peer `%s'\n",
220 s,
214 GNUNET_i2s (&s->target)); 221 GNUNET_i2s (&s->target));
215#endif 222#endif
216 223
@@ -229,9 +236,15 @@ client_disconnect (struct Session *s)
229 236
230#if DEBUG_HTTP 237#if DEBUG_HTTP
231 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 238 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
232 "Client: Deleting outbound GET session to peer `%s'\n", 239 "Client: %X Deleting outbound GET session to peer `%s'\n",
240 s,
233 GNUNET_i2s (&s->target)); 241 GNUNET_i2s (&s->target));
234#endif 242#endif
243 if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
244 {
245 GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
246 s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
247 }
235 248
236 if (s->client_get != NULL) 249 if (s->client_get != NULL)
237 { 250 {
@@ -290,6 +303,18 @@ client_receive_mst_cb (void *cls, void *client,
290#endif 303#endif
291 } 304 }
292} 305}
306static void
307client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
308{
309 struct Session *s = cls;
310
311 s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
312 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
313 return;
314
315 if (s->client_get != NULL)
316 curl_easy_pause(s->client_get, CURLPAUSE_CONT);
317}
293 318
294/** 319/**
295* Callback method used with libcurl 320* Callback method used with libcurl
@@ -305,6 +330,7 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls)
305{ 330{
306 struct Session *s = cls; 331 struct Session *s = cls;
307 struct Plugin *plugin = s->plugin; 332 struct Plugin *plugin = s->plugin;
333 struct GNUNET_TIME_Absolute now;
308 334
309#if VERBOSE_CLIENT 335#if VERBOSE_CLIENT
310 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received %Zu bytes from peer `%s'\n", 336 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received %Zu bytes from peer `%s'\n",
@@ -312,14 +338,21 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls)
312 GNUNET_i2s (&s->target)); 338 GNUNET_i2s (&s->target));
313#endif 339#endif
314 340
315 if (GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value) 341 now = GNUNET_TIME_absolute_get();
342 if (now.abs_value < s->delay.abs_value)
316 { 343 {
317#if DEBUG_CLIENT 344#if DEBUG_CLIENT
318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
319 "no inbound bandwidth available! Next read was delayed for %llu ms\n", 346 "No inbound bandwidth available! Next read was delayed for %llu ms\n",
320 s, GNUNET_TIME_absolute_get_difference(s->delay, GNUNET_TIME_absolute_get()).rel_value); 347 s, GNUNET_TIME_absolute_get_difference(s->delay, GNUNET_TIME_absolute_get()).rel_value);
321#endif 348#endif
322 return 0; 349 if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
350 {
351 GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
352 s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
353 }
354 s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s);
355 return CURLPAUSE_ALL;
323 } 356 }
324 357
325 358
@@ -345,7 +378,7 @@ static size_t
345client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) 378client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
346{ 379{
347 struct Session *s = cls; 380 struct Session *s = cls;
348 //struct Plugin *plugin = s->plugin; 381 struct Plugin *plugin = s->plugin;
349 size_t bytes_sent = 0; 382 size_t bytes_sent = 0;
350 size_t len; 383 size_t len;
351 384
@@ -394,9 +427,9 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
394 if (msg->pos == msg->size) 427 if (msg->pos == msg->size)
395 { 428 {
396#if VERBOSE_CLIENT 429#if VERBOSE_CLIENT
397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 430 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
398 "Message with %u bytes sent, removing message from queue\n", 431 "Client: %X Message with %u bytes sent, removing message from queue\n",
399 s, msg->pos); 432 s, msg->size, msg->pos);
400#endif 433#endif
401 /* Calling transmit continuation */ 434 /* Calling transmit continuation */
402 if (NULL != msg->transmit_cont) 435 if (NULL != msg->transmit_cont)
@@ -426,7 +459,6 @@ client_connect (struct Session *s)
426 plugin->last_tag++; 459 plugin->last_tag++;
427 /* create url */ 460 /* create url */
428 GNUNET_asprintf (&url, "%s%s;%u", http_plugin_address_to_string (plugin, s->addr, s->addrlen), GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),plugin->last_tag); 461 GNUNET_asprintf (&url, "%s%s;%u", http_plugin_address_to_string (plugin, s->addr, s->addrlen), GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),plugin->last_tag);
429 //GNUNET_asprintf (&url, "http://www.heise.de", http_plugin_address_to_string (plugin, s->addr, s->addrlen), GNUNET_h2s_full (&plugin->env->my_identity->hashPubKey),plugin->last_tag);
430#if 0 462#if 0
431 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 463 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
432 "URL `%s'\n", 464 "URL `%s'\n",
diff --git a/src/transport/plugin_transport_http_new.c b/src/transport/plugin_transport_http_new.c
index 5b7da9297..47d4743fd 100644
--- a/src/transport/plugin_transport_http_new.c
+++ b/src/transport/plugin_transport_http_new.c
@@ -34,22 +34,6 @@
34#define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) 34#define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6)
35 35
36/** 36/**
37 * Network format for IPv4 addresses.
38 */
39struct IPv4HttpAddress
40{
41 /**
42 * IPv4 address, in network byte order.
43 */
44 uint32_t ipv4_addr GNUNET_PACKED;
45
46 /**
47 * Port number, in network byte order.
48 */
49 uint16_t port GNUNET_PACKED;
50};
51
52/**
53 * Wrapper to manage IPv4 addresses 37 * Wrapper to manage IPv4 addresses
54 */ 38 */
55struct IPv4HttpAddressWrapper 39struct IPv4HttpAddressWrapper
@@ -64,24 +48,7 @@ struct IPv4HttpAddressWrapper
64 */ 48 */
65 struct IPv4HttpAddressWrapper *prev; 49 struct IPv4HttpAddressWrapper *prev;
66 50
67 struct IPv4HttpAddress *addr; 51 struct sockaddr_in addr;
68};
69
70/**
71 * Network format for IPv6 addresses.
72 */
73struct IPv6HttpAddress
74{
75 /**
76 * IPv6 address.
77 */
78 struct in6_addr ipv6_addr GNUNET_PACKED;
79
80 /**
81 * Port number, in network byte order.
82 */
83 uint16_t port GNUNET_PACKED;
84
85}; 52};
86 53
87/** 54/**
@@ -99,7 +66,10 @@ struct IPv6HttpAddressWrapper
99 */ 66 */
100 struct IPv6HttpAddressWrapper *prev; 67 struct IPv6HttpAddressWrapper *prev;
101 68
102 struct IPv6HttpAddress *addr; 69 /**
70 * IPv6 address.
71 */
72 struct sockaddr_in6 addr GNUNET_PACKED;
103}; 73};
104 74
105 75
@@ -188,33 +158,20 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
188 struct PrettyPrinterContext *ppc; 158 struct PrettyPrinterContext *ppc;
189 const void *sb; 159 const void *sb;
190 size_t sbs; 160 size_t sbs;
191 struct sockaddr_in a4; 161 uint16_t port = 0 ;
192 struct sockaddr_in6 a6;
193 const struct IPv4HttpAddress *t4;
194 const struct IPv6HttpAddress *t6;
195 uint16_t port;
196 162
197 if (addrlen == sizeof (struct IPv6HttpAddress)) 163 if (addrlen == sizeof (struct sockaddr_in6))
198 { 164 {
199 t6 = addr; 165 sb = addr;
200 memset (&a6, 0, sizeof (a6)); 166 sbs = sizeof (struct sockaddr_in6);
201 a6.sin6_family = AF_INET6; 167
202 a6.sin6_port = t6->port; 168 port = ntohs (((struct sockaddr_in6 *)addr)->sin6_port);
203 memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
204 port = ntohs (t6->port);
205 sb = &a6;
206 sbs = sizeof (a6);
207 } 169 }
208 else if (addrlen == sizeof (struct IPv4HttpAddress)) 170 else if (addrlen == sizeof (struct sockaddr_in))
209 { 171 {
210 t4 = addr; 172 sb = &addr;
211 memset (&a4, 0, sizeof (a4)); 173 sbs = sizeof (struct sockaddr_in);
212 a4.sin_family = AF_INET; 174 port = ntohs (((struct sockaddr_in *)addr)->sin_port);
213 a4.sin_port = t4->port;
214 a4.sin_addr.s_addr = t4->ipv4_addr;
215 port = ntohs (t4->ipv4_addr);
216 sb = &a4;
217 sbs = sizeof (a4);
218 } 175 }
219 else 176 else
220 { 177 {
@@ -248,23 +205,21 @@ http_plugin_address_pretty_printer (void *cls, const char *type,
248static int 205static int
249http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) 206http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
250{ 207{
208
251 struct Plugin *plugin = cls; 209 struct Plugin *plugin = cls;
252 struct IPv4HttpAddress *v4;
253 struct IPv6HttpAddress *v6;
254 struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head; 210 struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head;
255 struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head; 211 struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head;
256 212
257 GNUNET_assert (cls != NULL); 213 GNUNET_assert (cls != NULL);
258 if ((addrlen != sizeof (struct IPv4HttpAddress)) && 214 if ((addrlen != sizeof (struct sockaddr_in)) ||
259 (addrlen != sizeof (struct IPv6HttpAddress))) 215 (addrlen != sizeof (struct sockaddr_in6)))
260 return GNUNET_SYSERR; 216 return GNUNET_SYSERR;
261 if (addrlen == sizeof (struct IPv4HttpAddress)) 217
218 if (addrlen == sizeof (struct sockaddr_in))
262 { 219 {
263 v4 = (struct IPv4HttpAddress *) addr;
264 while (w_tv4 != NULL) 220 while (w_tv4 != NULL)
265 { 221 {
266 if (0 == 222 if (0 == memcmp (&w_tv4->addr, addr, sizeof (struct sockaddr_in)))
267 memcmp (&w_tv4->addr->ipv4_addr, &v4->ipv4_addr, sizeof (uint32_t)))
268 break; 223 break;
269 w_tv4 = w_tv4->next; 224 w_tv4 = w_tv4->next;
270 } 225 }
@@ -273,14 +228,13 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
273 else 228 else
274 return GNUNET_SYSERR; 229 return GNUNET_SYSERR;
275 } 230 }
276 if (addrlen == sizeof (struct IPv6HttpAddress)) 231 if (addrlen == sizeof (struct sockaddr_in6))
277 { 232 {
278 v6 = (struct IPv6HttpAddress *) addr;
279 while (w_tv6 != NULL) 233 while (w_tv6 != NULL)
280 { 234 {
281 if (0 == 235 if (0 ==
282 memcmp (&w_tv6->addr->ipv6_addr, &v6->ipv6_addr, 236 memcmp (&w_tv6->addr, addr,
283 sizeof (struct in6_addr))) 237 sizeof (struct sockaddr_in6)))
284 break; 238 break;
285 w_tv6 = w_tv6->next; 239 w_tv6 = w_tv6->next;
286 } 240 }
@@ -289,7 +243,7 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
289 else 243 else
290 return GNUNET_SYSERR; 244 return GNUNET_SYSERR;
291 } 245 }
292 return GNUNET_SYSERR; 246 return GNUNET_OK;
293} 247}
294 248
295struct GNUNET_TIME_Relative 249struct GNUNET_TIME_Relative
@@ -327,30 +281,27 @@ http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer,
327const char * 281const char *
328http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) 282http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
329{ 283{
330 const struct IPv4HttpAddress *t4; 284
331 const struct IPv6HttpAddress *t6; 285 struct sockaddr_in *a4;
332 struct sockaddr_in a4; 286 struct sockaddr_in6 *a6;
333 struct sockaddr_in6 a6;
334 char *address; 287 char *address;
335 static char rbuf[INET6_ADDRSTRLEN + 13]; 288 static char rbuf[INET6_ADDRSTRLEN + 13];
336 uint16_t port; 289 uint16_t port;
337 int res = 0; 290 int res = 0;
338 291
339 if (addrlen == sizeof (struct IPv6HttpAddress)) 292 if (addrlen == sizeof (struct sockaddr_in6))
340 { 293 {
294 a6 = (struct sockaddr_in6 *) addr;
341 address = GNUNET_malloc (INET6_ADDRSTRLEN); 295 address = GNUNET_malloc (INET6_ADDRSTRLEN);
342 t6 = addr; 296 inet_ntop (AF_INET6, &(a6->sin6_addr), address, INET6_ADDRSTRLEN);
343 a6.sin6_addr = t6->ipv6_addr; 297 port = ntohs (a6->sin6_port);
344 inet_ntop (AF_INET6, &(a6.sin6_addr), address, INET6_ADDRSTRLEN);
345 port = ntohs (t6->port);
346 } 298 }
347 else if (addrlen == sizeof (struct IPv4HttpAddress)) 299 else if (addrlen == sizeof (struct sockaddr_in))
348 { 300 {
301 a4 = (struct sockaddr_in *) addr;
349 address = GNUNET_malloc (INET_ADDRSTRLEN); 302 address = GNUNET_malloc (INET_ADDRSTRLEN);
350 t4 = addr; 303 inet_ntop (AF_INET, &(a4->sin_addr), address, INET_ADDRSTRLEN);
351 a4.sin_addr.s_addr = t4->ipv4_addr; 304 port = ntohs (a4->sin_port);
352 inet_ntop (AF_INET, &(a4.sin_addr), address, INET_ADDRSTRLEN);
353 port = ntohs (t4->port);
354 } 305 }
355 else 306 else
356 { 307 {
@@ -364,9 +315,9 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
364#endif 315#endif
365 316
366 GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13)); 317 GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13));
367 if (addrlen == sizeof (struct IPv6HttpAddress)) 318 if (addrlen == sizeof (struct sockaddr_in6))
368 res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port); 319 res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, address, port);
369 else if (addrlen == sizeof (struct IPv4HttpAddress)) 320 else if (addrlen == sizeof (struct sockaddr_in))
370 res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port); 321 res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, address, port);
371 322
372 GNUNET_free (address); 323 GNUNET_free (address);
@@ -392,11 +343,6 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
392 e_peer = GNUNET_NO; 343 e_peer = GNUNET_NO;
393 e_addr = GNUNET_NO; 344 e_addr = GNUNET_NO;
394 345
395#if DEBUG_HTTP
396 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
397 "Comparing session %X <-> %X\n", session, t);
398#endif
399
400 if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity))) 346 if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity)))
401 { 347 {
402 e_peer = GNUNET_YES; 348 e_peer = GNUNET_YES;
@@ -409,32 +355,16 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
409 } 355 }
410 if ((t == session)) 356 if ((t == session))
411 { 357 {
412#if DEBUG_HTTP
413 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
414 "Session %X: %s: \n", t, GNUNET_a2s (t->addr, t->addrlen));
415 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
416 "Session %X: %s: \n", session, GNUNET_a2s (session->addr, session->addrlen));
417
418#endif
419 if(t->addrlen == session->addrlen) 358 if(t->addrlen == session->addrlen)
420 { 359 {
421 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
422 "length ok\n");
423 if (0 == memcmp (session->addr, t->addr, t->addrlen)) 360 if (0 == memcmp (session->addr, t->addr, t->addrlen))
424 { 361 {
425 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
426 "equal\n");
427 e_addr = GNUNET_YES; 362 e_addr = GNUNET_YES;
428 } 363 }
429 } 364 }
430 } 365 }
431 } 366 }
432 367
433#if DEBUG_HTTP
434 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
435 "Session %X: E_PEER YES : %i E_ADDR: %i force %u: \n", t, e_peer, e_addr, force_address);
436#endif
437
438 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO)) 368 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO))
439 { 369 {
440 s = t; 370 s = t;
@@ -443,10 +373,6 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
443 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES)) 373 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES))
444 { 374 {
445 s = t; 375 s = t;
446#if DEBUG_HTTP
447 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
448 "Session %X: HERE!\n", t, e_addr, s);
449#endif
450 break; 376 break;
451 } 377 }
452 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR)) 378 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR))
@@ -557,7 +483,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
557#if DEBUG_HTTP 483#if DEBUG_HTTP
558 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 484 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
559 "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size, 485 "Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size,
560 GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), session, force_address); 486 GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, force_address);
561#endif 487#endif
562 488
563 struct Session *s = NULL; 489 struct Session *s = NULL;
@@ -613,7 +539,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
613 { 539 {
614#if DEBUG_HTTP 540#if DEBUG_HTTP
615 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 541 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
616 "Using client session to send to `%s'\n", 542 "Using outbound client session to send to `%s'\n",
617 GNUNET_i2s (target)); 543 GNUNET_i2s (target));
618#endif 544#endif
619 client_send (s, msg); 545 client_send (s, msg);
@@ -625,7 +551,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
625 res = msgbuf_size; 551 res = msgbuf_size;
626#if DEBUG_HTTP 552#if DEBUG_HTTP
627 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 553 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
628 "Using server session to send to `%s'\n", 554 "Using inbound server session to send to `%s'\n",
629 GNUNET_i2s (target)); 555 GNUNET_i2s (target));
630#endif 556#endif
631 557
@@ -670,9 +596,7 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
670 socklen_t addrlen) 596 socklen_t addrlen)
671{ 597{
672 struct Plugin *plugin = cls; 598 struct Plugin *plugin = cls;
673 struct IPv4HttpAddress *t4 = NULL;
674 struct IPv4HttpAddressWrapper *w_t4 = NULL; 599 struct IPv4HttpAddressWrapper *w_t4 = NULL;
675 struct IPv6HttpAddress *t6 = NULL;
676 struct IPv6HttpAddressWrapper *w_t6 = NULL; 600 struct IPv6HttpAddressWrapper *w_t6 = NULL;
677 int af; 601 int af;
678 602
@@ -683,9 +607,9 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
683 w_t4 = plugin->ipv4_addr_head; 607 w_t4 = plugin->ipv4_addr_head;
684 while (w_t4 != NULL) 608 while (w_t4 != NULL)
685 { 609 {
686 int res = memcmp (&w_t4->addr->ipv4_addr, 610 int res = memcmp (&w_t4->addr,
687 &((struct sockaddr_in *) addr)->sin_addr, 611 (struct sockaddr_in *) addr,
688 sizeof (struct in_addr)); 612 sizeof (struct sockaddr_in));
689 613
690 if (0 == res) 614 if (0 == res)
691 break; 615 break;
@@ -694,27 +618,27 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
694 if (w_t4 == NULL) 618 if (w_t4 == NULL)
695 { 619 {
696 w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); 620 w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper));
697 t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); 621 memcpy (&w_t4->addr, (struct sockaddr_in *) addr,
698 memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr, 622 sizeof (struct sockaddr_in));
699 sizeof (struct in_addr));
700 t4->port = htons (plugin->port);
701
702 w_t4->addr = t4;
703 623
704 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, 624 GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
705 plugin->ipv4_addr_tail, w_t4); 625 plugin->ipv4_addr_tail, w_t4);
706 } 626 }
707 plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, 627#if DEBUG_HTTP
708 sizeof (struct IPv4HttpAddress)); 628 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
629 "Notifying transport to add IPv4 address `%s'\n",
630 http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in)));
631#endif
632 plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, sizeof (struct sockaddr_in));
709 633
710 break; 634 break;
711 case AF_INET6: 635 case AF_INET6:
712 w_t6 = plugin->ipv6_addr_head; 636 w_t6 = plugin->ipv6_addr_head;
713 while (w_t6) 637 while (w_t6)
714 { 638 {
715 int res = memcmp (&w_t6->addr->ipv6_addr, 639 int res = memcmp (&w_t6->addr,
716 &((struct sockaddr_in6 *) addr)->sin6_addr, 640 (struct sockaddr_in6 *) addr,
717 sizeof (struct in6_addr)); 641 sizeof (struct sockaddr_in6));
718 642
719 if (0 == res) 643 if (0 == res)
720 break; 644 break;
@@ -723,19 +647,18 @@ nat_add_address (void *cls, int add_remove, const struct sockaddr *addr,
723 if (w_t6 == NULL) 647 if (w_t6 == NULL)
724 { 648 {
725 w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); 649 w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper));
726 t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); 650 memcpy (&w_t6->addr, (struct sockaddr_in6 *) addr,
727 651 sizeof (struct sockaddr_in6));
728 memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
729 sizeof (struct in6_addr));
730 t6->port = htons (plugin->port);
731
732 w_t6->addr = t6;
733 652
734 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, 653 GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head,
735 plugin->ipv6_addr_tail, w_t6); 654 plugin->ipv6_addr_tail, w_t6);
736 } 655 }
737 plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, 656#if DEBUG_HTTP
738 sizeof (struct IPv6HttpAddress)); 657 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
658 "Notifying transport to add IPv6 address `%s'\n",
659 http_plugin_address_to_string(NULL, &w_t6->addr, sizeof (struct sockaddr_in)));
660#endif
661 plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr, sizeof (struct sockaddr_in6));
739 break; 662 break;
740 default: 663 default:
741 return; 664 return;
@@ -759,7 +682,7 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
759 w_t4 = plugin->ipv4_addr_head; 682 w_t4 = plugin->ipv4_addr_head;
760 while (w_t4 != NULL) 683 while (w_t4 != NULL)
761 { 684 {
762 int res = memcmp (&w_t4->addr->ipv4_addr, 685 int res = memcmp (&(w_t4->addr.sin_addr),
763 &((struct sockaddr_in *) addr)->sin_addr, 686 &((struct sockaddr_in *) addr)->sin_addr,
764 sizeof (struct in_addr)); 687 sizeof (struct in_addr));
765 688
@@ -769,19 +692,24 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
769 } 692 }
770 if (w_t4 == NULL) 693 if (w_t4 == NULL)
771 return; 694 return;
772 plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, 695
773 sizeof (struct IPv4HttpAddress)); 696#if DEBUG_HTTP
697 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
698 "Notifying transport to remove IPv4 address `%s'\n",
699 http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in)));
700#endif
701 plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr,
702 sizeof (struct sockaddr_in));
774 703
775 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, 704 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail,
776 w_t4); 705 w_t4);
777 GNUNET_free (w_t4->addr);
778 GNUNET_free (w_t4); 706 GNUNET_free (w_t4);
779 break; 707 break;
780 case AF_INET6: 708 case AF_INET6:
781 w_t6 = plugin->ipv6_addr_head; 709 w_t6 = plugin->ipv6_addr_head;
782 while (w_t6 != NULL) 710 while (w_t6 != NULL)
783 { 711 {
784 int res = memcmp (&w_t6->addr->ipv6_addr, 712 int res = memcmp (&(w_t6->addr.sin6_addr),
785 &((struct sockaddr_in6 *) addr)->sin6_addr, 713 &((struct sockaddr_in6 *) addr)->sin6_addr,
786 sizeof (struct in6_addr)); 714 sizeof (struct in6_addr));
787 715
@@ -791,12 +719,16 @@ nat_remove_address (void *cls, int add_remove, const struct sockaddr *addr,
791 } 719 }
792 if (w_t6 == NULL) 720 if (w_t6 == NULL)
793 return; 721 return;
794 plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, 722#if DEBUG_HTTP
795 sizeof (struct IPv6HttpAddress)); 723 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
724 "Notifying transport to remove IPv6 address `%s'\n",
725 http_plugin_address_to_string(NULL, &w_t4->addr, sizeof (struct sockaddr_in)));
726#endif
727 plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr,
728 sizeof (struct sockaddr_in6 ));
796 729
797 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, 730 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail,
798 w_t6); 731 w_t6);
799 GNUNET_free (w_t6->addr);
800 GNUNET_free (w_t6); 732 GNUNET_free (w_t6);
801 break; 733 break;
802 default: 734 default:
@@ -820,7 +752,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr,
820{ 752{
821 GNUNET_assert (cls != NULL); 753 GNUNET_assert (cls != NULL);
822 struct Plugin *plugin = cls; 754 struct Plugin *plugin = cls;
823 static int limit; 755 //static int limit;
824#if DEBUG_HTTP 756#if DEBUG_HTTP
825 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 757 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
826 "NPMC called %s to address `%s'\n", 758 "NPMC called %s to address `%s'\n",
@@ -832,9 +764,9 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr,
832 { 764 {
833 case GNUNET_YES: 765 case GNUNET_YES:
834 // FIXME DEBUGGING 766 // FIXME DEBUGGING
835 if (limit < 1) 767 //if (limit < 1)
836 nat_add_address (cls, add_remove, addr, addrlen); 768 nat_add_address (cls, add_remove, addr, addrlen);
837 limit++; 769 //limit++;
838 // FIXME END 770 // FIXME END
839 break; 771 break;
840 case GNUNET_NO: 772 case GNUNET_NO:
@@ -895,7 +827,6 @@ stop_report_addresses (struct Plugin *plugin)
895 w_t4 = plugin->ipv4_addr_head; 827 w_t4 = plugin->ipv4_addr_head;
896 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, 828 GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail,
897 w_t4); 829 w_t4);
898 GNUNET_free (w_t4->addr);
899 GNUNET_free (w_t4); 830 GNUNET_free (w_t4);
900 } 831 }
901 832
@@ -904,7 +835,6 @@ stop_report_addresses (struct Plugin *plugin)
904 w_t6 = plugin->ipv6_addr_head; 835 w_t6 = plugin->ipv6_addr_head;
905 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, 836 GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail,
906 w_t6); 837 w_t6);
907 GNUNET_free (w_t6->addr);
908 GNUNET_free (w_t6); 838 GNUNET_free (w_t6);
909 } 839 }
910} 840}
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 7776f1655..fd5df5097 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -270,6 +270,7 @@ static ssize_t
270server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) 270server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
271{ 271{
272 struct Session *s = cls; 272 struct Session *s = cls;
273 struct Plugin *plugin = s->plugin;
273 struct HTTP_Message *msg; 274 struct HTTP_Message *msg;
274 int bytes_read = 0; 275 int bytes_read = 0;
275 //static int c = 0; 276 //static int c = 0;
@@ -301,8 +302,9 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
301 } 302 }
302 303
303#if VERBOSE_CLIENT 304#if VERBOSE_CLIENT
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u bytes\n", 305 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
305 s, bytes_read); 306 "Server: %X: sent %u bytes\n",
307 s, bytes_read);
306#endif 308#endif
307 return bytes_read; 309 return bytes_read;
308} 310}
@@ -372,7 +374,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
372 plugin->cur_connections++; 374 plugin->cur_connections++;
373 375
374#if VERBOSE_SERVER 376#if VERBOSE_SERVER
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag); 377 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
378 "Server: New inbound connection from %s with tag %u\n", GNUNET_i2s(&target), tag);
376#endif 379#endif
377 /* find duplicate session */ 380 /* find duplicate session */
378 381
@@ -389,7 +392,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
389 if (t != NULL) 392 if (t != NULL)
390 { 393 {
391#if VERBOSE_SERVER 394#if VERBOSE_SERVER
392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); 395 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
396 "Server: Duplicate session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
393#endif 397#endif
394 goto error; 398 goto error;
395 } 399 }
@@ -412,13 +416,15 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
412 goto create; 416 goto create;
413 417
414#if VERBOSE_SERVER 418#if VERBOSE_SERVER
415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target)); 419 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
420 "Server: Found existing semi-session for `%s'\n", GNUNET_i2s (&target));
416#endif 421#endif
417 422
418 if ((direction == _SEND) && (t->server_send != NULL)) 423 if ((direction == _SEND) && (t->server_send != NULL))
419 { 424 {
420#if VERBOSE_SERVER 425#if VERBOSE_SERVER
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); 426 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
427 "Server: Duplicate GET session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
422#endif 428#endif
423 goto error; 429 goto error;
424 } 430 }
@@ -428,7 +434,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
428 GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); 434 GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s);
429 GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); 435 GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
430#if VERBOSE_SERVER 436#if VERBOSE_SERVER
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); 437 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
438 "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
432#endif 439#endif
433 440
434 goto found; 441 goto found;
@@ -436,7 +443,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
436 if ((direction == _RECEIVE) && (t->server_recv != NULL)) 443 if ((direction == _RECEIVE) && (t->server_recv != NULL))
437 { 444 {
438#if VERBOSE_SERVER 445#if VERBOSE_SERVER
439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target)); 446 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
447 "Server: Duplicate PUT session, dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
440#endif 448#endif
441 goto error; 449 goto error;
442 } 450 }
@@ -446,7 +454,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
446 GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s); 454 GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, plugin->server_semi_tail, s);
447 GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s); 455 GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
448#if VERBOSE_SERVER 456#if VERBOSE_SERVER
449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target)); 457 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
458 "Server: Found matching semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
450#endif 459#endif
451 goto found; 460 goto found;
452 } 461 }
@@ -454,10 +463,11 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection,
454create: 463create:
455/* create new session */ 464/* create new session */
456#if VERBOSE_SERVER 465#if VERBOSE_SERVER
457 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target)); 466 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
467 "Server: Creating new session for peer `%s' \n", GNUNET_i2s (&target));
458#endif 468#endif
459 469
460 s = create_session(plugin, 470 s = create_session (plugin,
461 &target, 471 &target,
462 conn_info->client_addr, 472 conn_info->client_addr,
463 addrlen, 473 addrlen,
@@ -474,7 +484,10 @@ create:
474 484
475 goto found; 485 goto found;
476error: 486error:
477 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Invalid connection request\n"); 487#if VERBOSE_SERVER
488 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
489 "Server: Invalid connection request\n");
490#endif
478 response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); 491 response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
479 res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); 492 res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response);
480 MHD_destroy_response (response); 493 MHD_destroy_response (response);
@@ -490,8 +503,11 @@ found:
490 s->server_recv = sc; 503 s->server_recv = sc;
491 504
492 int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); 505 int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000);
493 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Setting Timeout to %u\n", to); 506#if VERBOSE_SERVER
494 //MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); 507 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
508 "Server: Setting Timeout to %u\n", to);
509#endif
510 MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to);
495 511
496 (*httpSessionCache) = sc; 512 (*httpSessionCache) = sc;
497 } 513 }
@@ -529,7 +545,7 @@ found:
529 { 545 {
530#if VERBOSE_SERVER 546#if VERBOSE_SERVER
531 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 547 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
532 "Server: peer `%s' PUT on address `%s' connected\n", 548 "Server: Peer `%s' PUT on address `%s' connected\n",
533 GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen)); 549 GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
534#endif 550#endif
535 return MHD_YES; 551 return MHD_YES;
@@ -545,17 +561,18 @@ found:
545#endif 561#endif
546 if ((GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)) 562 if ((GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value))
547 { 563 {
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 564#if VERBOSE_SERVER
549 "Connection %X: PUT with %u bytes forwarded to MST\n", s, 565 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
566 "Server: %X: PUT with %u bytes forwarded to MST\n", s,
550 *upload_data_size); 567 *upload_data_size);
551 568#endif
552 if (s->msg_tk == NULL) 569 if (s->msg_tk == NULL)
553 { 570 {
554 s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s); 571 s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s);
555 } 572 }
556 res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO); 573 res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO);
557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 574 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
558 "Server: Received %Zu bytes\n", 575 "Server: Received %Zu bytes\n",
559 *upload_data_size); 576 *upload_data_size);
560 (*upload_data_size) = 0; 577 (*upload_data_size) = 0;
561 } 578 }
@@ -652,7 +669,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
652 t = t->next; 669 t = t->next;
653 } 670 }
654 plugin->cur_connections--; 671 plugin->cur_connections--;
655 672/*
656 if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK) 673 if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK)
657 { 674 {
658 GNUNET_SCHEDULER_cancel(plugin->server_v4_task); 675 GNUNET_SCHEDULER_cancel(plugin->server_v4_task);
@@ -666,7 +683,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
666 plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; 683 plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
667 } 684 }
668 plugin->server_v6_task = server_schedule (plugin, plugin->server_v6); 685 plugin->server_v6_task = server_schedule (plugin, plugin->server_v6);
669 686*/
670 if ((s->server_send == NULL) && (s->server_recv == NULL)) 687 if ((s->server_send == NULL) && (s->server_recv == NULL))
671 { 688 {
672#if VERBOSE_SERVER 689#if VERBOSE_SERVER