66d4fa9774636d58b27d057163ace131140c15e2
[senf.git] / Socket / Protocols / GenericSockAddr.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 GenericSockAddr public header */
25
26 /** \defgroup addr_group Socket Addressing
27
28     To support the core socket functionality we need a collection of classing providing addressing
29     for the different protocols.
30     
31     For all standard BSD socket protocols we base the address classes on the corresponding \c
32     sockaddr structures, wrapped into appropriate C++ adapters. These Address classes are based on
33     GenericSockAddr, the corresponding addressing policy is defined in GenericAddressingPolicy.
34
35     You are however not limit to BSD type socket address classes as long as you implement the
36     corresponding addressing policy.
37  */
38
39 #ifndef HH_GenericSockAddr_
40 #define HH_GenericSockAddr_ 1
41
42 // Custom includes
43 #include <sys/socket.h>
44
45 //#include "GenericSockAddr.mpp"
46 ///////////////////////////////hh.p////////////////////////////////////////
47
48 namespace senf {
49
50     /// \addtogroup addr_group
51     /// @{
52
53     /** \brief Generic protocol-independant socket address
54
55         This address type does not depend on the protocol of the socket. It does nowever not support
56         any protocol specific API, so access to the address is very limited.
57      */
58     class GenericSockAddr
59     {
60     public:
61         GenericSockAddr();
62
63         /// \name Generic Address Interface
64         /// @{
65
66         struct sockaddr * sockaddr_p(); ///< Return a pointer to sockaddr structure
67                                         /**< The exact structure pointed to depends on the address
68                                              family. The data pointed to must be \e mutable. The
69                                              value must be changeable and any change of the value
70                                              through this pointer must be reflected in the visible
71                                              address interface.
72                                              \returns non-const (!) pointer to sockaddr structure */
73         struct sockaddr const * sockaddr_p() const; ///< Return a pointer to sockaddr structure
74                                         /**< This member is like sockaddr_p(), however it does not
75                                              allow changing the address.
76                                              \returns const pointer to sockaddr structure */
77         unsigned sockaddr_len() const;  ///< Return size of address
78                                         /**< This member return the size of the socket address
79                                              structure as returned by sockaddr_p() in bytes.
80                                              \returns size of respective sockaddr structure in bytes
81                                           */
82         /// @}
83
84     private:
85         struct ::sockaddr_storage addr_;
86     };
87
88     /// @}
89 }
90
91 ///////////////////////////////hh.e////////////////////////////////////////
92 #include "GenericSockAddr.cci"
93 //#include "GenericSockAddr.ct"
94 //#include "GenericSockAddr.cti"
95 //#include "GenericSockAddr.mpp"
96 #endif
97
98 \f
99 // Local Variables:
100 // mode: c++
101 // fill-column: 100
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"
106 // comment-column: 40
107 // End: