#define DEBUG_DV_GOSSIP GNUNET_NO
#define DEBUG_DV_GOSSIP_SEND GNUNET_NO
#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO
-#define DEBUG_DV_MESSAGES GNUNET_YES
+#define DEBUG_DV_MESSAGES GNUNET_NO
#define DEBUG_DV GNUNET_NO
#define DEBUG_DV_PEER_NUMBERS GNUNET_NO
#define DEBUG_MESSAGE_DROP GNUNET_NO
*/
struct GNUNET_PeerIdentity target;
- /**
- * The size of the msgbuf
- */
- uint32_t msgbuf_size;
-
/**
* Message priority
*/
GNUNET_DV_MessageReceivedHandler receive_handler,
void *receive_handler_cls);
+/**
+ * Disconnect from the DV service
+ *
+ * @param handle the current handle to the service to disconnect
+ */
+void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);
+
#endif
#include "dv.h"
#include "../transport/plugin_transport.h"
-
+/**
+ * Store ready to send messages
+ */
struct PendingMessages
{
/**
};
-
-
/**
* Handle for the service.
*/
*/
struct PendingMessages *current;
- /**
- * Kill off the connection and any pending messages.
- */
- int do_destroy;
-
/**
* Handler for messages we receive from the DV service
*/
/**
* Try to (re)connect to the dv service.
*
+ * @param ret handle to the (disconnected) dv service
+ *
* @return GNUNET_YES on success, GNUNET_NO on failure.
*/
static int
/**
* Send complete, schedule next
+ *
+ * @param handle handle to the dv service
+ * @param code return code for send (unused)
*/
static void
finish (struct GNUNET_DV_Handle *handle, int code)
GNUNET_free (pos);
}
-
+/**
+ * Notification that we can send data
+ *
+ * @param cls handle to the dv service (struct GNUNET_DV_Handle)
+ * @param size how many bytes can we send
+ * @buf where to copy the message to send
+ *
+ * @return how many bytes we copied to buf
+ */
static size_t
transmit_pending (void *cls, size_t size, void *buf)
{
/**
* Try to send messages from list of messages to send
+ *
+ * @param handle handle to the distance vector service
*/
static void process_pending_message(struct GNUNET_DV_Handle *handle)
{
handle->current = handle->pending_list;
if (NULL == handle->current)
{
- if (handle->do_destroy)
- {
- handle->do_destroy = GNUNET_NO;
- //GNUNET_DV_disconnect (handle); /* FIXME: replace with proper disconnect stuffs */
- }
return;
}
handle->pending_list = handle->pending_list->next;
if (NULL ==
(handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client,
- ntohl(handle->current->msg->msgbuf_size),
- handle->current->msg->timeout,
- GNUNET_YES,
- &transmit_pending, handle)))
+ ntohs(handle->current->msg->header.size),
+ handle->current->msg->timeout,
+ GNUNET_YES,
+ &transmit_pending, handle)))
{
#if DEBUG_DV
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
msg->header.size = htons(msize);
msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
- msg->msgbuf_size = htonl(msgbuf_size);
msg->priority = htonl(priority);
msg->timeout = timeout;
msg->addrlen = htonl(addrlen);
return GNUNET_OK;
}
-/* Forward declaration */
-void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);
-
+/**
+ * Callback to transmit a start message to
+ * the DV service, once we can send
+ *
+ * @param cls struct StartContext
+ * @param size how much can we send
+ * @param buf where to copy the message
+ *
+ * @return number of bytes copied to buf
+ */
static size_t
transmit_start (void *cls, size_t size, void *buf)
{
handle->sched = sched;
handle->pending_list = NULL;
handle->current = NULL;
- handle->do_destroy = GNUNET_NO;
handle->th = NULL;
handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg);
handle->receive_handler = receive_handler;
/**
* Stream tokenizer to handle messages coming in from core.
*/
-struct GNUNET_SERVER_MessageStreamTokenizer *coreMST;
+static struct GNUNET_SERVER_MessageStreamTokenizer *coreMST;
/**
* The identity of our peer.
address_len = ntohl(send_msg->addrlen);
GNUNET_assert(address_len == sizeof(struct GNUNET_PeerIdentity) * 2);
- message_size = ntohl(send_msg->msgbuf_size);
-
- GNUNET_assert(ntohs(message->size) == sizeof(struct GNUNET_DV_SendMessage) + address_len + message_size);
+ message_size = ntohs(message->size) - sizeof(struct GNUNET_DV_SendMessage) - address_len;
destination = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
direct = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
message_buf = GNUNET_malloc(message_size);
* @file dv/plugin_transport_dv.c
* @brief DV transport service, takes incoming DV requests and deals with
* the DV service
+ * @author Nathan Evans
* @author Christian Grothoff
*/
-/**
- * TODO:
- *
- * As a start, the dv plugin needs to listen for information from the dv
- * service. The plugin (?) will be notified by core (?) when a tcp/udp/whatever
- * message comes in that should be for dv. The plugin will then hand off the message
- * to the dv service which will decrypt/validate the message (?) and then send the
- * result back to us (the transport) which will then send the message to the transport
- * service (yikes).
- *
- * Or, core will notify the dv service directly which will validate,
- * etc. and then just send a message to us.
- *
- * For starters, this plugin needs to have a client which will listen for messages from
- * the dv service that need to be sent up to the gnunet-transport-service.
- *
- * Messages sent from the dv transport get passed to the dv service which deals
- * with the actual sending (how much state does this transport need? should it know
- * which peers it is currently connected to and their distances, or just assume that
- * anything should be passed along to the dv service?).
- */
#include "platform.h"
#include "gnunet_protocols.h"
#include "gnunet_connection_lib.h"
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
+ if (plugin->dv_handle != NULL)
+ GNUNET_DV_disconnect(plugin->dv_handle);
+
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
if ((total_messages_received == expected_messages) && (total_other_messages == 0))
{
GNUNET_SCHEDULER_cancel (sched, die_task);
- GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 420), &send_other_messages, NULL);
+ /*
+ if ((num_peers == 3) && (total_other_expected_messages == 2))
+ {
+ GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
+ }
+ else
+ {
+ GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
+ }*/
}
else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages))
{
fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname);
}
GNUNET_free(second_shortname);
+
+ if ((num_peers == 3) && (temp_total_other_messages == 2))
+ {
+ /*GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30), &send_other_messages, NULL);*/
+ GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
+ }
}
static void
#endif
NULL);
ret = check ();
-
/**
* Need to remove base directory, subdirectories taken care
* of by the testing framework.
PORT = 2565
PLUGINS = tcp dv
BLACKLIST_FILE = $SERVICEHOME/blacklist
-#PREFIX = xterm -e xterm -T transport -e gdb --args
-#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
-#PREFIX = valgrind --tool=memcheck --log-file=logs%p
+#PREFIX = xterm -hold -T transport -e gdb --args
+#PREFIX = gdb --args
+BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
+#BINARY = gnunet-service-transport
+PREFIX = valgrind --tool=memcheck --log-file=logs%p --track-origins=yes
#DEBUG = YES
[arm]
PORT = 2566
-DEFAULTSERVICES =
+DEFAULTSERVICES = transport
[statistics]
PORT = 2567
[dv]
AUTOSTART = YES
-DEBUG = YES
+DEBUG = NO
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
BINARY = gnunet-service-dv
[testing]
NUM_PEERS = 3
-DEBUG = YES
+DEBUG = NO
WEAKRANDOM = YES
TOPOLOGY = CLIQUE
CONNECT_TOPOLOGY = LINE