chiark / gitweb /
multicast_loop option
authorRichard Kettlewell <rjk@greenend.org.uk>
Wed, 28 Nov 2007 20:41:54 +0000 (20:41 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Wed, 28 Nov 2007 20:41:54 +0000 (20:41 +0000)
doc/disorder_config.5.in
lib/configuration.c
lib/configuration.h
server/speaker-network.c

index badedebca2b7b6355f125d6c450fd8f3432f064d..2b57c799c5dad8f718c7c288db71caafa2117d64 100644 (file)
@@ -157,6 +157,8 @@ for more details.
 .B broadcast \fIADDRESS\fR \fIPORT\fR
 Transmit sound data to \fIADDRESS\fR using UDP port \fIPORT\fR.  This implies
 \fBspeaker_backend network\fR.
+.IP
+See also \fBmulticast_loop\fR and \fBmulticast_ttl\fR.
 .TP
 .B broadcast_from \fIADDRESS\fR \fIPORT\fR
 Sets the (local) source address used by \fBbroadcast\fR.
@@ -224,8 +226,14 @@ Determines whether the server locks against concurrent operation.  Default is
 The path to the mixer device, if you want access to the volume control,
 e.g. \fB/dev/mixer\fR.
 .TP
+.B multicast_loop yes\fR|\fBno
+Determines whether multicast packets are loop backed to the sending host.  The
+default is \fByes\fR.  This only applies if
+\fBspeaker_backend\fR is set to \fBnetwork\fR and \fBbroadcast\fR is actually a
+multicast address.
+.TP
 .B multicast_ttl \fIHOPS\fR
-Set the maximum number of hops to send multicast packets.  This only applies is
+Set the maximum number of hops to send multicast packets.  This only applies if
 \fBspeaker_backend\fR is set to \fBnetwork\fR and \fBbroadcast\fR is actually a
 multicast address.
 .TP
index d758751d3d061d1ac19aef263abcf67e865a0231..90ff371a8f648b293a3204ae01029939d48c8745 100644 (file)
@@ -900,6 +900,7 @@ static const struct conf conf[] = {
   { C(listen),           &type_stringlist,       validate_port },
   { C(lock),             &type_boolean,          validate_any },
   { C(mixer),            &type_string,           validate_ischr },
+  { C(multicast_loop),   &type_boolean,          validate_any },
   { C(multicast_ttl),    &type_integer,          validate_non_negative },
   { C(namepart),         &type_namepart,         validate_any },
   { C2(nice, nice_rescan), &type_integer,        validate_non_negative },
@@ -1043,6 +1044,7 @@ static struct config *config_default(void) {
   c->queue_pad = 10;
   c->speaker_backend = -1;
   c->multicast_ttl = 1;
+  c->multicast_loop = 1;
   c->authorization_algorithm = xstrdup("sha1");
   c->noticed_history = 31;
   c->short_display = 32;
index a4ffa6337bfa047c828d8e6c111bd34465cd2228..6618e1ad3a5c6babfadbe40664bda170913c8590 100644 (file)
@@ -243,6 +243,9 @@ struct config {
   /** @brief TTL for multicast packets */
   long multicast_ttl;
 
+  /** @brief Whether to loop back multicast packets */
+  int multicast_loop;
+  
   /* derived values: */
   int nparts;                          /* number of distinct name parts */
   char **parts;                                /* name part list  */
index 40abca59f14aeeba85f4eee8ad9dfa32a112a379..150fea643a5191208575ec37f4c6d492ad0dbc5e 100644 (file)
@@ -125,6 +125,9 @@ static void network_init(void) {
       const int mttl = config->multicast_ttl;
       if(setsockopt(bfd, IPPROTO_IP, IP_MULTICAST_TTL, &mttl, sizeof mttl) < 0)
         fatal(errno, "error setting IP_MULTICAST_TTL on multicast socket");
+      if(setsockopt(bfd, IPPROTO_IP, IP_MULTICAST_LOOP,
+                    &config->multicast_loop, sizeof one) < 0)
+        fatal(errno, "error setting IP_MULTICAST_LOOP on multicast socket");
       break;
     }
     case PF_INET6: {
@@ -132,6 +135,9 @@ static void network_init(void) {
       if(setsockopt(bfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
                     &mttl, sizeof mttl) < 0)
         fatal(errno, "error setting IPV6_MULTICAST_HOPS on multicast socket");
+      if(setsockopt(bfd, IPPROTO_IP, IPV6_MULTICAST_LOOP,
+                    &config->multicast_loop, sizeof (int)) < 0)
+        fatal(errno, "error setting IPV6_MULTICAST_LOOP on multicast socket");
       break;
     }
     default: