new_match = GSC_TYPEMAP_test_match (tmap_new,
client->types,
client->tcnt);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying client about neighbour %s (%d/%d)\n",
+ GNUNET_i2s (neighbour),
+ old_match,
+ new_match);
if (old_match == new_match)
{
GNUNET_assert (old_match ==
GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->reserved = htonl (0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending NOTIFY_CONNECT message to client.\n");
+ "Sending NOTIFY_CONNECT message about peer %s to client.\n",
+ GNUNET_i2s (neighbour));
cnm->peer = *neighbour;
GNUNET_MQ_send (client->mq,
env);
env = GNUNET_MQ_msg (dcm,
GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
dcm->reserved = htonl (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending NOTIFY_DISCONNECT message about peer %s to client.\n",
+ GNUNET_i2s (neighbour));
dcm->peer = *neighbour;
GNUNET_MQ_send (client->mq,
env);
* Message queue for sending messages to @a peer.
*/
struct GNUNET_MQ_Handle *mq;
-
+
/**
* PING message we transmit to the other peer.
*/
void *handler_cls)
{
struct GSC_KeyExchangeInfo *kx = handler_cls;
-
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected from us.\n",
GNUNET_i2s (peer));
send_ping (struct GSC_KeyExchangeInfo *kx)
{
struct GNUNET_MQ_Envelope *env;
-
+
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# PING messages transmitted"),
1,
send_key (struct GSC_KeyExchangeInfo *kx)
{
struct GNUNET_MQ_Envelope *env;
-
+
GNUNET_assert (GNUNET_CORE_KX_STATE_DOWN != kx->status);
if (NULL != kx->retry_set_key_task)
{
sizeof (struct GNUNET_HashCode)))
{
/* checksum failed */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed checksum validation for a message from `%s'\n",
GNUNET_i2s (kx->peer));
return;
&m->sequence_number,
&buf[ENCRYPTED_HEADER_SIZE],
size - ENCRYPTED_HEADER_SIZE))
+ {
+ GNUNET_break_op (0);
return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted %u bytes from %s\n",
(unsigned int) (size - ENCRYPTED_HEADER_SIZE),
const struct GNUNET_PeerIdentity *pid,
void *connect_cls)
{
- struct GSC_KeyExchangeInfo *kx = connect_cls;
+ struct GSC_KeyExchangeInfo *kx = connect_cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s has excess bandwidth available\n",
{
struct DeliverMessageContext *dmc = client;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Decrypted message of type %d from %s\n",
+ ntohs (m->type),
+ GNUNET_i2s (dmc->peer));
if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status)
{
GNUNET_STATISTICS_update (GSC_stats,
NULL);
mst = GNUNET_SERVER_mst_create (&deliver_message,
NULL);
- transport
+ transport
= GNUNET_TRANSPORT_core_connect (GSC_cfg,
&GSC_my_identity,
handlers,
{
struct GNUNET_MQ_Envelope *env;
struct MonitorNotifyMessage *msg;
-
+
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY);
msg->state = htonl ((uint32_t) kx->status);
*/
struct SessionMessageEntry *prev;
+ /**
+ * How important is this message.
+ */
+ enum GNUNET_CORE_Priority priority;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap message.
+ */
+ int is_typemap;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap confirmation message.
+ */
+ int is_typemap_confirm;
+
/**
* Deadline for transmission, 1s after we received it (if we
* are not corking), otherwise "now". Note that this message
*/
size_t size;
- /**
- * How important is this message.
- */
- enum GNUNET_CORE_Priority priority;
-
};
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TIME_Relative delay;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
session->typemap_delay = GNUNET_TIME_STD_BACKOFF (session->typemap_delay);
delay = session->typemap_delay;
/* randomize a bit to avoid spont. sync */
delay.rel_value_us +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay,
- &transmit_typemap_task, session);
+ &transmit_typemap_task,
+ session);
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# type map refreshes sent"),
1,
struct Session *session;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating session for peer `%4s'\n",
+ "Creating session for peer `%s'\n",
GNUNET_i2s (peer));
session = GNUNET_new (struct Session);
session->tmap = GSC_TYPEMAP_create ();
gettext_noop
("# outdated typemap confirmations received"),
1, GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got outdated typemap confirmated from peer `%s'\n",
+ GNUNET_i2s (session->peer));
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got typemap confirmation from peer `%s'\n",
+ GNUNET_i2s (session->peer));
if (NULL != session->typemap_task)
{
GNUNET_SCHEDULER_cancel (session->typemap_task);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received client transmission request. queueing\n");
- GNUNET_CONTAINER_DLL_insert (session->active_client_request_head,
- session->active_client_request_tail,
- car);
+ GNUNET_CONTAINER_DLL_insert_tail (session->active_client_request_head,
+ session->active_client_request_tail,
+ car);
try_transmission (session);
}
while ( (NULL != (pos = session->sme_head)) &&
(used + pos->size <= msize) )
{
- GNUNET_memcpy (&pbuf[used], &pos[1], pos->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding message of type %d (%d/%d) to payload for %s\n",
+ ntohs (((const struct GNUNET_MessageHeader *)&pos[1])->type),
+ pos->is_typemap,
+ pos->is_typemap_confirm,
+ GNUNET_i2s (session->peer));
+ GNUNET_memcpy (&pbuf[used],
+ &pos[1],
+ pos->size);
used += pos->size;
GNUNET_CONTAINER_DLL_remove (session->sme_head,
session->sme_tail,
struct SessionMessageEntry *sme;
uint16_t size;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarting sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
size = ntohs (hdr->size);
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
+ sme->is_typemap = GNUNET_YES;
GNUNET_memcpy (&sme[1],
hdr,
size);
nmap = GSC_TYPEMAP_get_from_message (msg);
if (NULL == nmap)
+ {
+ GNUNET_break_op (0);
return; /* malformed */
+ }
session = find_session (peer);
if (NULL == session)
{
GNUNET_break (0);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received TYPEMAP from %s\n",
+ GNUNET_i2s (session->peer));
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap_confirm)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) +
sizeof (struct TypeMapConfirmationMessage));
sme->deadline = GNUNET_TIME_absolute_get ();
sme->size = sizeof (struct TypeMapConfirmationMessage);
sme->priority = GNUNET_CORE_PRIO_CRITICAL_CONTROL;
+ sme->is_typemap_confirm = GNUNET_YES;
tmc = (struct TypeMapConfirmationMessage *) &sme[1];
tmc->header.size = htons (sizeof (struct TypeMapConfirmationMessage));
tmc->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP);
return;
session = find_session (peer);
GNUNET_assert (NULL != session);
- if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap, &type, 1))
+ if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap,
+ &type, 1))
return; /* already in it */
- nmap = GSC_TYPEMAP_extend (session->tmap, &type, 1);
+ nmap = GSC_TYPEMAP_extend (session->tmap,
+ &type,
+ 1);
GSC_CLIENTS_notify_clients_about_neighbour (peer,
- session->tmap, nmap);
+ session->tmap,
+ nmap);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = nmap;
}
GNUNET_memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap));
return ret;
case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP:
- GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"),
- 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# type maps received"),
+ 1,
+ GNUNET_NO);
ret = GNUNET_new (struct GSC_TypeMap);
dlen = sizeof (struct GSC_TypeMap);
if ((Z_OK !=
hdr = GSC_TYPEMAP_compute_type_map_message ();
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# updates to my type map"), 1,
+ gettext_noop ("# updates to my type map"),
+ 1,
GNUNET_NO);
GSC_SESSIONS_broadcast_typemap (hdr);
GNUNET_free (hdr);
}
if (GNUNET_YES == changed)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Typemap changed, broadcasting!\n");
rehash_typemap ();
broadcast_my_type_map ();
}
GSC_TYPEMAP_remove (const uint16_t *types,
unsigned int tlen)
{
- unsigned int i;
int changed;
changed = GNUNET_NO;
- for (i = 0; i < tlen; i++)
+ for (unsigned int i = 0; i < tlen; i++)
{
if (0 == --map_counters[types[i]])
{
const uint16_t *types,
unsigned int tcnt)
{
- unsigned int i;
-
if (NULL == tmap)
return GNUNET_NO;
if (0 == tcnt)
return GNUNET_YES; /* matches all */
- for (i = 0; i < tcnt; i++)
+ for (unsigned int i = 0; i < tcnt; i++)
if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32))))
return GNUNET_YES;
return GNUNET_NO;
unsigned int tcnt)
{
struct GSC_TypeMap *ret;
- unsigned int i;
ret = GNUNET_new (struct GSC_TypeMap);
if (NULL != tmap)
GNUNET_memcpy (ret, tmap, sizeof (struct GSC_TypeMap));
- for (i = 0; i < tcnt; i++)
+ for (unsigned int i = 0; i < tcnt; i++)
ret->bits[types[i] / 32] |= (1 << (types[i] % 32));
return ret;
}
v6 = (const struct IPv6UdpAddress *) addr;
if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ return GNUNET_OK; /* plausible, if unlikely... */
memset (&s6, 0, sizeof (s6));
s6.sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
GNUNET_assert (sizeof(struct sockaddr_in) == addrlen);
i4 = (const struct sockaddr_in *) addr;
if (0 == ntohs (i4->sin_port))
- {
- GNUNET_break (0);
- return;
- }
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
memset (&u4,
0,
sizeof(u4));
GNUNET_assert (sizeof(struct sockaddr_in6) == addrlen);
i6 = (const struct sockaddr_in6 *) addr;
if (0 == ntohs (i6->sin6_port))
- {
- GNUNET_break (0);
- return;
- }
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
memset (&u6,
0,
sizeof(u6));
GNUNET_MQ_send (h->mq,
n->env);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Queued message for neighbour `%s'.\n",
+ "Queued message of type %u for neighbour `%s'.\n",
+ ntohs (msg->type),
GNUNET_i2s (&n->id));
}