4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief MulticastSocketProtocol public header */
26 #ifndef HH_SENF_Socket_Protocols_INet_MulticastSocketProtocol_
27 #define HH_SENF_Socket_Protocols_INet_MulticastSocketProtocol_ 1
30 #include <senf/Socket/SocketProtocol.hh>
31 #include "INet4Address.hh"
32 #include "INet6Address.hh"
34 //#include "MulticastSocketProtocol.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
39 ///\addtogroup protocol_facets_group
42 /** \brief Generic addressing type independent multicast protocol facet
44 \todo implement complete new multicast API from RFC3678 (as far as supported by linux)
45 \bug mcLeaveSSMSource fails with EADDRNOTAVAIL
47 class MulticastSocketProtocol
48 : public virtual SocketProtocol
51 void broadcastEnabled(bool v) const; ///< Enable broadcast send/receive
52 /**< If this option is enabled, broadcast UDP messages will
53 be received on the socket and the socket will be
54 allowed to send out broadcast UDP messages
55 \param[in] v \c true to enable broadcast send/receive,
56 \c false to disable */
58 bool broadcastEnabled() const; ///< Get broadcast send/receive state
59 /**< \returns Current state of the broadcastEnabled()
63 unsigned mcTTL() const; ///< Return current multicast TTL
64 void mcTTL(unsigned value) const; ///< Set multicast TTL
66 bool mcLoop() const; ///< Return current multicast loopback state.
67 void mcLoop(bool value) const; ///< Set multicast loopback state
68 /**< If set to false via \c mcLoop(value) multicast messages
69 will not be looped back to local sockets. Default value
72 void mcIface(std::string const & iface = std::string()) const;
73 ///< Set multicast send interface of the socket
74 /**< \param[in] iface name of interface to send multicast
77 Under current linux versions this option is broken at
81 /** \brief Multicast protocol facet for INet4 addressable multicast enabled sockets
83 class INet4MulticastSocketProtocol
84 : public MulticastSocketProtocol
87 void mcAddMembership(INet4Address const & mcAddr) const;
88 ///< Join multicast group on default interface
89 /**< This member will add \a mcAddr to the list of multicast
90 groups received. The group is joined on the default
92 \param[in] mcAddr address of group to join */
93 void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
94 ///< join multicast group on a specific interface
95 /**< This member will add \a mcAddr to the list of multicast
96 groups received. The group is joined on the interface
97 with the given local address.
98 \deprecated Use \link mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const mcAddMembership( \a mcAddr , \a iface )\endlink
99 for compatibility with the IPv6 API.
100 \param[in] mcAddr address of group to join
101 \param[in] localAddr address of interface to join on */
102 void mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const;
103 ///< join multicast group on a specific interface
104 /**< This member will add \a mcAddr to the list of multicast
105 groups received. The group is joined on the given
107 \param[in] mcAddr address of group to join
108 \param[in] iface interface name */
110 void mcDropMembership(INet4Address const & mcAddr) const;
111 ///< Leave multicast group
112 /**< This member will remove \a mcAddr from the list of
113 multicast groups received. The group is left from the
115 \param[in] mcAddr address of group to leave */
116 void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr)
118 ///< leave multicast group on a specific interface
119 /**< This member will remove \a mcAddr from the list of
120 multicast groups received. The group is left from the
121 interface with the given local address.
122 \deprecated Use \link mcDropMembership(INet4Address const & mcAddr, std::string const & iface) const mcDropMembership( \a mcAddr , \a iface )\endlink
123 for compatibility with the IPv6 API.
124 \param[in] mcAddr address of group to leave
125 \param[in] localAddr address of interface to leave
127 void mcDropMembership(INet4Address const & mcAddr, std::string const & iface)
129 ///< leave multicast group on a specific interface
130 /**< This member will remove \a mcAddr from the list of
131 multicast groups received. The group is left from the
132 interface with the given local address.
133 \param[in] mcAddr address of group to leave
134 \param[in] iface interface name */
136 void mcJoinSSMSource(INet4Address const & group, INet4Address const & source,
137 std::string const & iface) const;
138 ///< join SSM multicast group
139 /**< This call will join the multicast group \a group for
140 traffic from \a source. A single group may be joined
141 multiple times on different sources.
142 \param[in] group multicast group to join
143 \param[in] source SSM multicast source to join the
145 \param[in] iface interface to join the group on */
146 void mcLeaveSSMSource(INet4Address const & group, INet4Address const & source,
147 std::string const & iface) const;
148 ///< leave SSM multicast group
149 /**< This call will leave the multicast group \a group for
150 traffic from \a source.
151 \param[in] group multicast group to leave
152 \param[in] source SSM multicast source to leave the
154 \param[in] iface interface to leave the group on */
157 /** \brief Multicast protocol facet for INet6 addressable multicast enabled sockets
159 This implementation supports INet6 mapped INet4 multicast addresses. This is a linux
160 specific extension and NOT part of the relevant RFCs.
162 class INet6MulticastSocketProtocol
163 : public MulticastSocketProtocol
166 void mcAddMembership(INet6Address const & mcAddr) const;
167 ///< Join multicast group on default interface
168 /**< This member will add \a mcAddr to the list of multicast
169 groups received. The group is joined on the default
171 \param[in] mcAddr address of group to join */
172 void mcAddMembership(INet6Address const & mcAddr, std::string const & iface) const;
173 ///< join multicast group on a specific interface
174 /**< This member will add \a mcAddr to the list of multicast
175 groups received. The group is joined on the given
177 \param[in] mcAddr address of group to join
178 \param[in] iface interface name */
180 void mcDropMembership(INet6Address const & mcAddr) const;
181 ///< Leave multicast group
182 /**< This member will remove \a mcAddr from the list of
183 multicast groups received. The group is left from the
185 \param[in] mcAddr address of group to leave */
186 void mcDropMembership(INet6Address const & mcAddr, std::string const & iface) const;
187 ///< leave multicast group on a specific interface
188 /**< This member will remove \a mcAddr from the list of
189 multicast groups received. The group is left from the
190 interface with the given local address.
191 \param[in] mcAddr address of group to leave
192 \param[in] iface interface name */
194 void mcJoinSSMSource(INet6Address const & group, INet6Address const & source,
195 std::string const & iface) const;
196 ///< join SSM multicast group
197 /**< This call will join the multicast group \a group for
198 traffic from \a source. A single group may be joined
199 multiple times on different sources.
200 \param[in] group multicast group to join
201 \param[in] source SSM multicast source to join the
203 \param[in] iface interface to join the group on. If set
204 to the empty string, use the default interface. */
205 void mcJoinSSMSource(INet6Address const & group, INet6Address const & source,
206 int ifacei = 0) const;
207 ///< join SSM multicast group
208 /**< This call will join the multicast group \a group for
209 traffic from \a source. A single group may be joined
210 multiple times on different sources.
211 \param[in] group multicast group to join
212 \param[in] source SSM multicast source to join the
214 \param[in] ifacei optional interface index to join the
216 void mcLeaveSSMSource(INet6Address const & group, INet6Address const & source,
217 std::string const & iface) const;
218 ///< leave SSM multicast group
219 /**< This call will leave the multicast group \a group for
220 traffic from \a source.
221 \param[in] group multicast group to leave
222 \param[in] source SSM multicast source to leave the
224 \param[in] iface interface to leave the group on */
230 ///////////////////////////////hh.e////////////////////////////////////////
231 //#include "MulticastSocketProtocol.cci"
232 //#include "MulticastSocketProtocol.ct"
233 //#include "MulticastSocketProtocol.cti"
240 // comment-column: 40
241 // c-file-style: "senf"
242 // indent-tabs-mode: nil
243 // ispell-local-dictionary: "american"
244 // compile-command: "scons -u test"