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