b1dcf4a82703100a53cbe59acabc8ca636e35f97
[senf.git] / Socket / Protocols / INet / MulticastSocketProtocol.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief MulticastSocketProtocol public header */
25
26 #ifndef HH_MulticastSocketProtocol_
27 #define HH_MulticastSocketProtocol_ 1
28
29 // Custom includes
30 #include "../../../Socket/SocketProtocol.hh"
31 #include "INet4Address.hh"
32 #include "INet6Address.hh"
33
34 //#include "MulticastSocketProtocol.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
36
37 namespace senf {
38
39     ///\addtogroup protocol_facets_group
40     ///\{
41    
42     /** \brief Generic addressing type independent multicast protocol facet
43      */
44     class MulticastSocketProtocol 
45         : public virtual SocketProtocol
46     {
47     public:
48         void broadcastEnabled(bool v) const; ///< Enable broadcast send/receive
49                                         /**< If this option is enabled, broadcast UDP messages will
50                                              be received on the socket and the socket will be
51                                              allowed to send out broadcast UDP messages
52                                              \param[in] v \c true to enable broadcast send/receive,
53                                                  \c false to disable */
54
55         bool broadcastEnabled() const;  ///< Get broadcast send/receive state
56                                         /**< \returns Current state of the broadcastEnabled()
57                                              option. */
58
59
60         unsigned mcTTL() const;         ///< Return current multicast TTL
61         void mcTTL(unsigned value) const; ///< Set multicast TTL
62
63         bool mcLoop() const;            ///< Return current multicast loopback state
64         void mcLoop(bool value) const;  ///< Set multicast loopback state
65
66         void mcIface(std::string const & iface = std::string()) const;
67                                         ///< Set multicast send interface of the socket
68                                         /**< \param[in] iface name of interface to send multicast
69                                              data from */
70     };
71
72     /** \brief Multicast protocol facet for INet4 addressable multicast enabled sockets
73      */
74     class INet4MulticastSocketProtocol
75         : public virtual SocketProtocol
76     {
77     public:
78         void mcAddMembership(INet4Address const & mcAddr) const;
79                                         ///< Join multicast group on default interface
80                                         /**< This member will add \a mcAddr to the list of multicast
81                                              groups received. The group is joined on the default
82                                              interface.
83                                              \param[in] mcAddr address of group to join */
84         void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) 
85             const;
86                                         ///< join multicast group on a specific interface
87                                         /**< This member will add \a mcAddr to the list of multicast
88                                              groups received. The group is joined on the interface
89                                              with the given local address.
90                                              \deprecated Use \link mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const mcAddMembership( \a mcAddr , \a iface )\endlink 
91                                                  for compatibility with the IPv6 API.
92                                              \param[in] mcAddr address of group to join
93                                              \param[in] localAddr address of interface to join on */
94         void mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const;
95                                         ///< join multicast group on a specific interface
96                                         /**< This member will add \a mcAddr to the list of multicast
97                                              groups received. The group is joined on the given
98                                              interface.
99                                              \param[in] mcAddr address of group to join
100                                              \param[in] iface interface name */
101
102         void mcDropMembership(INet4Address const & mcAddr) const;
103                                         ///< Leave multicast group
104                                         /**< This member will remove \a mcAddr from the list of
105                                              multicast groups received. The group is left from the
106                                              default interface.
107                                              \param[in] mcAddr address of group to leave */
108         void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr) 
109             const;
110                                         ///< leave multicast group on a specific interface
111                                         /**< This member will remove \a mcAddr from the list of
112                                              multicast groups received. The group is left from the
113                                              interface with the given local address.
114                                              \deprecated Use \link mcDropMembership(INet4Address const & mcAddr, std::string const & iface) const mcDropMembership( \a mcAddr , \a iface )\endlink 
115                                                  for compatibility with the IPv6 API.
116                                              \param[in] mcAddr address of group to leave
117                                              \param[in] localAddr address of interface to leave
118                                                  from */
119         void mcDropMembership(INet4Address const & mcAddr, std::string const & iface) 
120             const;
121                                         ///< leave multicast group on a specific interface
122                                         /**< This member will remove \a mcAddr from the list of
123                                              multicast groups received. The group is left from the
124                                              interface with the given local address.
125                                              \param[in] mcAddr address of group to leave
126                                              \param[in] iface interface name */
127     };
128
129     /** \brief Multicast protocol facet for INet6 addressable multicast enabled sockets
130      */
131     class INet6MulticastSocketProtocol
132         : public virtual SocketProtocol
133     {
134     public:
135         void mcAddMembership(INet6Address const & mcAddr) const;
136                                         ///< Join multicast group on default interface
137                                         /**< This member will add \a mcAddr to the list of multicast
138                                              groups received. The group is joined on the default
139                                              interface.
140                                              \param[in] mcAddr address of group to join */
141         void mcAddMembership(INet6Address const & mcAddr, INet6Address const & localAddr) 
142             const;
143                                         ///< join multicast group on a specific interface
144                                         /**< This member will add \a mcAddr to the list of multicast
145                                              groups received. The group is joined on the interface
146                                              with the given local address.
147                                              \param[in] mcAddr address of group to join
148                                              \param[in] localAddr address of interface to join on */
149         void mcAddMembership(INet6Address const & mcAddr, std::string const & iface);
150                                         ///< join multicast group on a specific interface
151                                         /**< This member will add \a mcAddr to the list of multicast
152                                              groups received. The group is joined on the given
153                                              interface.
154                                              \param[in] mcAddr address of group to join
155                                              \param[in] iface interface name */
156
157         void mcDropMembership(INet6Address const & mcAddr) const;
158                                         ///< Leave multicast group
159                                         /**< This member will remove \a mcAddr from the list of
160                                              multicast groups received. The group is left from the
161                                              default interface.
162                                              \param[in] mcAddr address of group to leave */
163         void mcDropMembership(INet6Address const & mcAddr, INet6Address const & localAddr) 
164             const;
165                                         ///< leave multicast group on a specific interface
166                                         /**< This member will remove \a mcAddr from the list of
167                                              multicast groups received. The group is left from the
168                                              interface with the given local address.
169                                              \param[in] mcAddr address of group to leave
170                                              \param[in] localAddr address of interface to leave
171                                                  from */
172         void mcDropMembership(INet6Address const & mcAddr, std::string const & iface) 
173             const;
174                                         ///< leave multicast group on a specific interface
175                                         /**< This member will remove \a mcAddr from the list of
176                                              multicast groups received. The group is left from the
177                                              interface with the given local address.
178                                              \param[in] mcAddr address of group to leave
179                                              \param[in] localAddr address of interface to leave
180                                                  from */
181     };
182
183     ///\}
184 }
185
186 ///////////////////////////////hh.e////////////////////////////////////////
187 //#include "MulticastSocketProtocol.cci"
188 //#include "MulticastSocketProtocol.ct"
189 //#include "MulticastSocketProtocol.cti"
190 #endif
191
192 \f
193 // Local Variables:
194 // mode: c++
195 // fill-column: 100
196 // comment-column: 40
197 // c-file-style: "senf"
198 // indent-tabs-mode: nil
199 // ispell-local-dictionary: "american"
200 // compile-command: "scons -u test"
201 // End: