]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/multicast.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 07 Multicast */
12 #include "comm/Connection.h"
14 // XXX: for icpIncomingConn - need to pass it as a generic parameter.
17 #include "multicast.h"
20 mcastSetTtl(int fd
, int mcast_ttl
)
22 #ifdef IP_MULTICAST_TTL
23 char ttl
= (char) mcast_ttl
;
25 if (setsockopt(fd
, IPPROTO_IP
, IP_MULTICAST_TTL
, &ttl
, 1) < 0)
26 debugs(50, DBG_IMPORTANT
, "comm_set_mcast_ttl: FD " << fd
<< ", TTL: " << mcast_ttl
<< ": " << xstrerror());
34 mcastJoinGroups(const ipcache_addrs
*ia
, const DnsLookupDetails
&, void *)
36 #ifdef IP_MULTICAST_TTL
41 debugs(7, DBG_CRITICAL
, "comm_join_mcast_groups: Unknown host");
45 for (i
= 0; i
< (int) ia
->count
; ++i
) {
46 debugs(7, 9, "Listening for ICP requests on " << ia
->in_addrs
[i
] );
48 if ( ! ia
->in_addrs
[i
].isIPv4() ) {
49 debugs(7, 9, "ERROR: IPv6 Multicast Listen has not been implemented!");
53 ia
->in_addrs
[i
].getInAddr(mr
.imr_multiaddr
);
55 mr
.imr_interface
.s_addr
= INADDR_ANY
;
57 if (setsockopt(icpIncomingConn
->fd
, IPPROTO_IP
, IP_ADD_MEMBERSHIP
, (char *) &mr
, sizeof(struct ip_mreq
)) < 0)
58 debugs(7, DBG_IMPORTANT
, "ERROR: Join failed for " << icpIncomingConn
<< ", Multicast IP=" << ia
->in_addrs
[i
]);
61 if (setsockopt(icpIncomingConn
->fd
, IPPROTO_IP
, IP_MULTICAST_LOOP
, &c
, 1) < 0)
62 debugs(7, DBG_IMPORTANT
, "ERROR: " << icpIncomingConn
<< " can't disable multicast loopback: " << xstrerror());