Fixed whitespace in all files (no tabs)
[senf.git] / Socket / INetProtocol.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.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 IPv[46]Protocol public header
25
26     \todo what about OOB data?
27
28     \todo Implement IP_RECVERR / MSG_ERRQUEUE. This should be placed
29     into an additional protocol facet since IP_RECVERR is only valid
30     for SOCK_DGRAM (UDP) and not SOCK_STREAM (TCP) sockets
31  */
32
33 #ifndef HH_INetProtocol_
34 #define HH_INetProtocol_ 1
35
36 // Custom includes
37 #include "SocketProtocol.hh"
38 #include "INetAddressing.hh"
39 #include "ClientSocketHandle.hh"
40 #include "CommunicationPolicy.hh"
41
42 //#include "INetProtocol.mpp"
43 ///////////////////////////////hh.p////////////////////////////////////////
44
45 namespace senf {
46
47     /// \addtogroup protocol_facets_group
48     /// @{
49
50     /** \brief Protocol facet providing IPv4 Addressing related API
51
52         This protocol facet introduces all the socket api protocol members which are related to IPv4
53         addressing.
54
55         \todo Is it safe, not to allow setting the interface index on add/drop? what does it do
56         (especially if the local addres is given ?). What have I been thinking here ???
57
58         \todo move all multicast-methods into an extra IPv4MulticastProtocol class (it's only
59         available on datagram sockets)
60
61         \todo the multicast add/remove/iface semantics are quite unclear ...
62
63         \todo connect() is only available on stream sockets. We want to access bind() and connet()
64         via the ClientSocketHandle -> see SocketProtocol todo point
65      */
66     class IPv4Protocol
67         : public virtual SocketProtocol
68     {
69     public:
70         void connect(INet4Address const & address) const; ///< Connect to remote address
71                                         /**< \todo make this obsolete by allowing access to the
72                                              ClientSocketHandle from ConcreateSocketProtocol
73                                              \param[in] address Address to connect to */
74         void bind(INet4Address const & address) const; ///< Set local socket address
75                                         /**< \todo make this obsolete by allowing access to the
76                                              ClientSocketHandle from ConcreateSocketProtocol
77                                              \param[in] address Address to set */
78
79         unsigned mcTTL() const;         ///< Return current multicast TTL
80         void mcTTL(unsigned value) const; ///< Set multicast TTL
81
82         bool mcLoop() const;            ///< Return current multicast loopback state
83         void mcLoop(bool value) const;  ///< Set multicast loopback state
84
85         void mcAddMembership(INet4Address const & mcAddr) const;
86                                         ///< Join multicast group
87                                         /**< This member will add \a mcAddr to the list of multicast
88                                              groups received. The group is joined on the default
89                                              interface.
90                                              \param[in] mcAddr address of group to join
91                                              \todo fix this as soon as we have a real address class
92                                                  (differend from the sockaddress class */
93         void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
94                                         ///< join multicast group on a specific address/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                                              \param[in] mcAddr address of group to join
99                                              \param[in] localAddr address of interface to join on
100                                              \todo fix this as soon as we have a real address class
101                                                  (differend from the sockaddress class */
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                                              \todo fix this as soon as we have a real address class
110                                                  (differend from the sockaddress class */
111         void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
112                                         ///< leave multicast group on a specific address/interface
113                                         /**< This member will remove \a mcAddr from the list of
114                                              multicast groups received. The group is left from the
115                                              interface with the given local address.
116                                              \param[in] mcAddr address of group to leave
117                                              \param[in] localAddr address of interface to leave from
118                                              \todo fix this as soon as we have a real address class
119                                                  (differend from the sockaddress class */
120
121         void mcIface(std::string iface = std::string()) const;
122                                         ///< set default multicast interface of the socket
123                                         /**< \param[in] iface name of interface */
124     };
125
126     /** \brief Protocol facet providing IPv6 Addressing related API
127
128         This protocol facet introduces all the socket api protocol members which are related to IPv6
129         addressing.
130      */
131     class IPv6Protocol
132         : public virtual SocketProtocol
133     {
134     public:
135         void connect(INet6SocketAddress const & address) const; ///< Connect to remote address
136                                         /**< \todo make this obsolete by allowing access to the
137                                              ClientSocketHandle from ConcreateSocketProtocol
138                                              \param[in] address Address to connect to */
139         void bind(INet6SocketAddress const & address) const; ///< Set local socket address
140                                         /**< \todo make this obsolete by allowing access to the
141                                              ClientSocketHandle from ConcreateSocketProtocol
142                                              \param[in] address Address to set */
143     };
144
145     /// @}
146
147 }
148
149 ///////////////////////////////hh.e////////////////////////////////////////
150 //#include "INetProtocol.cci"
151 //#include "INetProtocol.ct"
152 //#include "INetProtocol.cti"
153 #endif
154
155 \f
156 // Local Variables:
157 // mode: c++
158 // fill-column: 100
159 // c-file-style: "senf"
160 // indent-tabs-mode: nil
161 // ispell-local-dictionary: "american"
162 // End: