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_MulticastSocketProtocol_
27 #define HH_MulticastSocketProtocol_ 1
30 #include "../../../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 will not be looped back to local sockets. Default value is \c true (1). */
70 void mcIface(std::string const & iface = std::string()) const;
71 ///< Set multicast send interface of the socket
72 /**< \param[in] iface name of interface to send multicast
76 /** \brief Multicast protocol facet for INet4 addressable multicast enabled sockets
78 class INet4MulticastSocketProtocol
79 : public MulticastSocketProtocol
82 void mcAddMembership(INet4Address const & mcAddr) const;
83 ///< Join multicast group on default interface
84 /**< This member will add \a mcAddr to the list of multicast
85 groups received. The group is joined on the default
87 \param[in] mcAddr address of group to join */
88 void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr)
90 ///< join multicast group on a specific interface
91 /**< This member will add \a mcAddr to the list of multicast
92 groups received. The group is joined on the interface
93 with the given local address.
94 \deprecated Use \link mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const mcAddMembership( \a mcAddr , \a iface )\endlink
95 for compatibility with the IPv6 API.
96 \param[in] mcAddr address of group to join
97 \param[in] localAddr address of interface to join on */
98 void mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const;
99 ///< join multicast group on a specific interface
100 /**< This member will add \a mcAddr to the list of multicast
101 groups received. The group is joined on the given
103 \param[in] mcAddr address of group to join
104 \param[in] iface interface name */
106 void mcDropMembership(INet4Address const & mcAddr) const;
107 ///< Leave multicast group
108 /**< This member will remove \a mcAddr from the list of
109 multicast groups received. The group is left from the
111 \param[in] mcAddr address of group to leave */
112 void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr)
114 ///< leave multicast group on a specific interface
115 /**< This member will remove \a mcAddr from the list of
116 multicast groups received. The group is left from the
117 interface with the given local address.
118 \deprecated Use \link mcDropMembership(INet4Address const & mcAddr, std::string const & iface) const mcDropMembership( \a mcAddr , \a iface )\endlink
119 for compatibility with the IPv6 API.
120 \param[in] mcAddr address of group to leave
121 \param[in] localAddr address of interface to leave
123 void mcDropMembership(INet4Address const & mcAddr, std::string const & iface)
125 ///< leave multicast group on a specific interface
126 /**< This member will remove \a mcAddr from the list of
127 multicast groups received. The group is left from the
128 interface with the given local address.
129 \param[in] mcAddr address of group to leave
130 \param[in] iface interface name */
132 void mcJoinSSMSource(INet4Address const & group, INet4Address const & source,
133 std::string const & iface) const;
134 ///< join SSM multicast group
135 /**< This call will join the multicast group \a group for
136 traffic from \a source. A single group may be joined
137 multiple times on different sources.
138 \param[in] group multicast group to join
139 \param[in] source SSM multicast source to join the
141 \param[in] iface interface to join the group on */
142 void mcLeaveSSMSource(INet4Address const & group, INet4Address const & source,
143 std::string const & iface) const;
144 ///< leave SSM multicast group
145 /**< This call will leave the multicast group \a group for
146 traffic from \a source.
147 \param[in] group multicast group to leave
148 \param[in] source SSM multicast source to leave the
150 \param[in] iface interface to leave the group on */
153 /** \brief Multicast protocol facet for INet6 addressable multicast enabled sockets
155 This implementation supports INet6 mapped INet4 multicast addresses. This is a linux
156 specific extension and NOT part of the relevant RFCs.
158 class INet6MulticastSocketProtocol
159 : public MulticastSocketProtocol
162 void mcAddMembership(INet6Address const & mcAddr) const;
163 ///< Join multicast group on default interface
164 /**< This member will add \a mcAddr to the list of multicast
165 groups received. The group is joined on the default
167 \param[in] mcAddr address of group to join */
168 void mcAddMembership(INet6Address const & mcAddr, std::string const & iface);
169 ///< join multicast group on a specific interface
170 /**< This member will add \a mcAddr to the list of multicast
171 groups received. The group is joined on the given
173 \param[in] mcAddr address of group to join
174 \param[in] iface interface name */
176 void mcDropMembership(INet6Address const & mcAddr) const;
177 ///< Leave multicast group
178 /**< This member will remove \a mcAddr from the list of
179 multicast groups received. The group is left from the
181 \param[in] mcAddr address of group to leave */
182 void mcDropMembership(INet6Address const & mcAddr, std::string const & iface) const;
183 ///< leave multicast group on a specific interface
184 /**< This member will remove \a mcAddr from the list of
185 multicast groups received. The group is left from the
186 interface with the given local address.
187 \param[in] mcAddr address of group to leave
188 \param[in] iface interface name */
190 void mcJoinSSMSource(INet6Address const & group, INet6Address const & source,
191 std::string const & iface) const;
192 ///< join SSM multicast group
193 /**< This call will join the multicast group \a group for
194 traffic from \a source. A single group may be joined
195 multiple times on different sources.
196 \param[in] group multicast group to join
197 \param[in] source SSM multicast source to join the
199 \param[in] iface interface to join the group on */
200 void mcJoinSSMSource(INet6Address const & group, INet6Address const & source,
202 ///< join SSM multicast group
203 /**< This call will join the multicast group \a group for
204 traffic from \a source. A single group may be joined
205 multiple times on different sources.
206 \param[in] group multicast group to join
207 \param[in] source SSM multicast source to join the
209 \param[in] ifacei interface index to join the group on */
210 void mcJoinSSMSource(INet6Address const & group, INet6Address const & source) const;
211 ///< join SSM multicast group
212 /**< This call will join the multicast group \a group for
213 traffic from \a source. A single group may be joined
214 multiple times on different sources.
215 \param[in] group multicast group to join
216 \param[in] source SSM multicast source to join the
218 void mcLeaveSSMSource(INet6Address const & group, INet6Address const & source,
219 std::string const & iface) const;
220 ///< leave SSM multicast group
221 /**< This call will leave the multicast group \a group for
222 traffic from \a source.
223 \param[in] group multicast group to leave
224 \param[in] source SSM multicast source to leave the
226 \param[in] iface interface to leave the group on */
232 ///////////////////////////////hh.e////////////////////////////////////////
233 //#include "MulticastSocketProtocol.cci"
234 //#include "MulticastSocketProtocol.ct"
235 //#include "MulticastSocketProtocol.cti"
242 // comment-column: 40
243 // c-file-style: "senf"
244 // indent-tabs-mode: nil
245 // ispell-local-dictionary: "american"
246 // compile-command: "scons -u test"