0de6997b53de6e33698765d4c97ca6054d657b63
[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         /**< If set to false via \c mcLoop(value) multicast messages will not be looped back  to local sockets. Default value is \c true (1).   */
66
67         void mcIface(std::string const & iface = std::string()) const;
68                                         ///< Set multicast send interface of the socket
69                                         /**< \param[in] iface name of interface to send multicast
70                                              data from */
71     };
72
73     /** \brief Multicast protocol facet for INet4 addressable multicast enabled sockets
74      */
75     class INet4MulticastSocketProtocol
76         : public MulticastSocketProtocol
77     {
78     public:
79         void mcAddMembership(INet4Address const & mcAddr) const;
80                                         ///< Join multicast group on default interface
81                                         /**< This member will add \a mcAddr to the list of multicast
82                                              groups received. The group is joined on the default
83                                              interface.
84                                              \param[in] mcAddr address of group to join */
85         void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) 
86             const;
87                                         ///< join multicast group on a specific interface
88                                         /**< This member will add \a mcAddr to the list of multicast
89                                              groups received. The group is joined on the interface
90                                              with the given local address.
91                                              \deprecated Use \link mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const mcAddMembership( \a mcAddr , \a iface )\endlink 
92                                                  for compatibility with the IPv6 API.
93                                              \param[in] mcAddr address of group to join
94                                              \param[in] localAddr address of interface to join on */
95         void mcAddMembership(INet4Address const & mcAddr, std::string const & iface) const;
96                                         ///< join multicast group on a specific interface
97                                         /**< This member will add \a mcAddr to the list of multicast
98                                              groups received. The group is joined on the given
99                                              interface.
100                                              \param[in] mcAddr address of group to join
101                                              \param[in] iface interface name */
102
103         void mcDropMembership(INet4Address const & mcAddr) const;
104                                         ///< Leave multicast group
105                                         /**< This member will remove \a mcAddr from the list of
106                                              multicast groups received. The group is left from the
107                                              default interface.
108                                              \param[in] mcAddr address of group to leave */
109         void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr) 
110             const;
111                                         ///< leave multicast group on a specific interface
112                                         /**< This member will remove \a mcAddr from the list of
113                                              multicast groups received. The group is left from the
114                                              interface with the given local address.
115                                              \deprecated Use \link mcDropMembership(INet4Address const & mcAddr, std::string const & iface) const mcDropMembership( \a mcAddr , \a iface )\endlink 
116                                                  for compatibility with the IPv6 API.
117                                              \param[in] mcAddr address of group to leave
118                                              \param[in] localAddr address of interface to leave
119                                                  from */
120         void mcDropMembership(INet4Address const & mcAddr, std::string const & iface) 
121             const;
122                                         ///< leave multicast group on a specific interface
123                                         /**< This member will remove \a mcAddr from the list of
124                                              multicast groups received. The group is left from the
125                                              interface with the given local address.
126                                              \param[in] mcAddr address of group to leave
127                                              \param[in] iface interface name */
128     };
129
130     /** \brief Multicast protocol facet for INet6 addressable multicast enabled sockets
131
132         This implementation supports INet6 mapped INet4 multicast addresses. This is a linux
133         specific extension and NOT part of the relevant RFCs.
134      */
135     class INet6MulticastSocketProtocol
136         : public MulticastSocketProtocol
137     {
138     public:
139         void mcAddMembership(INet6Address const & mcAddr) const;
140                                         ///< Join multicast group on default interface
141                                         /**< This member will add \a mcAddr to the list of multicast
142                                              groups received. The group is joined on the default
143                                              interface.
144                                              \param[in] mcAddr address of group to join */
145         void mcAddMembership(INet6Address const & mcAddr, std::string const & iface);
146                                         ///< join multicast group on a specific interface
147                                         /**< This member will add \a mcAddr to the list of multicast
148                                              groups received. The group is joined on the given
149                                              interface.
150                                              \param[in] mcAddr address of group to join
151                                              \param[in] iface interface name */
152
153         void mcDropMembership(INet6Address const & mcAddr) const;
154                                         ///< Leave multicast group
155                                         /**< This member will remove \a mcAddr from the list of
156                                              multicast groups received. The group is left from the
157                                              default interface.
158                                              \param[in] mcAddr address of group to leave */
159         void mcDropMembership(INet6Address const & mcAddr, std::string const & iface) 
160             const;
161                                         ///< leave multicast group on a specific interface
162                                         /**< This member will remove \a mcAddr from the list of
163                                              multicast groups received. The group is left from the
164                                              interface with the given local address.
165                                              \param[in] mcAddr address of group to leave
166                                              \param[in] iface interface name */
167     };
168
169     ///\}
170 }
171
172 ///////////////////////////////hh.e////////////////////////////////////////
173 //#include "MulticastSocketProtocol.cci"
174 //#include "MulticastSocketProtocol.ct"
175 //#include "MulticastSocketProtocol.cti"
176 #endif
177
178 \f
179 // Local Variables:
180 // mode: c++
181 // fill-column: 100
182 // comment-column: 40
183 // c-file-style: "senf"
184 // indent-tabs-mode: nil
185 // ispell-local-dictionary: "american"
186 // compile-command: "scons -u test"
187 // End: