#define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
+/**
+ * After how much inactivity should a UDP session time out?
+ */
#define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
/**
/**
* We keep a defragmentation queue per sender address. How many
* sender addresses do we support at the same time? Memory consumption
- * is roughly a factor of 32k * UDP_MAX_MESSAGES_IN_DEFRAG times this
+ * is roughly a factor of 32k * #UDP_MAX_MESSAGES_IN_DEFRAG times this
* value. (So 128 corresponds to 12 MB and should suffice for
* connecting to roughly 128 peers via UDP).
*/
};
-/**
- * Closure for #process_inbound_tokenized_messages().
- */
-struct SourceInformation
-{
- /**
- * Sender identity.
- */
- struct GNUNET_PeerIdentity sender;
-
- /**
- * Associated session.
- */
- struct Session *session;
-
-};
-
/**
* Closure for #find_receive_context().
*/
struct GNUNET_TRANSPORT_SessionInfo info;
if (NULL == plugin->sic)
- return;
+ return;
if (GNUNET_YES == session->in_destroy)
return; /* already destroyed, just RC>0 left-over actions */
memset (&info, 0, sizeof (info));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Calling continuation for %u byte message to `%s' with result %s\n",
- udpw->payload_size,
+ udpw->payload_size,
GNUNET_i2s (&udpw->session->target),
(GNUNET_OK == result) ? "OK" : "SYSERR");
udpw->cont (udpw->cont_cls,
&udpw->session->target,
result,
- udpw->payload_size,
+ udpw->payload_size,
udpw->msg_size);
}
GNUNET_STATISTICS_update (plugin->env->stats,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, unfragmented msgs, bytes payload, sent, success",
- udpw->payload_size,
+ udpw->payload_size,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes overhead, sent, success",
+ "# UDP, unfragmented msgs, bytes overhead, sent, success",
overhead,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes overhead, sent",
- overhead,
+ "# UDP, total, bytes overhead, sent",
+ overhead,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes payload, sent",
+ "# UDP, total, bytes payload, sent",
udpw->payload_size,
GNUNET_NO);
break;
case UMT_MSG_FRAGMENTED_COMPLETE:
GNUNET_assert(NULL != udpw->frag_ctx);
if (udpw->frag_ctx->cont != NULL )
- udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
+ udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
&udpw->session->target,
- GNUNET_OK,
+ GNUNET_OK,
udpw->frag_ctx->payload_size,
udpw->frag_ctx->on_wire_size);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, messages, sent, success",
- 1,
+ "# UDP, fragmented msgs, messages, sent, success",
+ 1,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, fragmented msgs, bytes payload, sent, success",
- udpw->payload_size,
+ udpw->payload_size,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, bytes overhead, sent, success",
+ "# UDP, fragmented msgs, bytes overhead, sent, success",
overhead,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes overhead, sent",
+ "# UDP, total, bytes overhead, sent",
overhead,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes payload, sent",
- udpw->payload_size,
+ "# UDP, total, bytes payload, sent",
+ udpw->payload_size,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, fragmented msgs, messages, pending",
case UMT_MSG_FRAGMENTED:
/* Fragmented message: enqueue next fragment */
if (NULL != udpw->cont)
- udpw->cont (udpw->cont_cls,
- &udpw->session->target,
+ udpw->cont (udpw->cont_cls,
+ &udpw->session->target,
result,
- udpw->payload_size,
+ udpw->payload_size,
udpw->msg_size);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, fragments, sent, success",
+ "# UDP, fragmented msgs, fragments, sent, success",
1,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
case UMT_MSG_ACK:
/* No continuation */
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, ACK msgs, messages, sent, success",
+ "# UDP, ACK msgs, messages, sent, success",
1,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes overhead, sent",
- overhead,
+ overhead,
GNUNET_NO);
break;
default:
udpw->cont (udpw->cont_cls,
&udpw->session->target,
result,
- udpw->payload_size,
+ udpw->payload_size,
overhead);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, unfragmented msgs, messages, sent, failure",
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, unfragmented msgs, bytes payload, sent, failure",
- udpw->payload_size,
+ udpw->payload_size,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes overhead, sent, failure",
+ "# UDP, unfragmented msgs, bytes overhead, sent, failure",
overhead,
GNUNET_NO);
break;
case UMT_MSG_FRAGMENTED_COMPLETE:
GNUNET_assert (NULL != udpw->frag_ctx);
if (udpw->frag_ctx->cont != NULL)
- udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
+ udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
&udpw->session->target,
- GNUNET_SYSERR,
+ GNUNET_SYSERR,
udpw->frag_ctx->payload_size,
udpw->frag_ctx->on_wire_size);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, messages, sent, failure",
- 1,
+ "# UDP, fragmented msgs, messages, sent, failure",
+ 1,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, fragmented msgs, bytes payload, sent, failure",
- udpw->payload_size,
+ udpw->payload_size,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, bytes payload, sent, failure",
+ "# UDP, fragmented msgs, bytes payload, sent, failure",
overhead,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
GNUNET_assert (NULL != udpw->frag_ctx);
/* Fragmented message: failed to send */
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, fragments, sent, failure",
+ "# UDP, fragmented msgs, fragments, sent, failure",
1,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
case UMT_MSG_ACK:
/* ACK message: failed to send */
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, ACK msgs, messages, sent, failure",
+ "# UDP, ACK msgs, messages, sent, failure",
1,
GNUNET_NO);
break;
GNUNET_assert (GNUNET_YES != s->in_destroy);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session %p to peer `%s' address ended\n", s,
+ "Session %p to peer `%s' address ended\n",
+ s,
GNUNET_i2s (&s->target),
udp_address_to_string (plugin,
s->address->address,
void *value)
{
struct SessionCompareContext *cctx = cls;
- const struct GNUNET_HELLO_Address *address = cctx->address;
struct Session *s = value;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Comparing address %s <-> %s\n",
- udp_address_to_string (s->plugin,
- address->address,
- address->address_length),
- udp_address_to_string (s->plugin,
- s->address->address,
- s->address->address_length));
- if (0 == GNUNET_HELLO_address_cmp(s->address, cctx->address))
+ if (0 == GNUNET_HELLO_address_cmp (s->address,
+ cctx->address))
{
cctx->res = s;
return GNUNET_NO;
(address->address_length != sizeof (struct IPv6UdpAddress))))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Trying to locate session for address of unexpected length %u (should be %u or %u)\n"),
+ "Trying to locate session for address of unexpected length %u (should be %u or %u)\n",
address->address_length,
sizeof (struct IPv4UdpAddress),
sizeof (struct IPv6UdpAddress));
(const struct sockaddr *) &v6,
sizeof (v6));
}
- return udp_plugin_create_session (cls,
- address,
+ return udp_plugin_create_session (cls,
+ address,
network_type);
}
else
{
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes in buffers", udpw->msg_size, GNUNET_NO);
+ "# UDP, total, bytes in buffers",
+ udpw->msg_size,
+ GNUNET_NO);
plugin->bytes_in_buffer += udpw->msg_size;
}
GNUNET_STATISTICS_update (plugin->env->stats,
* to the service.
*
* @param cls the `struct Plugin *`
- * @param client the `struct SourceInformation *`
+ * @param client the `struct Session *`
* @param hdr the actual message
* @return #GNUNET_OK (always)
*/
const struct GNUNET_MessageHeader *hdr)
{
struct Plugin *plugin = cls;
- struct SourceInformation *si = client;
+ struct Session *session = client;
struct GNUNET_TIME_Relative delay;
- GNUNET_assert (NULL != si->session);
- if (GNUNET_YES == si->session->in_destroy)
+ if (GNUNET_YES == session->in_destroy)
return GNUNET_OK;
/* setup ATS */
- reschedule_session_timeout (si->session);
+ reschedule_session_timeout (session);
delay = plugin->env->receive (plugin->env->cls,
- si->session->address,
- si->session,
+ session->address,
+ session,
hdr);
- si->session->flow_delay_for_other_peer = delay;
+ session->flow_delay_for_other_peer = delay;
return GNUNET_OK;
}
size_t udp_addr_len,
enum GNUNET_ATS_Network_Type network_type)
{
- struct SourceInformation si;
struct Session *s;
struct GNUNET_HELLO_Address *address;
GNUNET_free (address);
/* iterate over all embedded messages */
- si.session = s;
- si.sender = msg->sender;
s->rc++;
GNUNET_SERVER_mst_receive (plugin->mst,
- &si,
+ s,
(const char *) &msg[1],
ntohs (msg->header.size) - sizeof(struct UDPMessage),
GNUNET_YES,
GNUNET_HELLO_ADDRESS_INFO_NONE);
s = udp_plugin_lookup_session (plugin,
address);
- if ( (NULL == s) ||
- (NULL == s->frag_ctx) )
+ if (NULL == s)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"UDP session of address %s for ACK not found\n",
GNUNET_HELLO_address_free (address);
return;
}
+ if (NULL == s->frag_ctx)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Fragmentation context of address %s for ACK not found\n",
+ udp_address_to_string (plugin,
+ address->address,
+ address->address_length));
+ GNUNET_HELLO_address_free (address);
+ return;
+ }
GNUNET_HELLO_address_free (address);
flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "We received a sending delay of %s\n",
+ "We received a sending delay of %s for %s\n",
GNUNET_STRINGS_relative_time_to_string (flow_delay,
- GNUNET_YES));
+ GNUNET_YES),
+ GNUNET_i2s (&udp_ack->sender));
s->flow_delay_from_other_peer = GNUNET_TIME_relative_to_absolute (flow_delay);
ack = (const struct GNUNET_MessageHeader *) &udp_ack[1];
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Message full ACK'ed\n",
- (unsigned int ) ntohs (msg->size),
+ "Message from %s at %s full ACK'ed\n",
GNUNET_i2s (&udp_ack->sender),
udp_address_to_string (plugin,
udp_addr,
"# UDP, total, messages, sent, timeout",
1,
GNUNET_NO);
- call_continuation (udpw,
+ call_continuation (udpw,
GNUNET_SYSERR);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Fragment for message for peer `%s' with size %u timed out\n",
GNUNET_i2s (&udpw->session->target),
udpw->frag_ctx->payload_size);
-
+
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, fragmented msgs, messages, sent, timeout",
1,
udpw->frag_ctx->payload_size,
GNUNET_NO);
/* Remove fragmented message due to timeout */
- fragmented_message_done (udpw->frag_ctx,
+ fragmented_message_done (udpw->frag_ctx,
GNUNET_SYSERR);
break;
case UMT_MSG_ACK:
call_continuation (udpw,
GNUNET_SYSERR);
removed = GNUNET_YES;
- dequeue (plugin,
+ dequeue (plugin,
udpw);
GNUNET_free (udpw);
break;
/* Message is delayed, try next */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Message for peer `%s' (%u bytes) is delayed for %s\n",
- GNUNET_i2s (&udpw->session->target),
+ GNUNET_i2s (&udpw->session->target),
udpw->payload_size,
- GNUNET_STRINGS_relative_time_to_string (remaining,
+ GNUNET_STRINGS_relative_time_to_string (remaining,
GNUNET_YES));
udpw = udpw->next;
}
#endif
a4.sin_port = u4->u4_port;
memcpy (&a4.sin_addr,
- &u4->ipv4_addr,
+ &u4->ipv4_addr,
sizeof(struct in_addr));
a = (struct sockaddr *) &a4;
slen = sizeof (a4);
}
else
{
- call_continuation (udpw,
+ call_continuation (udpw,
GNUNET_OK);
- dequeue (plugin,
+ dequeue (plugin,
udpw);
notify_session_monitor (plugin,
udpw->session,
{
/* Failure */
analyze_send_error (plugin,
- a,
- slen,
+ a,
+ slen,
errno);
- call_continuation (udpw,
+ call_continuation (udpw,
GNUNET_SYSERR);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, bytes, sent, failure",
- sent,
+ "# UDP, total, bytes, sent, failure",
+ sent,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, total, messages, sent, failure",
+ "# UDP, total, messages, sent, failure",
1,
GNUNET_NO);
}