/** Depending on the type of \c Address, this will be either <tt>Address</tt> or <tt>Address
const &</tt>. See <a
href="http://www.boost.org/libs/utility/call_traits.htm">call_traits documentation in
- the Boost.Utility library\endlink.</a>
+ the Boost.Utility library.</a>
*/
typedef typename boost::call_traits<Address>::param_type AddressParam;
/// Corresponding server socket handle with the same policy
communication policy is ConnectedCommunicationPolicy.
\param[in] handle socket handle
- \param[in] address address of remote peer to connect
+ \param[in] addr address of remote peer to connect
to */
static void bind(FileHandle handle, Address const & addr);
///< Set local socket address
// Custom includes
#include <sys/socket.h>
#include <netinet/in.h>
-#include <net/if.h> // for if_nametoindex
#include "Utils/Exception.hh"
//#include "INetProtocol.mpp"
throw SystemException(errno);
}
-prefix_ bool senf::IPv4Protocol::mcLoop()
- const
-{
- int value;
- socklen_t len (sizeof(value));
- if (::getsockopt(body().fd(),SOL_IP,IP_MULTICAST_LOOP,&value,&len) < 0)
- throw SystemException(errno);
- return value;
-}
-
-prefix_ void senf::IPv4Protocol::mcLoop(bool value)
- const
-{
- int ivalue (value);
- if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_LOOP,&ivalue,sizeof(ivalue)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ void senf::IPv4Protocol::mcAddMembership(INet4Address const & mcAddr)
- const
-{
- struct ip_mreqn mreqn;
- mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
- mreqn.imr_address.s_addr = htons(INADDR_ANY);
- mreqn.imr_ifindex = 0;
- if (::setsockopt(body().fd(),SOL_IP,IP_ADD_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ void senf::IPv4Protocol::mcAddMembership(INet4Address const & mcAddr,
- INet4Address const & localAddr)
- const
-{
- struct ip_mreqn mreqn;
- mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
- mreqn.imr_address = reinterpret_cast<struct sockaddr_in const *>(localAddr.sockaddr_p())->sin_addr;
- mreqn.imr_ifindex = 0;
- if (::setsockopt(body().fd(),SOL_IP,IP_ADD_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ void senf::IPv4Protocol::mcDropMembership(INet4Address const & mcAddr)
- const
-{
- struct ip_mreqn mreqn;
- mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
- mreqn.imr_address.s_addr = htons(INADDR_ANY);
- mreqn.imr_ifindex = 0;
- if (::setsockopt(body().fd(),SOL_IP,IP_DROP_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ void senf::IPv4Protocol::mcDropMembership(INet4Address const & mcAddr,
- INet4Address const & localAddr)
- const
-{
- struct ip_mreqn mreqn;
- mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
- mreqn.imr_address = reinterpret_cast<struct sockaddr_in const *>(localAddr.sockaddr_p())->sin_addr;
- mreqn.imr_ifindex = 0;
- if (::setsockopt(body().fd(),SOL_IP,IP_DROP_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ void senf::IPv4Protocol::mcIface(std::string iface)
- const
-{
- struct ip_mreqn mreqn;
- ::memset(&mreqn,sizeof(mreqn),0);
- if (!iface.empty()) {
- mreqn.imr_ifindex = if_nametoindex(iface.c_str());
- if (mreqn.imr_ifindex == 0)
- throw SystemException(EINVAL);
- }
- if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_IF,&mreqn,sizeof(mreqn)) < 0)
- throw SystemException(errno);
-}
-
-prefix_ unsigned senf::IPv4Protocol::mcTTL()
- const
-{
- int value;
- socklen_t len (sizeof(value));
- if (::getsockopt(body().fd(),SOL_IP,IP_MULTICAST_TTL,&value,&len) < 0)
- throw SystemException(errno);
- return value;
-}
-
-prefix_ void senf::IPv4Protocol::mcTTL(unsigned value)
- const
-{
- if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_TTL,&value,sizeof(value)) < 0)
- throw SystemException(errno);
-}
///////////////////////////////////////////////////////////////////////////
// senf::IPv6Protocol
\todo Is it safe, not to allow setting the interface index on add/drop? what does it do
(especially if the local address is given ?). What have I been thinking here ???
- \todo move all multicast-methods into an extra IPv4MulticastProtocol class (it's only
- available on datagram sockets)
-
- \todo the multicast add/remove/iface semantics are quite unclear ...
-
\todo connect() is only available on stream sockets. We want to access bind() and connect()
via the ClientSocketHandle -> see SocketProtocol todo point
*/
/**< \todo make this obsolete by allowing access to the
ClientSocketHandle from ConcreateSocketProtocol
\param[in] address Address to set */
-
- unsigned mcTTL() const; ///< Return current multicast TTL
- void mcTTL(unsigned value) const; ///< Set multicast TTL
-
- bool mcLoop() const; ///< Return current multicast loopback state
- void mcLoop(bool value) const; ///< Set multicast loopback state
-
- void mcAddMembership(INet4Address const & mcAddr) const;
- ///< Join multicast group
- /**< This member will add \a mcAddr to the list of multicast
- groups received. The group is joined on the default
- interface.
- \param[in] mcAddr address of group to join
- \todo fix this as soon as we have a real address class
- (different from the sockaddress class */
- void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
- ///< join multicast group on a specific address/interface
- /**< This member will add \a mcAddr to the list of multicast
- groups received. The group is joined on the interface
- with the given local address.
- \param[in] mcAddr address of group to join
- \param[in] localAddr address of interface to join on
- \todo fix this as soon as we have a real address class
- (different from the sockaddress class */
-
- void mcDropMembership(INet4Address const & mcAddr) const;
- ///< Leave multicast group
- /**< This member will remove \a mcAddr from the list of
- multicast groups received. The group is left from the
- default interface.
- \param[in] mcAddr address of group to leave
- \todo fix this as soon as we have a real address class
- (different from the sockaddress class */
- void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
- ///< leave multicast group on a specific address/interface
- /**< This member will remove \a mcAddr from the list of
- multicast groups received. The group is left from the
- interface with the given local address.
- \param[in] mcAddr address of group to leave
- \param[in] localAddr address of interface to leave from
- \todo fix this as soon as we have a real address class
- (different from the sockaddress class */
-
- void mcIface(std::string iface = std::string()) const;
- ///< set default multicast interface of the socket
- /**< \param[in] iface name of interface */
};
/** \brief Protocol facet providing IPv6 Addressing related API
// are at least not sensible ...
// I'll have to move those to a UDPSocket test ... they should
// realy only be in the UDP Protocol implementation
- BOOST_CHECK_NO_THROW( sock.protocol().mcTTL() );
- BOOST_CHECK_THROW( sock.protocol().mcTTL(1), senf::SystemException );
- BOOST_CHECK_NO_THROW( sock.protocol().mcLoop() );
- BOOST_CHECK_NO_THROW( sock.protocol().mcLoop(false) );
- BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0") );
- BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0","127.0.0.1:0") );
- BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0","127.0.0.1:0") );
- BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0") );
- BOOST_CHECK_THROW( sock.protocol().mcIface("lo"), senf::SystemException );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcTTL() );
+// BOOST_CHECK_THROW( sock.protocol().mcTTL(1), senf::SystemException );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcLoop() );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcLoop(false) );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0") );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0","127.0.0.1:0") );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0","127.0.0.1:0") );
+// BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0") );
+// BOOST_CHECK_THROW( sock.protocol().mcIface("lo"), senf::SystemException );
// The following setsockopts are hard to REALLY test ...
BOOST_CHECK_NO_THROW( sock.protocol().nodelay(true) );
--- /dev/null
+// $Id$
+//
+// 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.
+
+/** \file
+ \brief TCPProtocol non-inline non-template implementation
+ */
+
+#include "UDPProtocol.hh"
+//#include "UDPProtocol.ih"
+
+// Custom includes
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/ioctl.h>
+#include <linux/sockios.h> // for SIOCINQ / SIOCOUTQ
+#include <net/if.h> // for if_nametoindex
+#include "SocketHandle.hh"
+
+//#include "UDPProtocol.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+prefix_ unsigned senf::UDPProtocol::available()
+ const
+{
+ int n;
+ if (::ioctl(body().fd(),SIOCINQ,&n) < 0)
+ throw senf::SystemException(errno);
+ return n;
+}
+
+prefix_ bool senf::UDPProtocol::eof()
+ const
+{
+ return false;
+}
+
+prefix_ bool senf::UDPProtocol::mcLoop()
+ const
+{
+ int value;
+ socklen_t len (sizeof(value));
+ if (::getsockopt(body().fd(),SOL_IP,IP_MULTICAST_LOOP,&value,&len) < 0)
+ throw SystemException(errno);
+ return value;
+}
+
+prefix_ void senf::UDPProtocol::mcLoop(bool value)
+ const
+{
+ int ivalue (value);
+ if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_LOOP,&ivalue,sizeof(ivalue)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ void senf::UDPProtocol::mcAddMembership(INet4Address const & mcAddr)
+ const
+{
+ struct ip_mreqn mreqn;
+ mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_address.s_addr = htons(INADDR_ANY);
+ mreqn.imr_ifindex = 0;
+ if (::setsockopt(body().fd(),SOL_IP,IP_ADD_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ void senf::UDPProtocol::mcAddMembership(INet4Address const & mcAddr,
+ INet4Address const & localAddr)
+ const
+{
+ struct ip_mreqn mreqn;
+ mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_address = reinterpret_cast<struct sockaddr_in const *>(localAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_ifindex = 0;
+ if (::setsockopt(body().fd(),SOL_IP,IP_ADD_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ void senf::UDPProtocol::mcDropMembership(INet4Address const & mcAddr)
+ const
+{
+ struct ip_mreqn mreqn;
+ mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_address.s_addr = htons(INADDR_ANY);
+ mreqn.imr_ifindex = 0;
+ if (::setsockopt(body().fd(),SOL_IP,IP_DROP_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ void senf::UDPProtocol::mcDropMembership(INet4Address const & mcAddr,
+ INet4Address const & localAddr)
+ const
+{
+ struct ip_mreqn mreqn;
+ mreqn.imr_multiaddr = reinterpret_cast<struct sockaddr_in const *>(mcAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_address = reinterpret_cast<struct sockaddr_in const *>(localAddr.sockaddr_p())->sin_addr;
+ mreqn.imr_ifindex = 0;
+ if (::setsockopt(body().fd(),SOL_IP,IP_DROP_MEMBERSHIP,&mreqn,sizeof(mreqn)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ void senf::UDPProtocol::mcIface(std::string iface)
+ const
+{
+ struct ip_mreqn mreqn;
+ ::memset(&mreqn,sizeof(mreqn),0);
+ if (!iface.empty()) {
+ mreqn.imr_ifindex = if_nametoindex(iface.c_str());
+ if (mreqn.imr_ifindex == 0)
+ throw SystemException(EINVAL);
+ }
+ if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_IF,&mreqn,sizeof(mreqn)) < 0)
+ throw SystemException(errno);
+}
+
+prefix_ unsigned senf::UDPProtocol::mcTTL()
+ const
+{
+ int value;
+ socklen_t len (sizeof(value));
+ if (::getsockopt(body().fd(),SOL_IP,IP_MULTICAST_TTL,&value,&len) < 0)
+ throw SystemException(errno);
+ return value;
+}
+
+prefix_ void senf::UDPProtocol::mcTTL(unsigned value)
+ const
+{
+ if (::setsockopt(body().fd(),SOL_IP,IP_MULTICAST_TTL,&value,sizeof(value)) < 0)
+ throw SystemException(errno);
+}
+
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "UDPProtocol.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// 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.
+
+/** \file
+ \brief UDPProtocol public header
+ */
+
+#ifndef HH_UDPProtocol_
+#define HH_UDPProtocol_ 1
+
+// Custom includes
+#include "SocketProtocol.hh"
+#include "INetAddressing.hh"
+
+//#include "UDPProtocol.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ /// \addtogroup protocol_facets_group
+ /// @{
+
+ /** \brief Protocol facat to support UDP operations
+
+ This protocol facet provides all those protocol functions,
+ which are available on any UDP socket.
+
+ \todo the multicast add/remove/iface semantics are quite unclear ...
+ */
+ class UDPProtocol
+ : public virtual SocketProtocol
+ {
+ public:
+ unsigned mcTTL() const; ///< Return current multicast TTL
+ void mcTTL(unsigned value) const; ///< Set multicast TTL
+
+ bool mcLoop() const; ///< Return current multicast loopback state
+ void mcLoop(bool value) const; ///< Set multicast loopback state
+
+ void mcAddMembership(INet4Address const & mcAddr) const;
+ ///< Join multicast group
+ /**< This member will add \a mcAddr to the list of multicast
+ groups received. The group is joined on the default
+ interface.
+ \param[in] mcAddr address of group to join
+ \todo fix this as soon as we have a real address class
+ (different from the sockaddress class */
+ void mcAddMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
+ ///< join multicast group on a specific address/interface
+ /**< This member will add \a mcAddr to the list of multicast
+ groups received. The group is joined on the interface
+ with the given local address.
+ \param[in] mcAddr address of group to join
+ \param[in] localAddr address of interface to join on
+ \todo fix this as soon as we have a real address class
+ (different from the sockaddress class */
+
+ void mcDropMembership(INet4Address const & mcAddr) const;
+ ///< Leave multicast group
+ /**< This member will remove \a mcAddr from the list of
+ multicast groups received. The group is left from the
+ default interface.
+ \param[in] mcAddr address of group to leave
+ \todo fix this as soon as we have a real address class
+ (different from the sockaddress class */
+ void mcDropMembership(INet4Address const & mcAddr, INet4Address const & localAddr) const;
+ ///< leave multicast group on a specific address/interface
+ /**< This member will remove \a mcAddr from the list of
+ multicast groups received. The group is left from the
+ interface with the given local address.
+ \param[in] mcAddr address of group to leave
+ \param[in] localAddr address of interface to leave from
+ \todo fix this as soon as we have a real address class
+ (different from the sockaddress class */
+
+ void mcIface(std::string iface = std::string()) const;
+ ///< set default multicast interface of the socket
+ /**< \param[in] iface name of interface */
+
+
+ ///\name Abstract Interface Implementation
+ ///@{
+
+ unsigned available() const;
+ bool eof() const;
+
+ ///@}
+ };
+
+ /// @}
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "UDPProtocol.cci"
+//#include "UDPProtocol.ct"
+//#include "UDPProtocol.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// End:
--- /dev/null
+// $Id$
+//
+// 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.
+
+/** \file
+ \brief UDPv4SocketHandle and UDPv6SocketHandle non-inline non-template implementation
+ */
+
+#include "UDPSocketHandle.hh"
+//#include "UDPSocketHandle.ih"
+
+// Custom includes
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include "Utils/Exception.hh"
+
+//#include "UDPSocketHandle.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::UDPv4SocketProtocol
+
+prefix_ void senf::UDPv4SocketProtocol::init_client()
+ const
+{
+ int sock = ::socket(PF_INET,SOCK_DGRAM,0);
+ if (sock < 0)
+ throw SystemException(errno);
+ body().fd(sock);
+}
+
+prefix_ void
+senf::UDPv4SocketProtocol::init_client(INet4Address const & address)
+ const
+{
+ init_client();
+ connect(address);
+}
+
+prefix_ std::auto_ptr<senf::SocketProtocol> senf::UDPv4SocketProtocol::clone()
+ const
+{
+ return std::auto_ptr<SocketProtocol>(new UDPv4SocketProtocol());
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::UDPv6SocketProtocol::
+
+prefix_ void senf::UDPv6SocketProtocol::init_client()
+ const
+{
+ int sock = ::socket(PF_INET6,SOCK_DGRAM,0);
+ if (sock < 0)
+ throw SystemException(errno);
+ body().fd(sock);
+}
+
+prefix_ void
+senf::UDPv6SocketProtocol::init_client(INet6SocketAddress const & address)
+ const
+{
+ init_client();
+ connect(address);
+}
+
+prefix_ std::auto_ptr<senf::SocketProtocol> senf::UDPv6SocketProtocol::clone()
+ const
+{
+ return std::auto_ptr<SocketProtocol>(new UDPv6SocketProtocol());
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "UDPSocketHandle.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// End:
--- /dev/null
+// $Id$
+//
+// 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.
+
+/** \file
+ \brief UDPv4SocketHandle and UDPv6SocketHandle public header
+
+ \todo Implement possibly non-blocking connect and SO_ERROR in the
+ protocol interface
+ */
+
+#ifndef HH_UDPSocketHandle_
+#define HH_UDPSocketHandle_ 1
+
+// Custom includes
+#include "INetProtocol.hh"
+#include "UDPProtocol.hh"
+#include "BSDSocketProtocol.hh"
+#include "FramingPolicy.hh"
+#include "CommunicationPolicy.hh"
+#include "ReadWritePolicy.hh"
+#include "BufferingPolicy.hh"
+#include "ProtocolClientSocketHandle.hh"
+
+//#include "UDPSocketHandle.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ /// \addtogroup concrete_protocol_group
+ /// @{
+
+ typedef MakeSocketPolicy<
+ INet4AddressingPolicy,
+ DatagramFramingPolicy,
+ UnconnectedCommunicationPolicy,
+ ReadablePolicy,
+ WriteablePolicy,
+ SocketBufferingPolicy
+ >::policy UDPv4Socket_Policy; ///< Socket Policy of the UDPv4 Protocol
+
+ /** \brief IPv4 UDP Socket Protocol
+
+ \par Socket Handle typedefs:
+ \ref UDPv4ClientSocketHandle (ProtocolClientSocketHandle)
+
+ \par Policy Interface:
+ ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
+ ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+
+ \par Address Type:
+ INet4Address
+
+ UDPv4SocketProtocol provides an internet protocol stream socket based on the UDP protocol
+ and IPv4 addressing.
+
+ This class is utilized as the protocol class of the ProtocolClientSocketHandle
+ via the Socket Handle typedefs above.
+
+ \see UDPv6SocketProtocol
+ */
+ class UDPv4SocketProtocol
+ : public ConcreteSocketProtocol<UDPv4Socket_Policy>,
+ public IPv4Protocol,
+ public UDPProtocol,
+ public BSDSocketProtocol,
+ public AddressableBSDSocketProtocol
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // internal interface
+
+ ///\name Constructors
+ ///@{
+
+ void init_client() const; ///< Create unconnected client socket
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+ void init_client(INet4Address const & address) const;
+ ///< Create client socket and connect
+ /**< Creates a new client socket and connects to the given
+ address.
+
+ \param[in] address remote address to connect to */
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+
+ ///@}
+ ///\name Abstract Interface Implementation
+
+ std::auto_ptr<SocketProtocol> clone() const;
+
+ ///@}
+ };
+
+ typedef ProtocolClientSocketHandle<UDPv4SocketProtocol> UDPv4ClientSocketHandle;
+
+ typedef MakeSocketPolicy<
+ UDPv4Socket_Policy,
+ INet6AddressingPolicy
+ >::policy UDPv6Socket_Policy;
+
+ /** \brief IPv6 UDP Socket Protocol
+
+ \par Socket Handle typedefs:
+ \ref UDPv6ClientSocketHandle (ProtocolClientSocketHandle)
+
+ \par Policy Interface:
+ ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
+ ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
+ ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
+
+ \par Address Type:
+ INet6Address
+
+ UDPv6SocketProtocol provides an internet protocol stream socket based on the UDP protocol
+ and IPv6 addressing.
+
+ This class is utilized as the protocol class of the ProtocolClientSocketHandle
+ via the Socket Handle typedefs above.
+
+ \see UDPv4SocketProtocol
+ */
+ class UDPv6SocketProtocol
+ : public ConcreteSocketProtocol<UDPv6Socket_Policy>,
+ public IPv6Protocol,
+ public UDPProtocol,
+ public BSDSocketProtocol,
+ public AddressableBSDSocketProtocol
+ {
+ public:
+ ///////////////////////////////////////////////////////////////////////////
+ // internal interface
+
+ ///\name Constructors
+ ///@{
+
+ void init_client() const; ///< Create unconnected client socket
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+ void init_client(INet6SocketAddress const & address) const;
+ ///< Create client socket and connect
+ /**< Creates a new client socket and connects to the given
+ address.
+
+ \param[in] address remote address to connect to */
+ /**< \note This member is implicitly called from the
+ ProtocolClientSocketHandle::ProtocolClientSocketHandle()
+ constructor */
+
+ ///@}
+ ///\name Abstract Interface Implementation
+
+ std::auto_ptr<SocketProtocol> clone() const;
+
+ ///@}
+ };
+
+ typedef ProtocolClientSocketHandle<UDPv6SocketProtocol> UDPv6ClientSocketHandle;
+
+ /// @}
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "UDPSocketHandle.cci"
+//#include "UDPSocketHandle.ct"
+//#include "UDPSocketHandle.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// End: