From: Richard Kettlewell Date: Wed, 28 Nov 2007 20:41:54 +0000 (+0000) Subject: multicast_loop option X-Git-Tag: 1.5.99+dev10~47 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/61941295f0eb457edc89f0337f732ff071838b6a multicast_loop option --- diff --git a/doc/disorder_config.5.in b/doc/disorder_config.5.in index badedeb..2b57c79 100644 --- a/doc/disorder_config.5.in +++ b/doc/disorder_config.5.in @@ -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 diff --git a/lib/configuration.c b/lib/configuration.c index d758751..90ff371 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -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; diff --git a/lib/configuration.h b/lib/configuration.h index a4ffa63..6618e1a 100644 --- a/lib/configuration.h +++ b/lib/configuration.h @@ -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 */ diff --git a/server/speaker-network.c b/server/speaker-network.c index 40abca5..150fea6 100644 --- a/server/speaker-network.c +++ b/server/speaker-network.c @@ -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: