From: dw6 Date: Wed, 8 Oct 2008 15:52:30 +0000 (+0000) Subject: adding flexibility to use interface index / no interface X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=6fe5e7e732ecb03e10c9bb430883d72d9cf0a86c;p=senf.git adding flexibility to use interface index / no interface git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@935 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/Protocols/INet/MulticastSocketProtocol.cc b/Socket/Protocols/INet/MulticastSocketProtocol.cc index 42f2126..b833144 100644 --- a/Socket/Protocols/INet/MulticastSocketProtocol.cc +++ b/Socket/Protocols/INet/MulticastSocketProtocol.cc @@ -311,23 +311,30 @@ senf::INet6MulticastSocketProtocol::mcDropMembership(INet6Address const & mcAddr } namespace { - void mc6SSMSourceRequest(int operation, int fd, senf::INet6Address const & group, - senf::INet6Address const & source, std::string const & iface) - { - struct group_source_req req; - ::memset(&req, 0, sizeof(req)); - req.gsr_interface = if_nametoindex(iface.c_str()); - if (req.gsr_interface == 0) - throw senf::SystemException("::if_nametoindex()", ENOENT SENF_EXC_DEBUGINFO); - req.gsr_group.ss_family = AF_INET6; - std::copy(group.begin(), group.end(), - reinterpret_cast(req.gsr_group).sin6_addr.s6_addr); - req.gsr_source.ss_family = AF_INET6; - std::copy(source.begin(), source.end(), - reinterpret_cast(req.gsr_source).sin6_addr.s6_addr); - if (::setsockopt(fd, SOL_IPV6, MCAST_JOIN_SOURCE_GROUP, &req, sizeof(req)) < 0) - SENF_THROW_SYSTEM_EXCEPTION("::setsockopt()"); +void mc6SSMSourceRequest(int operation, int fd, senf::INet6Address const & group, + senf::INet6Address const & source, int const & ifacei) +{ + struct group_source_req req; + ::memset(&req, 0, sizeof(req)); + req.gsr_interface = ifacei; + req.gsr_group.ss_family = AF_INET6; + std::copy(group.begin(), group.end(), + reinterpret_cast(req.gsr_group).sin6_addr.s6_addr); + req.gsr_source.ss_family = AF_INET6; + std::copy(source.begin(), source.end(), + reinterpret_cast(req.gsr_source).sin6_addr.s6_addr); + if (::setsockopt(fd, SOL_IPV6, MCAST_JOIN_SOURCE_GROUP, &req, sizeof(req)) < 0) + SENF_THROW_SYSTEM_EXCEPTION("::setsockopt()"); +} +void mc6SSMSourceRequest(int operation, int fd, senf::INet6Address const & group, + senf::INet6Address const & source, std::string const & iface) +{ + int ifacei = if_nametoindex(iface.c_str()); + if (ifacei == 0) + throw senf::SystemException("::if_nametoindex()", ENOENT SENF_EXC_DEBUGINFO); + mc6SSMSourceRequest(operation, fd, group, source, ifacei); } + } prefix_ void senf::INet6MulticastSocketProtocol::mcJoinSSMSource(INet6Address const & group, @@ -338,6 +345,20 @@ prefix_ void senf::INet6MulticastSocketProtocol::mcJoinSSMSource(INet6Address co mc6SSMSourceRequest(MCAST_JOIN_SOURCE_GROUP, fd(), group, source, iface); } +prefix_ void senf::INet6MulticastSocketProtocol::mcJoinSSMSource(INet6Address const & group, + INet6Address const & source, + int ifacei) + const +{ + mc6SSMSourceRequest(MCAST_JOIN_SOURCE_GROUP, fd(), group, source, ifacei); +} +prefix_ void senf::INet6MulticastSocketProtocol::mcJoinSSMSource(INet6Address const & group, + INet6Address const & source) + const +{ + mc6SSMSourceRequest(MCAST_JOIN_SOURCE_GROUP, fd(), group, source, 0); +} + prefix_ void senf::INet6MulticastSocketProtocol::mcLeaveSSMSource(INet6Address const & group, INet6Address const & source, std::string const & iface) @@ -346,6 +367,7 @@ prefix_ void senf::INet6MulticastSocketProtocol::mcLeaveSSMSource(INet6Address c mc6SSMSourceRequest(MCAST_LEAVE_SOURCE_GROUP, fd(), group, source, iface); } + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "MulticastSocketProtocol.mpp" diff --git a/Socket/Protocols/INet/MulticastSocketProtocol.hh b/Socket/Protocols/INet/MulticastSocketProtocol.hh index cf80740..90f74e7 100644 --- a/Socket/Protocols/INet/MulticastSocketProtocol.hh +++ b/Socket/Protocols/INet/MulticastSocketProtocol.hh @@ -197,6 +197,24 @@ namespace senf { \param[in] source SSM multicast source to join the group on \param[in] iface interface to join the group on */ + void mcJoinSSMSource(INet6Address const & group, INet6Address const & source, + int ifacei) const; + ///< join SSM multicast group + /**< This call will join the multicast group \a group for + traffic from \a source. A single group may be joined + multiple times on different sources. + \param[in] group multicast group to join + \param[in] source SSM multicast source to join the + group on + \param[in] ifacei interface index to join the group on */ + void mcJoinSSMSource(INet6Address const & group, INet6Address const & source) const; + ///< join SSM multicast group + /**< This call will join the multicast group \a group for + traffic from \a source. A single group may be joined + multiple times on different sources. + \param[in] group multicast group to join + \param[in] source SSM multicast source to join the + group on */ void mcLeaveSSMSource(INet6Address const & group, INet6Address const & source, std::string const & iface) const; ///< leave SSM multicast group