[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16386 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16386 - gnunet/src/transport |
Date: |
Fri, 5 Aug 2011 10:37:59 +0200 |
Author: grothoff
Date: 2011-08-05 10:37:59 +0200 (Fri, 05 Aug 2011)
New Revision: 16386
Modified:
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/transport.h
gnunet/src/transport/transport_api_address_lookup.c
Log:
use relative timeouts over network
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2011-08-05 08:27:50 UTC
(rev 16385)
+++ gnunet/src/transport/gnunet-service-transport.c 2011-08-05 08:37:59 UTC
(rev 16386)
@@ -5870,6 +5870,8 @@
}
else
{
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
}
}
@@ -5893,7 +5895,6 @@
const char *address;
uint16_t size;
struct GNUNET_SERVER_TransmitContext *tc;
- struct GNUNET_TIME_Absolute timeout;
struct GNUNET_TIME_Relative rtimeout;
int32_t numeric;
@@ -5921,8 +5922,7 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- timeout = GNUNET_TIME_absolute_ntoh (alum->timeout);
- rtimeout = GNUNET_TIME_absolute_get_remaining (timeout);
+ rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
numeric = ntohl (alum->numeric_only);
lsPlugin = find_transport (nameTransport);
if (NULL == lsPlugin)
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2011-08-05
08:27:50 UTC (rev 16385)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2011-08-05
08:37:59 UTC (rev 16386)
@@ -27,6 +27,7 @@
#include "gnunet-service-transport_clients.h"
#include "gnunet-service-transport_hello.h"
#include "gnunet-service-transport_neighbours.h"
+#include "gnunet-service-transport_plugins.h"
#include "gnunet-service-transport.h"
#include "transport.h"
@@ -473,6 +474,33 @@
/**
+ * Take the given address and append it to the set of results sent back to
+ * the client.
+ *
+ * @param cls the transmission context used ('struct
GNUNET_SERVER_TransmitContext*')
+ * @param address the resolved name, NULL to indicate the last response
+ */
+static void
+transmit_address_to_client (void *cls,
+ const char *address)
+{
+ struct GNUNET_SERVER_TransmitContext *tc = cls;
+
+ if (NULL == address)
+ {
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
+ GNUNET_SERVER_transmit_context_run (tc,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ return;
+ }
+ GNUNET_SERVER_transmit_context_append_data (tc,
+ address, strlen (address) + 1,
+
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
+}
+
+
+/**
* Client asked to resolve an address. Process the request.
*
* @param cls unused
@@ -484,6 +512,59 @@
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
+ const struct AddressLookupMessage *alum;
+ struct GNUNET_TRANSPORT_PluginFunctions *papi;
+ const char *plugin_name;
+ const char *address;
+ uint32_t address_len;
+ uint16_t size;
+ struct GNUNET_SERVER_TransmitContext *tc;
+ struct GNUNET_TIME_Relative rtimeout;
+ int32_t numeric;
+
+ size = ntohs (message->size);
+ if (size < sizeof (struct AddressLookupMessage))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ alum = (const struct AddressLookupMessage *) message;
+ address_len = ntohl (alum->addrlen);
+ if (size <= sizeof (struct AddressLookupMessage) + address_len)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ address = (const char *) &alum[1];
+ plugin_name = (const char *) &address[address_len];
+ if (plugin_name
+ [size - sizeof (struct AddressLookupMessage) - address_len - 1] != '\0')
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
+ numeric = ntohl (alum->numeric_only);
+ papi = GST_plugins_find (plugin_name);
+ if (NULL == papi)
+ {
+ tc = GNUNET_SERVER_transmit_context_create (client);
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
+ GNUNET_SERVER_transmit_context_run (tc, rtimeout);
+ return;
+ }
+ GNUNET_SERVER_disable_receive_done_warning (client);
+ tc = GNUNET_SERVER_transmit_context_create (client);
+ papi->address_pretty_printer (papi->cls,
+ plugin_name,
+ address, address_len,
+ numeric,
+ rtimeout,
+ &transmit_address_to_client, tc);
}
Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h 2011-08-05 08:27:50 UTC (rev 16385)
+++ gnunet/src/transport/transport.h 2011-08-05 08:37:59 UTC (rev 16386)
@@ -165,8 +165,8 @@
};
/**
- * Message used to set a particular bandwidth quota. Send TO the
- * service to set an incoming quota, send FROM the service to update
+ * Message used to set a particular bandwidth quota. Sent TO the
+ * service to set an incoming quota, sent FROM the service to update
* an outgoing quota.
*/
struct QuotaSetMessage
@@ -311,7 +311,7 @@
/**
* timeout to give up.
*/
- struct GNUNET_TIME_AbsoluteNBO timeout;
+ struct GNUNET_TIME_RelativeNBO timeout;
/**
* Length of the (binary) address in bytes, in big-endian.
Modified: gnunet/src/transport/transport_api_address_lookup.c
===================================================================
--- gnunet/src/transport/transport_api_address_lookup.c 2011-08-05 08:27:50 UTC
(rev 16385)
+++ gnunet/src/transport/transport_api_address_lookup.c 2011-08-05 08:37:59 UTC
(rev 16386)
@@ -131,7 +131,6 @@
size_t slen;
size_t len;
struct AddressLookupMessage *msg;
- struct GNUNET_TIME_Absolute abs_timeout;
struct AddressLookupCtx *aluCB;
struct GNUNET_CLIENT_Connection *client;
char *addrbuf;
@@ -150,12 +149,11 @@
aluc (aluc_cls, NULL);
return;
}
- abs_timeout = GNUNET_TIME_relative_to_absolute (timeout);
msg = GNUNET_malloc (len);
msg->header.size = htons (len);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP);
msg->numeric_only = htonl (numeric);
- msg->timeout = GNUNET_TIME_absolute_hton (abs_timeout);
+ msg->timeout = GNUNET_TIME_relative_hton (timeout);
msg->addrlen = htonl (addressLen);
addrbuf = (char *) &msg[1];
memcpy (addrbuf, address, addressLen);
@@ -163,7 +161,7 @@
aluCB = GNUNET_malloc (sizeof (struct AddressLookupCtx));
aluCB->cb = aluc;
aluCB->cb_cls = aluc_cls;
- aluCB->timeout = abs_timeout;
+ aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout);
aluCB->client = client;
GNUNET_assert (GNUNET_OK ==
GNUNET_CLIENT_transmit_and_get_response (client,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16386 - gnunet/src/transport,
gnunet <=