X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FSocket%2FProtocols%2FUN%2FUNAddressing.hh;fp=senf%2FSocket%2FProtocols%2FUN%2FUNAddressing.hh;h=eccb8d3578d9dd71c04cd5cb60896093bee1949e;hb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;hp=0000000000000000000000000000000000000000;hpb=164fe477094d42463722584e527a02379ab5d985;p=senf.git diff --git a/senf/Socket/Protocols/UN/UNAddressing.hh b/senf/Socket/Protocols/UN/UNAddressing.hh new file mode 100644 index 0000000..eccb8d3 --- /dev/null +++ b/senf/Socket/Protocols/UN/UNAddressing.hh @@ -0,0 +1,126 @@ +// $Id$ +// +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// David Wagner +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief UNAddressing public header */ + +#ifndef HH_SENF_Socket_Protocols_UN_UNAddressing_ +#define HH_SENF_Socket_Protocols_UN_UNAddressing_ 1 + +// Custom includes +#include +#include +#include +#include +#include "../BSDAddressingPolicy.hh" +#include "../BSDSocketAddress.hh" + +//#include "UNAddressing.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { + + /** \brief Unix domain socket address + + UNSocketAddress wraps the standard sockaddr_un datatype. It provides simple accessor methods + to access the path. + + \implementation This implementation is based on sockaddr_un. + + \ingroup addr_group + */ + class UNSocketAddress + : public BSDSocketAddress + { + public: + static short const addressFamily = AF_UNIX; + + UNSocketAddress(); + + explicit UNSocketAddress(std::string const & path); + ///< Construct an address constant from given path + + UNSocketAddress(const UNSocketAddress& other); + UNSocketAddress& operator=(const UNSocketAddress& other); + + std::string path() const ; ///< Return path as string + void path(std::string const & path); + + using BSDSocketAddress::sockaddr_p; + using BSDSocketAddress::socklen_p; + + private: + struct sockaddr_un addr_; + }; + + /** \brief Write path to os + + \related UNSocketAddress + */ + std::ostream & operator<<(std::ostream & os, UNSocketAddress const & addr); + + /// \addtogroup policy_impl_group + /// @{ + + /** \brief Addressing policy supporting unix domain addressing + + \par Address Type: + UNSocketAddress + + This addressing policy implements addressing using unix domain + addresses. + + The various members are directly imported from + BSDAddressingPolicyMixin which see for a detailed + documentation. + */ + struct UNAddressingPolicy + : public BSDAddressingPolicy, + private BSDAddressingPolicyMixin + { + typedef UNSocketAddress Address; + + using BSDAddressingPolicyMixin::peer; + using BSDAddressingPolicyMixin::local; + using BSDAddressingPolicyMixin::connect; + using BSDAddressingPolicyMixin::bind; + }; + + ///@} +} + +///////////////////////////////hh.e//////////////////////////////////////// +#include "UNAddressing.cci" +//#include "UNAddressing.ct" +//#include "UNAddressing.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: