}
prefix_ senf::UNAddress::UNAddress(boost::filesystem::path p)
- //:path(p)
{
-
+ path = p;
}
}
prefix_ std::string senf::UNAddress::pathString()
+ const
{
return path.string();
}
+prefix_ senf::UNAddress::UNAddress senf::UNAddress::clone()
+{
+ senf::UNAddress::UNAddress local_addr = senf::UNAddress::UNAddress(pathString());
+ return local_addr;
+}
-prefix_ const std::ostream & senf::operator<<(std::ostream & os, UNAddress const & addr)
+prefix_ std::ostream & senf::operator<<(std::ostream & os, UNAddress const & addr)
{
os << addr.pathString();
return os;
explicit UNAddress(boost::filesystem::path);///< Construct an address constant from given path
static UNAddress fromString(std::string & s); ///< Convert string to address by interpreting the string as path
static UNAddress fromPath(boost::filesystem::path & p);///< Convert path to address
- static std::string pathString(); ///< Return the path of the address as string
+ UNAddress clone(); ///< Clone object
+ std::string pathString() const; ///< Return the path of the address as string
/** \brief Base-class for UNAddress exceptions */
struct AddressException : public std::exception {};
private:
- static boost::filesystem::path path;
+ boost::filesystem::path path;
};
-const std::ostream & operator<<(std::ostream & os, UNAddress const & addr);
+std::ostream & operator<<(std::ostream & os, UNAddress const & addr);
}
///////////////////////////////hh.e////////////////////////////////////////
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+//
+// 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 UNAddress.test unit tests */
+
+//#include "UNAddress.test.hh"
+//#include "UNAddress.test.ih"
+
+// Custom includes
+#include "UNAddress.hh"
+#include <boost/filesystem/path.hpp>
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#include <iostream>
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(unAddress)
+{
+ // das koennt sicher mehr sein...
+ std::string testS = "/tmp/senfTestSocket";
+ boost::filesystem::path testp = boost::filesystem::path(testS);
+ senf::UNAddress addr1 = senf::UNAddress::fromString(testS);
+ senf::UNAddress addr2 = senf::UNAddress::fromPath(testp);
+ BOOST_CHECK( testS == addr1.pathString());
+ BOOST_CHECK( testS == addr2.pathString());
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// 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:
return senf::UNSocketAddress::UNSocketAddress(p);
}
prefix_ std::string senf::UNSocketAddress::path()
+ const
{
return std::string(sockAddr.sun_path);
}
}
prefix_ unsigned senf::UNSocketAddress::sockaddr_len()
- const
{
return sizeof(sockAddr);
}
namespace senf {
/** \brief Unix domain socket address
- UNSocketAddress wraps the standard sockaddr_in datatype. It provides simple accessor methods
+ UNSocketAddress wraps the standard sockaddr_un datatype. It provides simple accessor methods
to access the path.
\implementation This implementation is based on sockaddr_un.
///< Construct an address constant from given path
static UNSocketAddress from_string(std::string const s); ///< Create UNSocketAddress from string
static UNSocketAddress from_path(boost::filesystem::path const p); ///< Create UNSocketAddress from path
- static std::string path(); ///< Return path as string
- static sockaddr_un sockaddr();
-
- struct sockaddr * sockaddr_p();
+ std::string path() const ; ///< Return path as string
+ struct sockaddr_un sockaddr();
+ struct sockaddr * sockaddr_p() ;
struct sockaddr const * sockaddr_p() const;
- unsigned sockaddr_len() const;
+ unsigned sockaddr_len();
private:
- static struct sockaddr_un sockAddr;
+ struct sockaddr_un sockAddr;
};
/** \brief Write path os
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+//
+// 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.test unit tests */
+
+//#include "UNAddressing.test.hh"
+//#include "UNAddressing.test.ih"
+
+// Custom includes
+#include "UNAddressing.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(unSocketAddress)
+{
+ std::string testS = "/tmp/senfTestSocket";
+ senf::UNSocketAddress addr (testS) ;
+ int mySock = socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (bind(mySock, addr.sockaddr_p(), addr.sockaddr_len())) {
+ std::cout << "Error while binding name to unix socket" << std::endl;
+ }
+
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// 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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+//
+// 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.test unit tests */
+
+//#include "UNAddressing.test.hh"
+//#include "UNAddressing.test.ih"
+
+// Custom includes
+#include "UNAddressing.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(unSocketAddress)
+{
+ std::string testS = "/tmp/senfTestSocket";
+ senf::UNSocketAddress addr (testS) ;
+ mySock = socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (bind(mySock, addr.sockaddr_p(), addr.sockaddr_len())) {
+ std::cout << "Error while binding name to unix socket" std::endl;
+ }
+
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// 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:
typedef MakeSocketPolicy<
UNDatagramSocket_Policy,
UNAddressingPolicy
- >::policy UDPv6Socket_Policy;
+ >::policy UNDatagramSocket_Policy;
}
///////////////////////////////hh.e////////////////////////////////////////
//#include "UNDatagramSocketHandle.cci"
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+//
+// 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 UNDatagramSocketHandle.test unit tests */
+
+//#include "UNDatagramSocketHandle.test.hh"
+//#include "UNDatagramSocketHandle.test.ih"
+
+// Custom includes
+#include "UNDatagramSocketHandle.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(unDatagramSocketHandle)
+{
+ std::string testS = "/tmp/senfTestSocket";
+ senf::UNSocketAddress addr (testS) ;
+ //senf::UNDatagramSocketHandle init_client(addr);
+ senf::UNDatagramClientSocketHandle inputSocket(senf::UNSocketAddress(tests));
+}
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// 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:
prefix_ void senf::UNProtocol::connect(UNSocketAddress const & address)
const
{
- if(::connect(body().fd(), address.sockaddr_p(), sizeof(address.sockaddr())) < 0)
+ if(::connect(body().fd(), address.sockaddr_p(), sizeof(sockaddr_un)) < 0)
throw SystemException(errno);
}
prefix_ void senf::UNProtocol::bind(UNSocketAddress const & address)
const
{
- if(::bind(body().fd(), address.sockaddr_p(), sizeof(address.sockaddr())) < 0)
+ if(::bind(body().fd(), address.sockaddr_p(), sizeof(sockaddr_un)) < 0)
throw SystemException(errno);
}
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+//
+// 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 UNProtocol.test unit tests */
+
+//#include "UNProtocol.test.hh"
+//#include "UNProtocol.test.ih"
+
+// Custom includes
+#include "UNProtocol.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(unProtocol)
+{
+ std::string testS = "/tmp/senfTestSocket";
+ //zZ leer
+}
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// 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:
--- /dev/null
+// $Id: main.test.cc 296 2007-07-10 20:39:34Z g0dil $
+//
+// Copyright (C) 2006
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+//
+// 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.
+
+// Definition of non-inline non-template functions
+
+//#include "test.hh"
+//#include "test.ih"
+
+// Custom includes
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End: