-switching (again) to named sockets, see #2887
[oweals/gnunet.git] / src / transport / plugin_transport_udp_broadcasting.c
index e8e08727627feb11b66aebd3639b406c552a75ac..1f26706d4d3d05ac545c7bb02e3ee657049a8800 100644 (file)
@@ -272,7 +272,7 @@ udp_ipv4_broadcast_send (void *cls,
   plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
 
   msg_size = prepare_beacon(plugin, (struct UDP_Beacon_Message *) &buf);
-  sent = 0;
+
   baddr = plugin->ipv4_broadcast_head;
   /* just IPv4 */
   while ((msg_size > 0) && (baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in)))
@@ -324,7 +324,6 @@ udp_ipv6_broadcast_send (void *cls,
   plugin->send_ipv6_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
 
   msg_size = prepare_beacon(plugin, (struct UDP_Beacon_Message *) &buf);
-  sent = 0;
   sent = GNUNET_NETWORK_socket_sendto (plugin->sockv6, &buf, msg_size,
                                     (const struct sockaddr *)
                                     &plugin->ipv6_multicast_address,
@@ -394,9 +393,20 @@ iface_proc (void *cls, const char *name, int isDefault,
 void
 setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struct sockaddr_in *serverAddrv4)
 {
+  const struct GNUNET_MessageHeader *hello;
+  hello = plugin->env->get_our_hello ();
+
+  if (GNUNET_YES == GNUNET_HELLO_is_friend_only((const struct GNUNET_HELLO_Message *) hello))
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         _("Disabling HELLO broadcasting due to friend-to-friend only configuration!\n"));
+    return;
+  }
+
+
   /* create IPv4 broadcast socket */
   plugin->broadcast_ipv4 = GNUNET_NO;
-  if (plugin->sockv4 != NULL)
+  if ((GNUNET_YES == plugin->enable_ipv4) && (plugin->sockv4 != NULL))
   {
     int yes = 1;
 
@@ -424,7 +434,7 @@ setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struc
   }
 
   plugin->broadcast_ipv6 = GNUNET_NO;
-  if (plugin->sockv6 != NULL)
+  if ((GNUNET_YES == plugin->enable_ipv6) && (plugin->sockv6 != NULL))
   {
     memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6));
     GNUNET_assert (1 ==