#define DEBUG_PING_PONG GNUNET_NO
-#define DEBUG_TRANSPORT_HELLO GNUNET_NO
+#define DEBUG_TRANSPORT_HELLO GNUNET_YES
/**
* Should we do some additional checks (to validate behavior
fal = find_peer_address (n, tname, NULL, addr, addrlen);
if (fal == NULL)
{
-#if DEBUG_TRANSPORT
+#if DEBUG_TRANSPORT_HELLO
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n",
a2s (tname, addr, addrlen),
}
if (fal == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to add new address for `%4s'\n",
GNUNET_i2s (&n->id));
return GNUNET_OK;
n = find_neighbour(peer);
if (n != NULL)
{
- cont (cont_cls, n);
+ if (cont != NULL)
+ cont (cont_cls, n);
return;
}
if (bl_head == NULL)
{
- cont (cont_cls,
- setup_new_neighbour (peer, do_hello));
+ if (cont != NULL)
+ cont (cont_cls, setup_new_neighbour (peer, do_hello));
+ else
+ setup_new_neighbour(peer, do_hello);
return;
}
bc = GNUNET_malloc (sizeof (struct BlacklistCheck));
}
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received message of type %u and size %u from `%4s', sending to all clients.\n",
ntohs (message->type),
ntohs (message->size),
NULL);
GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
GNUNET_free (plain_hello);
-#if DEBUG_TRANSPORT
+#if DEBUG_TRANSPORT_HELLO
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PEERINFO had no `%s' message for peer `%4s', full validation needed.\n",
"HELLO",
}
if (h == NULL)
return;
-#if DEBUG_TRANSPORT
+#if DEBUG_TRANSPORT_HELLO
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PEERINFO had `%s' message for peer `%4s', validating only new addresses.\n",
"HELLO",
n = find_neighbour (peer);
if (n != NULL)
{
+#if DEBUG_TRANSPORT_HELLO
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Calling hello_iterate_addresses for %s!\n",
+ GNUNET_i2s (peer));
+#endif
GNUNET_HELLO_iterate_addresses (h,
GNUNET_NO,
&add_to_foreign_address_list,
}
else
{
+#if DEBUG_TRANSPORT_HELLO
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No existing neighbor record for %s!\n",
+ GNUNET_i2s (peer));
+#endif
GNUNET_STATISTICS_update (stats,
gettext_noop ("# no existing neighbour record (validating HELLO)"),
1,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
&target.hashPubKey);
+#if DEBUG_TRANSPORT_HELLO
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message for `%4s'\n",
+ "HELLO",
+ GNUNET_i2s (&target));
+#endif
+
if (0 == memcmp (&my_identity,
&target,
sizeof (struct GNUNET_PeerIdentity)))
obm = (const struct OutboundMessage *) message;
obmm = (const struct GNUNET_MessageHeader *) &obm[1];
msize = size - sizeof (struct OutboundMessage);
-#if DEBUG_TRANSPORT
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' request from client with target `%4s' and message of type %u and size %u\n",
"SEND", GNUNET_i2s (&obm->peer),
ntohs (obmm->type),
msize);
-#endif
+
tcmc = GNUNET_malloc (sizeof (struct TransmitClientMessageContext) + msize);
tcmc->client = client;
tcmc->priority = ntohl (obm->priority);
}
+/**
+ * Handle request connect message
+ *
+ * @param cls closure (always NULL)
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void
+handle_request_connect (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct TransportRequestConnectMessage *trcm =
+ (const struct TransportRequestConnectMessage *) message;
+
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# REQUEST CONNECT messages received"),
+ 1,
+ GNUNET_NO);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received a request connect message for peer %s\n", GNUNET_i2s(&trcm->peer));
+ setup_peer_check_blacklist (&trcm->peer, GNUNET_YES,
+ NULL, NULL);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
/**
* Handle SET_QUOTA-message.
*
GNUNET_MESSAGE_TYPE_HELLO, 0},
{&handle_send, NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0},
+ {&handle_request_connect, NULL,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT, sizeof(struct TransportRequestConnectMessage)},
{&handle_set_quota, NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA, sizeof (struct QuotaSetMessage)},
{&handle_address_lookup, NULL,
next = n->next;
if (n->transmit_stage != TS_QUEUED)
continue; /* not eligible */
+ if (n->is_connected != GNUNET_YES)
+ continue;
+
th = &n->transmit_handle;
GNUNET_break (n == th->neighbour);
/* check outgoing quota */
th->notify_size - sizeof (struct OutboundMessage),
GNUNET_i2s (&n->id));
#endif
+
if ( (ret == NULL) ||
(ret->priority < th->priority) )
ret = th;
return;
if (h->client == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Could not yet schedule transmission: we are not yet connected to the transport service!\n"));
return; /* not yet connected */
}
size = th->notify_size;
timeout = GNUNET_TIME_absolute_get_remaining (th->timeout);
}
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Calling notify_transmit_ready\n");
+#endif
h->network_handle =
GNUNET_CLIENT_notify_transmit_ready (h->client,
size,
if (buf == NULL)
{
#if DEBUG_TRANSPORT_TIMEOUT
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Timeout while trying to transmit `%s' request.\n",
"HELLO");
#endif
}
+/**
+ * Send request connect message to the service.
+ *
+ * @param cls the TransportRequestConnectMessage
+ * @param size number of bytes available in buf
+ * @param buf where to copy the message
+ * @return number of bytes copied to buf
+ */
+static size_t
+send_transport_request_connect (void *cls, size_t size, void *buf)
+{
+ struct TransportRequestConnectMessage *trcm = cls;
+
+ if (buf == NULL)
+ {
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Buffer null for %s\n",
+ "REQUEST_CONNECT");
+#endif
+ GNUNET_free (trcm);
+ return 0;
+ }
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting `%s' request for `%4s'.\n",
+ "REQUEST_CONNECT",
+ GNUNET_i2s (&trcm->peer));
+#endif
+ GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
+ memcpy(buf, trcm, sizeof(struct TransportRequestConnectMessage));
+ return sizeof(struct TransportRequestConnectMessage);
+}
+
/**
* Add neighbour to our list
*
const struct GNUNET_PeerIdentity *pid)
{
struct NeighbourList *n;
+ struct TransportRequestConnectMessage *trcm;
if (GNUNET_YES == h->in_disconnect)
return NULL;
n->next = h->neighbours;
n->h = h;
h->neighbours = n;
+
+ trcm = GNUNET_malloc(sizeof(struct TransportRequestConnectMessage));
+ trcm->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
+ trcm->header.size = htons(sizeof(struct TransportRequestConnectMessage));
+ memcpy(&trcm->peer, pid, sizeof(struct GNUNET_PeerIdentity));
+ schedule_control_transmit (h,
+ sizeof (struct TransportRequestConnectMessage),
+ GNUNET_NO,
+ GNUNET_TIME_UNIT_FOREVER_REL, &send_transport_request_connect, trcm);
return n;
}
th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
n = th->neighbour;
#if DEBUG_TRANSPORT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Triggering timeout for request to transmit to `%4s' (%d)\n",
GNUNET_i2s (&n->id),
n->transmit_stage);
GNUNET_break (0);
return NULL;
}
-#if DEBUG_TRANSPORT
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking transport service for transmission of %u bytes to peer `%4s' within %llu ms.\n",
size, GNUNET_i2s (target),
(unsigned long long) timeout.value);
-#endif
+
n = neighbour_find (handle, target);
if (n == NULL)
- n = neighbour_add (handle, target);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created neighbour entry for peer `%s'\n",
+ GNUNET_i2s (target));
+ n = neighbour_add (handle, target);
+
+ }
if (n == NULL)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Could not create neighbour entry for peer `%s'\n",
GNUNET_i2s (target));
return NULL;