-void
+int
broadcast_ipv6_mst_cb (void *cls, void *client,
const struct GNUNET_MessageHeader *message)
{
if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON !=
ntohs (msg->header.type))
- return;
+ return GNUNET_OK;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received beacon with %u bytes from peer `%s' via address `%s'\n",
ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
GNUNET_break (ntohl(mc->ats_address_network_type) != GNUNET_ATS_NET_UNSPECIFIED);
hello = (struct GNUNET_MessageHeader *) &msg[1];
- plugin->env->receive (plugin->env->cls, &msg->sender, hello,
- (const struct GNUNET_ATS_Information *) &atsi, 2, NULL,
- (const char *) &mc->addr, sizeof (mc->addr));
+ plugin->env->receive (plugin->env->cls,
+ &msg->sender,
+ hello,
+ NULL,
+ (const char *) &mc->addr,
+ sizeof (mc->addr));
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &msg->sender,
+ (const char *) &mc->addr,
+ sizeof (mc->addr),
+ NULL,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
GNUNET_STATISTICS_update (plugin->env->stats,
_
("# IPv6 multicast HELLO beacons received via udp"),
1, GNUNET_NO);
GNUNET_free (mc);
+ return GNUNET_OK;
}
-void
+int
broadcast_ipv4_mst_cb (void *cls, void *client,
const struct GNUNET_MessageHeader *message)
{
if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON !=
ntohs (msg->header.type))
- return;
+ return GNUNET_OK;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received beacon with %u bytes from peer `%s' via address `%s'\n",
ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
GNUNET_break (ntohl(mc->ats_address_network_type) != GNUNET_ATS_NET_UNSPECIFIED);
hello = (struct GNUNET_MessageHeader *) &msg[1];
- plugin->env->receive (plugin->env->cls, &msg->sender, hello,
- (const struct GNUNET_ATS_Information *) &atsi, 2, NULL,
- (const char *) &mc->addr, sizeof (mc->addr));
+ plugin->env->receive (plugin->env->cls,
+ &msg->sender,
+ hello,
+ NULL,
+ (const char *) &mc->addr,
+ sizeof (mc->addr));
+
+ plugin->env->update_address_metrics (plugin->env->cls,
+ &msg->sender,
+ (const char *) &mc->addr,
+ sizeof (mc->addr),
+ NULL,
+ (struct GNUNET_ATS_Information *) &atsi, 2);
GNUNET_STATISTICS_update (plugin->env->stats,
_
("# IPv4 broadcast HELLO beacons received via udp"),
1, GNUNET_NO);
GNUNET_free (mc);
+ return GNUNET_OK;
}
void
{
struct GNUNET_ATS_Information ats;
- if (addrlen == sizeof (struct sockaddr_in))
+ if ((GNUNET_YES == plugin->broadcast_ipv4) && (addrlen == sizeof (struct sockaddr_in)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n",
mc->addr.u4_port = av4->sin_port;
ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) addr, addrlen);
mc->ats_address_network_type = ats.value;
+
+ GNUNET_assert (NULL != plugin->broadcast_ipv4_mst);
if (GNUNET_OK !=
GNUNET_SERVER_mst_receive (plugin->broadcast_ipv4_mst, mc, buf, size,
GNUNET_NO, GNUNET_NO))
GNUNET_free (mc);
}
- else if (addrlen == sizeof (struct sockaddr_in6))
+ else if ((GNUNET_YES == plugin->broadcast_ipv4) && (addrlen == sizeof (struct sockaddr_in6)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n",
mc->addr.u6_port = av6->sin6_port;
ats = plugin->env->get_address_type (plugin->env->cls, (const struct sockaddr *) addr, addrlen);
mc->ats_address_network_type = ats.value;
-
+ GNUNET_assert (NULL != plugin->broadcast_ipv4_mst);
if (GNUNET_OK !=
GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, size,
GNUNET_NO, GNUNET_NO))
const struct GNUNET_MessageHeader *hello;
hello = plugin->env->get_our_hello ();
+ if (NULL == hello)
+ return 0;
hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
msg_size = hello_size + sizeof (struct UDP_Beacon_Message);
sent = 0;
baddr = plugin->ipv4_broadcast_head;
/* just IPv4 */
- while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
+ while ((msg_size > 0) && (baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
{
struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr;
(const struct sockaddr *) addr,
baddr->addrlen);
if (sent == GNUNET_SYSERR)
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
+ {
+ if ((ENETUNREACH == errno) || (ENETDOWN == errno))
+ {
+ /* "Network unreachable" or "Network down"
+ *
+ * This indicates that we just do not have network connectivity
+ */
+ GNUNET_log (GNUNET_ERROR_TYPE_BULK | GNUNET_ERROR_TYPE_WARNING,
+ "Network connectivity is down, cannot send beacon!\n");
+ }
+ else
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
+ }
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
&plugin->ipv6_multicast_address,
sizeof (struct sockaddr_in6));
if (sent == GNUNET_SYSERR)
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
+ {
+ if ((ENETUNREACH == errno) || (ENETDOWN == errno))
+ {
+ /* "Network unreachable" or "Network down"
+ *
+ * This indicates that this system is IPv6 enabled, but does not
+ * have a valid global IPv6 address assigned
+ */
+ GNUNET_log (GNUNET_ERROR_TYPE_BULK | GNUNET_ERROR_TYPE_WARNING,
+ "Network connectivity is down, cannot send beacon!\n");
+ }
+ else
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto");
+ }
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,