Packets: Fix VariantParser invalid parser access bug
[senf.git] / Socket / Protocols / Raw / PacketSocketHandle.hh
index 873b7ef..3cae497 100644 (file)
@@ -1,9 +1,9 @@
 // $Id:PacketSocketHandle.hh 218 2007-03-20 14:39:32Z tho $
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.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
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief PacketProtocol and PacketSocketHandle public header
-
-    \todo Implement global promisc() helper based on ioctl() interface.
+    \brief PacketSocketProtocol and PacketSocketHandle public header
  */
 
-#ifndef HH_PacketSocketHandle_
-#define HH_PacketSocketHandle_ 1
+#ifndef HH_SENF_Socket_Protocols_Raw_PacketSocketHandle_
+#define HH_SENF_Socket_Protocols_Raw_PacketSocketHandle_ 1
 
 // Custom includes
-#include "Socket/SocketPolicy.hh"
-#include "Socket/SocketProtocol.hh"
-#include "Socket/ProtocolClientSocketHandle.hh"
-#include "Socket/FramingPolicy.hh"
-#include "Socket/CommunicationPolicy.hh"
-#include "Socket/ReadWritePolicy.hh"
-#include "Socket/BufferingPolicy.hh"
-#include "Socket/Protocols/BSDSocketProtocol.hh"
+#include "../../../Socket/SocketPolicy.hh"
+#include "../../../Socket/SocketProtocol.hh"
+#include "../../../Socket/ProtocolClientSocketHandle.hh"
+#include "../../../Socket/FramingPolicy.hh"
+#include "../../../Socket/CommunicationPolicy.hh"
+#include "../../../Socket/ReadWritePolicy.hh"
+#include "../../../Socket/Protocols/BSDSocketProtocol.hh"
+#include "../../../Socket/Protocols/DatagramSocketProtocol.hh"
 #include "LLAddressing.hh"
 
 //#include "PacketSocketHandle.mpp"
-#include "PacketSocketHandle.ih"
+//#include "PacketSocketHandle.ih"
 ///////////////////////////////hh.p////////////////////////////////////////
 
 namespace senf {
@@ -54,9 +52,8 @@ namespace senf {
         DatagramFramingPolicy,
         UnconnectedCommunicationPolicy,
         ReadablePolicy,
-        WriteablePolicy,
-        SocketBufferingPolicy
-        >::policy Packet_Policy;        ///< Policy of PacketProtocol
+        WriteablePolicy
+        >::policy Packet_Policy;        ///< Policy of PacketSocketProtocol
 
     /** \brief Raw Packet-Socket access (Linux)
 
@@ -65,23 +62,22 @@ namespace senf {
 
         \par Policy Interface:
         ClientSocketHandle::read(), ClientSocketHandle::readfrom(), ClientSocketHandle::writeto(),
-        ClientSocketHandle::bind(), ClientSocketHandle::local(), ClientSocketHandle::rcvbuf(),
-        ClientSocketHandle::sndbuf()
+        ClientSocketHandle::bind(), ClientSocketHandle::local()
 
         \par Address Type:
-        LLSocketAddress
+            LLSocketAddress
 
-        The PacketProtocol provides access to the linux packet socket API. This API gives access to
+        The PacketSocketProtocol provides access to the linux packet socket API. This API gives access to
         the low level network packets. The packet socket allows read() and write() operations. The
-        PacketProtocol has no concept of a server socket.
+        PacketSocketProtocol has no concept of a server socket.
 
         This class is utilized as the protocol class of the ProtocolClientSocketHandle via the
         Socket Handle typedefs above.
      */
-    class PacketProtocol
-        : public ConcreteSocketProtocol<Packet_Policy>,
-          public BSDSocketProtocol,
-          public senf::pool_alloc_mixin<PacketProtocol>
+    class PacketSocketProtocol
+        : public ConcreteSocketProtocol<Packet_Policy, PacketSocketProtocol>,
+          public DatagramSocketProtocol,
+          public BSDSocketProtocol
     {
     public:
         enum SocketType { RawSocket, DatagramSocket };
@@ -114,45 +110,31 @@ namespace senf {
         ///\name Protocol Interface
         ///@{
 
-        // See LLSocketAddress for a discussion/rationale for ForwardRange here
-        template <class ForwardRange>
-        void mcAdd(std::string interface, ForwardRange const & address) const;
+        void mcAdd(std::string const & interface, MACAddress const & address) const;
                                         ///< Enable reception of a multicast group
-                                        /**< mcAdd will join a new multicast group. The address
-                                             parameter is specified as an arbitrary forward range
-                                             (see <a
-                                             href="http://www.boost.org/libs/range/index.html">Boost.Range</a>)
-                                             of up to 8 bytes. This  allows to initialize the
-                                             address from an arbitrary sources without excessive
-                                             copying.
+                                        /**< mcAdd will join a new multicast group.
 
                                              \param[in] interface interface with which to join
                                              \param[in] address multicast address to join
 
                                              \see \ref LLSocketAddress */
-        template <class ForwardRange>
-        void mcDrop(std::string interface, ForwardRange const & address) const;
+        void mcDrop(std::string const & interface, MACAddress const & address) const;
                                         ///< Disable reception of a multicast group
                                         /**< \see \ref mcAdd() */
+
         ///@}
 
         ///\name Abstract Interface Implementation
         ///@{
 
-        std::auto_ptr<SocketProtocol> clone() const;
         unsigned available() const;
         bool eof() const;
 
         ///@}
-
-    private:
-        template<class ForwardRange>
-        void do_mc(std::string interface, ForwardRange const & address, bool add) const;
-        void do_mc_i(std::string interface, detail::LLAddressCopier const & copier, bool add) const;
     };
 
-    typedef ProtocolClientSocketHandle<PacketProtocol> PacketSocketHandle;
-                                        ///< SocketHandle of the PacketProtocol
+    typedef ProtocolClientSocketHandle<PacketSocketProtocol> PacketSocketHandle;
+                                        ///< SocketHandle of the PacketSocketProtocol
                                         /**< \related PacketPrototol */
 
     /// @}
@@ -160,8 +142,8 @@ namespace senf {
 
 ///////////////////////////////hh.e////////////////////////////////////////
 //#include "PacketSocketHandle.cci"
-#include "PacketSocketHandle.ct"
-#include "PacketSocketHandle.cti"
+//#include "PacketSocketHandle.ct"
+//#include "PacketSocketHandle.cti"
 //#include "PacketSocketHandle.mpp"
 #endif