aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_http_new.c')
-rw-r--r--src/transport/plugin_transport_http_new.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_http_new.c b/src/transport/plugin_transport_http_new.c
index 719182cc0..48477b809 100644
--- a/src/transport/plugin_transport_http_new.c
+++ b/src/transport/plugin_transport_http_new.c
@@ -292,6 +292,27 @@ http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
292 return GNUNET_SYSERR; 292 return GNUNET_SYSERR;
293} 293}
294 294
295struct GNUNET_TIME_Relative
296http_plugin_receive (void *cls, const struct GNUNET_PeerIdentity * peer,
297 const struct GNUNET_MessageHeader * message,
298 struct Session * session,
299 const char *sender_address,
300 uint16_t sender_address_len)
301{
302 struct Session *s = cls;
303 struct Plugin *plugin = s->plugin;
304 struct GNUNET_TRANSPORT_ATS_Information distance[2];
305 struct GNUNET_TIME_Relative delay;
306
307 distance[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
308 distance[0].value = htonl (1);
309 distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
310 distance[1].value = htonl (0);
311
312 delay = plugin->env->receive (plugin->env->cls, &s->target, message, (const struct GNUNET_TRANSPORT_ATS_Information*) &distance, 2, s, s->addr, s->addrlen);
313 return delay;
314}
315
295/** 316/**
296 * Function called for a quick conversion of the binary address to 317 * Function called for a quick conversion of the binary address to
297 * a numeric address. Note that the caller must not free the 318 * a numeric address. Note that the caller must not free the
@@ -425,7 +446,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
425 s->transmit_cont = cont; 446 s->transmit_cont = cont;
426 s->transmit_cont_cls = cont_cls; 447 s->transmit_cont_cls = cont_cls;
427 s->next = NULL; 448 s->next = NULL;
428 449 s->delay = GNUNET_TIME_absolute_get_forever();
429 return s; 450 return s;
430} 451}
431 452
@@ -486,7 +507,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
486 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 507 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
487{ 508{
488 struct Plugin *plugin = cls; 509 struct Plugin *plugin = cls;
489 510 struct HTTP_Message *msg;
490 GNUNET_assert (plugin != NULL); 511 GNUNET_assert (plugin != NULL);
491 512
492 int res = GNUNET_SYSERR; 513 int res = GNUNET_SYSERR;
@@ -529,10 +550,20 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
529 return GNUNET_SYSERR; 550 return GNUNET_SYSERR;
530 } 551 }
531 } 552 }
532 else if (s->inbound == GNUNET_NO) 553
533 res = client_send (s, msgbuf, msgbuf_size); 554 msg = GNUNET_malloc (sizeof (struct HTTP_Message) + msgbuf_size);
534 else if (s->inbound == GNUNET_YES) 555 msg->next = NULL;
535 res = server_send (s, msgbuf, msgbuf_size); 556 msg->size = msgbuf_size;
557 msg->pos = 0;
558 msg->buf = (char *) &msg[1];
559 msg->transmit_cont = cont;
560 msg->transmit_cont_cls = cont_cls;
561 memcpy (msg->buf, msgbuf, msgbuf_size);
562
563 if (s->inbound == GNUNET_NO)
564 res = client_send (s, msg);
565 if (s->inbound == GNUNET_YES)
566 res = server_send (s, msg);
536 567
537 return res; 568 return res;
538} 569}