]> git.ipfire.org Git - thirdparty/squid.git/blame - src/multicast.cc
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / multicast.cc
CommitLineData
42cc2e53 1
2/*
262a0e14 3 * $Id$
42cc2e53 4 *
6f6f0853 5 * DEBUG: section 7 Multicast
42cc2e53 6 * AUTHOR: Martin Hamilton
7 *
2b6662ba 8 * SQUID Web Proxy Cache http://www.squid-cache.org/
e25c139f 9 * ----------------------------------------------------------
42cc2e53 10 *
2b6662ba 11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
42cc2e53 19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
26ac0430 24 *
42cc2e53 25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
26ac0430 29 *
42cc2e53 30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
cbdec147 32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
e25c139f 33 *
42cc2e53 34 */
35
36#include "squid.h"
37
38int
39mcastSetTtl(int fd, int mcast_ttl)
40{
41#ifdef IP_MULTICAST_TTL
42 char ttl = (char) mcast_ttl;
62e76326 43
42cc2e53 44 if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, 1) < 0)
bf8fe701 45 debugs(50, 1, "comm_set_mcast_ttl: FD " << fd << ", TTL: " << mcast_ttl << ": " << xstrerror());
62e76326 46
42cc2e53 47#endif
62e76326 48
42cc2e53 49 return 0;
50}
51
52void
79d39a72 53mcastJoinGroups(const ipcache_addrs * ia, void *datanotused)
42cc2e53 54{
55#ifdef IP_MULTICAST_TTL
56 int fd = theInIcpConnection;
62e76326 57
42cc2e53 58 struct ip_mreq mr;
59 int i;
60 int x;
61 char c = 0;
62e76326 62
42cc2e53 63 if (ia == NULL) {
bf8fe701 64 debugs(7, 0, "comm_join_mcast_groups: Unknown host");
62e76326 65 return;
42cc2e53 66 }
62e76326 67
42cc2e53 68 for (i = 0; i < (int) ia->count; i++) {
cc192b50 69 debugs(7, 10, "Listening for ICP requests on " << ia->in_addrs[i] );
70
71#if USE_IPV6
26ac0430 72 if ( ! ia->in_addrs[i].IsIPv4() ) {
cc192b50 73 debugs(7, 10, "ERROR: IPv6 Multicast Listen has not been implemented!");
74 continue;
75 }
76#endif
77
78 ia->in_addrs[i].GetInAddr(mr.imr_multiaddr);
79
62e76326 80 mr.imr_interface.s_addr = INADDR_ANY;
81 x = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
62e76326 82 (char *) &mr, sizeof(struct ip_mreq));
83
84 if (x < 0)
cc192b50 85 debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", IP=" << ia->in_addrs[i]);
62e76326 86
87 x = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &c, 1);
88
89 if (x < 0)
bf8fe701 90 debugs(7, 1, "Can't disable multicast loopback: " << xstrerror());
42cc2e53 91 }
62e76326 92
42cc2e53 93#endif
94}