tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: IPv6 scopeid not supported?
On Sun, Nov 07, 2010 at 04:28:50PM +1300, Lloyd Parkes wrote:
> Hi all,
> While trying to get ntp running on an IPv6 network using multicast I
> ran in to a bit of a problem. It looks like the sin6_scope_id field
> in struct sockaddr_in6 isn't used by bind(2), resulting in multicast
> listeners only being able to listen the first interface. This is
> especially troublesome if your first interface is fwip0.
Lloyd,
You're probably right that the scope ID is not supported.
You can use setsockopt(2) to set the interfaces on which to transmit and
receive IPv6 multicasts. ip6(4) should tell how. In a routing daemon, I
used these routines to choose the multicast interface:
static int
beacon6_rx_v6mcast_joinleave(int s, int optname,
const struct in6_addr *addr, u_int ifindex)
{
struct ipv6_mreq mreq6;
mreq6.ipv6mr_interface = ifindex;
(void)memcpy(&mreq6.ipv6mr_multiaddr, addr,
sizeof(mreq6.ipv6mr_multiaddr));
return setsockopt(s, IPPROTO_IPV6, optname, &mreq6,
(socklen_t)sizeof(mreq6));
}
int
beacon6_rx_v6mcast_leave(int s, const struct in6_addr *addr, u_int ifindex)
{
return beacon6_rx_v6mcast_joinleave(s, IPV6_LEAVE_GROUP, addr, ifindex);
}
int
beacon6_rx_v6mcast_join(int s, const struct in6_addr *addr, u_int ifindex)
{
return beacon6_rx_v6mcast_joinleave(s, IPV6_JOIN_GROUP, addr, ifindex);
}
int
beacon6_tx_mcastif_set(int s, u_int outif0)
{
u_int outif = outif0;
LOGLIB_LOG(&log_warn,
"%s: setsockopt(, IPV6_MULTICAST_IF, ifindex<%#08x>, %zu)",
__func__, outif, sizeof(outif));
return setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &outif,
(socklen_t)sizeof(outif));
}
Dave
--
David Young OJC Technologies
dyoung%ojctech.com@localhost Urbana, IL * (217) 278-3933
Home |
Main Index |
Thread Index |
Old Index