4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // David Wagner <dw6@berlios.de>
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.
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.
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.
24 \brief UNAddressing public header */
26 #ifndef HH_UNAddressing_
27 #define HH_UNAddressing_ 1
32 #include <sys/socket.h>
34 #include <boost/cstdint.hpp>
35 #include <boost/operators.hpp>
36 #include "../../../Socket/SocketPolicy.hh"
37 #include "../../../Socket/ClientSocketHandle.hh"
38 #include "../../../Socket/CommunicationPolicy.hh"
39 #include "../../../Socket/Protocols/GenericAddressingPolicy.hh"
40 #include "../../../Utils/safe_bool.hh"
42 //#include "UNAddressing.mpp"
43 ///////////////////////////////hh.p////////////////////////////////////////
47 /** \brief Unix domain socket address
49 UNSocketAddress wraps the standard sockaddr_un datatype. It provides simple accessor methods
52 \implementation This implementation is based on sockaddr_un.
56 \fixme Why both std::string constructor and from_string member ?
59 : public comparable_safe_bool<UNSocketAddress>
63 explicit UNSocketAddress(std::string p);
64 ///< Construct an address constant from given path
65 static UNSocketAddress from_string(std::string const s);
66 ///< Create UNSocketAddress from string
68 bool operator==(UNSocketAddress const & other) const;
69 ///< Compare UNSocketAddress for equality
71 std::string path() const ; ///< Return path as string
73 bool boolean_test() const; ///< \c true, if address is not empty
75 void clear(); ///< Clear address
77 struct sockaddr * sockaddr_p() ;
78 struct sockaddr const * sockaddr_p() const;
79 unsigned sockaddr_len() const;
82 struct sockaddr_un addr_;
85 /** \brief Write path to os
87 \related UNSocketAddress
89 std::ostream & operator<<(std::ostream & os, UNSocketAddress const & addr);
91 /// \addtogroup policy_impl_group
94 /** \brief Addressing policy supporting unix domain addressing
99 This addressing policy implements addressing using unix domain
102 The various members are directly imported from
103 GenericAddressingPolicy which see for a detailed
106 struct UNAddressingPolicy
107 : public AddressingPolicyBase,
108 private GenericAddressingPolicy<UNSocketAddress>
110 typedef UNSocketAddress Address;
112 using GenericAddressingPolicy<UNSocketAddress>::peer;
113 using GenericAddressingPolicy<UNSocketAddress>::local;
114 using GenericAddressingPolicy<UNSocketAddress>::connect;
115 using GenericAddressingPolicy<UNSocketAddress>::bind;
121 ///////////////////////////////hh.e////////////////////////////////////////
122 //#include "UNAddressing.cci"
123 //#include "UNAddressing.ct"
124 //#include "UNAddressing.cti"
131 // comment-column: 40
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"